Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,14 @@ st.markdown("""
|
|
18 |
| π teaching about health | π Patient info, #Education topic |
|
19 |
""")
|
20 |
# Create a DataFrame with CPT codes, procedures, and expected costs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
data = {
|
22 |
'Code Type': ['CPT', 'SNOMED', 'RXNORM', 'DEA', 'LOINC', 'ORI', 'ORU', 'CCD'],
|
23 |
'Code Value': ['99201', 'A-12345', 'R-12345', 'D-12345', 'L-12345', 'O-12345', 'U-12345', 'C-12345'],
|
@@ -26,15 +34,33 @@ data = {
|
|
26 |
}
|
27 |
df = pd.DataFrame(data)
|
28 |
|
29 |
-
# Create a
|
30 |
-
fig =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
# Display the
|
33 |
st.plotly_chart(fig)
|
34 |
|
35 |
# Save DataFrame to JSONL file
|
36 |
-
|
|
|
|
|
37 |
writer.write(df.to_dict(orient='records'))
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
# Display a link to download the JSONL file
|
40 |
-
st.markdown(
|
|
|
18 |
| π teaching about health | π Patient info, #Education topic |
|
19 |
""")
|
20 |
# Create a DataFrame with CPT codes, procedures, and expected costs
|
21 |
+
import pandas as pd
|
22 |
+
import plotly.graph_objects as go
|
23 |
+
import streamlit as st
|
24 |
+
import jsonlines
|
25 |
+
import base64
|
26 |
+
from datetime import datetime
|
27 |
+
|
28 |
+
# Create a DataFrame with Code types, values, descriptions, and expected costs
|
29 |
data = {
|
30 |
'Code Type': ['CPT', 'SNOMED', 'RXNORM', 'DEA', 'LOINC', 'ORI', 'ORU', 'CCD'],
|
31 |
'Code Value': ['99201', 'A-12345', 'R-12345', 'D-12345', 'L-12345', 'O-12345', 'U-12345', 'C-12345'],
|
|
|
34 |
}
|
35 |
df = pd.DataFrame(data)
|
36 |
|
37 |
+
# Create a sunburst plot with Plotly
|
38 |
+
fig = go.Figure(go.Sunburst(
|
39 |
+
labels=df['Code Type'],
|
40 |
+
parents=['']*len(df),
|
41 |
+
values=df['Expected Cost'],
|
42 |
+
text=df['Code Description'],
|
43 |
+
hoverinfo="label+value+text",
|
44 |
+
branchvalues="total",
|
45 |
+
))
|
46 |
+
|
47 |
+
fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
|
48 |
|
49 |
+
# Display the sunburst plot in Streamlit
|
50 |
st.plotly_chart(fig)
|
51 |
|
52 |
# Save DataFrame to JSONL file
|
53 |
+
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
54 |
+
filename = f"output_{timestamp}.jsonl"
|
55 |
+
with jsonlines.open(filename, mode='w') as writer:
|
56 |
writer.write(df.to_dict(orient='records'))
|
57 |
|
58 |
+
# Function to create a download link
|
59 |
+
def create_download_link(filename):
|
60 |
+
with open(filename, 'r') as file:
|
61 |
+
data = file.read()
|
62 |
+
b64 = base64.b64encode(data.encode()).decode()
|
63 |
+
return f'<a href="data:file/txt;base64,{b64}" download="{filename}">Download data as JSONL</a>'
|
64 |
+
|
65 |
# Display a link to download the JSONL file
|
66 |
+
st.markdown(create_download_link(filename), unsafe_allow_html=True)
|