neerajkalyank commited on
Commit
09047cc
1 Parent(s): 5915fd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -57
app.py CHANGED
@@ -44,7 +44,7 @@ def registration_interface(name, father_name, age, gender, phone, address):
44
  "name": name,
45
  "father_name": father_name,
46
  "age": age,
47
- "gender": gender, # Updated field for gender
48
  "phone": phone,
49
  "address": address,
50
  "tests": [],
@@ -52,7 +52,7 @@ def registration_interface(name, father_name, age, gender, phone, address):
52
  }
53
 
54
  save_data(patients, last_sequence)
55
- return f"Patient Registered. Patient ID: {patient_id}"
56
 
57
  # Tests Selection Tab
58
  def test_interface(categories):
@@ -74,6 +74,80 @@ def billing_interface(patient_id):
74
  else:
75
  return "Invalid Patient ID. Please check the ID."
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  # Custom CSS styling
78
  custom_css = """
79
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
@@ -240,59 +314,4 @@ input, select, textarea {
240
  padding: 8px 16px;
241
  }
242
  """
243
-
244
- # Gradio Interface
245
- with gr.Blocks(css=custom_css) as app:
246
- gr.Markdown("<h1 style='text-align: center;'>👩🏻‍🔬丂卂ㄒ卄Ҝ尺ㄩㄒ卄卂 ㄥ丨爪丂🔬</h1>", elem_id="header")
247
-
248
- with gr.Tab("Patient Registration"):
249
- gr.Markdown("<h2>Register a New Patient</h2>")
250
-
251
- with gr.Row():
252
- name = gr.Textbox(label="Patient Name", placeholder="Enter patient's full name", elem_id="name_field")
253
- father_name = gr.Textbox(label="Father/Husband's Name", placeholder="Enter father/husband's full name", elem_id="father_name_field")
254
-
255
- with gr.Row():
256
- age = gr.Number(label="Age", value=None, minimum=0, maximum=120, elem_id="age_field")
257
- gender = gr.Radio(
258
- choices=["Male", "Female", "Other"],
259
- label="Gender",
260
- elem_id="gender_field"
261
- )
262
-
263
- with gr.Row():
264
- phone = gr.Textbox(label="Phone Number", placeholder="Enter a valid 10-digit phone number", elem_id="phone_field")
265
- address = gr.Textbox(label="Address", placeholder="Enter full address", lines=2, elem_id="address_field")
266
-
267
- register_button = gr.Button("Register Patient", elem_id="register_button")
268
- registration_output = gr.Markdown(label="Registration Output", elem_id="registration_output")
269
-
270
- register_button.click(registration_interface, [name, father_name, age, gender, phone, address], registration_output)
271
-
272
- with gr.Tab("Tests"):
273
- gr.Markdown("<h2>Select Tests for the Patient</h2>")
274
- patient_id_test = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
275
- categories = gr.CheckboxGroup(
276
- ["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
277
- label="Select Test Categories"
278
- )
279
- available_tests = gr.CheckboxGroup(label="Available Tests")
280
- confirm_button = gr.Button("Confirm Selected Tests")
281
-
282
- # Use Markdown for Test Selection Output to allow for auto-expanding content
283
- test_output = gr.Markdown(label="Test Selection Output", elem_id="test_output")
284
-
285
- categories.change(test_interface, inputs=categories, outputs=available_tests)
286
- confirm_button.click(confirm_tests_interface, [patient_id_test, available_tests], test_output)
287
-
288
- with gr.Tab("Billing"):
289
- gr.Markdown("<h2>Billing Information</h2>")
290
- patient_id_bill = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID for Billing")
291
- fetch_button = gr.Button("Fetch Billing Details")
292
-
293
- # Use Markdown for Billing Output to allow for auto-expanding content
294
- billing_output = gr.Markdown(label="Billing Information", elem_id="billing_output")
295
-
296
- fetch_button.click(billing_interface, [patient_id_bill], billing_output)
297
-
298
  app.launch()
 
44
  "name": name,
45
  "father_name": father_name,
46
  "age": age,
47
+ "gender": gender,
48
  "phone": phone,
49
  "address": address,
50
  "tests": [],
 
52
  }
53
 
54
  save_data(patients, last_sequence)
55
+ return f"Patient Registered. Patient ID: {patient_id}", patient_id
56
 
57
  # Tests Selection Tab
58
  def test_interface(categories):
 
74
  else:
75
  return "Invalid Patient ID. Please check the ID."
76
 
77
+ # Custom CSS styling
78
+ custom_css = """
79
+ /* Include your CSS code here */
80
+ """
81
+
82
+ # Gradio Interface
83
+ with gr.Blocks(css=custom_css) as app:
84
+ gr.Markdown("<h1 style='text-align: center;'>👩🏻‍🔬丂卂ㄒ卄Ҝ尺ㄩㄒ卄卂 ㄥ丨爪丂🔬</h1>", elem_id="header")
85
+
86
+ with gr.Tab("Patient Registration"):
87
+ gr.Markdown("<h2>Register a New Patient</h2>")
88
+
89
+ with gr.Row():
90
+ name = gr.Textbox(label="Patient Name", placeholder="Enter patient's full name", elem_id="name_field")
91
+ father_name = gr.Textbox(label="Father/Husband's Name", placeholder="Enter father/husband's full name", elem_id="father_name_field")
92
+
93
+ with gr.Row():
94
+ age = gr.Number(label="Age", value=None, minimum=0, maximum=120, elem_id="age_field")
95
+ gender = gr.Radio(
96
+ choices=["Male", "Female", "Other"],
97
+ label="Gender",
98
+ elem_id="gender_field"
99
+ )
100
+
101
+ with gr.Row():
102
+ phone = gr.Textbox(label="Phone Number", placeholder="Enter a valid 10-digit phone number", elem_id="phone_field")
103
+ address = gr.Textbox(label="Address", placeholder="Enter full address", lines=2, elem_id="address_field")
104
+
105
+ register_button = gr.Button("Register Patient", elem_id="register_button")
106
+ registration_output = gr.Markdown(elem_id="registration_output")
107
+ patient_id_display = gr.Textbox(label="Patient ID", interactive=False) # Display Patient ID as non-editable text
108
+ copy_button = gr.Button("Copy Patient ID")
109
+
110
+ # Callback for registration and display Patient ID
111
+ register_button.click(registration_interface, [name, father_name, age, gender, phone, address], [registration_output, patient_id_display])
112
+
113
+ # Copy button to copy Patient ID to clipboard
114
+ copy_button.click(lambda x: x, patient_id_display, None, _js="navigator.clipboard.writeText")
115
+
116
+ with gr.Tab("Tests"):
117
+ gr.Markdown("<h2>Select Tests for the Patient</h2>")
118
+ patient_id_test = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
119
+ paste_button_test = gr.Button("Paste Patient ID") # Paste button to auto-fill Patient ID
120
+ categories = gr.CheckboxGroup(
121
+ ["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
122
+ label="Select Test Categories"
123
+ )
124
+ available_tests = gr.CheckboxGroup(label="Available Tests")
125
+ confirm_button = gr.Button("Confirm Selected Tests")
126
+
127
+ # Test output to allow for auto-expanding content
128
+ test_output = gr.Markdown(label="Test Selection Output", elem_id="test_output")
129
+
130
+ # Event for updating available tests based on categories
131
+ categories.change(test_interface, inputs=categories, outputs=available_tests)
132
+ confirm_button.click(confirm_tests_interface, [patient_id_test, available_tests], test_output)
133
+
134
+ # Paste button action for Tests Tab
135
+ paste_button_test.click(lambda x: x, patient_id_display, patient_id_test)
136
+
137
+ with gr.Tab("Billing"):
138
+ gr.Markdown("<h2>Billing Information</h2>")
139
+ patient_id_bill = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID for Billing")
140
+ paste_button_bill = gr.Button("Paste Patient ID") # Paste button for Billing
141
+ fetch_button = gr.Button("Fetch Billing Details")
142
+
143
+ billing_output = gr.Markdown(label="Billing Information", elem_id="billing_output")
144
+
145
+ # Event for fetching billing details
146
+ fetch_button.click(billing_interface, [patient_id_bill], billing_output)
147
+
148
+ # Paste button action for Billing Tab
149
+ paste_button_bill.click(lambda x: x, patient_id_display, patient_id_bill)
150
+
151
  # Custom CSS styling
152
  custom_css = """
153
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
 
314
  padding: 8px 16px;
315
  }
316
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  app.launch()