hamnamughal commited on
Commit
e44e4d2
·
verified ·
1 Parent(s): 6fc4fc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -114
app.py CHANGED
@@ -1,115 +1,27 @@
 
1
  import streamlit as st
2
- import openai
3
- from dotenv import load_dotenv
4
- import os
5
- from appointment_agent import book_appointment, cancel_appointment, follow_up_appointment
6
- from medication_agent import set_medication_reminder, mark_medication_taken, suggest_medications
7
- from health_tracker_agent import log_symptom, get_health_report, track_health_stat, personalized_health_advice
8
- from lifestyle_agent import recommend_lifestyle, get_fitness_tips, get_sleep_advice, get_diet_tips
9
-
10
- # Load environment variables
11
- load_dotenv()
12
- openai.api_key = os.getenv("OPENAI_API_KEY")
13
-
14
- # Streamlit page configuration
15
- st.set_page_config(page_title="PHS - 2025 Healthcare System", layout="wide")
16
- st.title("PHS - 2025 Healthcare Management System")
17
-
18
- # Sidebar Navigation
19
- st.sidebar.title("Navigation")
20
- menu = ["Book Appointment", "Medication Management", "Health Tracker", "Lifestyle Recommendations"]
21
- choice = st.sidebar.selectbox("Select a Feature", menu)
22
-
23
- if choice == "Book Appointment":
24
- st.subheader("Book an Appointment")
25
- doctor = st.text_input("Enter Doctor's Name")
26
- date = st.date_input("Select Appointment Date")
27
- time = st.time_input("Select Appointment Time")
28
-
29
- if st.button("Book Appointment"):
30
- appointment_message = book_appointment(doctor, str(date), str(time))
31
- st.success(appointment_message)
32
-
33
- st.subheader("Follow-up on Appointment")
34
- appointment_id = st.text_input("Enter Appointment ID to Follow-up")
35
- if st.button("Follow-up Appointment"):
36
- follow_up_message = follow_up_appointment(appointment_id)
37
- st.info(follow_up_message)
38
-
39
- st.subheader("Cancel Appointment")
40
- cancel_id = st.text_input("Enter Appointment ID to Cancel")
41
- if st.button("Cancel Appointment"):
42
- cancel_message = cancel_appointment(cancel_id)
43
- st.warning(cancel_message)
44
-
45
- elif choice == "Medication Management":
46
- st.subheader("Medication Reminder Setup")
47
- medicine = st.text_input("Enter Medicine Name")
48
- reminder_time = st.time_input("Set Reminder Time")
49
-
50
- if st.button("Set Medication Reminder"):
51
- reminder_message = set_medication_reminder(medicine, str(reminder_time))
52
- st.success(reminder_message)
53
-
54
- st.subheader("Mark Medication as Taken")
55
- reminder_id = st.text_input("Enter Medication Reminder ID to Mark Taken")
56
- if st.button("Mark as Taken"):
57
- taken_message = mark_medication_taken(reminder_id)
58
- st.success(taken_message)
59
-
60
- st.subheader("Medication Suggestions")
61
- symptom = st.text_input("Enter Symptom (e.g., headache, fever)")
62
- if st.button("Get Medication Suggestions"):
63
- suggestions = suggest_medications(symptom)
64
- st.info(f"Suggested Medications: {', '.join(suggestions)}")
65
-
66
- elif choice == "Health Tracker":
67
- st.subheader("Log Symptom")
68
- symptom = st.text_input("Enter Symptom (e.g., headache, fatigue)")
69
- value = st.text_input("Enter Symptom Value (e.g., 5/10)")
70
- if st.button("Log Symptom"):
71
- log_message = log_symptom(symptom, value)
72
- st.success(log_message)
73
-
74
- st.subheader("Health Report")
75
- if st.button("Get Health Report"):
76
- health_report = get_health_report()
77
- st.dataframe(health_report)
78
-
79
- st.subheader("Track Health Stats")
80
- stat_type = st.selectbox("Select Stat to Track", ["blood_pressure", "weight", "heart_rate"])
81
- if st.button("Track Health Stat"):
82
- stats = track_health_stat(stat_type)
83
- st.write(stats)
84
-
85
- st.subheader("Personalized Health Advice from AI")
86
- if st.button("Get Personalized Health Advice"):
87
- advice = personalized_health_advice(symptom, value)
88
- st.info(advice)
89
-
90
- elif choice == "Lifestyle Recommendations":
91
- st.subheader("Lifestyle Recommendations")
92
- symptom = st.text_input("Enter Symptom (e.g., high blood pressure, diabetes)")
93
- value = st.text_input("Enter Symptom Value")
94
- if st.button("Get AI-based Lifestyle Recommendations"):
95
- response = openai.completions.create(
96
- model="gpt-3.5-turbo",
97
- prompt=f"Recommend a lifestyle modification plan for someone with {symptom} and value {value}.",
98
- max_tokens=150
99
- )
100
- st.info(response['choices'][0]['text'].strip())
101
-
102
- st.subheader("Fitness Tips")
103
- if st.button("Get Fitness Tips"):
104
- fitness_tips = get_fitness_tips()
105
- st.info(fitness_tips)
106
-
107
- st.subheader("Sleep Advice")
108
- if st.button("Get Sleep Advice"):
109
- sleep_advice = get_sleep_advice()
110
- st.info(sleep_advice)
111
-
112
- st.subheader("Diet Tips")
113
- if st.button("Get Diet Tips"):
114
- diet_tips = get_diet_tips()
115
- st.info(diet_tips)
 
1
+ # app.py
2
  import streamlit as st
3
+ from medication_agent import get_medication_suggestions
4
+ from health_tracker_agent import track_health_status
5
+ from lifestyle_agent import get_lifestyle_tips
6
+
7
+ st.title("Healthcare Assistant")
8
+
9
+ menu = st.sidebar.selectbox("Choose Service", ("Medication", "Health Tracker", "Lifestyle Advice"))
10
+
11
+ if menu == "Medication":
12
+ symptom = st.text_input("Enter your symptom:")
13
+ if st.button("Get Medication Suggestions") and symptom:
14
+ suggestions = get_medication_suggestions(symptom)
15
+ st.write(suggestions)
16
+
17
+ elif menu == "Health Tracker":
18
+ health_input = st.text_area("Enter your current health status or condition:")
19
+ if st.button("Track Health") and health_input:
20
+ result = track_health_status(health_input)
21
+ st.write(result)
22
+
23
+ elif menu == "Lifestyle Advice":
24
+ lifestyle_query = st.text_input("Enter your lifestyle concern or goal:")
25
+ if st.button("Get Advice") and lifestyle_query:
26
+ advice = get_lifestyle_tips(lifestyle_query)
27
+ st.write(advice)