healthguide / app.py
Muhammadtaha12's picture
Update app.py
e9e1caa verified
raw
history blame
4.37 kB
import streamlit as st
# Disease and Treatment Information Data
diseases_info = {
"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.",
},
}
# Function to display disease info
def display_disease_info(disease_name):
disease_name = disease_name.lower().replace(" ", "_")
if disease_name in diseases_info:
disease = diseases_info[disease_name]
result = f"\n**Disease:** {disease_name.replace('_', ' ').title()}"
result += f"\n**Symptoms:** {', '.join(disease['symptoms'])}"
result += f"\n**Treatment:** {disease['treatment']}"
return result
else:
return "\nSorry, no information available for this disease."
# Function to handle the chat bot
def chat_bot(user_input):
if 'cha hal aa' in user_input.lower():
if 'are you healthcare app' in user_input.lower():
return "na rai mazak na kar maa app"
return "Khair aa, tu budha!"
elif 'exit' in user_input.lower():
return "Goodbye!"
else:
return "I'm not sure how to respond to that. Type 'exit' to end the chat."
# Streamlit App Interface
def main():
# Title of the app
st.title("Disease Information and Chat Bot")
# Disease Input
disease_name = st.text_input("Enter Disease Name", "")
if disease_name:
st.subheader("Disease Information")
disease_info = display_disease_info(disease_name)
st.text_area("Disease Info", disease_info, height=150)
# Chat Bot Section
st.subheader("Chat with Bot")
user_input = st.text_input("Enter a Message (e.g., How are you?)", "")
if user_input:
response = chat_bot(user_input)
st.text_area("Chat Bot Response", response, height=100)
# Add some helpful instructions
st.markdown("""
- **Enter a disease name** in the input box to get information about symptoms and treatments.
- **Ask the chat bot** something like "How are you?" to interact with it.
- Type "exit" to end the chat session.
""")
# Run the app
if __name__ == "__main__":
main()