Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,10 @@ def load_data(file):
|
|
18 |
uploaded_file = st.sidebar.file_uploader("Upload Patient Data CSV", type="csv")
|
19 |
if uploaded_file:
|
20 |
df = load_data(uploaded_file)
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Sidebar: Select or create patient
|
23 |
action = st.sidebar.selectbox("Action", ["Select Patient", "Create New Patient"])
|
@@ -92,6 +96,10 @@ if uploaded_file:
|
|
92 |
bytes_data = io.BytesIO(buffer.getvalue().encode('utf-8'))
|
93 |
st.success("New visit entry added successfully!")
|
94 |
|
|
|
|
|
|
|
|
|
95 |
# Download button (moved outside the form)
|
96 |
st.download_button(
|
97 |
label="Download Updated Data",
|
@@ -100,10 +108,6 @@ if uploaded_file:
|
|
100 |
mime="text/csv"
|
101 |
)
|
102 |
|
103 |
-
# Reload data
|
104 |
-
df = load_data(io.StringIO(buffer.getvalue()))
|
105 |
-
patient_data = df[df['Patient ID'] == patient_id]
|
106 |
-
|
107 |
# Dropdown menu of previous visits
|
108 |
st.header("Previous Visits")
|
109 |
visit_date = st.selectbox("Select Visit Date", patient_data['Visit Date'].dt.strftime('%Y-%m-%d').unique())
|
|
|
18 |
uploaded_file = st.sidebar.file_uploader("Upload Patient Data CSV", type="csv")
|
19 |
if uploaded_file:
|
20 |
df = load_data(uploaded_file)
|
21 |
+
buffer = io.StringIO()
|
22 |
+
df.to_csv(buffer, index=False)
|
23 |
+
buffer.seek(0)
|
24 |
+
bytes_data = io.BytesIO(buffer.getvalue().encode('utf-8'))
|
25 |
|
26 |
# Sidebar: Select or create patient
|
27 |
action = st.sidebar.selectbox("Action", ["Select Patient", "Create New Patient"])
|
|
|
96 |
bytes_data = io.BytesIO(buffer.getvalue().encode('utf-8'))
|
97 |
st.success("New visit entry added successfully!")
|
98 |
|
99 |
+
# Reload data
|
100 |
+
df = load_data(io.StringIO(buffer.getvalue()))
|
101 |
+
patient_data = df[df['Patient ID'] == patient_id]
|
102 |
+
|
103 |
# Download button (moved outside the form)
|
104 |
st.download_button(
|
105 |
label="Download Updated Data",
|
|
|
108 |
mime="text/csv"
|
109 |
)
|
110 |
|
|
|
|
|
|
|
|
|
111 |
# Dropdown menu of previous visits
|
112 |
st.header("Previous Visits")
|
113 |
visit_date = st.selectbox("Select Visit Date", patient_data['Visit Date'].dt.strftime('%Y-%m-%d').unique())
|