mohitrajdeo
commited on
Commit
·
06e6ec0
1
Parent(s):
40aa75e
feat(navigation): add 'Health Score' option to navigation menu
Browse filesThis commit introduces a new 'Health Score' option to the navigation menu in the app, allowing users to access the health score assessment feature directly from the sidebar. The change enhances the user experience by providing quick access to this important functionality.
- app.py +1 -1
- result.txt +392 -0
app.py
CHANGED
@@ -62,7 +62,7 @@ with st.sidebar:
|
|
62 |
|
63 |
selected = option_menu(
|
64 |
menu_title="Navigation",
|
65 |
-
options=['Home',
|
66 |
icons=['house', 'activity', 'lungs', 'heart-pulse', 'brain', 'bar-chart', 'chat'],
|
67 |
menu_icon="cast",
|
68 |
default_index=0,
|
|
|
62 |
|
63 |
selected = option_menu(
|
64 |
menu_title="Navigation",
|
65 |
+
options=['Home','Health Score' , 'Diabetes Prediction','Hypertension Prediction', 'Cardiovascular Disease Prediction', 'Stroke Prediction','Asthma Prediction', 'Sleep Health Analysis','Mental-Analysis','Medical Consultant', 'Data Visualization'],
|
66 |
icons=['house', 'activity', 'lungs', 'heart-pulse', 'brain', 'bar-chart', 'chat'],
|
67 |
menu_icon="cast",
|
68 |
default_index=0,
|
result.txt
ADDED
@@ -0,0 +1,392 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import plotly.express as px
|
6 |
+
import plotly.graph_objects as go
|
7 |
+
from plotly.subplots import make_subplots
|
8 |
+
|
9 |
+
# Set page config
|
10 |
+
st.set_page_config(
|
11 |
+
page_title="HealthPredict AI",
|
12 |
+
page_icon="🏥",
|
13 |
+
layout="wide"
|
14 |
+
)
|
15 |
+
|
16 |
+
# Initialize session state variables if they don't exist
|
17 |
+
if 'current_step' not in st.session_state:
|
18 |
+
st.session_state.current_step = 0
|
19 |
+
if 'assessment_data' not in st.session_state:
|
20 |
+
st.session_state.assessment_data = {}
|
21 |
+
if 'results_calculated' not in st.session_state:
|
22 |
+
st.session_state.results_calculated = False
|
23 |
+
if 'risk_data' not in st.session_state:
|
24 |
+
st.session_state.risk_data = []
|
25 |
+
if 'health_score' not in st.session_state:
|
26 |
+
st.session_state.health_score = 0
|
27 |
+
if 'recommendations' not in st.session_state:
|
28 |
+
st.session_state.recommendations = []
|
29 |
+
|
30 |
+
# Define steps for the assessment
|
31 |
+
steps = [
|
32 |
+
{"title": "Basic Information", "fields": ["age", "gender", "height", "weight"]},
|
33 |
+
{"title": "Lifestyle", "fields": ["smoking_status", "alcohol_consumption", "physical_activity", "diet_type"]},
|
34 |
+
{"title": "Medical History", "fields": ["family_history_diabetes", "family_history_heart_disease",
|
35 |
+
"family_history_hypertension", "previous_diagnoses"]},
|
36 |
+
{"title": "Vital Signs", "fields": ["systolic_bp", "diastolic_bp", "resting_heart_rate"]},
|
37 |
+
{"title": "Mental Health", "fields": ["stress_level", "sleep_quality", "sleep_duration"]},
|
38 |
+
{"title": "Nutrition", "fields": ["daily_water_intake", "daily_fruit_veg_servings"]},
|
39 |
+
{"title": "Additional Metrics", "fields": ["waist_circumference", "body_fat_percentage"]},
|
40 |
+
{"title": "Additional Health Information", "fields": ["family_history_asthma", "family_history_obesity",
|
41 |
+
"family_history_depression", "allergies",
|
42 |
+
"chronic_pain", "mental_health_history"]}
|
43 |
+
]
|
44 |
+
|
45 |
+
# Function to calculate risk for different diseases
|
46 |
+
def calculate_risk(disease, data):
|
47 |
+
risk = 0
|
48 |
+
|
49 |
+
if disease == "Diabetes":
|
50 |
+
if data.get("age", 0) > 45: risk += 10
|
51 |
+
if float(data.get("bmi", 0)) > 30: risk += 15
|
52 |
+
if data.get("family_history_diabetes", False): risk += 15
|
53 |
+
if data.get("physical_activity", "") == "sedentary": risk += 10
|
54 |
+
|
55 |
+
elif disease == "Heart Disease":
|
56 |
+
if data.get("age", 0) > 55: risk += 10
|
57 |
+
if data.get("systolic_bp", 0) > 140 or data.get("diastolic_bp", 0) > 90: risk += 15
|
58 |
+
if data.get("family_history_heart_disease", False): risk += 15
|
59 |
+
if data.get("smoking_status", "") == "current": risk += 15
|
60 |
+
|
61 |
+
elif disease == "Hypertension":
|
62 |
+
if data.get("systolic_bp", 0) > 140 or data.get("diastolic_bp", 0) > 90: risk += 20
|
63 |
+
if data.get("family_history_hypertension", False): risk += 15
|
64 |
+
if data.get("alcohol_consumption", "") == "heavy": risk += 10
|
65 |
+
|
66 |
+
elif disease == "Obesity":
|
67 |
+
if float(data.get("bmi", 0)) > 30: risk += 30
|
68 |
+
if data.get("physical_activity", "") == "sedentary": risk += 15
|
69 |
+
if data.get("family_history_obesity", False): risk += 10
|
70 |
+
|
71 |
+
elif disease == "Asthma":
|
72 |
+
if data.get("family_history_asthma", False): risk += 20
|
73 |
+
if data.get("smoking_status", "") == "current": risk += 15
|
74 |
+
allergies = data.get("allergies", "").lower()
|
75 |
+
if "pollen" in allergies or "dust" in allergies: risk += 10
|
76 |
+
|
77 |
+
elif disease == "Depression":
|
78 |
+
if data.get("family_history_depression", False): risk += 15
|
79 |
+
if data.get("stress_level", 0) > 7: risk += 15
|
80 |
+
if data.get("sleep_quality", "") == "poor": risk += 10
|
81 |
+
mental_health = data.get("mental_health_history", "").lower()
|
82 |
+
if "depression" in mental_health or "anxiety" in mental_health: risk += 20
|
83 |
+
|
84 |
+
return min(risk, 100)
|
85 |
+
|
86 |
+
# Function to generate recommendations
|
87 |
+
def generate_recommendations(data):
|
88 |
+
recommendations = []
|
89 |
+
|
90 |
+
if data.get("physical_activity", "") in ["sedentary", "light"]:
|
91 |
+
recommendations.append("Increase your daily physical activity to at least 30 minutes of moderate exercise.")
|
92 |
+
|
93 |
+
if data.get("daily_fruit_veg_servings", 0) < 5:
|
94 |
+
recommendations.append("Increase your daily intake of fruits and vegetables to at least 5 servings.")
|
95 |
+
|
96 |
+
if data.get("daily_water_intake", 0) < 2000:
|
97 |
+
recommendations.append("Increase your daily water intake to at least 2 liters (2000ml).")
|
98 |
+
|
99 |
+
if data.get("sleep_duration", 0) < 7 or data.get("sleep_quality", "") in ["poor", "fair"]:
|
100 |
+
recommendations.append("Aim for 7-9 hours of quality sleep per night to improve overall health.")
|
101 |
+
|
102 |
+
if data.get("stress_level", 0) > 7:
|
103 |
+
recommendations.append("Practice stress-reduction techniques such as meditation or deep breathing exercises.")
|
104 |
+
|
105 |
+
if data.get("smoking_status", "") == "current":
|
106 |
+
recommendations.append("Consider quitting smoking to significantly reduce your risk of heart disease and other health problems.")
|
107 |
+
|
108 |
+
if data.get("alcohol_consumption", "") == "heavy":
|
109 |
+
recommendations.append("Reduce alcohol consumption to moderate levels or consider abstaining completely.")
|
110 |
+
|
111 |
+
if float(data.get("bmi", 0)) > 25:
|
112 |
+
recommendations.append("Work on maintaining a healthy weight through a balanced diet and regular exercise.")
|
113 |
+
|
114 |
+
if data.get("chronic_pain", "") != "none":
|
115 |
+
recommendations.append("Consult with a healthcare professional about managing your chronic pain and consider physical therapy or pain management techniques.")
|
116 |
+
|
117 |
+
if data.get("mental_health_history", "") != "":
|
118 |
+
recommendations.append("Continue to prioritize your mental health. Consider regular check-ins with a mental health professional.")
|
119 |
+
|
120 |
+
return recommendations
|
121 |
+
|
122 |
+
# Function to calculate results
|
123 |
+
def calculate_results():
|
124 |
+
# Calculate BMI if not already done
|
125 |
+
if "bmi" not in st.session_state.assessment_data:
|
126 |
+
height_m = st.session_state.assessment_data.get("height", 170) / 100
|
127 |
+
weight = st.session_state.assessment_data.get("weight", 70)
|
128 |
+
bmi = weight / (height_m * height_m)
|
129 |
+
st.session_state.assessment_data["bmi"] = round(bmi, 1)
|
130 |
+
|
131 |
+
# Calculate risk for each disease
|
132 |
+
diseases = ["Diabetes", "Heart Disease", "Hypertension", "Obesity", "Asthma", "Depression"]
|
133 |
+
risk_data = []
|
134 |
+
|
135 |
+
for disease in diseases:
|
136 |
+
risk = calculate_risk(disease, st.session_state.assessment_data)
|
137 |
+
risk_data.append({"disease": disease, "risk": risk})
|
138 |
+
|
139 |
+
st.session_state.risk_data = risk_data
|
140 |
+
|
141 |
+
# Calculate overall health score (scaled to 0-100)
|
142 |
+
total_risk = sum(item["risk"] for item in risk_data)
|
143 |
+
health_score = round(100 * (1 - total_risk / (len(diseases) * 100)))
|
144 |
+
st.session_state.health_score = health_score
|
145 |
+
|
146 |
+
# Generate recommendations
|
147 |
+
st.session_state.recommendations = generate_recommendations(st.session_state.assessment_data)
|
148 |
+
|
149 |
+
st.session_state.results_calculated = True
|
150 |
+
|
151 |
+
# Function to handle form submission for each step
|
152 |
+
def process_step(step_index):
|
153 |
+
# Save form data to session state
|
154 |
+
for field in steps[step_index]["fields"]:
|
155 |
+
if field in st.session_state:
|
156 |
+
st.session_state.assessment_data[field] = st.session_state[field]
|
157 |
+
|
158 |
+
# Move to next step or calculate results
|
159 |
+
if step_index < len(steps) - 1:
|
160 |
+
st.session_state.current_step += 1
|
161 |
+
else:
|
162 |
+
calculate_results()
|
163 |
+
|
164 |
+
# Function to go back to previous step
|
165 |
+
def go_back():
|
166 |
+
if st.session_state.current_step > 0:
|
167 |
+
st.session_state.current_step -= 1
|
168 |
+
|
169 |
+
# Function to restart assessment
|
170 |
+
def restart_assessment():
|
171 |
+
st.session_state.current_step = 0
|
172 |
+
st.session_state.assessment_data = {}
|
173 |
+
st.session_state.results_calculated = False
|
174 |
+
st.session_state.risk_data = []
|
175 |
+
st.session_state.health_score = 0
|
176 |
+
st.session_state.recommendations = []
|
177 |
+
|
178 |
+
# Main app
|
179 |
+
def main():
|
180 |
+
st.title("HealthPredict AI")
|
181 |
+
|
182 |
+
# Display results if calculated
|
183 |
+
if st.session_state.results_calculated:
|
184 |
+
st.header("Your Health Assessment Results")
|
185 |
+
|
186 |
+
# Create columns for layout
|
187 |
+
col1, col2 = st.columns(2)
|
188 |
+
|
189 |
+
with col1:
|
190 |
+
# Bar chart for disease risks
|
191 |
+
risk_df = pd.DataFrame(st.session_state.risk_data)
|
192 |
+
fig = px.bar(
|
193 |
+
risk_df,
|
194 |
+
x='disease',
|
195 |
+
y='risk',
|
196 |
+
title='Disease Risk Assessment',
|
197 |
+
labels={'disease': 'Disease', 'risk': 'Risk Score'},
|
198 |
+
color='risk',
|
199 |
+
color_continuous_scale=[(0, 'green'), (0.5, 'yellow'), (1, 'red')]
|
200 |
+
)
|
201 |
+
st.plotly_chart(fig, use_container_width=True)
|
202 |
+
|
203 |
+
with col2:
|
204 |
+
# Radar chart for disease risks
|
205 |
+
fig = go.Figure()
|
206 |
+
|
207 |
+
fig.add_trace(go.Scatterpolar(
|
208 |
+
r=[item["risk"] for item in st.session_state.risk_data],
|
209 |
+
theta=[item["disease"] for item in st.session_state.risk_data],
|
210 |
+
fill='toself',
|
211 |
+
name='Risk Profile'
|
212 |
+
))
|
213 |
+
|
214 |
+
fig.update_layout(
|
215 |
+
polar=dict(
|
216 |
+
radialaxis=dict(
|
217 |
+
visible=True,
|
218 |
+
range=[0, 100]
|
219 |
+
)
|
220 |
+
),
|
221 |
+
title="Health Risk Radar"
|
222 |
+
)
|
223 |
+
|
224 |
+
st.plotly_chart(fig, use_container_width=True)
|
225 |
+
|
226 |
+
# Health score gauge
|
227 |
+
fig = go.Figure(go.Indicator(
|
228 |
+
mode="gauge+number",
|
229 |
+
value=st.session_state.health_score,
|
230 |
+
domain={'x': [0, 1], 'y': [0, 1]},
|
231 |
+
title={'text': "Overall Health Score"},
|
232 |
+
gauge={
|
233 |
+
'axis': {'range': [0, 100]},
|
234 |
+
'bar': {'color': "darkblue"},
|
235 |
+
'steps': [
|
236 |
+
{'range': [0, 30], 'color': "red"},
|
237 |
+
{'range': [30, 70], 'color': "yellow"},
|
238 |
+
{'range': [70, 100], 'color': "green"}
|
239 |
+
]
|
240 |
+
}
|
241 |
+
))
|
242 |
+
|
243 |
+
st.plotly_chart(fig, use_container_width=True)
|
244 |
+
|
245 |
+
# Recommendations
|
246 |
+
st.subheader("Recommendations")
|
247 |
+
for i, recommendation in enumerate(st.session_state.recommendations):
|
248 |
+
st.markdown(f"- {recommendation}")
|
249 |
+
|
250 |
+
# Button to restart assessment
|
251 |
+
if st.button("Retake Assessment"):
|
252 |
+
restart_assessment()
|
253 |
+
|
254 |
+
# Display assessment form if results not calculated
|
255 |
+
else:
|
256 |
+
current_step = st.session_state.current_step
|
257 |
+
step = steps[current_step]
|
258 |
+
|
259 |
+
st.header(f"Comprehensive Health Assessment")
|
260 |
+
st.subheader(f"{step['title']} (Step {current_step + 1} of {len(steps)})")
|
261 |
+
|
262 |
+
# Create a centered container with smaller width
|
263 |
+
col1, form_col, col3 = st.columns([1, 2, 1])
|
264 |
+
|
265 |
+
with form_col:
|
266 |
+
with st.form(f"step_{current_step}_form"):
|
267 |
+
# Basic Information
|
268 |
+
if "age" in step["fields"]:
|
269 |
+
st.session_state.age = st.number_input("Age", 0, 120, st.session_state.assessment_data.get("age", 30))
|
270 |
+
|
271 |
+
if "gender" in step["fields"]:
|
272 |
+
st.session_state.gender = st.selectbox("Gender",
|
273 |
+
["male", "female", "other"],
|
274 |
+
["male", "female", "other"].index(st.session_state.assessment_data.get("gender", "male")))
|
275 |
+
|
276 |
+
if "height" in step["fields"]:
|
277 |
+
st.session_state.height = st.number_input("Height (cm)", 100, 250, st.session_state.assessment_data.get("height", 170))
|
278 |
+
|
279 |
+
if "weight" in step["fields"]:
|
280 |
+
st.session_state.weight = st.number_input("Weight (kg)", 30, 300, st.session_state.assessment_data.get("weight", 70))
|
281 |
+
|
282 |
+
# Lifestyle
|
283 |
+
if "smoking_status" in step["fields"]:
|
284 |
+
st.session_state.smoking_status = st.selectbox("Smoking Status",
|
285 |
+
["never", "former", "current"],
|
286 |
+
["never", "former", "current"].index(st.session_state.assessment_data.get("smoking_status", "never")))
|
287 |
+
|
288 |
+
if "alcohol_consumption" in step["fields"]:
|
289 |
+
st.session_state.alcohol_consumption = st.selectbox("Alcohol Consumption",
|
290 |
+
["none", "moderate", "heavy"],
|
291 |
+
["none", "moderate", "heavy"].index(st.session_state.assessment_data.get("alcohol_consumption", "moderate")))
|
292 |
+
|
293 |
+
if "physical_activity" in step["fields"]:
|
294 |
+
st.session_state.physical_activity = st.selectbox("Physical Activity Level",
|
295 |
+
["sedentary", "light", "moderate", "vigorous"],
|
296 |
+
["sedentary", "light", "moderate", "vigorous"].index(st.session_state.assessment_data.get("physical_activity", "moderate")))
|
297 |
+
|
298 |
+
if "diet_type" in step["fields"]:
|
299 |
+
st.session_state.diet_type = st.selectbox("Diet Type",
|
300 |
+
["balanced", "high-carb", "high-protein", "vegetarian", "vegan"],
|
301 |
+
["balanced", "high-carb", "high-protein", "vegetarian", "vegan"].index(st.session_state.assessment_data.get("diet_type", "balanced")))
|
302 |
+
|
303 |
+
# Medical History
|
304 |
+
if "family_history_diabetes" in step["fields"]:
|
305 |
+
st.session_state.family_history_diabetes = st.checkbox("Family History of Diabetes", st.session_state.assessment_data.get("family_history_diabetes", False))
|
306 |
+
|
307 |
+
if "family_history_heart_disease" in step["fields"]:
|
308 |
+
st.session_state.family_history_heart_disease = st.checkbox("Family History of Heart Disease", st.session_state.assessment_data.get("family_history_heart_disease", False))
|
309 |
+
|
310 |
+
if "family_history_hypertension" in step["fields"]:
|
311 |
+
st.session_state.family_history_hypertension = st.checkbox("Family History of Hypertension", st.session_state.assessment_data.get("family_history_hypertension", False))
|
312 |
+
|
313 |
+
if "previous_diagnoses" in step["fields"]:
|
314 |
+
st.session_state.previous_diagnoses = st.text_input("Previous Diagnoses (comma separated)", st.session_state.assessment_data.get("previous_diagnoses", ""))
|
315 |
+
|
316 |
+
# Vital Signs
|
317 |
+
if "systolic_bp" in step["fields"]:
|
318 |
+
st.session_state.systolic_bp = st.number_input("Systolic Blood Pressure", 70, 220, st.session_state.assessment_data.get("systolic_bp", 120))
|
319 |
+
|
320 |
+
if "diastolic_bp" in step["fields"]:
|
321 |
+
st.session_state.diastolic_bp = st.number_input("Diastolic Blood Pressure", 40, 130, st.session_state.assessment_data.get("diastolic_bp", 80))
|
322 |
+
|
323 |
+
if "resting_heart_rate" in step["fields"]:
|
324 |
+
st.session_state.resting_heart_rate = st.number_input("Resting Heart Rate", 40, 120, st.session_state.assessment_data.get("resting_heart_rate", 70))
|
325 |
+
|
326 |
+
# Mental Health
|
327 |
+
if "stress_level" in step["fields"]:
|
328 |
+
st.session_state.stress_level = st.slider("Stress Level (1-10)", 1, 10, st.session_state.assessment_data.get("stress_level", 5))
|
329 |
+
|
330 |
+
if "sleep_quality" in step["fields"]:
|
331 |
+
st.session_state.sleep_quality = st.selectbox("Sleep Quality",
|
332 |
+
["poor", "fair", "good", "excellent"],
|
333 |
+
["poor", "fair", "good", "excellent"].index(st.session_state.assessment_data.get("sleep_quality", "good")))
|
334 |
+
|
335 |
+
if "sleep_duration" in step["fields"]:
|
336 |
+
st.session_state.sleep_duration = st.number_input("Sleep Duration (hours)", 3.0, 12.0, float(st.session_state.assessment_data.get("sleep_duration", 7.0)), 0.5)
|
337 |
+
|
338 |
+
# Nutrition
|
339 |
+
if "daily_water_intake" in step["fields"]:
|
340 |
+
st.session_state.daily_water_intake = st.number_input("Daily Water Intake (ml)", 0, 5000, st.session_state.assessment_data.get("daily_water_intake", 2000), 100)
|
341 |
+
|
342 |
+
if "daily_fruit_veg_servings" in step["fields"]:
|
343 |
+
st.session_state.daily_fruit_veg_servings = st.number_input("Daily Fruit & Vegetable Servings", 0, 10, st.session_state.assessment_data.get("daily_fruit_veg_servings", 3))
|
344 |
+
|
345 |
+
# Additional Metrics
|
346 |
+
if "waist_circumference" in step["fields"]:
|
347 |
+
st.session_state.waist_circumference = st.number_input("Waist Circumference (cm)", 50, 200, st.session_state.assessment_data.get("waist_circumference", 80))
|
348 |
+
|
349 |
+
if "body_fat_percentage" in step["fields"]:
|
350 |
+
st.session_state.body_fat_percentage = st.number_input("Body Fat Percentage", 5.0, 50.0, float(st.session_state.assessment_data.get("body_fat_percentage", 20.0)), 0.5)
|
351 |
+
|
352 |
+
# Additional Health Information
|
353 |
+
if "family_history_asthma" in step["fields"]:
|
354 |
+
st.session_state.family_history_asthma = st.checkbox("Family History of Asthma", st.session_state.assessment_data.get("family_history_asthma", False))
|
355 |
+
|
356 |
+
if "family_history_obesity" in step["fields"]:
|
357 |
+
st.session_state.family_history_obesity = st.checkbox("Family History of Obesity", st.session_state.assessment_data.get("family_history_obesity", False))
|
358 |
+
|
359 |
+
if "family_history_depression" in step["fields"]:
|
360 |
+
st.session_state.family_history_depression = st.checkbox("Family History of Depression", st.session_state.assessment_data.get("family_history_depression", False))
|
361 |
+
|
362 |
+
if "allergies" in step["fields"]:
|
363 |
+
st.session_state.allergies = st.text_input("Allergies (comma separated)", st.session_state.assessment_data.get("allergies", ""))
|
364 |
+
|
365 |
+
if "chronic_pain" in step["fields"]:
|
366 |
+
st.session_state.chronic_pain = st.selectbox("Chronic Pain Level",
|
367 |
+
["none", "mild", "moderate", "severe"],
|
368 |
+
["none", "mild", "moderate", "severe"].index(st.session_state.assessment_data.get("chronic_pain", "none")))
|
369 |
+
|
370 |
+
if "mental_health_history" in step["fields"]:
|
371 |
+
st.session_state.mental_health_history = st.text_area("Mental Health History", st.session_state.assessment_data.get("mental_health_history", ""))
|
372 |
+
|
373 |
+
# Form buttons
|
374 |
+
col1, col2 = st.columns(2)
|
375 |
+
with col1:
|
376 |
+
if current_step > 0:
|
377 |
+
back_button = st.form_submit_button("Back")
|
378 |
+
if back_button:
|
379 |
+
go_back()
|
380 |
+
|
381 |
+
with col2:
|
382 |
+
if current_step < len(steps) - 1:
|
383 |
+
next_button = st.form_submit_button("Next")
|
384 |
+
if next_button:
|
385 |
+
process_step(current_step)
|
386 |
+
else:
|
387 |
+
submit_button = st.form_submit_button("Submit Assessment")
|
388 |
+
if submit_button:
|
389 |
+
process_step(current_step)
|
390 |
+
|
391 |
+
if __name__ == "__main__":
|
392 |
+
main()
|