Spaces:
Sleeping
Sleeping
Create connect_doctor.py
Browse files- connect_doctor.py +24 -0
connect_doctor.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import csv
|
| 3 |
+
|
| 4 |
+
# Hard-coded file path for doctor connections
|
| 5 |
+
doctor_connection_file_path = "doctor_connections.csv"
|
| 6 |
+
|
| 7 |
+
# Function to connect doctor
|
| 8 |
+
def connect_doctor(patient_id, doctor_name):
|
| 9 |
+
with open(doctor_connection_file_path, mode='a', newline='') as file:
|
| 10 |
+
writer = csv.writer(file)
|
| 11 |
+
writer.writerow([patient_id, doctor_name])
|
| 12 |
+
return f"Doctor {doctor_name} connected with Patient ID {patient_id}."
|
| 13 |
+
|
| 14 |
+
# Gradio UI for connecting doctor
|
| 15 |
+
app = gr.Blocks()
|
| 16 |
+
|
| 17 |
+
with app:
|
| 18 |
+
with gr.Tab("Connect Doctor"):
|
| 19 |
+
patient_id = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID", lines=1)
|
| 20 |
+
doctor_name = gr.Textbox(label="Doctor Name", placeholder="Enter Doctor Name", lines=1)
|
| 21 |
+
connection_output = gr.Textbox(label="Connection Status", lines=1)
|
| 22 |
+
gr.Button("Connect Doctor").click(connect_doctor, inputs=[patient_id, doctor_name], outputs=connection_output)
|
| 23 |
+
|
| 24 |
+
app.launch()
|