SanaAdeel commited on
Commit
7293380
·
verified ·
1 Parent(s): 1474153

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -45
app.py CHANGED
@@ -42,56 +42,54 @@ def generate_menu(data, season, sub_category_pref, outings):
42
 
43
  # Function to calculate BMI and recommend diet for adults
44
  def bmi_insights(weight, height_cm):
45
- # Convert height from cm to meters
46
  height_m = height_cm / 100
47
  bmi = weight / (height_m ** 2)
48
 
49
  if bmi < 18.5:
50
- return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial. Consider incorporating more calories and nutritious snacks."
51
  elif 18.5 <= bmi < 24.9:
52
- return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet, including fruits, vegetables, whole grains, and lean proteins."
53
  elif 25 <= bmi < 29.9:
54
- return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight. Consider reducing sugar intake."
55
  else:
56
- return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods, vegetables, and lean proteins is recommended. Consult a health professional for personalized guidance."
57
 
58
  # Function to provide general diet recommendation for infants
59
  def infant_diet_recommendation():
60
  return (
61
  "For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
62
  "Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
63
- "Ensure a variety of textures as they grow and introduce protein-rich foods, like pureed meat or lentils. "
64
  "Consult with your pediatrician for more personalized advice."
65
  )
66
 
67
- # Function to provide specific recommendations based on medical conditions
68
  def medical_condition_recommendation(condition):
69
  recommendations = {
70
- "Diabetes": "For Type 1 and Type 2 diabetes, it is important to focus on a low-glycemic diet. Incorporate whole grains, non-starchy vegetables, lean proteins, and healthy fats. Avoid sugary foods and monitor carbohydrate intake.",
71
- "Celiac Disease": "For celiac disease, a gluten-free diet is essential. Avoid all wheat, rye, barley, and their derivatives. Focus on naturally gluten-free foods like fruits, vegetables, lean meats, and gluten-free grains like rice and quinoa.",
72
- "Hypertension": "For high blood pressure, it is recommended to reduce sodium intake, increase potassium-rich foods (like bananas, spinach), and focus on a heart-healthy diet with plenty of fruits, vegetables, lean proteins, and whole grains.",
73
- "Heart Disease": "A heart-healthy diet should be low in saturated fats and cholesterol. Focus on lean meats, fatty fish, fruits, vegetables, whole grains, and nuts. Avoid processed foods and limit salt intake.",
74
- "Obesity": "For obesity, focus on a calorie-controlled diet rich in fruits, vegetables, lean proteins, and whole grains. Reduce consumption of sugary foods, processed snacks, and refined carbs. Consider portion control and regular physical activity.",
75
- "Cholesterol Disorders": "For cholesterol issues, a diet low in saturated fats, trans fats, and cholesterol is essential. Include more fiber from fruits, vegetables, and whole grains, and opt for lean meats and fish like salmon.",
76
- "Irritable Bowel Syndrome (IBS)": "For IBS, a low FODMAP diet can be helpful. Avoid foods like onions, garlic, dairy products, and high-sugar foods. Focus on easily digestible foods like white rice, carrots, and lean proteins.",
77
- "Gastroesophageal Reflux Disease (GERD)": "For GERD, avoid spicy foods, caffeine, citrus, and fatty foods. Focus on non-citrus fruits, vegetables, whole grains, and lean meats, and eat smaller, more frequent meals.",
78
- "Peptic Ulcers": "For peptic ulcers, avoid spicy foods, alcohol, and caffeine. Focus on bland, non-acidic foods like oatmeal, rice, non-citrus fruits, and lean proteins like chicken or turkey.",
79
- "Lactose Intolerance": "For lactose intolerance, avoid dairy products that contain lactose. Opt for lactose-free alternatives such as almond milk, rice milk, and lactose-free yogurt.",
80
- "Kidney Disease (CKD)": "For kidney disease, it is essential to limit protein, sodium, and potassium intake. Focus on low-protein foods, fresh fruits, and vegetables, and consult with a healthcare provider for personalized dietary restrictions.",
81
- "Hypothyroidism": "For hypothyroidism, a balanced diet rich in fruits, vegetables, lean proteins, and whole grains is important. Avoid excessive soy products, and ensure adequate iodine intake.",
82
- "Anemia": "For iron-deficiency anemia, focus on iron-rich foods such as lean meats, spinach, lentils, and fortified cereals. Pair with vitamin C-rich foods (like oranges) to enhance iron absorption.",
83
- "Food Allergies": "For food allergies, avoid the specific allergens identified. This can include dairy, nuts, shellfish, etc. Always read labels carefully and opt for hypoallergenic foods.",
84
- "Acid Reflux and Heartburn": "For acid reflux, avoid spicy, fatty foods, and caffeine. Focus on non-citrus fruits, vegetables, and lean meats. Smaller, more frequent meals can help reduce symptoms.",
85
- "Crohn's Disease and Ulcerative Colitis": "For inflammatory bowel disease, focus on a diet low in fiber during flare-ups. Avoid high-fiber fruits, vegetables, and whole grains. Ensure adequate protein intake and stay hydrated.",
86
- "Osteoporosis": "For osteoporosis, ensure adequate calcium and vitamin D intake. Include dairy or fortified alternatives, leafy greens, and fatty fish like salmon.",
87
- "Autoimmune Diseases": "For autoimmune diseases like rheumatoid arthritis or lupus, focus on anti-inflammatory foods such as omega-3-rich fatty fish, nuts, seeds, fruits, and vegetables. Avoid processed foods.",
88
- "Migraines": "For migraines, avoid triggers like caffeine, chocolate, and alcohol. Focus on regular, balanced meals with a good mix of protein, healthy fats, and complex carbs.",
89
- "PCOS": "For PCOS, a low glycemic index diet with plenty of fiber, lean proteins, and healthy fats can help manage insulin resistance. Avoid sugary foods and refined carbs.",
90
- "Chronic Fatigue Syndrome": "For chronic fatigue syndrome, focus on a nutrient-dense diet rich in fruits, vegetables, whole grains, and lean proteins. Avoid processed foods and excessive sugar.",
91
- "Mental Health Conditions": "For mental health conditions like depression and anxiety, focus on a balanced diet rich in omega-3 fatty acids, B vitamins, and whole grains. Limit sugar and processed foods."
 
92
  }
93
-
94
- return recommendations.get(condition, "Please consult a healthcare professional for personalized advice.")
95
 
96
  # Main workflow
97
  def main():
@@ -123,26 +121,26 @@ def main():
123
  st.sidebar.success(bmi_message)
124
 
125
  # Dropdown for selecting medical condition(s)
126
- st.sidebar.header("Do you have any of the following medical conditions?")
127
  medical_condition = st.sidebar.selectbox(
128
- "Select a medical condition", [
129
- "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
130
- "Cholesterol Disorders", "Irritable Bowel Syndrome (IBS)", "GERD", "Peptic Ulcers",
131
- "Gout", "Lactose Intolerance", "Kidney Disease", "Hypothyroidism", "Anemia",
132
- "Food Allergies", "Acid Reflux", "Crohn's Disease", "Osteoporosis", "Autoimmune Diseases",
133
- "Migraines", "PCOS", "Chronic Fatigue Syndrome", "Mental Health Conditions"
134
  ]
135
  )
136
 
137
- # Get condition-based recommendations
138
- condition_recommendation = medical_condition_recommendation(medical_condition)
139
- st.sidebar.write(condition_recommendation)
140
 
141
- # Google Drive file URL
142
- file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file link
143
- data = load_data(file_url)
144
 
145
- # Main menu generation section
 
146
  season = st.selectbox("Select the current season", ["Summer", "Winter"])
147
 
148
  outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0)
 
42
 
43
  # Function to calculate BMI and recommend diet for adults
44
  def bmi_insights(weight, height_cm):
 
45
  height_m = height_cm / 100
46
  bmi = weight / (height_m ** 2)
47
 
48
  if bmi < 18.5:
49
+ return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial."
50
  elif 18.5 <= bmi < 24.9:
51
+ return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet."
52
  elif 25 <= bmi < 29.9:
53
+ return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight."
54
  else:
55
+ return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods and lean proteins is recommended."
56
 
57
  # Function to provide general diet recommendation for infants
58
  def infant_diet_recommendation():
59
  return (
60
  "For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
61
  "Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
 
62
  "Consult with your pediatrician for more personalized advice."
63
  )
64
 
65
+ # Function to provide dietary recommendations based on medical conditions
66
  def medical_condition_recommendation(condition):
67
  recommendations = {
68
+ "Diabetes": "A low-carb diet is essential. Focus on fiber-rich vegetables, lean proteins, and healthy fats. Avoid sugary foods.",
69
+ "Celiac Disease": "Avoid gluten-containing foods like wheat, barley, and rye. Focus on gluten-free grains, fruits, vegetables, and lean proteins.",
70
+ "Hypertension": "Limit salt intake. Incorporate potassium-rich foods such as bananas, spinach, and potatoes. A heart-healthy diet with lean proteins is ideal.",
71
+ "Heart Disease": "Consume a heart-healthy diet rich in omega-3 fatty acids, vegetables, and whole grains. Limit saturated fats and processed foods.",
72
+ "Obesity": "Focus on a calorie-restricted diet, prioritizing vegetables, lean meats, and whole grains. Avoid sugary snacks and drinks.",
73
+ "Cholesterol Disorders": "Eat foods rich in fiber, such as oats, fruits, and vegetables. Limit saturated fats and trans fats.",
74
+ "IBS": "Incorporate fiber-rich foods like oats and vegetables. Avoid foods that cause bloating, such as beans, cabbage, and onions.",
75
+ "GERD": "Avoid acidic and spicy foods, caffeine, and alcohol. Focus on bland, easy-to-digest meals like rice, oatmeal, and non-citrus fruits.",
76
+ "Peptic Ulcers": "Avoid spicy, fatty, and acidic foods. Focus on bland foods like rice, oatmeal, and non-citrus fruits.",
77
+ "Gout": "Limit foods high in purines, such as red meat, shellfish, and alcohol. Focus on low-fat dairy, fruits, and vegetables.",
78
+ "Lactose Intolerance": "Avoid dairy products or choose lactose-free alternatives. Incorporate plant-based sources of calcium.",
79
+ "Kidney Disease": "Reduce sodium, potassium, and phosphorus intake. Focus on lean proteins and avoid processed foods.",
80
+ "Hypothyroidism": "Increase iodine-rich foods like seaweed, eggs, and dairy. Focus on vegetables and lean proteins.",
81
+ "Anemia": "Focus on iron-rich foods such as red meat, spinach, and beans. Pair with vitamin C-rich foods for better absorption.",
82
+ "Food Allergies": "Avoid allergenic foods like peanuts, tree nuts, dairy, eggs, shellfish, and others. Focus on a balanced, allergy-free diet.",
83
+ "Acid Reflux": "Avoid acidic and spicy foods. Incorporate alkaline foods like bananas, melons, and oatmeal.",
84
+ "Crohn's Disease": "Focus on low-fiber foods and avoid spicy, fatty, and acidic foods. Prioritize lean meats and easy-to-digest grains.",
85
+ "Osteoporosis": "Ensure adequate calcium and vitamin D intake through dairy or fortified alternatives. Incorporate weight-bearing exercises.",
86
+ "Autoimmune Diseases": "A diet rich in anti-inflammatory foods like leafy greens, berries, nuts, and fatty fish is ideal.",
87
+ "Migraines": "Avoid foods that trigger migraines, such as chocolate, caffeine, and aged cheeses. Focus on magnesium-rich foods.",
88
+ "PCOS": "Focus on a low-glycemic index diet with plenty of fruits, vegetables, and lean proteins. Limit processed sugars.",
89
+ "CFS": "A balanced diet with adequate calories and nutrients is essential. Focus on anti-inflammatory foods and avoid refined sugars.",
90
+ "Mental Health": "Focus on omega-3 fatty acids, whole grains, fruits, and vegetables. Avoid processed foods and sugar."
91
  }
92
+ return recommendations.get(condition, "No specific recommendations available.")
 
93
 
94
  # Main workflow
95
  def main():
 
121
  st.sidebar.success(bmi_message)
122
 
123
  # Dropdown for selecting medical condition(s)
 
124
  medical_condition = st.sidebar.selectbox(
125
+ "Select any medical condition", [
126
+ "None", "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
127
+ "Cholesterol Disorders", "IBS", "GERD", "Peptic Ulcers", "Gout", "Lactose Intolerance",
128
+ "Kidney Disease", "Hypothyroidism", "Anemia", "Food Allergies", "Acid Reflux",
129
+ "Crohn's Disease", "Osteoporosis", "Autoimmune Diseases", "Migraines", "PCOS",
130
+ "CFS", "Mental Health"
131
  ]
132
  )
133
 
134
+ if medical_condition != "None":
135
+ condition_recommendation = medical_condition_recommendation(medical_condition)
136
+ st.sidebar.write(condition_recommendation)
137
 
138
+ # Google Drive file URL
139
+ file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file link
140
+ data = load_data(file_url)
141
 
142
+ # Main menu generation section (for Adults)
143
+ if category == "Adult":
144
  season = st.selectbox("Select the current season", ["Summer", "Winter"])
145
 
146
  outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0)