neerajkalyank commited on
Commit
fe8c4f6
1 Parent(s): 01ac39a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -4
app.py CHANGED
@@ -1,9 +1,18 @@
1
  import gradio as gr
2
  import json
3
  from datetime import datetime
4
- from patient_registration import register_patient
5
- from test_selection import select_tests, get_tests_by_category
6
- from billing import fetch_billing
 
 
 
 
 
 
 
 
 
7
 
8
  # Load data
9
  def load_data():
@@ -62,6 +71,29 @@ def registration_interface(name, father_name, age, phone, address, pincode):
62
  save_data(patients, last_sequence)
63
  return f"Patient Registered. Patient ID: {patient_id}", patient_id
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  # Copy functionality
66
  def copy_patient_id(patient_id):
67
  return f"{patient_id} copied to clipboard!"
@@ -102,7 +134,7 @@ with gr.Blocks() as app:
102
  with gr.Tab("Tests"):
103
  patient_id_test = gr.Textbox(label="Patient ID")
104
  categories = gr.CheckboxGroup(
105
- ["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
106
  label="Select Test Categories"
107
  )
108
  available_tests = gr.CheckboxGroup(label="Available Tests")
 
1
  import gradio as gr
2
  import json
3
  from datetime import datetime
4
+
5
+ # Sample test categories for demonstration
6
+ TEST_CATEGORIES = {
7
+ "Haematology": ["Complete Blood Count", "Haemoglobin"],
8
+ "Clinical Pathology": ["Urinalysis", "Stool Analysis"],
9
+ "Biochemistry": ["Liver Function Test", "Kidney Function Test"],
10
+ "Microbiology": ["Culture Test", "Sensitivity Test"],
11
+ "Specific Diseases": ["Malaria", "Dengue"],
12
+ "Serology": ["HIV Test", "Hepatitis Test"],
13
+ "Radiology": ["X-ray", "CT Scan"],
14
+ "Other Diagnostic Tests": ["Blood Sugar", "Cholesterol"]
15
+ }
16
 
17
  # Load data
18
  def load_data():
 
71
  save_data(patients, last_sequence)
72
  return f"Patient Registered. Patient ID: {patient_id}", patient_id
73
 
74
+ # Tests Selection Tab
75
+ def test_interface(categories):
76
+ available_tests = []
77
+ for category in categories:
78
+ available_tests.extend(TEST_CATEGORIES.get(category, []))
79
+ return available_tests
80
+
81
+ def confirm_tests_interface(patient_id, selected_tests):
82
+ patients, last_sequence = load_data() # Load both patients and last_sequence
83
+ if patient_id not in patients:
84
+ return "Patient ID not found."
85
+ patients[patient_id]["tests"] = selected_tests
86
+ save_data(patients, last_sequence) # Save both patients and last_sequence
87
+ return "Tests confirmed for patient."
88
+
89
+ # Billing Tab
90
+ def billing_interface(patient_id):
91
+ patients, _ = load_data() # Load patients and ignore last_sequence
92
+ if patient_id in patients:
93
+ return f"Billing for {patient_id}: Tests: {patients[patient_id]['tests']}"
94
+ else:
95
+ return "Invalid Patient ID. Please check the ID."
96
+
97
  # Copy functionality
98
  def copy_patient_id(patient_id):
99
  return f"{patient_id} copied to clipboard!"
 
134
  with gr.Tab("Tests"):
135
  patient_id_test = gr.Textbox(label="Patient ID")
136
  categories = gr.CheckboxGroup(
137
+ list(TEST_CATEGORIES.keys()),
138
  label="Select Test Categories"
139
  )
140
  available_tests = gr.CheckboxGroup(label="Available Tests")