yougandar commited on
Commit
e8d469e
·
verified ·
1 Parent(s): 9426499

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -12,20 +12,23 @@ if not os.path.exists(CSV_FILE):
12
 
13
  # Function to handle registration
14
  def register_patient(name, age, phone):
15
- # Load existing data
16
- df = pd.read_csv(CSV_FILE)
17
-
18
- # Generate new patient ID
19
- new_id = len(df) + 1
20
-
21
- # Append new patient data
22
- new_data = pd.DataFrame([[new_id, name, age, phone]], columns=["Patient ID", "Patient Name", "Age", "Phone Number"])
23
- df = pd.concat([df, new_data], ignore_index=True)
24
-
25
- # Save updated data
26
- df.to_csv(CSV_FILE, index=False)
27
-
28
- return f"Patient {name} with ID {new_id} registered successfully!"
 
 
 
29
 
30
  # Define Gradio interface
31
  with gr.Blocks() as demo:
 
12
 
13
  # Function to handle registration
14
  def register_patient(name, age, phone):
15
+ try:
16
+ # Load existing data
17
+ df = pd.read_csv(CSV_FILE)
18
+
19
+ # Generate new patient ID
20
+ new_id = len(df) + 1
21
+
22
+ # Append new patient data
23
+ new_data = pd.DataFrame([[new_id, name, age, phone]], columns=["Patient ID", "Patient Name", "Age", "Phone Number"])
24
+ df = pd.concat([df, new_data], ignore_index=True)
25
+
26
+ # Save updated data
27
+ df.to_csv(CSV_FILE, index=False)
28
+
29
+ return f"Patient {name} with ID {new_id} registered successfully!"
30
+ except Exception as e:
31
+ return f"An error occurred: {e}"
32
 
33
  # Define Gradio interface
34
  with gr.Blocks() as demo: