Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -490,7 +490,6 @@ st.markdown("πΉ Powered by Mayank, Wasim, Pravishank β Innovating Healthcare
|
|
490 |
|
491 |
|
492 |
|
493 |
-
'''
|
494 |
import streamlit as st
|
495 |
import speech_recognition as sr
|
496 |
from deep_translator import GoogleTranslator
|
@@ -527,6 +526,15 @@ 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 |
if option == "Home":
|
531 |
user_question = st.text_input("Type your symptoms or disease name:")
|
532 |
|
@@ -571,50 +579,73 @@ elif option == "Symptom Checker":
|
|
571 |
response = llm.invoke(symptom_query)
|
572 |
st.write(response.content if hasattr(response, "content") else str(response))
|
573 |
|
|
|
574 |
elif option == "Doctor Connect":
|
575 |
-
st.subheader("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
|
584 |
-
def find_nearby_hospitals(user_location):
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
|
599 |
-
user_location = get_user_location()
|
600 |
-
if user_location:
|
601 |
-
|
602 |
|
603 |
-
|
604 |
-
|
605 |
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
|
615 |
-
|
616 |
-
else:
|
617 |
-
|
618 |
|
619 |
elif option == "Health Stats":
|
620 |
st.subheader("π Health Trends & Data")
|
@@ -641,12 +672,11 @@ st.markdown("πΉ Powered by Mayank, Wasim, Pravishank β Innovating Healthcare
|
|
641 |
|
642 |
|
643 |
|
644 |
-
'''
|
645 |
-
|
646 |
|
647 |
|
648 |
|
649 |
|
|
|
650 |
import streamlit as st
|
651 |
import speech_recognition as sr
|
652 |
from deep_translator import GoogleTranslator
|
@@ -778,3 +808,4 @@ st.sidebar.write("- π *Police:* 1000")
|
|
778 |
st.markdown("---")
|
779 |
st.markdown("πΉ Powered by Mayank, Wasim, Pravishank β Innovating Healthcare with AI! π‘ Your Health, Our Mission. π")
|
780 |
|
|
|
|
490 |
|
491 |
|
492 |
|
|
|
493 |
import streamlit as st
|
494 |
import speech_recognition as sr
|
495 |
from deep_translator import GoogleTranslator
|
|
|
526 |
option = st.sidebar.radio("Select an option:", ["Home", "Symptom Checker", "Doctor Connect", "Health Stats"])
|
527 |
translator = GoogleTranslator(source='auto', target='en')
|
528 |
|
529 |
+
# Function to Get User Location
|
530 |
+
def get_user_location():
|
531 |
+
try:
|
532 |
+
response = requests.get("https://ipinfo.io/json").json()
|
533 |
+
location = response["loc"].split(",")
|
534 |
+
return float(location[0]), float(location[1])
|
535 |
+
except:
|
536 |
+
return None, None
|
537 |
+
|
538 |
if option == "Home":
|
539 |
user_question = st.text_input("Type your symptoms or disease name:")
|
540 |
|
|
|
579 |
response = llm.invoke(symptom_query)
|
580 |
st.write(response.content if hasattr(response, "content") else str(response))
|
581 |
|
582 |
+
|
583 |
elif option == "Doctor Connect":
|
584 |
+
st.subheader("π₯ Find a Doctor Near You")
|
585 |
+
lat, lon = get_user_location()
|
586 |
+
|
587 |
+
if lat is None or lon is None:
|
588 |
+
st.warning("Unable to fetch location. Please allow location access or enter manually.")
|
589 |
+
address = st.text_input("Enter your location (City, State or Latitude, Longitude):")
|
590 |
+
if address:
|
591 |
+
geolocator = Nominatim(user_agent="geoapi")
|
592 |
+
location = geolocator.geocode(address)
|
593 |
+
if location:
|
594 |
+
lat, lon = location.latitude, location.longitude
|
595 |
+
else:
|
596 |
+
st.error("Invalid address! Try again.")
|
597 |
+
|
598 |
+
if lat and lon:
|
599 |
+
st.success(f"π Location detected: {lat}, {lon}")
|
600 |
+
map_ = folium.Map(location=[lat, lon], zoom_start=13)
|
601 |
+
folium.Marker([lat, lon], popup="You are here!", icon=folium.Icon(color="blue")).add_to(map_)
|
602 |
+
folium_static(map_)
|
603 |
+
|
604 |
+
|
605 |
+
# elif option == "Doctor Connect":
|
606 |
+
# st.subheader("π Doctor Connect - Find Nearby Hospitals")
|
607 |
|
608 |
+
# def get_user_location():
|
609 |
+
# geolocator = Nominatim(user_agent="geoapi")
|
610 |
+
# location = geolocator.geocode("Phagwara") # Replace with dynamic location if needed
|
611 |
+
# if location:
|
612 |
+
# return location.latitude, location.longitude
|
613 |
+
# return None
|
614 |
|
615 |
+
# def find_nearby_hospitals(user_location):
|
616 |
+
# hospitals = [
|
617 |
+
# {"name": "Apollo Hospital", "location": (30.7333, 76.7794)},
|
618 |
+
# {"name": "Fortis Hospital", "location": (30.7194, 76.7644)},
|
619 |
+
# {"name": "Max Hospital", "location": (30.7086, 76.7853)},
|
620 |
+
# {"name": "AIIMS Hospital", "location": (30.7500, 76.7800)}
|
621 |
+
# ]
|
622 |
|
623 |
+
# nearby_hospitals = []
|
624 |
+
# for hospital in hospitals:
|
625 |
+
# distance = geodesic(user_location, hospital["location"]).km
|
626 |
+
# if distance <= 10:
|
627 |
+
# nearby_hospitals.append(hospital)
|
628 |
+
# return nearby_hospitals
|
629 |
|
630 |
+
# user_location = get_user_location()
|
631 |
+
# if user_location:
|
632 |
+
# st.success(f"π Your Location: {user_location}")
|
633 |
|
634 |
+
# m = folium.Map(location=user_location, zoom_start=13)
|
635 |
+
# folium.Marker(user_location, tooltip="Your Location", icon=folium.Icon(color="blue")).add_to(m)
|
636 |
|
637 |
+
# hospitals = find_nearby_hospitals(user_location)
|
638 |
+
# if hospitals:
|
639 |
+
# st.write("π₯ Nearby Hospitals:")
|
640 |
+
# for hospital in hospitals:
|
641 |
+
# st.write(f"πΉ {hospital['name']}")
|
642 |
+
# folium.Marker(hospital["location"], tooltip=hospital["name"], icon=folium.Icon(color="red")).add_to(m)
|
643 |
+
# else:
|
644 |
+
# st.write("β οΈ No nearby hospitals found within 10 km.")
|
645 |
|
646 |
+
# folium_static(m)
|
647 |
+
# else:
|
648 |
+
# st.error("β οΈ Unable to fetch location. Please allow location access or enter manually.")
|
649 |
|
650 |
elif option == "Health Stats":
|
651 |
st.subheader("π Health Trends & Data")
|
|
|
672 |
|
673 |
|
674 |
|
|
|
|
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
+
'''
|
680 |
import streamlit as st
|
681 |
import speech_recognition as sr
|
682 |
from deep_translator import GoogleTranslator
|
|
|
808 |
st.markdown("---")
|
809 |
st.markdown("πΉ Powered by Mayank, Wasim, Pravishank β Innovating Healthcare with AI! π‘ Your Health, Our Mission. π")
|
810 |
|
811 |
+
'''
|