Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,135 +1,88 @@
|
|
1 |
-
# Disease
|
2 |
-
|
3 |
"flu": {
|
4 |
"symptoms": ["fever", "cough", "sore throat", "body aches", "fatigue"],
|
5 |
-
"treatment": "Rest, fluids, pain relievers, and anti-viral medications if prescribed."
|
6 |
},
|
7 |
"headache": {
|
8 |
"symptoms": ["head pain", "nausea", "sensitivity to light"],
|
9 |
-
"treatment": "Rest, hydration, over-the-counter painkillers, and avoid triggers."
|
10 |
},
|
11 |
"diabetes": {
|
12 |
"symptoms": ["increased thirst", "frequent urination", "fatigue", "blurred vision"],
|
13 |
-
"treatment": "Insulin therapy, lifestyle changes, and dietary management."
|
|
|
|
|
|
|
|
|
14 |
},
|
15 |
"asthma": {
|
16 |
"symptoms": ["shortness of breath", "wheezing", "chest tightness", "coughing"],
|
17 |
-
"treatment": "Inhalers, bronchodilators, corticosteroids, and avoiding triggers."
|
18 |
},
|
19 |
"pneumonia": {
|
20 |
"symptoms": ["cough with mucus", "fever", "shortness of breath", "chest pain"],
|
21 |
-
"treatment": "Antibiotics for bacterial pneumonia, rest, fluids, and pain relievers."
|
22 |
-
},
|
23 |
-
"diabetes type 1": {
|
24 |
-
"symptoms": ["frequent urination", "increased thirst", "fatigue", "unexplained weight loss"],
|
25 |
-
"treatment": "Insulin injections, blood sugar monitoring, and a healthy diet."
|
26 |
-
},
|
27 |
-
"diabetes type 2": {
|
28 |
-
"symptoms": ["increased thirst", "frequent urination", "fatigue", "blurred vision"],
|
29 |
-
"treatment": "Lifestyle changes, oral medications, and insulin therapy if needed."
|
30 |
},
|
31 |
"hypertension": {
|
32 |
"symptoms": ["headaches", "dizziness", "shortness of breath", "nosebleeds"],
|
33 |
-
"treatment": "Medications like beta-blockers, ACE inhibitors, lifestyle changes including exercise and diet."
|
34 |
-
},
|
35 |
-
"arthritis": {
|
36 |
-
"symptoms": ["joint pain", "swelling", "stiffness", "reduced range of motion"],
|
37 |
-
"treatment": "Pain relievers, anti-inflammatory drugs, physical therapy, and joint protection."
|
38 |
-
},
|
39 |
-
"cancer": {
|
40 |
-
"symptoms": ["unexplained weight loss", "fatigue", "pain", "skin changes"],
|
41 |
-
"treatment": "Chemotherapy, radiation, surgery, and immunotherapy."
|
42 |
-
},
|
43 |
-
"alzheimer's disease": {
|
44 |
-
"symptoms": ["memory loss", "confusion", "difficulty performing familiar tasks"],
|
45 |
-
"treatment": "Cognitive therapy, medications to slow progression, and support for caregivers."
|
46 |
-
},
|
47 |
-
"migraine": {
|
48 |
-
"symptoms": ["severe headache", "nausea", "sensitivity to light and sound"],
|
49 |
-
"treatment": "Pain relievers, anti-nausea medications, and lifestyle adjustments."
|
50 |
},
|
51 |
-
"
|
52 |
-
"symptoms": ["
|
53 |
-
"treatment": "
|
54 |
},
|
55 |
-
|
56 |
-
|
57 |
-
"
|
58 |
-
"treatment": "Surgery or endovascular aneurysm repair (EVAR)."
|
59 |
},
|
60 |
-
"
|
61 |
-
"symptoms": ["
|
62 |
-
"treatment": "
|
63 |
-
},
|
64 |
-
"acute myeloid leukemia": {
|
65 |
-
"symptoms": ["fever", "fatigue", "easy bruising", "shortness of breath"],
|
66 |
-
"treatment": "Chemotherapy, stem cell transplant, and targeted therapy."
|
67 |
-
},
|
68 |
-
"acromegaly": {
|
69 |
-
"symptoms": ["enlarged hands and feet", "facial changes", "joint pain"],
|
70 |
-
"treatment": "Surgery, radiation therapy, and medications to control growth hormone."
|
71 |
-
},
|
72 |
-
"actinomycosis": {
|
73 |
-
"symptoms": ["painful lumps", "fever", "abscesses"],
|
74 |
-
"treatment": "Antibiotics, typically penicillin."
|
75 |
-
},
|
76 |
-
"addison's disease": {
|
77 |
-
"symptoms": ["fatigue", "low blood pressure", "weight loss", "skin darkening"],
|
78 |
-
"treatment": "Hormone replacement therapy, particularly corticosteroids."
|
79 |
},
|
80 |
-
"
|
81 |
-
"symptoms": ["
|
82 |
-
"treatment": "
|
83 |
},
|
84 |
-
|
85 |
-
|
86 |
-
"
|
|
|
87 |
},
|
88 |
-
"
|
89 |
-
"symptoms": ["
|
90 |
-
"treatment": "
|
91 |
},
|
92 |
-
#
|
93 |
}
|
94 |
|
95 |
-
# Function to display disease information
|
96 |
def display_disease_info(disease_name):
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
print("
|
102 |
-
|
103 |
-
|
104 |
-
print(f"\nTreatment: {disease['treatment']}")
|
105 |
else:
|
106 |
-
print("
|
107 |
|
108 |
-
# Function to handle chat feature
|
109 |
def chat_bot():
|
110 |
-
|
|
|
111 |
while True:
|
112 |
-
user_input = input("You: ").
|
113 |
-
|
114 |
-
# Responding to the "cha hal aa?" query with "khair aa"
|
115 |
-
if user_input == "cha hal aa?":
|
116 |
-
print("Bot: khair aa")
|
117 |
-
|
118 |
-
# Check if the user wants to know about a disease
|
119 |
-
elif user_input in diseases:
|
120 |
-
display_disease_info(user_input)
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
125 |
break
|
126 |
-
|
127 |
-
# If the input is unrecognized
|
128 |
else:
|
129 |
-
print("Bot:
|
130 |
|
131 |
-
# Main menu to choose between disease info or chat
|
132 |
def main():
|
|
|
133 |
print("Welcome to the Disease Information and Chat Bot!\n")
|
134 |
|
135 |
while True:
|
@@ -138,10 +91,14 @@ def main():
|
|
138 |
print("2. Chat with Bot")
|
139 |
print("3. Exit")
|
140 |
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
|
143 |
if option == "1":
|
144 |
-
disease_name = input("Enter the name of the disease: ").strip()
|
145 |
display_disease_info(disease_name)
|
146 |
|
147 |
elif option == "2":
|
@@ -154,6 +111,5 @@ def main():
|
|
154 |
else:
|
155 |
print("Invalid choice. Please try again.")
|
156 |
|
157 |
-
# Run the program
|
158 |
if __name__ == "__main__":
|
159 |
main()
|
|
|
1 |
+
# Disease and Treatment Information Data
|
2 |
+
diseases_info = {
|
3 |
"flu": {
|
4 |
"symptoms": ["fever", "cough", "sore throat", "body aches", "fatigue"],
|
5 |
+
"treatment": "Rest, fluids, pain relievers, and anti-viral medications if prescribed.",
|
6 |
},
|
7 |
"headache": {
|
8 |
"symptoms": ["head pain", "nausea", "sensitivity to light"],
|
9 |
+
"treatment": "Rest, hydration, over-the-counter painkillers, and avoid triggers.",
|
10 |
},
|
11 |
"diabetes": {
|
12 |
"symptoms": ["increased thirst", "frequent urination", "fatigue", "blurred vision"],
|
13 |
+
"treatment": "Insulin therapy, lifestyle changes, and dietary management.",
|
14 |
+
},
|
15 |
+
"cold": {
|
16 |
+
"symptoms": ["sore throat", "runny nose", "cough", "sneezing", "mild body aches"],
|
17 |
+
"treatment": "Rest, hydration, decongestants, and over-the-counter pain relief.",
|
18 |
},
|
19 |
"asthma": {
|
20 |
"symptoms": ["shortness of breath", "wheezing", "chest tightness", "coughing"],
|
21 |
+
"treatment": "Inhalers, bronchodilators, corticosteroids, and avoiding triggers.",
|
22 |
},
|
23 |
"pneumonia": {
|
24 |
"symptoms": ["cough with mucus", "fever", "shortness of breath", "chest pain"],
|
25 |
+
"treatment": "Antibiotics for bacterial pneumonia, rest, fluids, and pain relievers.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
},
|
27 |
"hypertension": {
|
28 |
"symptoms": ["headaches", "dizziness", "shortness of breath", "nosebleeds"],
|
29 |
+
"treatment": "Medications like beta-blockers, ACE inhibitors, lifestyle changes including exercise and diet.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
},
|
31 |
+
"anxiety": {
|
32 |
+
"symptoms": ["excessive worry", "restlessness", "fatigue", "difficulty concentrating", "irritability"],
|
33 |
+
"treatment": "Cognitive-behavioral therapy (CBT), medications like SSRIs, relaxation techniques.",
|
34 |
},
|
35 |
+
"depression": {
|
36 |
+
"symptoms": ["persistent sadness", "loss of interest", "fatigue", "changes in appetite or sleep patterns"],
|
37 |
+
"treatment": "Antidepressants, therapy (CBT), exercise, and social support.",
|
|
|
38 |
},
|
39 |
+
"arthritis": {
|
40 |
+
"symptoms": ["joint pain", "swelling", "stiffness", "reduced range of motion"],
|
41 |
+
"treatment": "Pain relievers, anti-inflammatory drugs, physical therapy, and joint protection.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
},
|
43 |
+
"covid-19": {
|
44 |
+
"symptoms": ["fever", "dry cough", "fatigue", "loss of taste or smell", "shortness of breath"],
|
45 |
+
"treatment": "Rest, fluids, over-the-counter medications, and antiviral drugs if prescribed.",
|
46 |
},
|
47 |
+
# Adding the larger list of diseases
|
48 |
+
"abdominal_aortic_aneurysm": {
|
49 |
+
"symptoms": ["pulsating feeling in the abdomen", "pain in the back or abdomen", "dizziness"],
|
50 |
+
"treatment": "Surgical repair or monitoring depending on severity.",
|
51 |
},
|
52 |
+
"acute_lymphoblastic_leukemia": {
|
53 |
+
"symptoms": ["fatigue", "fever", "pale skin", "easy bruising", "swollen lymph nodes"],
|
54 |
+
"treatment": "Chemotherapy, bone marrow transplant.",
|
55 |
},
|
56 |
+
# Add more diseases here similarly...
|
57 |
}
|
58 |
|
|
|
59 |
def display_disease_info(disease_name):
|
60 |
+
"""Display disease info if available."""
|
61 |
+
disease_name = disease_name.lower().replace(" ", "_")
|
62 |
+
if disease_name in diseases_info:
|
63 |
+
disease = diseases_info[disease_name]
|
64 |
+
print(f"Disease: {disease_name.replace('_', ' ').title()}")
|
65 |
+
print(f"Symptoms: {', '.join(disease['symptoms'])}")
|
66 |
+
print(f"Treatment: {disease['treatment']}")
|
|
|
67 |
else:
|
68 |
+
print("Sorry, no information available for this disease.")
|
69 |
|
|
|
70 |
def chat_bot():
|
71 |
+
"""Chat bot functionality."""
|
72 |
+
print("Chat Bot: Hello! How can I assist you today?")
|
73 |
while True:
|
74 |
+
user_input = input("You: ").lower()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
if 'how are you' in user_input:
|
77 |
+
print("Chat Bot: Khair aa, thank you for asking!")
|
78 |
+
elif 'exit' in user_input:
|
79 |
+
print("Chat Bot: Goodbye!")
|
80 |
break
|
|
|
|
|
81 |
else:
|
82 |
+
print("Chat Bot: I'm not sure how to respond to that. Type 'exit' to end the chat.")
|
83 |
|
|
|
84 |
def main():
|
85 |
+
"""Main program function."""
|
86 |
print("Welcome to the Disease Information and Chat Bot!\n")
|
87 |
|
88 |
while True:
|
|
|
91 |
print("2. Chat with Bot")
|
92 |
print("3. Exit")
|
93 |
|
94 |
+
try:
|
95 |
+
option = input("Enter your choice (1/2/3): ").strip()
|
96 |
+
except EOFError:
|
97 |
+
print("\nError: Input is required. Exiting...")
|
98 |
+
break
|
99 |
|
100 |
if option == "1":
|
101 |
+
disease_name = input("Enter the name of the disease: ").strip()
|
102 |
display_disease_info(disease_name)
|
103 |
|
104 |
elif option == "2":
|
|
|
111 |
else:
|
112 |
print("Invalid choice. Please try again.")
|
113 |
|
|
|
114 |
if __name__ == "__main__":
|
115 |
main()
|