Spaces:
Running
Running
neerajkalyank
commited on
Commit
•
bdde5b9
1
Parent(s):
fe8c4f6
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
from datetime import datetime
|
4 |
-
|
5 |
-
|
6 |
-
|
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():
|
@@ -69,35 +60,28 @@ def registration_interface(name, father_name, age, phone, address, pincode):
|
|
69 |
|
70 |
# Save data and updated sequence
|
71 |
save_data(patients, last_sequence)
|
72 |
-
return f"Patient Registered. Patient ID: {patient_id}"
|
73 |
|
74 |
# Tests Selection Tab
|
75 |
def test_interface(categories):
|
76 |
-
available_tests =
|
77 |
-
|
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 |
-
|
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
|
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 |
-
|
|
|
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!"
|
100 |
-
|
101 |
# Gradio Interface
|
102 |
with gr.Blocks() as app:
|
103 |
gr.Markdown("<h1 style='text-align: center;'>Sathkrutha LIMS</h1>", elem_id="header")
|
@@ -112,29 +96,15 @@ with gr.Blocks() as app:
|
|
112 |
with gr.Row():
|
113 |
address = gr.Textbox(label="Address", placeholder="Enter address", lines=2)
|
114 |
pincode = gr.Number(label="Pincode", value=None, elem_id="pincode_field")
|
115 |
-
|
116 |
register_button = gr.Button("Register Patient")
|
117 |
registration_output = gr.Textbox(label="Registration Output")
|
118 |
-
patient_id_display = gr.Textbox(label="Patient ID", interactive=False) # Display Patient ID here
|
119 |
-
copy_button = gr.Button("Copy Patient ID")
|
120 |
-
copy_output = gr.Textbox(label="Copy Status", interactive=False)
|
121 |
-
|
122 |
-
register_button.click(
|
123 |
-
registration_interface,
|
124 |
-
[name, father_name, age, phone, address, pincode],
|
125 |
-
[registration_output, patient_id_display]
|
126 |
-
)
|
127 |
|
128 |
-
|
129 |
-
copy_patient_id,
|
130 |
-
[patient_id_display], # Pass the Patient ID to the function
|
131 |
-
copy_output
|
132 |
-
)
|
133 |
|
134 |
with gr.Tab("Tests"):
|
135 |
patient_id_test = gr.Textbox(label="Patient ID")
|
136 |
categories = gr.CheckboxGroup(
|
137 |
-
|
138 |
label="Select Test Categories"
|
139 |
)
|
140 |
available_tests = gr.CheckboxGroup(label="Available Tests")
|
@@ -246,4 +216,4 @@ h1, h2, h3, h4, h5, h6 {
|
|
246 |
}
|
247 |
"""
|
248 |
|
249 |
-
app.launch()
|
|
|
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():
|
|
|
60 |
|
61 |
# Save data and updated sequence
|
62 |
save_data(patients, last_sequence)
|
63 |
+
return f"Patient Registered. Patient ID: {patient_id}"
|
64 |
|
65 |
# Tests Selection Tab
|
66 |
def test_interface(categories):
|
67 |
+
available_tests = get_tests_by_category(categories)
|
68 |
+
return gr.update(choices=available_tests) # Update dropdown with available tests
|
|
|
|
|
69 |
|
70 |
def confirm_tests_interface(patient_id, selected_tests):
|
71 |
patients, last_sequence = load_data() # Load both patients and last_sequence
|
72 |
+
response = select_tests(patient_id, selected_tests, patients) # Update patients directly
|
|
|
|
|
73 |
save_data(patients, last_sequence) # Save both patients and last_sequence
|
74 |
+
return response
|
75 |
|
76 |
# Billing Tab
|
77 |
def billing_interface(patient_id):
|
78 |
patients, _ = load_data() # Load patients and ignore last_sequence
|
79 |
if patient_id in patients:
|
80 |
+
billing_info = fetch_billing(patient_id, patients)
|
81 |
+
return billing_info
|
82 |
else:
|
83 |
return "Invalid Patient ID. Please check the ID."
|
84 |
|
|
|
|
|
|
|
|
|
85 |
# Gradio Interface
|
86 |
with gr.Blocks() as app:
|
87 |
gr.Markdown("<h1 style='text-align: center;'>Sathkrutha LIMS</h1>", elem_id="header")
|
|
|
96 |
with gr.Row():
|
97 |
address = gr.Textbox(label="Address", placeholder="Enter address", lines=2)
|
98 |
pincode = gr.Number(label="Pincode", value=None, elem_id="pincode_field")
|
|
|
99 |
register_button = gr.Button("Register Patient")
|
100 |
registration_output = gr.Textbox(label="Registration Output")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
+
register_button.click(registration_interface, [name, father_name, age, phone, address, pincode], registration_output)
|
|
|
|
|
|
|
|
|
103 |
|
104 |
with gr.Tab("Tests"):
|
105 |
patient_id_test = gr.Textbox(label="Patient ID")
|
106 |
categories = gr.CheckboxGroup(
|
107 |
+
["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
|
108 |
label="Select Test Categories"
|
109 |
)
|
110 |
available_tests = gr.CheckboxGroup(label="Available Tests")
|
|
|
216 |
}
|
217 |
"""
|
218 |
|
219 |
+
app.launch()
|