yougandar commited on
Commit
ab7c187
·
verified ·
1 Parent(s): 4714c9c

Update book_appointment.py

Browse files
Files changed (1) hide show
  1. book_appointment.py +3 -11
book_appointment.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import csv
3
  import os
4
- from datetime import datetime
5
 
6
  # Define the paths to the CSV files
7
  appointments_file_path = "appointments.csv"
@@ -36,13 +35,6 @@ def book_appointment_ui(patient_id, doctor_name, appointment_date, appointment_t
36
  """Book an appointment and save to the CSV file."""
37
  patient_name = get_patient_details(patient_id)
38
  if patient_name:
39
- try:
40
- # Convert the date to YYYY-MM-DD format for consistency in storage
41
- appointment_date_obj = datetime.strptime(appointment_date, "%d-%m-%Y")
42
- formatted_date = appointment_date_obj.strftime("%Y-%m-%d")
43
- except ValueError:
44
- return "Invalid date format. Please enter the date as DD-MM-YYYY."
45
-
46
  # Generate a unique Appointment ID
47
  try:
48
  with open(appointments_file_path, mode='r') as file:
@@ -60,7 +52,7 @@ def book_appointment_ui(patient_id, doctor_name, appointment_date, appointment_t
60
  "Patient ID": patient_id,
61
  "Patient Name": patient_name,
62
  "Doctor Name": doctor_name,
63
- "Appointment Date": formatted_date,
64
  "Appointment Time": appointment_time
65
  })
66
  return f"Appointment for {patient_name} with {doctor_name} on {appointment_date} at {appointment_time} booked successfully!"
@@ -77,7 +69,7 @@ def create_gradio_interface():
77
  with gr.Column():
78
  patient_id = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
79
  patient_name = gr.Textbox(label="Patient Name", interactive=False)
80
- appointment_date = gr.Textbox(label="Appointment Date (DD-MM-YYYY)", placeholder="26-08-2024")
81
 
82
  with gr.Column():
83
  doctor_name = gr.Dropdown(choices=[
@@ -110,4 +102,4 @@ def create_gradio_interface():
110
 
111
  # Run the interface
112
  if __name__ == "__main__":
113
- create_gradio_interface().launch()
 
1
  import gradio as gr
2
  import csv
3
  import os
 
4
 
5
  # Define the paths to the CSV files
6
  appointments_file_path = "appointments.csv"
 
35
  """Book an appointment and save to the CSV file."""
36
  patient_name = get_patient_details(patient_id)
37
  if patient_name:
 
 
 
 
 
 
 
38
  # Generate a unique Appointment ID
39
  try:
40
  with open(appointments_file_path, mode='r') as file:
 
52
  "Patient ID": patient_id,
53
  "Patient Name": patient_name,
54
  "Doctor Name": doctor_name,
55
+ "Appointment Date": appointment_date,
56
  "Appointment Time": appointment_time
57
  })
58
  return f"Appointment for {patient_name} with {doctor_name} on {appointment_date} at {appointment_time} booked successfully!"
 
69
  with gr.Column():
70
  patient_id = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
71
  patient_name = gr.Textbox(label="Patient Name", interactive=False)
72
+ appointment_date = gr.Textbox(label="Appointment Date (YYYY-MM-DD)", placeholder="2024-08-26")
73
 
74
  with gr.Column():
75
  doctor_name = gr.Dropdown(choices=[
 
102
 
103
  # Run the interface
104
  if __name__ == "__main__":
105
+ create_gradio_interface().launch()