""" Hospital Map Component for DermaScan AI """ import os import streamlit as st def render_hospital_map(result, selected_city, selected_state): hosp_type = result.get("hospital_type", "Dermatologist") location = result.get("hospital_location", f"{selected_city}, {selected_state}") search_query = result.get("hospital_search_query", "dermatologist near me") full_query = f"{search_query} in {selected_city}, {selected_state}, India" encoded_query = full_query.replace(" ", "+") maps_url = "https://www.google.com/maps/search/" + encoded_query st.markdown( f'
' f"

πŸ₯ Find {hosp_type}

" f"

πŸ“ Searching in: {location}

" f"
", unsafe_allow_html=True, ) api_key = os.environ.get("MAPS_API_KEY", "") if api_key: embed_url = f"https://www.google.com/maps/embed/v1/search?key={api_key}&q={encoded_query}" st.markdown( f'', unsafe_allow_html=True, ) else: st.info("Set the MAPS_API_KEY secret in HF Space settings to enable the embedded map.") st.link_button( f"πŸ—ΊοΈ Open Google Maps β€” {hosp_type}", maps_url, use_container_width=True, ) st.markdown("") emergency = result.get("emergency_numbers", {}) if emergency: emer_html = '

🚨 Emergency Contacts

' for label, num in emergency.items(): emer_html += f"

πŸ“ž {label}: {num}

" emer_html += "
" st.markdown(emer_html, unsafe_allow_html=True)