Spaces:
Sleeping
Sleeping
ahmed-7124
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -24,12 +24,157 @@ patients_db = []
|
|
24 |
|
25 |
# Disease details for medical report analyzer
|
26 |
disease_details = {
|
27 |
-
"anemia": {
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
-
|
33 |
# Passwords
|
34 |
doctor_password = "doctor123"
|
35 |
|
@@ -201,6 +346,14 @@ analyze_report_interface = gr.Interface(
|
|
201 |
# outputs="text",
|
202 |
# )
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
doctor_space_interface = gr.Interface(
|
205 |
fn=doctor_space,
|
206 |
inputs=gr.Number(label="Patient ID"),
|
@@ -266,13 +419,16 @@ with gr.Blocks() as app:
|
|
266 |
|
267 |
with gr.Tab("Pharmacist Space"):
|
268 |
pharmacist_space_interface.render()
|
269 |
-
|
|
|
|
|
|
|
270 |
with gr.Tab("Patient Dashboard"):
|
271 |
patient_dashboard_interface.render()
|
272 |
|
273 |
with gr.Tab("Doctor Dashboard"):
|
274 |
doctor_dashboard_interface.render()
|
275 |
-
|
276 |
|
277 |
# Launch the app
|
278 |
app.launch(share=True)
|
|
|
24 |
|
25 |
# Disease details for medical report analyzer
|
26 |
disease_details = {
|
27 |
+
"anemia": {
|
28 |
+
"medication": (
|
29 |
+
"Iron supplements (e.g., ferrous sulfate), "
|
30 |
+
"Vitamin B12 injections (for pernicious anemia), "
|
31 |
+
"Folic acid supplements."
|
32 |
+
),
|
33 |
+
"precaution": (
|
34 |
+
"Consume iron-rich foods like spinach, red meat, and lentils. "
|
35 |
+
"Pair iron-rich foods with vitamin C to enhance absorption. "
|
36 |
+
"Avoid tea or coffee with meals as they inhibit iron absorption."
|
37 |
+
),
|
38 |
+
"doctor": "Hematologist",
|
39 |
+
},
|
40 |
+
"viral infection": {
|
41 |
+
"medication": (
|
42 |
+
"Antiviral drugs (e.g., oseltamivir for flu, acyclovir for herpes). "
|
43 |
+
"Over-the-counter medications for symptom relief, such as ibuprofen for fever and body aches."
|
44 |
+
),
|
45 |
+
"precaution": (
|
46 |
+
"Stay hydrated by drinking plenty of fluids. "
|
47 |
+
"Isolate to prevent spreading the infection. "
|
48 |
+
"Rest adequately to support recovery. Maintain proper hygiene."
|
49 |
+
),
|
50 |
+
"doctor": "Infectious Disease Specialist",
|
51 |
+
},
|
52 |
+
"liver disease": {
|
53 |
+
"medication": (
|
54 |
+
"Hepatoprotective drugs (e.g., ursodeoxycholic acid, silymarin). "
|
55 |
+
"Antiviral therapy for viral hepatitis. "
|
56 |
+
"Diuretics for managing fluid retention (e.g., spironolactone)."
|
57 |
+
),
|
58 |
+
"precaution": (
|
59 |
+
"Avoid alcohol and hepatotoxic drugs. "
|
60 |
+
"Follow a low-fat diet and avoid processed foods. "
|
61 |
+
"Regularly monitor liver function tests."
|
62 |
+
),
|
63 |
+
"doctor": "Hepatologist",
|
64 |
+
},
|
65 |
+
"diabetes": {
|
66 |
+
"medication": (
|
67 |
+
"Oral hypoglycemics (e.g., metformin). "
|
68 |
+
"Insulin therapy for Type 1 diabetes or advanced Type 2 diabetes. "
|
69 |
+
"GLP-1 receptor agonists (e.g., liraglutide) for improving blood sugar control."
|
70 |
+
),
|
71 |
+
"precaution": (
|
72 |
+
"Monitor blood glucose levels daily. "
|
73 |
+
"Follow a low-carb, high-fiber diet. "
|
74 |
+
"Engage in regular physical activity. "
|
75 |
+
"Avoid sugary foods and beverages."
|
76 |
+
),
|
77 |
+
"doctor": "Endocrinologist",
|
78 |
+
},
|
79 |
+
"hypertension": {
|
80 |
+
"medication": (
|
81 |
+
"ACE inhibitors (e.g., lisinopril). "
|
82 |
+
"Beta-blockers (e.g., metoprolol). "
|
83 |
+
"Calcium channel blockers (e.g., amlodipine). "
|
84 |
+
"Diuretics (e.g., hydrochlorothiazide)."
|
85 |
+
),
|
86 |
+
"precaution": (
|
87 |
+
"Reduce salt intake to less than 2g per day. "
|
88 |
+
"Engage in at least 150 minutes of moderate exercise weekly. "
|
89 |
+
"Avoid smoking and excessive alcohol consumption. "
|
90 |
+
"Manage stress through relaxation techniques like yoga or meditation."
|
91 |
+
),
|
92 |
+
"doctor": "Cardiologist",
|
93 |
+
},
|
94 |
+
"pneumonia": {
|
95 |
+
"medication": (
|
96 |
+
"Antibiotics (e.g., amoxicillin or azithromycin for bacterial pneumonia). "
|
97 |
+
"Antiviral therapy if caused by viruses like influenza. "
|
98 |
+
"Supplemental oxygen in severe cases."
|
99 |
+
),
|
100 |
+
"precaution": (
|
101 |
+
"Get plenty of rest and stay hydrated. "
|
102 |
+
"Use a humidifier to ease breathing. "
|
103 |
+
"Avoid smoking or exposure to pollutants. "
|
104 |
+
"Ensure vaccination against influenza and pneumococcus."
|
105 |
+
),
|
106 |
+
"doctor": "Pulmonologist",
|
107 |
+
},
|
108 |
+
"asthma": {
|
109 |
+
"medication": (
|
110 |
+
"Short-acting bronchodilators (e.g., albuterol) for quick relief. "
|
111 |
+
"Inhaled corticosteroids (e.g., fluticasone) for long-term control. "
|
112 |
+
"Leukotriene receptor antagonists (e.g., montelukast) for reducing inflammation."
|
113 |
+
),
|
114 |
+
"precaution": (
|
115 |
+
"Avoid known allergens like pollen, dust, and pet dander. "
|
116 |
+
"Carry a rescue inhaler at all times. "
|
117 |
+
"Practice breathing exercises to strengthen lungs. "
|
118 |
+
"Avoid cold air or strenuous exercise without a warm-up."
|
119 |
+
),
|
120 |
+
"doctor": "Pulmonologist",
|
121 |
+
},
|
122 |
+
"kidney disease": {
|
123 |
+
"medication": (
|
124 |
+
"ACE inhibitors or ARBs (e.g., losartan) for controlling blood pressure. "
|
125 |
+
"Erythropoietin-stimulating agents for anemia management. "
|
126 |
+
"Phosphate binders (e.g., sevelamer) to manage high phosphate levels."
|
127 |
+
),
|
128 |
+
"precaution": (
|
129 |
+
"Limit salt, potassium, and phosphorus in the diet. "
|
130 |
+
"Stay hydrated but avoid overhydration. "
|
131 |
+
"Avoid NSAIDs and other nephrotoxic drugs. "
|
132 |
+
"Monitor kidney function and blood pressure regularly."
|
133 |
+
),
|
134 |
+
"doctor": "Nephrologist",
|
135 |
+
},
|
136 |
+
"thyroid disorder": {
|
137 |
+
"medication": (
|
138 |
+
"Levothyroxine for hypothyroidism. "
|
139 |
+
"Antithyroid medications (e.g., methimazole) for hyperthyroidism. "
|
140 |
+
"Beta-blockers for symptomatic relief in hyperthyroidism."
|
141 |
+
),
|
142 |
+
"precaution": (
|
143 |
+
"Ensure regular thyroid function tests. "
|
144 |
+
"Avoid foods that interfere with thyroid hormone absorption (e.g., soy, certain vegetables). "
|
145 |
+
"Follow medication schedules precisely without skipping doses."
|
146 |
+
),
|
147 |
+
"doctor": "Endocrinologist",
|
148 |
+
},
|
149 |
+
"arthritis": {
|
150 |
+
"medication": (
|
151 |
+
"Nonsteroidal anti-inflammatory drugs (NSAIDs) for pain relief. "
|
152 |
+
"Disease-modifying antirheumatic drugs (DMARDs) for rheumatoid arthritis. "
|
153 |
+
"Biologics (e.g., adalimumab) in severe cases."
|
154 |
+
),
|
155 |
+
"precaution": (
|
156 |
+
"Engage in low-impact exercises like swimming or yoga. "
|
157 |
+
"Use ergonomic furniture to reduce joint strain. "
|
158 |
+
"Maintain a healthy weight to reduce joint stress. "
|
159 |
+
"Apply heat or cold therapy for symptom relief."
|
160 |
+
),
|
161 |
+
"doctor": "Rheumatologist",
|
162 |
+
},
|
163 |
+
"depression": {
|
164 |
+
"medication": (
|
165 |
+
"Selective serotonin reuptake inhibitors (SSRIs, e.g., sertraline). "
|
166 |
+
"Serotonin-norepinephrine reuptake inhibitors (SNRIs, e.g., venlafaxine). "
|
167 |
+
"Tricyclic antidepressants (e.g., amitriptyline) in specific cases."
|
168 |
+
),
|
169 |
+
"precaution": (
|
170 |
+
"Engage in regular physical exercise. "
|
171 |
+
"Maintain a routine and avoid isolation. "
|
172 |
+
"Consider therapy (e.g., CBT or psychotherapy). "
|
173 |
+
"Avoid alcohol and recreational drugs."
|
174 |
+
),
|
175 |
+
"doctor": "Psychiatrist",
|
176 |
+
},
|
177 |
}
|
|
|
178 |
# Passwords
|
179 |
doctor_password = "doctor123"
|
180 |
|
|
|
346 |
# outputs="text",
|
347 |
# )
|
348 |
|
349 |
+
# Gradio Interface for Medical Query Answering
|
350 |
+
medical_query_interface = gr.Interface(
|
351 |
+
fn=answer_medical_query,
|
352 |
+
inputs=gr.Textbox(label="Ask a Medical Term"),
|
353 |
+
outputs="text",
|
354 |
+
)
|
355 |
+
|
356 |
+
|
357 |
doctor_space_interface = gr.Interface(
|
358 |
fn=doctor_space,
|
359 |
inputs=gr.Number(label="Patient ID"),
|
|
|
419 |
|
420 |
with gr.Tab("Pharmacist Space"):
|
421 |
pharmacist_space_interface.render()
|
422 |
+
|
423 |
+
with gr.Tab("Encyclopedia"):
|
424 |
+
medical_query_interface.render()
|
425 |
+
|
426 |
with gr.Tab("Patient Dashboard"):
|
427 |
patient_dashboard_interface.render()
|
428 |
|
429 |
with gr.Tab("Doctor Dashboard"):
|
430 |
doctor_dashboard_interface.render()
|
431 |
+
|
432 |
|
433 |
# Launch the app
|
434 |
app.launch(share=True)
|