MayankGupta06 commited on
Commit
b78a176
ยท
verified ยท
1 Parent(s): 2c2aa04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -2
app.py CHANGED
@@ -501,6 +501,7 @@ import folium
501
  from streamlit_folium import folium_static
502
  from geopy.geocoders import Nominatim
503
  from geopy.distance import geodesic
 
504
 
505
  # Set up AI model
506
  llm = ChatGoogleGenerativeAI(
@@ -524,7 +525,7 @@ st.write("Empowering healthcare with AI-driven insights and recommendations!")
524
 
525
  # Sidebar Navigation
526
  st.sidebar.title("๐Ÿ” Navigation")
527
- option = st.sidebar.radio("Select an option:", ["Home", "Symptom Checker", "Doctor Connect", "Health Stats"])
528
  translator = GoogleTranslator(source='auto', target='en')
529
 
530
  # Function to Get User Location
@@ -663,6 +664,79 @@ elif option == "Health Stats":
663
  ax.set_title("Disease Prevalence Statistics")
664
  st.pyplot(fig)
665
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  # Emergency Contact Section
667
  st.sidebar.markdown("---")
668
  st.sidebar.subheader("๐Ÿ“ž Emergency Contacts")
@@ -673,7 +747,7 @@ st.sidebar.write("- โ˜Ž *COVID-19 Helpline:* 1075")
673
  st.sidebar.write("- ๐Ÿš“ *Police:* 100")
674
 
675
  st.markdown("---")
676
- st.markdown("๐Ÿ”น Powered by Mayank, Wasim, Pravishank โ€“ Innovating Healthcare with AI! ๐Ÿ’ก Your Health, Our Mission. ๐Ÿš€")
677
 
678
 
679
 
 
501
  from streamlit_folium import folium_static
502
  from geopy.geocoders import Nominatim
503
  from geopy.distance import geodesic
504
+ import requests
505
 
506
  # Set up AI model
507
  llm = ChatGoogleGenerativeAI(
 
525
 
526
  # Sidebar Navigation
527
  st.sidebar.title("๐Ÿ” Navigation")
528
+ option = st.sidebar.radio("Select an option:", ["Home", "Symptom Checker", "Doctor Connect", "Health Stats", "Health Risk Calculator"])
529
  translator = GoogleTranslator(source='auto', target='en')
530
 
531
  # Function to Get User Location
 
664
  ax.set_title("Disease Prevalence Statistics")
665
  st.pyplot(fig)
666
 
667
+ elif option == "Health Risk Calculator":
668
+ st.subheader("๐Ÿงฎ Health Risk Calculator")
669
+ tabs = st.tabs(["๐Ÿ‹๏ธ BMI Calculator", "โค๏ธ Heart Risk Estimator", "๐Ÿฉธ Diabetes Risk Score"])
670
+
671
+ # --- BMI CALCULATOR ---
672
+ with tabs[0]:
673
+ st.markdown("### ๐Ÿ‹๏ธ Body Mass Index (BMI) Calculator")
674
+ height_cm = st.number_input("Enter height (in cm):", min_value=50.0, max_value=250.0, step=0.1)
675
+ weight_kg = st.number_input("Enter weight (in kg):", min_value=10.0, max_value=300.0, step=0.1)
676
+
677
+ if st.button("Calculate BMI"):
678
+ if height_cm > 0:
679
+ height_m = height_cm / 100
680
+ bmi = weight_kg / (height_m ** 2)
681
+ st.success(f"Your BMI is: **{bmi:.2f}**")
682
+ if bmi < 18.5:
683
+ st.info("Underweight")
684
+ elif 18.5 <= bmi < 24.9:
685
+ st.success("Normal weight")
686
+ elif 25 <= bmi < 29.9:
687
+ st.warning("Overweight")
688
+ else:
689
+ st.error("Obese")
690
+ else:
691
+ st.warning("Height must be greater than 0.")
692
+
693
+ # --- HEART ATTACK RISK ---
694
+ with tabs[1]:
695
+ st.markdown("### โค๏ธ Heart Attack Risk Estimator")
696
+ age = st.slider("Age", 18, 100, 30)
697
+ gender = st.radio("Gender", ["Male", "Female"])
698
+ smoker = st.radio("Do you smoke?", ["Yes", "No"])
699
+ systolic_bp = st.slider("Systolic Blood Pressure (mmHg)", 80, 200, 120)
700
+ cholesterol = st.slider("Cholesterol Level (mg/dL)", 100, 400, 200)
701
+
702
+ if st.button("Estimate Heart Attack Risk"):
703
+ risk_score = 0
704
+ if age > 45: risk_score += 1
705
+ if smoker == "Yes": risk_score += 1
706
+ if systolic_bp > 140: risk_score += 1
707
+ if cholesterol > 240: risk_score += 1
708
+ if gender == "Male": risk_score += 0.5
709
+
710
+ if risk_score <= 1:
711
+ st.success("Low Risk โœ…")
712
+ elif 2 <= risk_score <= 3:
713
+ st.warning("Moderate Risk โš ๏ธ")
714
+ else:
715
+ st.error("High Risk โŒ")
716
+
717
+ # --- DIABETES RISK ---
718
+ with tabs[2]:
719
+ st.markdown("### ๐Ÿฉธ Diabetes Risk Score Estimator")
720
+ age_d = st.slider("Age", 10, 100, 30, key="d1")
721
+ bmi_d = st.slider("BMI", 10.0, 50.0, 22.0, step=0.1, key="d2")
722
+ family_history = st.radio("Family History of Diabetes?", ["Yes", "No"], key="d3")
723
+ physical_activity = st.radio("Do you exercise regularly?", ["Yes", "No"], key="d4")
724
+ diet = st.radio("Do you consume sugary or high-carb food often?", ["Yes", "No"], key="d5")
725
+
726
+ if st.button("Estimate Diabetes Risk"):
727
+ d_score = 0
728
+ if age_d > 45: d_score += 1
729
+ if bmi_d > 30: d_score += 1
730
+ if family_history == "Yes": d_score += 1
731
+ if physical_activity == "No": d_score += 1
732
+ if diet == "Yes": d_score += 1
733
+
734
+ if d_score <= 1:
735
+ st.success("Low Risk โœ…")
736
+ elif 2 <= d_score <= 3:
737
+ st.warning("Moderate Risk โš ๏ธ")
738
+ else:
739
+ st.error("High Risk โŒ")
740
  # Emergency Contact Section
741
  st.sidebar.markdown("---")
742
  st.sidebar.subheader("๐Ÿ“ž Emergency Contacts")
 
747
  st.sidebar.write("- ๐Ÿš“ *Police:* 100")
748
 
749
  st.markdown("---")
750
+ st.markdown("๐Ÿ”น Powered by Mayank, Wasim, Pravishank, Ananya โ€“ Innovating Healthcare with AI! ๐Ÿ’ก Your Health, Our Mission. ๐Ÿš€")
751
 
752
 
753