Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,21 +4,34 @@ import os
|
|
4 |
import glob
|
5 |
|
6 |
# Load the provider specialty dataset CSV
|
7 |
-
@st.
|
8 |
def load_specialties(csv_file='Provider-Specialty.csv'):
|
9 |
return pd.read_csv(csv_file)
|
10 |
|
11 |
specialties = load_specialties()
|
12 |
|
13 |
# User interface for specialty selection
|
14 |
-
st.title('Provider Specialty Analyzer')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Dropdown for selecting a specialty
|
17 |
specialty_options = specialties['Display Name'].unique()
|
18 |
-
selected_specialty = st.selectbox('Select a Specialty', options=specialty_options)
|
19 |
|
20 |
# Display specialties matching the selected option or search keyword
|
21 |
-
search_keyword = st.text_input('Or search for a keyword in specialties')
|
22 |
if search_keyword:
|
23 |
filtered_specialties = specialties[specialties.apply(lambda row: row.astype(str).str.contains(search_keyword, case=False).any(), axis=1)]
|
24 |
else:
|
@@ -36,12 +49,12 @@ def process_state_files(specialty_code):
|
|
36 |
state_df = pd.read_csv(file, names=['Code', 'Grouping', 'Classification', 'Specialization', 'Definition', 'Notes', 'Display Name', 'Section'])
|
37 |
filtered_df = state_df[state_df['Code'] == specialty_code]
|
38 |
if not filtered_df.empty:
|
39 |
-
results.append((os.path.basename(file), filtered_df))
|
40 |
|
41 |
return results
|
42 |
|
43 |
# Show DataFrame UI for files matching the specialty code in the selected state
|
44 |
-
if st.button('Analyze Text Files for Selected Specialty'):
|
45 |
specialty_code = specialties[specialties['Display Name'] == selected_specialty].iloc[0]['Code']
|
46 |
state_data = process_state_files(specialty_code)
|
47 |
if state_data:
|
@@ -49,5 +62,4 @@ if st.button('Analyze Text Files for Selected Specialty'):
|
|
49 |
st.subheader(f"Providers in {state} with Specialty '{selected_specialty}':")
|
50 |
st.dataframe(df)
|
51 |
else:
|
52 |
-
st.write("No matching records found in text files for the selected specialty.")
|
53 |
-
|
|
|
4 |
import glob
|
5 |
|
6 |
# Load the provider specialty dataset CSV
|
7 |
+
@st.cache(allow_output_mutation=True)
|
8 |
def load_specialties(csv_file='Provider-Specialty.csv'):
|
9 |
return pd.read_csv(csv_file)
|
10 |
|
11 |
specialties = load_specialties()
|
12 |
|
13 |
# User interface for specialty selection
|
14 |
+
st.title('π Provider Specialty Analyzer')
|
15 |
+
|
16 |
+
# Markdown outline for the fields description
|
17 |
+
st.markdown("""
|
18 |
+
## Specialty Fields Description π
|
19 |
+
- **Code**: Unique identifier for the specialty.
|
20 |
+
- **Grouping**: General category the specialty belongs to.
|
21 |
+
- **Classification**: More detailed classification within the grouping.
|
22 |
+
- **Specialization**: Further specialization details if applicable.
|
23 |
+
- **Definition**: Brief description of the specialty.
|
24 |
+
- **Notes**: Any additional notes or historical information.
|
25 |
+
- **Display Name**: The common name used to display the specialty.
|
26 |
+
- **Section**: The section of healthcare the specialty falls under.
|
27 |
+
""")
|
28 |
|
29 |
# Dropdown for selecting a specialty
|
30 |
specialty_options = specialties['Display Name'].unique()
|
31 |
+
selected_specialty = st.selectbox('Select a Specialty π', options=specialty_options)
|
32 |
|
33 |
# Display specialties matching the selected option or search keyword
|
34 |
+
search_keyword = st.text_input('Or search for a keyword in specialties π')
|
35 |
if search_keyword:
|
36 |
filtered_specialties = specialties[specialties.apply(lambda row: row.astype(str).str.contains(search_keyword, case=False).any(), axis=1)]
|
37 |
else:
|
|
|
49 |
state_df = pd.read_csv(file, names=['Code', 'Grouping', 'Classification', 'Specialization', 'Definition', 'Notes', 'Display Name', 'Section'])
|
50 |
filtered_df = state_df[state_df['Code'] == specialty_code]
|
51 |
if not filtered_df.empty:
|
52 |
+
results.append((os.path.basename(file).split('.')[0], filtered_df))
|
53 |
|
54 |
return results
|
55 |
|
56 |
# Show DataFrame UI for files matching the specialty code in the selected state
|
57 |
+
if st.button('Analyze Text Files for Selected Specialty π'):
|
58 |
specialty_code = specialties[specialties['Display Name'] == selected_specialty].iloc[0]['Code']
|
59 |
state_data = process_state_files(specialty_code)
|
60 |
if state_data:
|
|
|
62 |
st.subheader(f"Providers in {state} with Specialty '{selected_specialty}':")
|
63 |
st.dataframe(df)
|
64 |
else:
|
65 |
+
st.write("No matching records found in text files for the selected specialty. π«")
|
|