Update app.py
Browse files
app.py
CHANGED
|
@@ -28,14 +28,16 @@ def register_patient(name, age, phone):
|
|
| 28 |
new_id = len(df) + 1
|
| 29 |
|
| 30 |
# Append new patient data
|
| 31 |
-
new_data = pd.DataFrame(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
df = pd.concat([df, new_data], ignore_index=True)
|
| 33 |
|
| 34 |
# Save updated data
|
| 35 |
-
|
| 36 |
-
df.to_csv(file, index=False)
|
| 37 |
-
file.flush()
|
| 38 |
-
os.fsync(file.fileno()) # Ensure data is written to disk
|
| 39 |
|
| 40 |
logging.info(f"Successfully registered patient {name} with ID {new_id}")
|
| 41 |
return f"Patient {name} with ID {new_id} registered successfully!"
|
|
@@ -57,4 +59,4 @@ with gr.Blocks() as demo:
|
|
| 57 |
|
| 58 |
# Launch the app
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
demo.launch()
|
|
|
|
| 28 |
new_id = len(df) + 1
|
| 29 |
|
| 30 |
# Append new patient data
|
| 31 |
+
new_data = pd.DataFrame({
|
| 32 |
+
"Patient ID": [new_id],
|
| 33 |
+
"Patient Name": [name],
|
| 34 |
+
"Age": [age],
|
| 35 |
+
"Phone Number": [phone]
|
| 36 |
+
})
|
| 37 |
df = pd.concat([df, new_data], ignore_index=True)
|
| 38 |
|
| 39 |
# Save updated data
|
| 40 |
+
df.to_csv(CSV_FILE, index=False)
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
logging.info(f"Successfully registered patient {name} with ID {new_id}")
|
| 43 |
return f"Patient {name} with ID {new_id} registered successfully!"
|
|
|
|
| 59 |
|
| 60 |
# Launch the app
|
| 61 |
if __name__ == "__main__":
|
| 62 |
+
demo.launch()
|