neerajkalyank commited on
Commit
e55bd6f
1 Parent(s): c619372

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +130 -113
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,
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}", patient_id
56
 
57
  # Tests Selection Tab
58
  def test_interface(categories):
@@ -74,8 +74,62 @@ 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');
80
 
81
  /* General Page Style */
@@ -91,6 +145,17 @@ body {
91
  min-height: 100vh;
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
94
  /* Header Styling */
95
  #header {
96
  color: #7fffd4;
@@ -133,30 +198,11 @@ input, select, textarea {
133
  box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.15);
134
  }
135
 
136
- /* Button Style */
137
- .gr-button {
138
- color: #ffffff;
139
- background: linear-gradient(135deg, #1de9b6, #007aff);
140
- border: none;
141
- border-radius: 12px;
142
- padding: 12px 30px;
143
- cursor: pointer;
144
- font-weight: 600;
145
- font-size: 16px;
146
- transition: 0.3s ease;
147
- box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
148
- }
149
-
150
- .gr-button:hover {
151
- background: linear-gradient(135deg, #005cbf, #00bfa5);
152
- transform: scale(1.05);
153
- box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
154
- }
155
-
156
- /* Checkbox Group Styling */
157
- .gr-checkbox-group label {
158
  display: flex;
159
  align-items: center;
 
160
  padding: 10px 20px;
161
  border: 2px solid #7fffd4;
162
  border-radius: 8px;
@@ -168,35 +214,77 @@ input, select, textarea {
168
  margin-right: 10px;
169
  }
170
 
171
- .gr-checkbox-group label:hover {
172
  background: #e0f7fa;
173
  color: #00bfa5;
174
  }
175
 
176
- /* Checkbox Styling */
177
- .gr-checkbox-group input[type="checkbox"] {
178
  appearance: none;
179
  width: 20px;
180
  height: 20px;
181
  border: 2px solid #7fffd4;
182
- border-radius: 4px;
183
  margin-right: 10px;
184
  transition: all 0.3s ease;
 
185
  }
186
 
187
- /* Selected Checkbox Styling */
188
- .gr-checkbox-group input[type="checkbox"]:checked {
189
  background-color: #ff8c00;
190
  border-color: #ff8c00;
191
  }
192
 
193
- /* Simple checkmark indicator */
194
- .gr-checkbox-group input[type="checkbox"]:checked::after {
195
  content: "✓";
 
196
  font-size: 14px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  color: #ffffff;
198
- display: block;
199
- text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
 
202
  /* Tab Styling */
@@ -233,7 +321,7 @@ input, select, textarea {
233
  padding: 8px 16px;
234
  }
235
 
236
- /* Label Styling */
237
  label {
238
  font-size: 1em;
239
  font-weight: 600;
@@ -265,82 +353,11 @@ label {
265
  font-size: 1em;
266
  padding: 10px;
267
  }
 
 
 
 
 
268
  }
269
  """
270
-
271
- # Gradio Interface
272
- with gr.Blocks(css=custom_css) as app:
273
- gr.Markdown("<h1 style='text-align: center;'>👩🏻‍🔬丂卂ㄒ卄Ҝ尺ㄩㄒ卄卂 ㄥ丨爪丂🔬</h1>", elem_id="header")
274
-
275
- with gr.Tab("Patient Registration"):
276
- gr.Markdown("<h2>Register a New Patient</h2>")
277
-
278
- with gr.Row():
279
- name = gr.Textbox(label="Patient Name", placeholder="Enter patient's full name", elem_id="name_field")
280
- father_name = gr.Textbox(label="Father/Husband's Name", placeholder="Enter father/husband's full name", elem_id="father_name_field")
281
-
282
- with gr.Row():
283
- age = gr.Number(label="Age", value=None, minimum=0, maximum=120, elem_id="age_field")
284
- gender = gr.Radio(
285
- choices=["Male", "Female", "Other"],
286
- label="Gender",
287
- elem_id="gender_field"
288
- )
289
-
290
- with gr.Row():
291
- phone = gr.Textbox(label="Phone Number", placeholder="Enter a valid 10-digit phone number", elem_id="phone_field")
292
- address = gr.Textbox(label="Address", placeholder="Enter full address", lines=2, elem_id="address_field")
293
-
294
- register_button = gr.Button("Register Patient", elem_id="register_button")
295
- registration_output = gr.Markdown(elem_id="registration_output")
296
- patient_id_display = gr.Textbox(label="Patient ID", interactive=False, elem_id="patient_id_display") # Display Patient ID as non-editable text
297
-
298
- # Copy Patient ID functionality with JavaScript
299
- gr.Markdown("""
300
- <button onclick="copyPatientID()" class="gr-button" style="margin-top: 10px;">Copy Patient ID</button>
301
- <script>
302
- function copyPatientID() {
303
- const patientID = document.querySelector('#patient_id_display input').value;
304
- navigator.clipboard.writeText(patientID).then(() => {
305
- alert('Patient ID copied to clipboard');
306
- });
307
- }
308
- </script>
309
- """)
310
-
311
- # Callback for registration and display Patient ID
312
- register_button.click(registration_interface, [name, father_name, age, gender, phone, address], [registration_output, patient_id_display])
313
-
314
- with gr.Tab("Tests"):
315
- gr.Markdown("<h2>Select Tests for the Patient</h2>")
316
- patient_id_test = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
317
- paste_button_test = gr.Button("Paste Patient ID") # Paste button to auto-fill Patient ID
318
- categories = gr.CheckboxGroup(
319
- ["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
320
- label="Select Test Categories"
321
- )
322
- available_tests = gr.CheckboxGroup(label="Available Tests")
323
- confirm_button = gr.Button("Confirm Selected Tests")
324
-
325
- test_output = gr.Markdown(label="Test Selection Output", elem_id="test_output")
326
-
327
- categories.change(test_interface, inputs=categories, outputs=available_tests)
328
- confirm_button.click(confirm_tests_interface, [patient_id_test, available_tests], test_output)
329
-
330
- # Paste button action for Tests Tab
331
- paste_button_test.click(lambda x: x, patient_id_display, patient_id_test)
332
-
333
- with gr.Tab("Billing"):
334
- gr.Markdown("<h2>Billing Information</h2>")
335
- patient_id_bill = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID for Billing")
336
- paste_button_bill = gr.Button("Paste Patient ID") # Paste button for Billing
337
- fetch_button = gr.Button("Fetch Billing Details")
338
-
339
- billing_output = gr.Markdown(label="Billing Information", elem_id="billing_output")
340
-
341
- fetch_button.click(billing_interface, [patient_id_bill], billing_output)
342
-
343
- # Paste button action for Billing Tab
344
- paste_button_bill.click(lambda x: x, patient_id_display, patient_id_bill)
345
-
346
- app.launch()
 
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
  }
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
  else:
75
  return "Invalid Patient ID. Please check the ID."
76
 
77
+ # Gradio Interface
78
+ with gr.Blocks() as app:
79
+ gr.Markdown("<h1 style='text-align: center;'>👩🏻‍🔬丂卂ㄒ卄Ҝ尺ㄩㄒ卄卂 ㄥ丨爪丂🔬</h1>", elem_id="header")
80
+
81
+ with gr.Tab("Patient Registration"):
82
+ gr.Markdown("<h2>Register a New Patient</h2>")
83
+
84
+ with gr.Row():
85
+ name = gr.Textbox(label="Patient Name", placeholder="Enter patient's full name", elem_id="name_field")
86
+ father_name = gr.Textbox(label="Father/Husband's Name", placeholder="Enter father/husband's full name", elem_id="father_name_field")
87
+
88
+ with gr.Row():
89
+ age = gr.Number(label="Age", value=None, minimum=0, maximum=120, elem_id="age_field")
90
+ gender = gr.CheckboxGroup(
91
+ choices=["Male", "Female", "Other"],
92
+ label="Gender",
93
+ elem_id="gender_field"
94
+ )
95
+
96
+ with gr.Row():
97
+ phone = gr.Textbox(label="Phone Number", placeholder="Enter a valid 10-digit phone number", elem_id="phone_field")
98
+ address = gr.Textbox(label="Address", placeholder="Enter full address", lines=2, elem_id="address_field")
99
+
100
+ register_button = gr.Button("Register Patient", elem_id="register_button")
101
+ registration_output = gr.Markdown(label="Registration Output", elem_id="registration_output")
102
+
103
+ register_button.click(registration_interface, [name, father_name, age, gender, phone, address], registration_output)
104
+
105
+ with gr.Tab("Tests"):
106
+ gr.Markdown("<h2>Select Tests for the Patient</h2>")
107
+ patient_id_test = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
108
+ categories = gr.CheckboxGroup(
109
+ ["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
110
+ label="Select Test Categories"
111
+ )
112
+ available_tests = gr.CheckboxGroup(label="Available Tests")
113
+ confirm_button = gr.Button("Confirm Selected Tests")
114
+
115
+ # Use Markdown for Test Selection Output to allow for auto-expanding content
116
+ test_output = gr.Markdown(label="Test Selection Output", elem_id="test_output")
117
+
118
+ categories.change(test_interface, inputs=categories, outputs=available_tests)
119
+ confirm_button.click(confirm_tests_interface, [patient_id_test, available_tests], test_output)
120
+
121
+ with gr.Tab("Billing"):
122
+ gr.Markdown("<h2>Billing Information</h2>")
123
+ patient_id_bill = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID for Billing")
124
+ fetch_button = gr.Button("Fetch Billing Details")
125
+
126
+ # Use Markdown for Billing Output to allow for auto-expanding content
127
+ billing_output = gr.Markdown(label="Billing Information", elem_id="billing_output")
128
+
129
+ fetch_button.click(billing_interface, [patient_id_bill], billing_output)
130
+
131
+
132
  # Custom CSS styling
 
133
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
134
 
135
  /* General Page Style */
 
145
  min-height: 100vh;
146
  }
147
 
148
+ /* Heading Colors */
149
+ h1 {
150
+ color: #ffffff; /* White color for h1 */
151
+ text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
152
+ }
153
+
154
+ h2, h3, h4, h5, h6 {
155
+ color: #f0e68c; /* Light yellow shadow for other headings */
156
+ text-shadow: 2px 2px 10px rgba(255, 255, 0, 0.3);
157
+ }
158
+
159
  /* Header Styling */
160
  #header {
161
  color: #7fffd4;
 
198
  box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.15);
199
  }
200
 
201
+ /* Radio Button Group Styling */
202
+ .gr-radio-group label {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  display: flex;
204
  align-items: center;
205
+ justify-content: center;
206
  padding: 10px 20px;
207
  border: 2px solid #7fffd4;
208
  border-radius: 8px;
 
214
  margin-right: 10px;
215
  }
216
 
217
+ .gr-radio-group label:hover {
218
  background: #e0f7fa;
219
  color: #00bfa5;
220
  }
221
 
222
+ /* Radio Button Styling */
223
+ .gr-radio-group input[type="radio"] {
224
  appearance: none;
225
  width: 20px;
226
  height: 20px;
227
  border: 2px solid #7fffd4;
228
+ border-radius: 50%;
229
  margin-right: 10px;
230
  transition: all 0.3s ease;
231
+ position: relative;
232
  }
233
 
234
+ /* Selected Radio Button Styling with Checkmark */
235
+ .gr-radio-group input[type="radio"]:checked {
236
  background-color: #ff8c00;
237
  border-color: #ff8c00;
238
  }
239
 
240
+ .gr-radio-group input[type="radio"]:checked::after {
 
241
  content: "✓";
242
+ color: #ffffff;
243
  font-size: 14px;
244
+ position: absolute;
245
+ top: 1px;
246
+ left: 1px;
247
+ width: 18px;
248
+ height: 18px;
249
+ border-radius: 50%;
250
+ display: flex;
251
+ align-items: center;
252
+ justify-content: center;
253
+ background-color: #ff8c00;
254
+ }
255
+
256
+ /* Adjust label for responsive alignment */
257
+ .gr-radio-group span {
258
+ font-size: 1em;
259
+ font-weight: 600;
260
+ color: #2d2d2d;
261
+ }
262
+
263
+ /* Form Field Hover and Focus */
264
+ input:focus, textarea:focus, select:focus {
265
+ border-color: #00ffcc;
266
+ box-shadow: 0 0 10px rgba(0, 255, 204, 0.6);
267
+ transform: scale(1.02);
268
+ }
269
+
270
+ /* Button Style */
271
+ .gr-button {
272
  color: #ffffff;
273
+ background: linear-gradient(135deg, #1de9b6, #007aff);
274
+ border: none;
275
+ border-radius: 12px;
276
+ padding: 12px 30px;
277
+ cursor: pointer;
278
+ font-weight: 600;
279
+ font-size: 16px;
280
+ transition: 0.3s ease;
281
+ box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
282
+ }
283
+
284
+ .gr-button:hover {
285
+ background: linear-gradient(135deg, #005cbf, #00bfa5);
286
+ transform: scale(1.05);
287
+ box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
288
  }
289
 
290
  /* Tab Styling */
 
321
  padding: 8px 16px;
322
  }
323
 
324
+ /* Field Labels */
325
  label {
326
  font-size: 1em;
327
  font-weight: 600;
 
353
  font-size: 1em;
354
  padding: 10px;
355
  }
356
+
357
+ .gr-radio-group {
358
+ flex-direction: column;
359
+ align-items: flex-start;
360
+ }
361
  }
362
  """
363
+ app.launch()