Spaces:
Sleeping
Sleeping
neerajkalyank
commited on
Commit
•
140a2ce
1
Parent(s):
09047cc
Update app.py
Browse files
app.py
CHANGED
@@ -74,80 +74,6 @@ 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 |
-
/* 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');
|
@@ -165,17 +91,6 @@ body {
|
|
165 |
min-height: 100vh;
|
166 |
}
|
167 |
|
168 |
-
/* Heading Colors */
|
169 |
-
h1 {
|
170 |
-
color: #ffffff; /* White color for h1 */
|
171 |
-
text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
|
172 |
-
}
|
173 |
-
|
174 |
-
h2, h3, h4, h5, h6 {
|
175 |
-
color: #f0e68c; /* Light yellow shadow for other headings */
|
176 |
-
text-shadow: 2px 2px 10px rgba(255, 255, 0, 0.3);
|
177 |
-
}
|
178 |
-
|
179 |
/* Header Styling */
|
180 |
#header {
|
181 |
color: #7fffd4;
|
@@ -193,91 +108,24 @@ h2, h3, h4, h5, h6 {
|
|
193 |
transform: scale(1.05);
|
194 |
}
|
195 |
|
196 |
-
/*
|
197 |
-
.
|
198 |
-
max-width: 850px;
|
199 |
-
margin: 30px auto;
|
200 |
-
padding: 40px;
|
201 |
-
background: rgba(0, 0, 50, 0.95);
|
202 |
-
border-radius: 15px;
|
203 |
-
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
204 |
-
color: #e0f7fa;
|
205 |
-
}
|
206 |
-
|
207 |
-
/* Form Field Styles */
|
208 |
-
input, select, textarea {
|
209 |
-
max-width: 700px;
|
210 |
-
border: 1px solid #7fffd4;
|
211 |
-
border-radius: 8px;
|
212 |
-
padding: 10px 12px;
|
213 |
-
background: rgba(245, 245, 245, 0.95);
|
214 |
-
color: #2d2d2d;
|
215 |
-
font-size: 15px;
|
216 |
-
margin-bottom: 20px;
|
217 |
-
transition: all 0.3s ease;
|
218 |
-
box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.15);
|
219 |
-
}
|
220 |
-
|
221 |
-
/* Radio Button Group Styling */
|
222 |
-
.gr-radio-group label {
|
223 |
-
display: flex;
|
224 |
-
align-items: center;
|
225 |
-
justify-content: center;
|
226 |
-
padding: 10px 20px;
|
227 |
-
border: 2px solid #7fffd4;
|
228 |
-
border-radius: 8px;
|
229 |
-
transition: all 0.3s ease;
|
230 |
-
cursor: pointer;
|
231 |
-
color: #7fffd4;
|
232 |
-
background: rgba(245, 245, 245, 0.95);
|
233 |
-
box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.15);
|
234 |
-
margin-right: 10px;
|
235 |
-
}
|
236 |
-
|
237 |
-
.gr-radio-group label:hover {
|
238 |
-
background: #e0f7fa;
|
239 |
-
color: #00bfa5;
|
240 |
-
}
|
241 |
-
|
242 |
-
/* Radio Button Styling */
|
243 |
-
.gr-radio-group input[type="radio"] {
|
244 |
-
appearance: none;
|
245 |
-
width: 20px;
|
246 |
-
height: 20px;
|
247 |
-
border: 2px solid #7fffd4;
|
248 |
-
border-radius: 50%;
|
249 |
-
margin-right: 10px;
|
250 |
-
transition: all 0.3s ease;
|
251 |
-
position: relative;
|
252 |
-
}
|
253 |
-
|
254 |
-
/* Selected Radio Button Styling with Checkmark */
|
255 |
-
.gr-radio-group input[type="radio"]:checked {
|
256 |
-
background-color: #ff8c00;
|
257 |
-
border-color: #ff8c00;
|
258 |
-
}
|
259 |
-
|
260 |
-
.gr-radio-group input[type="radio"]:checked::after {
|
261 |
-
content: "✓";
|
262 |
color: #ffffff;
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
justify-content: center;
|
273 |
-
background-color: #ff8c00;
|
274 |
}
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
color: #2d2d2d;
|
281 |
}
|
282 |
|
283 |
/* Tab Styling */
|
@@ -314,4 +162,78 @@ input, select, textarea {
|
|
314 |
padding: 8px 16px;
|
315 |
}
|
316 |
"""
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
91 |
min-height: 100vh;
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/* Header Styling */
|
95 |
#header {
|
96 |
color: #7fffd4;
|
|
|
108 |
transform: scale(1.05);
|
109 |
}
|
110 |
|
111 |
+
/* Button Style */
|
112 |
+
.gr-button {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
color: #ffffff;
|
114 |
+
background: linear-gradient(135deg, #1de9b6, #007aff);
|
115 |
+
border: none;
|
116 |
+
border-radius: 12px;
|
117 |
+
padding: 12px 30px;
|
118 |
+
cursor: pointer;
|
119 |
+
font-weight: 600;
|
120 |
+
font-size: 16px;
|
121 |
+
transition: 0.3s ease;
|
122 |
+
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
|
|
|
|
|
123 |
}
|
124 |
|
125 |
+
.gr-button:hover {
|
126 |
+
background: linear-gradient(135deg, #005cbf, #00bfa5);
|
127 |
+
transform: scale(1.05);
|
128 |
+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
|
|
|
129 |
}
|
130 |
|
131 |
/* Tab Styling */
|
|
|
162 |
padding: 8px 16px;
|
163 |
}
|
164 |
"""
|
165 |
+
|
166 |
+
# Gradio Interface
|
167 |
+
with gr.Blocks(css=custom_css) as app:
|
168 |
+
gr.Markdown("<h1 style='text-align: center;'>👩🏻🔬丂卂ㄒ卄Ҝ尺ㄩㄒ卄卂 ㄥ丨爪丂🔬</h1>", elem_id="header")
|
169 |
+
|
170 |
+
with gr.Tab("Patient Registration"):
|
171 |
+
gr.Markdown("<h2>Register a New Patient</h2>")
|
172 |
+
|
173 |
+
with gr.Row():
|
174 |
+
name = gr.Textbox(label="Patient Name", placeholder="Enter patient's full name", elem_id="name_field")
|
175 |
+
father_name = gr.Textbox(label="Father/Husband's Name", placeholder="Enter father/husband's full name", elem_id="father_name_field")
|
176 |
+
|
177 |
+
with gr.Row():
|
178 |
+
age = gr.Number(label="Age", value=None, minimum=0, maximum=120, elem_id="age_field")
|
179 |
+
gender = gr.Radio(
|
180 |
+
choices=["Male", "Female", "Other"],
|
181 |
+
label="Gender",
|
182 |
+
elem_id="gender_field"
|
183 |
+
)
|
184 |
+
|
185 |
+
with gr.Row():
|
186 |
+
phone = gr.Textbox(label="Phone Number", placeholder="Enter a valid 10-digit phone number", elem_id="phone_field")
|
187 |
+
address = gr.Textbox(label="Address", placeholder="Enter full address", lines=2, elem_id="address_field")
|
188 |
+
|
189 |
+
register_button = gr.Button("Register Patient", elem_id="register_button")
|
190 |
+
registration_output = gr.Markdown(elem_id="registration_output")
|
191 |
+
patient_id_display = gr.Textbox(label="Patient ID", interactive=False, elem_id="patient_id_display") # Display Patient ID as non-editable text
|
192 |
+
copy_button = gr.Button("Copy Patient ID", elem_id="copy_button")
|
193 |
+
|
194 |
+
# Callback for registration and display Patient ID
|
195 |
+
register_button.click(registration_interface, [name, father_name, age, gender, phone, address], [registration_output, patient_id_display])
|
196 |
+
|
197 |
+
# JavaScript function to copy Patient ID
|
198 |
+
copy_button.click(None, [], None, _js="""
|
199 |
+
function(){
|
200 |
+
const text = document.querySelector('#patient_id_display input').value;
|
201 |
+
navigator.clipboard.writeText(text).then(() => {
|
202 |
+
alert('Patient ID copied to clipboard');
|
203 |
+
});
|
204 |
+
}
|
205 |
+
""")
|
206 |
+
|
207 |
+
with gr.Tab("Tests"):
|
208 |
+
gr.Markdown("<h2>Select Tests for the Patient</h2>")
|
209 |
+
patient_id_test = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID")
|
210 |
+
paste_button_test = gr.Button("Paste Patient ID") # Paste button to auto-fill Patient ID
|
211 |
+
categories = gr.CheckboxGroup(
|
212 |
+
["Haematology", "Clinical Pathology", "Biochemistry", "Microbiology", "Specific Diseases", "Serology", "Radiology", "Other Diagnostic Tests"],
|
213 |
+
label="Select Test Categories"
|
214 |
+
)
|
215 |
+
available_tests = gr.CheckboxGroup(label="Available Tests")
|
216 |
+
confirm_button = gr.Button("Confirm Selected Tests")
|
217 |
+
|
218 |
+
test_output = gr.Markdown(label="Test Selection Output", elem_id="test_output")
|
219 |
+
|
220 |
+
categories.change(test_interface, inputs=categories, outputs=available_tests)
|
221 |
+
confirm_button.click(confirm_tests_interface, [patient_id_test, available_tests], test_output)
|
222 |
+
|
223 |
+
# Paste button action for Tests Tab
|
224 |
+
paste_button_test.click(lambda x: x, patient_id_display, patient_id_test)
|
225 |
+
|
226 |
+
with gr.Tab("Billing"):
|
227 |
+
gr.Markdown("<h2>Billing Information</h2>")
|
228 |
+
patient_id_bill = gr.Textbox(label="Patient ID", placeholder="Enter Patient ID for Billing")
|
229 |
+
paste_button_bill = gr.Button("Paste Patient ID") # Paste button for Billing
|
230 |
+
fetch_button = gr.Button("Fetch Billing Details")
|
231 |
+
|
232 |
+
billing_output = gr.Markdown(label="Billing Information", elem_id="billing_output")
|
233 |
+
|
234 |
+
fetch_button.click(billing_interface, [patient_id_bill], billing_output)
|
235 |
+
|
236 |
+
# Paste button action for Billing Tab
|
237 |
+
paste_button_bill.click(lambda x: x, patient_id_display, patient_id_bill)
|
238 |
+
|
239 |
+
app.launch()
|