File size: 10,687 Bytes
00a6b9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import streamlit as st
import folium
from folium.plugins import MarkerCluster
from streamlit_folium import folium_static
import googlemaps
from datetime import datetime
import os

# Initialize Google Maps
gmaps = googlemaps.Client(key=os.getenv('GOOGLE_KEY'))

# Function to fetch directions
def get_directions_and_coords(source, destination):
    now = datetime.now()
    directions_info = gmaps.directions(source, destination, mode='driving', departure_time=now)
    if directions_info:
        steps = directions_info[0]['legs'][0]['steps']
        coords = [(step['start_location']['lat'], step['start_location']['lng']) for step in steps]
        return steps, coords
    else:
        return None, None

# Function to render map with directions
def render_folium_map(coords):
    m = folium.Map(location=[coords[0][0], coords[0][1]], zoom_start=13)
    folium.PolyLine(coords, color="blue", weight=2.5, opacity=1).add_to(m)
    return m

# Function to add medical center paths and annotate distance
def add_medical_center_paths(m, source, med_centers):
    for name, lat, lon, specialty, city in med_centers:
        _, coords = get_directions_and_coords(source, (lat, lon))
        if coords:
            folium.PolyLine(coords, color="red", weight=2.5, opacity=1).add_to(m)
            folium.Marker([lat, lon], popup=name).add_to(m)
            distance_info = gmaps.distance_matrix(source, (lat, lon), mode='driving')
            distance = distance_info['rows'][0]['elements'][0]['distance']['text']
            folium.PolyLine(coords, color='red').add_to(m)
            folium.map.Marker(
                [coords[-1][0], coords[-1][1]],
                icon=folium.DivIcon(
                    icon_size=(150, 36),
                    icon_anchor=(0, 0),
                    html=f'<div style="font-size: 10pt; color : red;">{distance}</div>',
                    )
                ).add_to(m)

# Driving Directions Sidebar
st.sidebar.header('Directions πŸš—')
source_location = st.sidebar.text_input("Source Location", "4 Brotherton Way, Auburn, MA 01501")
destination_location = st.sidebar.text_input("Destination Location", "366 Shrewsbury Street, Worcester, MA, 01604")

# Fetch and Display Directions
if st.sidebar.button('Get Directions'):
    steps, coords = get_directions_and_coords(source_location, destination_location)
    if steps and coords:
        st.subheader('Driving Directions:')
        for i, step in enumerate(steps):
            st.write(f"{i+1}. {step['html_instructions']}")
        st.subheader('Route on Map:')
        m1 = render_folium_map(coords)
        folium_static(m1)
    else:
        st.write("No available routes.")

# Massachusetts Medical Centers
st.markdown("### πŸ—ΊοΈ Maps - πŸ₯ Massachusetts Medical Centers 🌳")
m2 = folium.Map(location=[42.3601, -71.0589], zoom_start=8)
marker_cluster = MarkerCluster().add_to(m2)

massachusetts_med_centers = [
    ('The Endoscopy Center', 42.2098, -71.8356, '4 Brotherton Way, (508) 425-5446', 'Auburn'),
    ('ReadyMED – Auburn', 42.2090, -71.8358, '460 Southbridge Street, (508) 595-2700', 'Auburn'),
    ('Durable Medical Equipment', 42.2115, -71.8370, '42 Southbridge Street, (508) 407-7700', 'Auburn'),
    ('Auburn', 42.2098, -71.8356, '4 Brotherton Way, (508) 832-9621', 'Auburn'),
    ('Framingham', 42.2793, -71.4162, '761 Worcester Rd, (508) 872-1107', 'Framingham'),
    ('Holden', 42.3518, -71.8634, '64 Boyden Road, (508) 829-6765', 'Holden'),
    ('ReadyMED – Hudson', 42.3912, -71.5662, '234 Washington Street, (508) 595-2700', 'Hudson'),
    ('ReadyMED – Leominster', 42.5251, -71.7598, '241 North Main Street, (508) 595-2700', 'Leominster'),
    ('Leominster', 42.5204, -71.7717, '225 New Lancaster Road, (978) 534-6500', 'Leominster'),
    ('ReadyMED – Milford', 42.1487, -71.5152, '340 East Main Street, (508) 595-2700', 'Milford'),
    ('Milford', 42.1398, -71.5163, '101 Cedar Street, (508) 634-3100', 'Milford'),
    ('The Surgery Center', 42.2924, -71.7131, '151 Main St, (844) 258-4272', 'Shrewsbury'),
    ('Shrewsbury Occupational Medicine', 42.2930, -71.7240, '222 Boston Turnpike, (508) 853-2854', 'Shrewsbury'),
    ('Shrewsbury', 42.2865, -71.7147, '378 Maple Ave, (508) 368-7820', 'Shrewsbury'),
    ('Southborough', 42.3057, -71.5256, '24-28 Newton Street, (508) 481-5500', 'Southborough'),
    ('Webster', 42.0474, -71.8801, '344 Thompson Road, (508) 671-4050', 'Webster'),
    ('Westborough', 42.2695, -71.6161, '900 Union Street, (508) 366-8836', 'Westborough'),
    ('Worcester – Saint Vincent Cancer and Wellness Center', 42.2626, -71.8027, '1 Eaton Place, (508) 368-5430', 'Worcester'),
    ('Worcester – Neponset Street', 42.2614, -71.8007, '5 Neponset Street, (508) 368-7800', 'Worcester'),
    ('Worcester Medical Center', 42.2614, -71.8006, '123 Summer Street, (508) 852-0600', 'Worcester'),
    ('Worcester – Harding Street Rehabilitation & Sports Medicine', 42.2605, -71.8000, '112 Harding Street, (508) 964-5592', 'Worcester'),
    ('Worcester – Gold Star Boulevard Rehabilitation and Sports Medicine', 42.2910, -71.7999, '50 Gold Star Boulevard, (508) 856-9510', 'Worcester'),
    ('Worcester – Front Street', 42.2619, -71.8008, '100 Front Street, (508) 595-2000', 'Worcester'),
    ('Surgical Eye Experts', 42.2620, -71.8029, '385 Grove Street, (508) 453-8802', 'Worcester'),
    ('ReadyMED PLUS – Worcester', 42.2612, -71.8010, '366 Shrewsbury Street, (508) 595-2700', 'Worcester')
]


# Dropdown to select medical center to focus on
medical_center_names = [center[0] for center in massachusetts_med_centers]
selected_medical_center = st.selectbox("Select Medical Center to Focus On:", medical_center_names)

# Zoom into the selected medical center
for name, lat, lon, specialty, city in massachusetts_med_centers:
    if name == selected_medical_center:
        m2 = folium.Map(location=[lat, lon], zoom_start=15)

# Annotate distances and paths for each medical center
add_medical_center_paths(m2, source_location, massachusetts_med_centers)

folium_static(m2)

def Fairness():
    # List of 10 Types of Bias πŸ˜“
    st.markdown("### 10 Types of Bias in Geographical Healthcare Data πŸ‘©β€βš•οΈπŸŒ")
    st.markdown("""
    1. **Sampling Bias**: When the clinics or medical centers chosen for analysis do not represent the entire population.
    2. **Confirmation Bias**: Picking clinics or centers that confirm pre-existing assumptions.
    3. **Location Bias**: Focusing only on urban or rural areas.
    4. **Temporal Bias**: Not considering the seasonality or time-sensitive factors.
    5. **Accessibility Bias**: Overlooking clinics that are hard to reach but may offer unique specialties.
    6. **Economic Bias**: Focusing only on wealthy areas.
    7. **Size Bias**: Ignoring smaller clinics or new centers.
    8. **Technology Bias**: Assuming higher tech facilities provide better care.
    9. **Specialization Bias**: Overemphasis on one type of specialty.
    10. **Reporting Bias**: Basing judgments on self-reported data without validation.
    """)

    # List of 10 Types of Fairness πŸ˜‡
    st.markdown("### 10 Types of Fairness in Geographical Healthcare Data πŸŒπŸ‘©β€βš•οΈ")
    st.markdown("""
    1. **Geographical Fairness**: Equal representation of urban and rural areas.
    2. **Socioeconomic Fairness**: Diverse economic statuses in the sample.
    3. **Healthcare Need Fairness**: Clinics catering to various healthcare needs.
    4. **Accessibility Fairness**: Including centers reachable by public transportation.
    5. **Specialization Fairness**: A balanced view across various medical specialties.
    6. **Temporal Fairness**: Data that accounts for seasonal or time-sensitive changes.
    7. **Cultural Fairness**: Inclusion of centers serving diverse cultural communities.
    8. **Demographic Fairness**: Representation across different age groups and genders.
    9. **Quality of Care Fairness**: Balanced data on patient satisfaction and quality of care.
    10. **Resource Allocation Fairness**: Fair distribution of resources among different centers.
    """)

Fairness()

def Fairness2():
    st.title("Bias and Fairness in Geographical Healthcare Data πŸŒπŸ‘©β€βš•οΈ")

    st.markdown("### 10 Types of Bias in Geographical Healthcare Data πŸ‘©β€βš•οΈπŸŒ")
    bias_types = {
        "Sampling Bias": r"\frac{\text{Unrepresented Population}}{\text{Total Population}}",
        "Confirmation Bias": r"\frac{\text{Data Confirming Assumptions}}{\text{Total Data Points}}",
        "Location Bias": r"\left| \frac{\text{Urban Centers}}{\text{Rural Centers}} - 1 \right|",
        "Temporal Bias": r"\frac{\text{Time-Sensitive Data Ignored}}{\text{Total Data Points}}",
        "Accessibility Bias": r"\frac{\text{Inaccessible Clinics}}{\text{Total Clinics}}",
        "Economic Bias": r"\frac{\text{Wealthy Area Clinics}}{\text{Total Clinics}}",
        "Size Bias": r"\frac{\text{Ignored Small Clinics}}{\text{Total Clinics}}",
        "Technology Bias": r"\frac{\text{High-Tech Clinics}}{\text{Total Clinics}}",
        "Specialization Bias": r"\frac{\text{Overemphasized Specialties}}{\text{Total Specialties}}",
        "Reporting Bias": r"\frac{\text{Unvalidated Reports}}{\text{Total Reports}}"
    }
    
    for bias, formula in bias_types.items():
        st.markdown(f"**{bias}**")
        st.latex(f"{formula}")
        
    st.markdown("### 10 Types of Fairness in Geographical Healthcare Data πŸŒπŸ‘©β€βš•οΈ")
    fairness_types = {
        "Geographical Fairness": r"1 - \left| \frac{\text{Urban Centers}}{\text{Rural Centers}} - 1 \right|",
        "Socioeconomic Fairness": r"\frac{\text{Diverse Economic Clinics}}{\text{Total Clinics}}",
        "Healthcare Need Fairness": r"\frac{\text{Various Healthcare Need Clinics}}{\text{Total Clinics}}",
        "Accessibility Fairness": r"\frac{\text{Accessible Clinics}}{\text{Total Clinics}}",
        "Specialization Fairness": r"1 - \left| \frac{\text{Specialized Clinics}}{\text{General Clinics}} - 1 \right|",
        "Temporal Fairness": r"1 - \frac{\text{Time-Sensitive Data Ignored}}{\text{Total Data Points}}",
        "Cultural Fairness": r"\frac{\text{Diverse Cultural Clinics}}{\text{Total Clinics}}",
        "Demographic Fairness": r"\frac{\text{Diverse Demographic Clinics}}{\text{Total Clinics}}",
        "Quality of Care Fairness": r"\frac{\text{High-Quality Clinics}}{\text{Total Clinics}}",
        "Resource Allocation Fairness": r"\frac{\text{Evenly Distributed Resources}}{\text{Total Resources}}"
    }
    
    for fairness, formula in fairness_types.items():
        st.markdown(f"**{fairness}**")
        st.latex(f"{formula}")

if __name__ == "__main__":
    Fairness2()