SuriRaja commited on
Commit
d0eadd2
·
verified ·
1 Parent(s): 8067507

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -81
app.py CHANGED
@@ -30,7 +30,7 @@ def view_consultations(patient_id):
30
  if not records.empty:
31
  return records
32
  else:
33
- return "No consultations found for this patient."
34
 
35
  def book_appointment(patient_id, doctor_name, appointment_date):
36
  if patient_id <= 0 or not doctor_name or not appointment_date:
@@ -58,16 +58,15 @@ def view_appointments_and_reports(patient_id):
58
  return "Error: Please provide a valid patient ID."
59
  upcoming_appointments = appointments[appointments['PatientID'] == patient_id]
60
  patient_reports = reports[reports['PatientID'] == patient_id]
61
- data = {
62
- "Upcoming Appointments": upcoming_appointments[['DoctorName', 'Date', 'JitsiLink']],
63
- "Reports": patient_reports[['Date', 'ReportLink']],
64
- }
65
- return data
66
 
67
  def jitsi_iframe(appointment_id):
68
  if appointment_id <= 0:
69
  return "Error: Please provide a valid appointment ID."
70
- jitsi_link = appointments.loc[appointments['ID'] == appointment_id, 'JitsiLink'].values[0]
 
 
 
71
  if jitsi_link:
72
  return f'<iframe src="{jitsi_link}" style="width: 100%; height: 100%; border: 0;" allow="camera; microphone; fullscreen; display-capture"></iframe>'
73
  return "No meeting link found for this appointment."
@@ -76,77 +75,4 @@ def jitsi_iframe(appointment_id):
76
  register_image = "https://via.placeholder.com/800x400.png?text=Register+Image"
77
  consultation_image = "https://via.placeholder.com/800x400.png?text=Consultation+Image"
78
  appointment_image = "https://via.placeholder.com/800x400.png?text=Appointment+Image"
79
- report_image = "https://via.placeholder.com/800x400.png?text=Report+Image"
80
-
81
- # Define Gradio interfaces with images and styles
82
- register_interface = gr.Interface(
83
- fn=register_patient,
84
- inputs=[gr.Textbox(label="Name"), gr.Number(label="Age"), gr.Textbox(label="Contact")],
85
- outputs="text",
86
- title="Register Patient",
87
- description="Register new patients by filling out their details below.",
88
- article=register_image
89
- )
90
-
91
- view_consultations_interface = gr.Interface(
92
- fn=view_consultations,
93
- inputs=gr.Number(label="Patient ID"),
94
- outputs="dataframe",
95
- title="View Previous Consultations",
96
- description="View previous consultations and prescriptions for a patient.",
97
- article=consultation_image
98
- )
99
-
100
- book_appointment_interface = gr.Interface(
101
- fn=book_appointment,
102
- inputs=[gr.Number(label="Patient ID"), gr.Textbox(label="Doctor Name"), gr.Textbox(label="Appointment Date")],
103
- outputs="text",
104
- title="Book Appointment",
105
- description="Book an appointment with a doctor.",
106
- article=appointment_image
107
- )
108
-
109
- add_report_interface = gr.Interface(
110
- fn=add_report,
111
- inputs=[gr.Number(label="Patient ID"), gr.Textbox(label="Report Date"), gr.Textbox(label="Report Link")],
112
- outputs="text",
113
- title="Add Report",
114
- description="Add a new report for a patient.",
115
- article=report_image
116
- )
117
-
118
- view_appointments_reports_interface = gr.Interface(
119
- fn=view_appointments_and_reports,
120
- inputs=gr.Number(label="Patient ID"),
121
- outputs=[gr.Dataframe(label="Upcoming Appointments"), gr.Dataframe(label="Reports")],
122
- title="View Appointments and Reports",
123
- description="View upcoming appointments and reports for a patient.",
124
- article=report_image
125
- )
126
-
127
- join_meeting_interface = gr.Interface(
128
- fn=jitsi_iframe,
129
- inputs=gr.Number(label="Appointment ID"),
130
- outputs="html",
131
- title="Join Meeting",
132
- description="Join the online meeting with your doctor."
133
- )
134
-
135
- app = gr.TabbedInterface([
136
- register_interface,
137
- view_consultations_interface,
138
- book_appointment_interface,
139
- add_report_interface,
140
- view_appointments_reports_interface,
141
- join_meeting_interface
142
- ], [
143
- "Register Patient",
144
- "View Consultations",
145
- "Book Appointment",
146
- "Add Report",
147
- "View Appointments and Reports",
148
- "Join Meeting"
149
- ])
150
-
151
- if __name__ == "__main__":
152
- app.launch()
 
30
  if not records.empty:
31
  return records
32
  else:
33
+ return pd.DataFrame(columns=['ID', 'PatientID', 'DoctorName', 'Date', 'Diagnosis', 'Prescription'])
34
 
35
  def book_appointment(patient_id, doctor_name, appointment_date):
36
  if patient_id <= 0 or not doctor_name or not appointment_date:
 
58
  return "Error: Please provide a valid patient ID."
59
  upcoming_appointments = appointments[appointments['PatientID'] == patient_id]
60
  patient_reports = reports[reports['PatientID'] == patient_id]
61
+ return upcoming_appointments, patient_reports
 
 
 
 
62
 
63
  def jitsi_iframe(appointment_id):
64
  if appointment_id <= 0:
65
  return "Error: Please provide a valid appointment ID."
66
+ appointment = appointments.loc[appointments['ID'] == appointment_id]
67
+ if appointment.empty:
68
+ return "No meeting link found for this appointment."
69
+ jitsi_link = appointment['JitsiLink'].values[0]
70
  if jitsi_link:
71
  return f'<iframe src="{jitsi_link}" style="width: 100%; height: 100%; border: 0;" allow="camera; microphone; fullscreen; display-capture"></iframe>'
72
  return "No meeting link found for this appointment."
 
75
  register_image = "https://via.placeholder.com/800x400.png?text=Register+Image"
76
  consultation_image = "https://via.placeholder.com/800x400.png?text=Consultation+Image"
77
  appointment_image = "https://via.placeholder.com/800x400.png?text=Appointment+Image"
78
+ report_image = "https://via.placeholder.com/800x400.png?text=Report+Image