SuriRaja commited on
Commit
201a544
·
verified ·
1 Parent(s): fd799d8

Upload 14 files

Browse files
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🩺
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
7
- sdk_version: "4.16.0"
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: "4.27.0"
8
  app_file: app.py
9
  pinned: false
10
  ---
add_reports.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ FILE = "reports.csv"
6
+
7
+ def init_file():
8
+ if not os.path.exists(FILE):
9
+ with open(FILE, 'w', newline='') as file:
10
+ writer = csv.writer(file)
11
+ writer.writerow(["Report ID", "Patient", "Report Type", "Details"])
12
+
13
+ def write_report(patient, rtype, details):
14
+ init_file()
15
+ with open(FILE, 'r') as file:
16
+ rows = list(csv.reader(file))
17
+ idx = len(rows)
18
+ with open(FILE, 'a', newline='') as file:
19
+ writer = csv.writer(file)
20
+ writer.writerow([idx, patient, rtype, details])
21
+ return f"✅ Report #{idx} added for {patient}"
22
+
23
+ def gradio_interface():
24
+ init_file()
25
+ with gr.Blocks() as demo:
26
+ gr.Markdown("## 📤 Add Medical Report")
27
+ pat = gr.Textbox(label="Patient")
28
+ typ = gr.Textbox(label="Report Type")
29
+ det = gr.Textbox(label="Details")
30
+ res = gr.Textbox(label="Result")
31
+ gr.Button("Upload").click(fn=write_report, inputs=[pat, typ, det], outputs=res)
32
+ return demo
app (1).py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Function to handle authentication
4
+ def authenticate(hospital_name, username, password):
5
+ """Simple authentication logic."""
6
+ # You can replace this logic with actual authentication (e.g., checking against a database)
7
+ return True # Bypassing actual authentication for simplicity
8
+
9
+ def register_patient_page():
10
+ import register_patient
11
+ return register_patient.create_gradio_interface()
12
+
13
+ def book_appointment_page():
14
+ import book_appointment
15
+ return book_appointment.create_gradio_interface()
16
+
17
+ def consultation_page():
18
+ import consultation
19
+ return consultation.gradio_interface()
20
+
21
+ def view_consultation_page():
22
+ import view_consultation
23
+ return view_consultation.gradio_interface()
24
+
25
+ def view_appointments_page():
26
+ import view_appointments
27
+ return view_appointments.gradio_interface()
28
+
29
+ def add_reports_page():
30
+ import add_reports
31
+ return add_reports.gradio_interface()
32
+
33
+ def view_patient_reports_page():
34
+ import view_patient_reports
35
+ return view_patient_reports.create_gradio_interface()
36
+
37
+ def connect_doctor_page():
38
+ import connect_doctor
39
+ return connect_doctor.create_gradio_interface()
40
+
41
+ # Role selection interface
42
+ def role_selection():
43
+ return gr.Radio(choices=["Doctor Management", "Patient Management"], label="Select Your Role")
44
+
45
+ # Update visible tabs based on role
46
+ def update_role(role):
47
+ if role == "Doctor Management":
48
+ return (
49
+ gr.update(visible=True), # Doctor View Appointments Tab (Now First)
50
+ gr.update(visible=True), # Doctor Consultation Tab (Now Second)
51
+ gr.update(visible=True), # Doctor Add Reports Tab
52
+ gr.update(visible=False), # Patient Register Tab
53
+ gr.update(visible=False), # Patient Book Appointment Tab
54
+ gr.update(visible=False), # Patient View Consultation Tab
55
+ gr.update(visible=False), # Patient View Patient Reports Tab
56
+ gr.update(visible=True) # Connect Doctor Tab
57
+ )
58
+ elif role == "Patient Management":
59
+ return (
60
+ gr.update(visible=False), # Doctor View Appointments Tab
61
+ gr.update(visible=False), # Doctor Consultation Tab
62
+ gr.update(visible=False), # Doctor Add Reports Tab
63
+ gr.update(visible=True), # Patient Register Tab
64
+ gr.update(visible=True), # Patient Book Appointment Tab
65
+ gr.update(visible=True), # Patient View Consultation Tab
66
+ gr.update(visible=True), # Patient View Patient Reports Tab
67
+ gr.update(visible=True) # Connect Doctor Tab
68
+ )
69
+
70
+ # Define the app layout with login functionality
71
+ with gr.Blocks() as app:
72
+ gr.Markdown("## Multi-Tenant Patient Management App")
73
+
74
+ # Multi-Tenant Login Section
75
+ hospital_name = gr.Dropdown(choices=["Hospital A", "Hospital B"], label="Select Hospital")
76
+ username = gr.Textbox(label="Username")
77
+ password = gr.Textbox(label="Password", type="password")
78
+ login_button = gr.Button("Login")
79
+ login_output = gr.Textbox(label="Login Status", interactive=False)
80
+ role_radio = gr.Radio(choices=["Doctor Management", "Patient Management"], label="Select Your Role", visible=False)
81
+
82
+ # Placeholder for showing/hiding the app sections
83
+ app_section = gr.Group(visible=False)
84
+
85
+ # Login Action
86
+ def login_action(hospital_name, username, password):
87
+ if authenticate(hospital_name, username, password):
88
+ return gr.update(visible=True), gr.update(visible=True), "Login successful!"
89
+ else:
90
+ return gr.update(visible=False), gr.update(visible=False), "Invalid credentials, please try again."
91
+
92
+ login_button.click(
93
+ login_action,
94
+ inputs=[hospital_name, username, password],
95
+ outputs=[app_section, role_radio, login_output]
96
+ )
97
+
98
+ # Doctor tabs
99
+ with app_section:
100
+ with gr.Tab("View Appointments", visible=False) as doctor_view_appt_tab:
101
+ view_appointments_page()
102
+
103
+ with gr.Tab("Consultation", visible=False) as doctor_consult_tab:
104
+ consultation_page()
105
+
106
+ with gr.Tab("Add Reports", visible=False) as doctor_add_reports_tab:
107
+ add_reports_page()
108
+
109
+ # Patient tabs
110
+ with gr.Tab("Register Patient", visible=False) as patient_reg_tab:
111
+ register_patient_page()
112
+
113
+ with gr.Tab("Book Appointment", visible=False) as patient_book_appt_tab:
114
+ book_appointment_page()
115
+
116
+ with gr.Tab("View Consultation", visible=False) as patient_view_consult_tab:
117
+ view_consultation_page()
118
+
119
+ with gr.Tab("View Patient Reports", visible=False) as patient_view_reports_tab:
120
+ view_patient_reports_page()
121
+
122
+ # Common tab for both roles
123
+ with gr.Tab("Connect Doctor", visible=False) as connect_doctor_tab:
124
+ connect_doctor_page()
125
+
126
+ # Function to update visible tabs based on role selection
127
+ role_radio.change(
128
+ fn=update_role,
129
+ inputs=role_radio,
130
+ outputs=[
131
+ doctor_view_appt_tab, doctor_consult_tab, doctor_add_reports_tab,
132
+ patient_reg_tab, patient_book_appt_tab, patient_view_consult_tab,
133
+ patient_view_reports_tab, connect_doctor_tab
134
+ ]
135
+ )
136
+
137
+ if __name__ == "__main__":
138
+ app.launch()
app.py CHANGED
@@ -9,6 +9,8 @@ import view_appointments
9
  import add_reports
10
  import view_patient_reports
11
  import connect_doctor
 
 
12
 
13
  # Authentication (simplified)
14
  def authenticate(hospital_name, username, password):
@@ -59,6 +61,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
59
  ])
60
 
61
  with gr.Tabs():
 
 
 
 
62
  with gr.Tab("📅 View Appointments", elem_id="view_appt_tab", visible=False):
63
  view_appointments.gradio_interface()
64
  with gr.Tab("💬 Consultation", elem_id="consult_tab", visible=False):
 
9
  import add_reports
10
  import view_patient_reports
11
  import connect_doctor
12
+ import medbot_chat
13
+ import symptom_checker
14
 
15
  # Authentication (simplified)
16
  def authenticate(hospital_name, username, password):
 
61
  ])
62
 
63
  with gr.Tabs():
64
+ with gr.Tab("💬 MedBot", elem_id="chat_tab", visible=True):
65
+ medbot_chat.create_gradio_interface()
66
+ with gr.Tab("🧠 Symptom Checker", elem_id="diagnosis_tab", visible=True):
67
+ symptom_checker.create_gradio_interface()
68
  with gr.Tab("📅 View Appointments", elem_id="view_appt_tab", visible=False):
69
  view_appointments.gradio_interface()
70
  with gr.Tab("💬 Consultation", elem_id="consult_tab", visible=False):
book_appointment.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ APPT_FILE = "appointments.csv"
6
+
7
+ def init_storage():
8
+ if not os.path.exists(APPT_FILE):
9
+ with open(APPT_FILE, mode='w', newline='') as file:
10
+ writer = csv.writer(file)
11
+ writer.writerow(["Appointment ID", "Patient Name", "Doctor", "Date", "Time"])
12
+
13
+ def generate_appointment_id():
14
+ with open(APPT_FILE, mode='r') as file:
15
+ rows = list(csv.reader(file))
16
+ return int(rows[-1][0]) + 1 if len(rows) > 1 else 1
17
+
18
+ def save_appointment(record):
19
+ with open(APPT_FILE, mode='a', newline='') as file:
20
+ writer = csv.writer(file)
21
+ writer.writerow(record)
22
+
23
+ def book_appointment(name, doctor, date, time):
24
+ init_storage()
25
+ appt_id = generate_appointment_id()
26
+ save_appointment([appt_id, name, doctor, date, time])
27
+ return f"✅ Appointment #{appt_id} booked for {name} with Dr. {doctor} on {date} at {time}."
28
+
29
+ def create_gradio_interface():
30
+ init_storage()
31
+ with gr.Blocks() as demo:
32
+ gr.Markdown("## 📆 Book an Appointment")
33
+
34
+ with gr.Group():
35
+ with gr.Row():
36
+ with gr.Column():
37
+ name = gr.Textbox(label="Patient Name", placeholder="Enter your full name")
38
+ doctor = gr.Dropdown(["Dr. Smith", "Dr. Lee", "Dr. Patel"], label="Choose Doctor")
39
+ with gr.Column():
40
+ date = gr.Textbox(label="Date (YYYY-MM-DD)", placeholder="e.g., 2025-05-20")
41
+ time = gr.Textbox(label="Time (HH:MM)", placeholder="e.g., 10:00 AM")
42
+
43
+ result = gr.Textbox(label="Result", interactive=False)
44
+ btn = gr.Button("Book Appointment")
45
+
46
+ btn.click(fn=book_appointment, inputs=[name, doctor, date, time], outputs=result)
47
+
48
+ return demo
connect_doctor.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def create_gradio_interface():
4
+ with gr.Blocks() as demo:
5
+ gr.Markdown("## 🔗 Connect with a Doctor")
6
+ gr.Markdown("This feature will include video/voice/chat in the future.")
7
+ gr.Textbox(label="Doctor Name")
8
+ gr.Textbox(label="Purpose")
9
+ gr.Button("Connect").click(fn=lambda: "🔔 Connection requested.", outputs="textbox")
10
+ return demo
consultation.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ FILE = "consultations.csv"
6
+
7
+ def init_file():
8
+ if not os.path.exists(FILE):
9
+ with open(FILE, 'w', newline='') as file:
10
+ writer = csv.writer(file)
11
+ writer.writerow(["ID", "Doctor", "Patient", "Notes"])
12
+
13
+ def write_data(doctor, patient, notes):
14
+ init_file()
15
+ with open(FILE, 'r') as file:
16
+ rows = list(csv.reader(file))
17
+ idx = len(rows)
18
+ with open(FILE, 'a', newline='') as file:
19
+ writer = csv.writer(file)
20
+ writer.writerow([idx, doctor, patient, notes])
21
+ return f"✅ Consultation #{idx} saved."
22
+
23
+ def gradio_interface():
24
+ init_file()
25
+ with gr.Blocks() as demo:
26
+ gr.Markdown("## 💬 Add Consultation")
27
+ doc = gr.Textbox(label="Doctor")
28
+ pat = gr.Textbox(label="Patient")
29
+ note = gr.Textbox(label="Notes")
30
+ result = gr.Textbox(label="Result")
31
+ gr.Button("Save").click(fn=write_data, inputs=[doc, pat, note], outputs=result)
32
+ return demo
medbot_chat.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import torch
4
+ import csv
5
+ import os
6
+ from datetime import datetime
7
+ import pyttsx3
8
+
9
+ MODEL_NAME = "tiiuae/falcon-rw-1b"
10
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
11
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
12
+ model.eval()
13
+
14
+ CHAT_LOG_FILE = "chat_logs.csv"
15
+
16
+ def init_log():
17
+ if not os.path.exists(CHAT_LOG_FILE):
18
+ with open(CHAT_LOG_FILE, 'w', newline='') as f:
19
+ writer = csv.writer(f)
20
+ writer.writerow(["Patient", "Timestamp", "User Message", "Bot Reply"])
21
+
22
+ def chat_with_bot(message, history, patient_name, voice_enabled):
23
+ init_log()
24
+ full_prompt = ""
25
+ for user, bot in history:
26
+ full_prompt += f"User: {user}\nBot: {bot}\n"
27
+ full_prompt += f"User: {message}\nBot:"
28
+ inputs = tokenizer.encode(full_prompt, return_tensors="pt", truncation=True)
29
+ with torch.no_grad():
30
+ outputs = model.generate(inputs, max_new_tokens=100, do_sample=True, top_p=0.9, temperature=0.7)
31
+ decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
32
+ bot_reply = decoded.split("Bot:")[-1].strip().split("User:")[0].strip()
33
+
34
+ # Save to log
35
+ with open(CHAT_LOG_FILE, 'a', newline='') as f:
36
+ writer = csv.writer(f)
37
+ writer.writerow([patient_name, datetime.now().isoformat(), message, bot_reply])
38
+
39
+ history.append((message, bot_reply))
40
+
41
+ audio = None
42
+ if voice_enabled and bot_reply:
43
+ tts = pyttsx3.init()
44
+ tts.save_to_file(bot_reply, "medbot_output.mp3")
45
+ tts.runAndWait()
46
+ audio = "medbot_output.mp3"
47
+
48
+ return history, history, audio
49
+
50
+ def create_gradio_interface():
51
+ init_log()
52
+ with gr.Blocks() as demo:
53
+ gr.Markdown("## 💬 MedBot – AI Chat Assistant with Voice and Logging")
54
+ patient_name = gr.Textbox(label="Patient Name")
55
+ chatbot = gr.Chatbot()
56
+ message = gr.Textbox(label="Your Message")
57
+ voice_toggle = gr.Checkbox(label="Enable Voice Response", value=False)
58
+ audio_output = gr.Audio(label="Bot Audio", interactive=False)
59
+ state = gr.State([])
60
+
61
+ submit = gr.Button("Send")
62
+ clear = gr.Button("Clear Chat")
63
+
64
+ submit.click(chat_with_bot, inputs=[message, state, patient_name, voice_toggle], outputs=[chatbot, state, audio_output])
65
+ clear.click(lambda: ([], [], None), outputs=[chatbot, state, audio_output])
66
+
67
+ return demo
register_patient.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ # Define the path to the CSV file
6
+ patient_file_path = "patients.csv"
7
+
8
+ def initialize_csv():
9
+ """Initialize the CSV file if it doesn't exist."""
10
+ if not os.path.exists(patient_file_path):
11
+ with open(patient_file_path, mode='w', newline='') as file:
12
+ writer = csv.writer(file)
13
+ writer.writerow(["Patient ID", "Name", "Age", "Age Unit", "Gender", "Address", "Contact Number"])
14
+
15
+ def register_patient(name, age, age_unit, gender, contact):
16
+ """Register a new patient and return the registration status."""
17
+ address = "Hyderabad"
18
+ initialize_csv() # Ensure the CSV is initialized
19
+
20
+ # Read the last Patient ID and increment it
21
+ with open(patient_file_path, mode='r') as file:
22
+ reader = csv.reader(file)
23
+ rows = list(reader)
24
+ last_id = int(rows[-1][0]) if len(rows) > 1 else 0 # Get the last Patient ID
25
+
26
+ new_id = last_id + 1
27
+
28
+ # Write the new patient details to the CSV file
29
+ with open(patient_file_path, mode='a', newline='') as file:
30
+ writer = csv.writer(file)
31
+ writer.writerow([new_id, name, age, age_unit, gender, address, contact])
32
+
33
+ return f"Patient ID: {new_id}, Name: {name} registered successfully."
34
+
35
+ def create_gradio_interface():
36
+ """Create and return the Gradio interface for patient registration."""
37
+ initialize_csv() # Ensure CSV is initialized before launching the interface
38
+
39
+ with gr.Blocks() as demo:
40
+ gr.Markdown("## Register Patient")
41
+
42
+ with gr.Row():
43
+ with gr.Column():
44
+ # Define Gradio inputs
45
+ name = gr.Textbox(label="Patient Name", placeholder="Enter patient name")
46
+
47
+ # Age input with number and unit selection similar to gender buttons
48
+ age = gr.Number(label="Age", value=0)
49
+ age_unit = gr.Radio(["Years", "Months", "Days"], label="Age Unit", value="Years")
50
+
51
+ contact_number = gr.Textbox(label="Contact Number", placeholder="Enter contact number")
52
+
53
+ with gr.Column():
54
+ # Gender input
55
+ gender = gr.Radio(["Male", "Female", "Transgender"], label="Gender")
56
+
57
+ # Define result output
58
+ result = gr.Textbox(label="Result", interactive=False)
59
+
60
+ # Define Register button
61
+ register_button = gr.Button("Register")
62
+
63
+ # Define the registration logic
64
+ register_button.click(
65
+ fn=register_patient,
66
+ inputs=[name, age, age_unit, gender, contact_number],
67
+ outputs=result
68
+ )
69
+
70
+ return demo
71
+
72
+ if __name__ == "__main__":
73
+ create_gradio_interface().launch()
requirements.txt CHANGED
@@ -1,2 +1,7 @@
1
  gradio
2
  pandas
 
 
 
 
 
 
1
  gradio
2
  pandas
3
+
4
+ transformers
5
+ torch
6
+
7
+ pyttsx3
symptom_checker.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def mock_diagnosis(symptoms, age, gender):
4
+ # Placeholder logic
5
+ if "fever" in symptoms.lower():
6
+ return "🩺 Likely Diagnosis: Viral Infection\n📋 Suggested: General Physician\n⚠️ Urgency: Low"
7
+ elif "pain" in symptoms.lower():
8
+ return "🩺 Likely Diagnosis: Musculoskeletal issue\n📋 Suggested: Orthopedic\n⚠️ Urgency: Medium"
9
+ return "🩺 Diagnosis not clear\n📋 Suggested: General Checkup"
10
+
11
+ def create_gradio_interface():
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("## 🧠 Symptom Checker")
14
+ with gr.Row():
15
+ symptoms = gr.Textbox(label="Describe your symptoms")
16
+ age = gr.Number(label="Age", value=30)
17
+ gender = gr.Radio(["Male", "Female", "Other"], label="Gender")
18
+ result = gr.Textbox(label="AI Diagnosis")
19
+ btn = gr.Button("Analyze")
20
+ btn.click(fn=mock_diagnosis, inputs=[symptoms, age, gender], outputs=result)
21
+ return demo
view_appointments.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ APPT_FILE = "appointments.csv"
6
+
7
+ def load_appointments():
8
+ if not os.path.exists(APPT_FILE):
9
+ return [["No appointments found"]]
10
+ with open(APPT_FILE, mode='r') as file:
11
+ reader = list(csv.reader(file))
12
+ return reader[1:] if len(reader) > 1 else [["No appointments available"]]
13
+
14
+ def gradio_interface():
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("## 📅 View Appointments")
17
+ output = gr.Dataframe(headers=["Appointment ID", "Patient Name", "Doctor", "Date", "Time"], datatype="str")
18
+ refresh = gr.Button("🔄 Refresh")
19
+ refresh.click(fn=load_appointments, outputs=output)
20
+ return demo
view_consultation.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ FILE = "consultations.csv"
6
+
7
+ def load_consults():
8
+ if not os.path.exists(FILE):
9
+ return [["No consultation data"]]
10
+ with open(FILE, mode='r') as file:
11
+ reader = list(csv.reader(file))
12
+ return reader[1:] if len(reader) > 1 else [["No data"]]
13
+
14
+ def gradio_interface():
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("## 💬 View Consultations")
17
+ df = gr.Dataframe(headers=["ID", "Doctor", "Patient", "Notes"], datatype="str")
18
+ gr.Button("🔄 Load Data").click(fn=load_consults, outputs=df)
19
+ return demo
view_patient_reports.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import csv
3
+ import os
4
+
5
+ FILE = "reports.csv"
6
+
7
+ def load_reports():
8
+ if not os.path.exists(FILE):
9
+ return [["No reports available"]]
10
+ with open(FILE, mode='r') as file:
11
+ reader = list(csv.reader(file))
12
+ return reader[1:] if len(reader) > 1 else [["No data"]]
13
+
14
+ def create_gradio_interface():
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("## 📄 Patient Reports")
17
+ df = gr.Dataframe(headers=["Report ID", "Patient", "Report Type", "Details"], datatype="str")
18
+ gr.Button("🔄 Refresh").click(fn=load_reports, outputs=df)
19
+ return demo