Update app.py
Browse files
app.py
CHANGED
@@ -4,19 +4,6 @@ import os
|
|
4 |
import glob
|
5 |
import matplotlib.pyplot as plt
|
6 |
|
7 |
-
# Set page configuration with a title and favicon
|
8 |
-
st.set_page_config(
|
9 |
-
page_title="π©Ίπ Care Team Finder - Care Providers by Specialty and Location",
|
10 |
-
page_icon="π©Ί",
|
11 |
-
layout="wide",
|
12 |
-
initial_sidebar_state="expanded",
|
13 |
-
menu_items={
|
14 |
-
'Get Help': 'https://huggingface.co/awacke1',
|
15 |
-
'Report a bug': "https://huggingface.co/awacke1",
|
16 |
-
'About': "# π©Ίπ Care Team Finder By Aaron Wacker - https://huggingface.co/awacke1"
|
17 |
-
}
|
18 |
-
)
|
19 |
-
|
20 |
headers = [
|
21 |
"NPI", "EntityTypeCode", "ReplacementNPI", "EmployerIdentificationNumberEIN",
|
22 |
"ProviderOrganizationNameLegalBusinessName", "ProviderLastNameLegalName",
|
@@ -41,6 +28,41 @@ headers = [
|
|
41 |
"HealthcareProviderPrimaryTaxonomySwitch"
|
42 |
]
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
# Cache the loading of specialties for efficiency
|
45 |
@st.cache_resource
|
46 |
def load_specialties(csv_file='Provider-Specialty.csv'):
|
@@ -51,11 +73,35 @@ def load_specialties(csv_file='Provider-Specialty.csv'):
|
|
51 |
def find_state_files():
|
52 |
return [file for file in glob.glob('./*.csv') if len(os.path.basename(file).split('.')[0]) == 2]
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
specialties = load_specialties()
|
56 |
st.markdown("# π©Ίπ Care Team Finder ")
|
57 |
st.markdown("#### Search for Care Providers by Specialty and Location")
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
# Allows users to select or search for a specialty
|
61 |
specialty_options = specialties['Display Name'].unique()
|
@@ -84,18 +130,16 @@ def process_files(specialty_codes, specific_state='MN'):
|
|
84 |
file_to_process = f'./{specific_state}.csv' if use_specific_state else state_files
|
85 |
|
86 |
for file in [file_to_process] if use_specific_state else state_files:
|
87 |
-
|
88 |
-
state_df = pd.read_csv(file, header=0) # Assuming no header for simplicity
|
89 |
|
90 |
for code in specialty_codes:
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
except:
|
98 |
-
st.write('.')
|
99 |
return results
|
100 |
|
101 |
# Button to initiate the analysis
|
@@ -110,4 +154,3 @@ if st.button('Analyze Text Files for Selected Specialty π'):
|
|
110 |
st.dataframe(df)
|
111 |
else:
|
112 |
st.write("No matching records found in text files for the selected specialties.")
|
113 |
-
|
|
|
4 |
import glob
|
5 |
import matplotlib.pyplot as plt
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
headers = [
|
8 |
"NPI", "EntityTypeCode", "ReplacementNPI", "EmployerIdentificationNumberEIN",
|
9 |
"ProviderOrganizationNameLegalBusinessName", "ProviderLastNameLegalName",
|
|
|
28 |
"HealthcareProviderPrimaryTaxonomySwitch"
|
29 |
]
|
30 |
|
31 |
+
def process_files_new(specialty_codes, specific_state='MN', use_specific_state=True):
|
32 |
+
results = []
|
33 |
+
city_counts = {} # Dictionary to keep track of city counts
|
34 |
+
file_to_process = f'./{specific_state}.csv' if use_specific_state else state_files
|
35 |
+
|
36 |
+
for file in [file_to_process] if use_specific_state else state_files:
|
37 |
+
# Now using the 'names' parameter to specify column names
|
38 |
+
state_df = pd.read_csv(file, header=None, names=headers)
|
39 |
+
for code in specialty_codes:
|
40 |
+
filtered_df = state_df[state_df['HealthcareProviderTaxonomyCode'].isin([code])]
|
41 |
+
if not filtered_df.empty:
|
42 |
+
# Update city counts
|
43 |
+
for city in filtered_df['ProviderBusinessPracticeLocationAddressCityName'].unique():
|
44 |
+
city_counts[city] = city_counts.get(city, 0) + filtered_df[filtered_df['ProviderBusinessPracticeLocationAddressCityName'] == city].shape[0]
|
45 |
+
|
46 |
+
# Prepare display information (assuming 'specialties' DataFrame exists)
|
47 |
+
display_info = specialties[specialties['Code'] == code][['Code', 'Grouping', 'Classification']].iloc[0].to_dict()
|
48 |
+
results.append((os.path.basename(file).replace('.csv', ''), display_info, filtered_df))
|
49 |
+
|
50 |
+
# Plotting the city counts
|
51 |
+
cities = list(city_counts.keys())
|
52 |
+
counts = list(city_counts.values())
|
53 |
+
|
54 |
+
#plt.figure(figsize=(10, 6))
|
55 |
+
#plt.bar(cities, counts, color='skyblue')
|
56 |
+
#plt.xlabel('City')
|
57 |
+
#plt.ylabel('Count')
|
58 |
+
#plt.xticks(rotation=45, ha='right')
|
59 |
+
#plt.title('Counts per City')
|
60 |
+
#plt.tight_layout()
|
61 |
+
#plt.show()
|
62 |
+
|
63 |
+
return results
|
64 |
+
|
65 |
+
|
66 |
# Cache the loading of specialties for efficiency
|
67 |
@st.cache_resource
|
68 |
def load_specialties(csv_file='Provider-Specialty.csv'):
|
|
|
73 |
def find_state_files():
|
74 |
return [file for file in glob.glob('./*.csv') if len(os.path.basename(file).split('.')[0]) == 2]
|
75 |
|
76 |
+
# Set page configuration with a title and favicon
|
77 |
+
st.set_page_config(
|
78 |
+
page_title="π©Ίπ Care Team Finder - Care Providers by Specialty and Location",
|
79 |
+
page_icon="π©Ί",
|
80 |
+
layout="wide",
|
81 |
+
initial_sidebar_state="expanded",
|
82 |
+
menu_items={
|
83 |
+
'Get Help': 'https://huggingface.co/awacke1',
|
84 |
+
'Report a bug': "https://huggingface.co/spaces/awacke1/WebDataDownload",
|
85 |
+
'About': "# π©Ίπ Care Team Finder By Aaron Wacker - https://huggingface.co/awacke1"
|
86 |
+
}
|
87 |
+
)
|
88 |
|
89 |
specialties = load_specialties()
|
90 |
st.markdown("# π©Ίπ Care Team Finder ")
|
91 |
st.markdown("#### Search for Care Providers by Specialty and Location")
|
92 |
|
93 |
+
if st.expander('π©Ί Understand Provider Specialties π'):
|
94 |
+
st.markdown('''
|
95 |
+
## Discover Care Providers by Specialty & Location: Quick Guide
|
96 |
+
- **Code**: Unique ID identifies each specialty clearly. π
|
97 |
+
- **Grouping**: Broad category umbrella for general expertise area. π·οΈ
|
98 |
+
- **Classification**: Specifies type of practice within broader category. π―
|
99 |
+
- **Specialization**: Details focus within classification for precise expertise. π
|
100 |
+
- **Definition**: Concise overview of the specialty's scope. π
|
101 |
+
- **Notes**: Extra information or recent updates provided. ποΈ
|
102 |
+
- **Display Name**: Commonly recognized name of the specialty. π·οΈ
|
103 |
+
- **Section**: Healthcare segment the specialty belongs to. π
|
104 |
+
''')
|
105 |
|
106 |
# Allows users to select or search for a specialty
|
107 |
specialty_options = specialties['Display Name'].unique()
|
|
|
130 |
file_to_process = f'./{specific_state}.csv' if use_specific_state else state_files
|
131 |
|
132 |
for file in [file_to_process] if use_specific_state else state_files:
|
133 |
+
state_df = pd.read_csv(file, header=None) # Assuming no header for simplicity
|
134 |
+
#state_df = pd.read_csv(file, header=0) # Assuming no header for simplicity
|
135 |
|
136 |
for code in specialty_codes:
|
137 |
+
filtered_df = state_df[state_df[47].isin([code])] # Match against 48th column, adjust as needed
|
138 |
+
if not filtered_df.empty:
|
139 |
+
# Enhance the display to include 'Code', 'Grouping', and 'Classification' information
|
140 |
+
display_info = specialties[specialties['Code'] == code][['Code', 'Grouping', 'Classification']].iloc[0].to_dict()
|
141 |
+
results.append((os.path.basename(file).replace('.csv', ''), display_info, filtered_df))
|
142 |
+
|
|
|
|
|
143 |
return results
|
144 |
|
145 |
# Button to initiate the analysis
|
|
|
154 |
st.dataframe(df)
|
155 |
else:
|
156 |
st.write("No matching records found in text files for the selected specialties.")
|
|