Spaces:
Sleeping
Sleeping
import gradio as gr | |
import json | |
from patient_registration import register_patient | |
from test_selection import select_tests | |
from billing import fetch_billing | |
# Load data | |
def load_data(): | |
try: | |
with open("data.json", "r") as file: | |
return json.load(file) | |
except FileNotFoundError: | |
return {} | |
# Save data | |
def save_data(data): | |
with open("data.json", "w") as file: | |
json.dump(data, file) | |
# Patient Registration Tab | |
def registration_interface(name, father_name, age, phone, address, pincode): | |
patient_id = register_patient(name, father_name, age, phone, address, pincode) | |
data = load_data() | |
data[patient_id] = {"name": name, "father_name": father_name, "age": age, "phone": phone, "address": address, "pincode": pincode, "tests": [], "total_cost": 0} | |
save_data(data) | |
return f"Patient Registered. Patient ID: {patient_id}" | |
# Tests Selection Tab | |
def test_interface(patient_id, categories, selected_tests): | |
data = load_data() | |
response = select_tests(patient_id, categories, selected_tests, data) | |
save_data(data) | |
return response | |
# Billing Tab | |
def billing_interface(patient_id): | |
data = load_data() | |
billing_info = fetch_billing(patient_id, data) | |
return billing_info | |
# Gradio Interface | |
with gr.Blocks() as app: | |
gr.Markdown("# Sathkrutha LIMS - Patient Management and Billing App") | |
with gr.Tab("Patient Registration"): | |
name = gr.Textbox(label="Name") | |
father_name = gr.Textbox(label="Father/Husband Name") | |
age = gr.Number(label="Age") | |
phone = gr.Textbox(label="Phone Number") | |
address = gr.Textbox(label="Address") | |
pincode = gr.Textbox(label="Pincode") | |
register_button = gr.Button("Register Patient") | |
registration_output = gr.Textbox(label="Registration Output") | |
register_button.click(registration_interface, [name, father_name, age, phone, address, pincode], registration_output) | |
with gr.Tab("Tests"): | |
patient_id_test = gr.Textbox(label="Patient ID") | |
categories = gr.CheckboxGroup(["Hematology", "Biochemistry"], label="Select Test Categories") | |
selected_tests = gr.CheckboxGroup([], label="Select Specific Tests") | |
confirm_button = gr.Button("Confirm Tests") | |
test_output = gr.Textbox(label="Test Selection Output") | |
confirm_button.click(test_interface, [patient_id_test, categories, selected_tests], test_output) | |
with gr.Tab("Billing"): | |
patient_id_bill = gr.Textbox(label="Patient ID") | |
fetch_button = gr.Button("Fetch Billing") | |
billing_output = gr.Textbox(label="Billing Information") | |
fetch_button.click(billing_interface, [patient_id_bill], billing_output) | |
app.launch() | |