Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,12 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import datetime as dt
|
4 |
import matplotlib.pyplot as plt
|
|
|
5 |
|
6 |
# Function to load data
|
7 |
@st.cache_data
|
8 |
def load_data(file):
|
|
|
9 |
df = pd.read_csv(file)
|
10 |
df['Date of Birth'] = pd.to_datetime(df['Date of Birth'])
|
11 |
df['Visit Date'] = pd.to_datetime(df['Visit Date'])
|
@@ -82,11 +84,22 @@ if uploaded_file:
|
|
82 |
"Other Notes": other_notes,
|
83 |
}
|
84 |
df = pd.concat([df, pd.DataFrame([new_entry])], ignore_index=True)
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
st.success("New visit entry added successfully!")
|
87 |
|
88 |
# Reload data
|
89 |
-
df = load_data(
|
90 |
patient_data = df[df['Patient ID'] == patient_id]
|
91 |
|
92 |
# Dropdown menu of previous visits
|
@@ -135,5 +148,16 @@ if uploaded_file:
|
|
135 |
"Other Notes": None,
|
136 |
}
|
137 |
df = pd.concat([df, pd.DataFrame([new_patient])], ignore_index=True)
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
st.success("New patient account created successfully!")
|
|
|
2 |
import pandas as pd
|
3 |
import datetime as dt
|
4 |
import matplotlib.pyplot as plt
|
5 |
+
import io
|
6 |
|
7 |
# Function to load data
|
8 |
@st.cache_data
|
9 |
def load_data(file):
|
10 |
+
file.seek(0) # Move to the start of the file
|
11 |
df = pd.read_csv(file)
|
12 |
df['Date of Birth'] = pd.to_datetime(df['Date of Birth'])
|
13 |
df['Visit Date'] = pd.to_datetime(df['Visit Date'])
|
|
|
84 |
"Other Notes": other_notes,
|
85 |
}
|
86 |
df = pd.concat([df, pd.DataFrame([new_entry])], ignore_index=True)
|
87 |
+
|
88 |
+
# Save the updated data to CSV
|
89 |
+
buffer = io.StringIO()
|
90 |
+
df.to_csv(buffer, index=False)
|
91 |
+
buffer.seek(0)
|
92 |
+
|
93 |
+
st.download_button(
|
94 |
+
label="Download Updated Data",
|
95 |
+
data=buffer,
|
96 |
+
file_name="updated_patient_data.csv",
|
97 |
+
mime="text/csv"
|
98 |
+
)
|
99 |
st.success("New visit entry added successfully!")
|
100 |
|
101 |
# Reload data
|
102 |
+
df = load_data(buffer)
|
103 |
patient_data = df[df['Patient ID'] == patient_id]
|
104 |
|
105 |
# Dropdown menu of previous visits
|
|
|
148 |
"Other Notes": None,
|
149 |
}
|
150 |
df = pd.concat([df, pd.DataFrame([new_patient])], ignore_index=True)
|
151 |
+
|
152 |
+
# Save the updated data to CSV
|
153 |
+
buffer = io.StringIO()
|
154 |
+
df.to_csv(buffer, index=False)
|
155 |
+
buffer.seek(0)
|
156 |
+
|
157 |
+
st.download_button(
|
158 |
+
label="Download Updated Data",
|
159 |
+
data=buffer,
|
160 |
+
file_name="updated_patient_data.csv",
|
161 |
+
mime="text/csv"
|
162 |
+
)
|
163 |
st.success("New patient account created successfully!")
|