neerajkalyank commited on
Commit
2295b8f
1 Parent(s): 88607f9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ from patient_registration import register_patient
4
+ from test_selection import select_tests
5
+ from billing import fetch_billing
6
+
7
+ # Load data
8
+ def load_data():
9
+ try:
10
+ with open("data.json", "r") as file:
11
+ return json.load(file)
12
+ except FileNotFoundError:
13
+ return {}
14
+
15
+ # Save data
16
+ def save_data(data):
17
+ with open("data.json", "w") as file:
18
+ json.dump(data, file)
19
+
20
+ # Patient Registration Tab
21
+ def registration_interface(name, father_name, age, phone, address, pincode):
22
+ patient_id = register_patient(name, father_name, age, phone, address, pincode)
23
+ data = load_data()
24
+ data[patient_id] = {"name": name, "father_name": father_name, "age": age, "phone": phone, "address": address, "pincode": pincode, "tests": [], "total_cost": 0}
25
+ save_data(data)
26
+ return f"Patient Registered. Patient ID: {patient_id}"
27
+
28
+ # Tests Selection Tab
29
+ def test_interface(patient_id, categories, selected_tests):
30
+ data = load_data()
31
+ response = select_tests(patient_id, categories, selected_tests, data)
32
+ save_data(data)
33
+ return response
34
+
35
+ # Billing Tab
36
+ def billing_interface(patient_id):
37
+ data = load_data()
38
+ billing_info = fetch_billing(patient_id, data)
39
+ return billing_info
40
+
41
+ # Gradio Interface
42
+ with gr.Blocks() as app:
43
+ gr.Markdown("# Sathkrutha LIMS - Patient Management and Billing App")
44
+
45
+ with gr.Tab("Patient Registration"):
46
+ name = gr.Textbox(label="Name")
47
+ father_name = gr.Textbox(label="Father/Husband Name")
48
+ age = gr.Number(label="Age")
49
+ phone = gr.Textbox(label="Phone Number")
50
+ address = gr.Textbox(label="Address")
51
+ pincode = gr.Textbox(label="Pincode")
52
+ register_button = gr.Button("Register Patient")
53
+ registration_output = gr.Textbox(label="Registration Output")
54
+ register_button.click(registration_interface, [name, father_name, age, phone, address, pincode], registration_output)
55
+
56
+ with gr.Tab("Tests"):
57
+ patient_id_test = gr.Textbox(label="Patient ID")
58
+ categories = gr.CheckboxGroup(["Hematology", "Biochemistry"], label="Select Test Categories")
59
+ selected_tests = gr.CheckboxGroup([], label="Select Specific Tests")
60
+ confirm_button = gr.Button("Confirm Tests")
61
+ test_output = gr.Textbox(label="Test Selection Output")
62
+ confirm_button.click(test_interface, [patient_id_test, categories, selected_tests], test_output)
63
+
64
+ with gr.Tab("Billing"):
65
+ patient_id_bill = gr.Textbox(label="Patient ID")
66
+ fetch_button = gr.Button("Fetch Billing")
67
+ billing_output = gr.Textbox(label="Billing Information")
68
+ fetch_button.click(billing_interface, [patient_id_bill], billing_output)
69
+
70
+ app.launch()