Spaces:
Sleeping
Sleeping
File size: 9,112 Bytes
80ffae0 99032ef 978364c 80ffae0 978364c 80ffae0 978364c 80ffae0 978364c 80ffae0 99032ef 978364c 99032ef 978364c 99032ef 978364c 99032ef 978364c 99032ef 978364c 99032ef 978364c 99032ef 978364c 99032ef 978364c 99032ef 978364c 80ffae0 978364c 80ffae0 be9ce02 80ffae0 be9ce02 80ffae0 be9ce02 80ffae0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
import streamlit as st
# Define the healthcare knowledge base with a wider set of diseases and conditions
{
"flu": {
"symptoms": ["fever", "cough", "sore throat", "body aches", "fatigue"],
"treatment": "Rest, fluids, pain relievers, and anti-viral medications if prescribed."
},
"headache": {
"symptoms": ["head pain", "nausea", "sensitivity to light"],
"treatment": "Rest, hydration, over-the-counter painkillers, and avoid triggers."
},
"diabetes": {
"symptoms": ["increased thirst", "frequent urination", "fatigue", "blurred vision"],
"treatment": "Insulin therapy, lifestyle changes, and dietary management."
},
"cold": {
"symptoms": ["sore throat", "runny nose", "cough", "sneezing", "mild body aches"],
"treatment": "Rest, hydration, decongestants, and over-the-counter pain relief."
},
"asthma": {
"symptoms": ["shortness of breath", "wheezing", "chest tightness", "coughing"],
"treatment": "Inhalers, bronchodilators, corticosteroids, and avoiding triggers."
},
"pneumonia": {
"symptoms": ["cough with mucus", "fever", "shortness of breath", "chest pain"],
"treatment": "Antibiotics for bacterial pneumonia, rest, fluids, and pain relievers."
},
"hypertension": {
"symptoms": ["headaches", "dizziness", "shortness of breath", "nosebleeds"],
"treatment": "Medications like beta-blockers, ACE inhibitors, lifestyle changes including exercise and diet."
},
"anxiety": {
"symptoms": ["excessive worry", "restlessness", "fatigue", "difficulty concentrating", "irritability"],
"treatment": "Cognitive-behavioral therapy (CBT), medications like SSRIs, relaxation techniques."
},
"depression": {
"symptoms": ["persistent sadness", "loss of interest", "fatigue", "changes in appetite or sleep patterns"],
"treatment": "Antidepressants, therapy (CBT), exercise, and social support."
},
"arthritis": {
"symptoms": ["joint pain", "swelling", "stiffness", "reduced range of motion"],
"treatment": "Pain relievers, anti-inflammatory drugs, physical therapy, and joint protection."
},
"covid-19": {
"symptoms": ["fever", "dry cough", "fatigue", "loss of taste or smell", "shortness of breath"],
"treatment": "Rest, fluids, over-the-counter medications, and antiviral drugs if prescribed."
},
"abdominal_aortic_aneurysm": {
"symptoms": ["back pain", "abdominal pain", "pulsating mass in the abdomen"],
"treatment": "Surgical intervention, blood pressure control, and monitoring."
},
"acute_lymphoblastic_leukemia": {
"symptoms": ["fever", "pale skin", "unexplained weight loss", "easy bruising"],
"treatment": "Chemotherapy, bone marrow transplant, and supportive care."
},
"acute_myeloid_leukemia": {
"symptoms": ["fatigue", "fever", "easy bruising or bleeding", "shortness of breath"],
"treatment": "Chemotherapy, stem cell transplant, and supportive care."
},
"acromegaly": {
"symptoms": ["enlarged hands and feet", "joint pain", "thickened skin", "enlarged facial features"],
"treatment": "Surgery, radiation therapy, and medication to control growth hormone production."
},
"actinomycosis": {
"symptoms": ["abscesses", "fever", "painful lumps", "swelling"],
"treatment": "Long-term antibiotics such as penicillin."
},
"acute_renal_failure": {
"symptoms": ["decreased urine output", "fatigue", "swelling in the legs", "confusion"],
"treatment": "Dialysis, fluid management, and treatment of underlying causes."
},
"addisons_disease": {
"symptoms": ["fatigue", "muscle weakness", "low blood pressure", "darkening of the skin"],
"treatment": "Corticosteroid therapy and lifestyle modifications."
},
"adhd": {
"symptoms": ["impulsivity", "difficulty focusing", "hyperactivity", "forgetfulness"],
"treatment": "Stimulant medications, therapy (CBT), and lifestyle management."
},
"aids": {
"symptoms": ["weight loss", "fever", "night sweats", "fatigue", "recurrent infections"],
"treatment": "Antiretroviral therapy (ART) to manage the virus and prevent complications."
},
"albinism": {
"symptoms": ["pale skin", "light-colored eyes", "vision problems", "sensitivity to light"],
"treatment": "UV protection, corrective lenses for vision, and skin protection."
},
"alcoholic_hepatitis": {
"symptoms": ["nausea", "abdominal pain", "yellowing of the skin (jaundice)", "loss of appetite"],
"treatment": "Avoid alcohol, medications to manage symptoms, and possible liver transplant."
},
"alcoholism": {
"symptoms": ["strong cravings for alcohol", "inability to control drinking", "neglect of responsibilities"],
"treatment": "Behavioral therapy, support groups, medications like disulfiram, and rehabilitation."
},
"alkaptonuria": {
"symptoms": ["dark urine", "arthritis", "heart disease", "darkening of the ears or eyes"],
"treatment": "Managing symptoms, physical therapy, and joint replacement if necessary."
},
"allergies": {
"symptoms": ["sneezing", "itchy eyes", "runny nose", "hives", "swelling"],
"treatment": "Antihistamines, decongestants, and avoiding triggers."
},
"alzheimers_disease": {
"symptoms": ["memory loss", "difficulty with tasks", "confusion", "personality changes"],
"treatment": "Cognitive-enhancing drugs, therapy, and support for caregivers."
},
"amyotrophic_lateral_sclerosis": {
"symptoms": ["muscle weakness", "difficulty speaking or swallowing", "breathing problems"],
"treatment": "Symptom management, physical therapy, and breathing support."
},
"anemia": {
"symptoms": ["fatigue", "pale skin", "dizziness", "shortness of breath"],
"treatment": "Iron supplements, B12 injections, or blood transfusions depending on the cause."
},
"aneurysm": {
"symptoms": ["severe headache", "nausea", "blurred vision", "pain in the chest or abdomen"],
"treatment": "Surgical repair, blood pressure control, and monitoring."
},
"angelman_syndrome": {
"symptoms": ["delayed development", "lack of speech", "seizures", "smiling and laughter"],
"treatment": "Physical therapy, speech therapy, and medications for seizures."
},
"anorexia_nervosa": {
"symptoms": ["extreme weight loss", "fear of gaining weight", "distorted body image", "restricted eating"],
"treatment": "Nutritional rehabilitation, psychotherapy, and medical monitoring."
},
"anthrax": {
"symptoms": ["fever", "cough", "chest pain", "difficulty breathing", "swelling"],
"treatment": "Antibiotics and in some cases, vaccination."
},
"antiphospholipid_syndrome": {
"symptoms": ["recurrent miscarriages", "blood clots", "stroke", "rashes"],
"treatment": "Blood thinners and management of clotting disorders."
},
"aortic_stenosis": {
"symptoms": ["chest pain", "shortness of breath", "fatigue", "fainting"],
"treatment": "Surgical valve replacement or balloon valvuloplasty."
},
"aortic_dissection": {
"symptoms": ["severe chest or back pain", "difficulty breathing", "sweating", "loss of consciousness"],
"treatment": "Emergency surgery, blood pressure control, and monitoring."
},
"apraxia": {
"symptoms": ["difficulty planning and coordinating muscle movements", "speech and motor difficulties"],
"treatment": "Speech therapy, physical therapy, and occupational therapy."
}
}
# Function to search for health information in the knowledge base
def get_health_info(query):
query = query.lower()
# List to store matching results
matching_conditions = []
# Search for conditions that match the query
for condition, info in health_knowledge_base.items():
if condition in query or any(symptom in query for symptom in info['symptoms']):
matching_conditions.append(f"Condition: {condition.title()}\n"
f"Symptoms: {', '.join(info['symptoms'])}\n"
f"Treatment: {info['treatment']}\n")
# If we have matching conditions, return all of them, otherwise return a message
if matching_conditions:
return "\n\n".join(matching_conditions)
else:
return "Sorry, I couldn't find information on that condition. Please try another query."
# Set up the Streamlit app interface
st.title("Healthcare Knowledge Chatbot")
st.write("Ask me about health conditions, symptoms, treatments, and I'll provide relevant information.")
# Input field for user queries
user_input = st.text_input("Ask a healthcare-related question...")
# Display response based on user input
if user_input:
response = get_health_info(user_input)
st.write(response)
|