Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,113 +1,72 @@
|
|
| 1 |
# app.py
|
| 2 |
-
|
| 3 |
-
import
|
| 4 |
-
from
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
return
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
if request.method == 'POST':
|
| 74 |
-
patient_id = request.form['patient_id']
|
| 75 |
-
selected_tests = request.form.getlist('tests')
|
| 76 |
-
conn = get_db_connection()
|
| 77 |
-
|
| 78 |
-
total_amount = 0
|
| 79 |
-
for test in selected_tests:
|
| 80 |
-
amount = tests[test]
|
| 81 |
-
total_amount += amount
|
| 82 |
-
conn.execute("INSERT INTO lab_tests (patient_id, test_name, amount) VALUES (?, ?, ?)",
|
| 83 |
-
(patient_id, test, amount))
|
| 84 |
-
|
| 85 |
-
# Link total amount to billing
|
| 86 |
-
conn.execute("INSERT INTO billing (patient_id, total_amount) VALUES (?, ?)",
|
| 87 |
-
(patient_id, total_amount))
|
| 88 |
-
conn.commit()
|
| 89 |
-
conn.close()
|
| 90 |
-
flash(f"Lab tests booked successfully! Total amount: {total_amount}", "success")
|
| 91 |
-
|
| 92 |
-
return redirect(url_for('lab'))
|
| 93 |
-
|
| 94 |
-
return render_template('lab.html', tests=tests)
|
| 95 |
-
|
| 96 |
-
### 4. Reports ###
|
| 97 |
-
@app.route('/reports/<int:patient_id>')
|
| 98 |
-
def reports(patient_id):
|
| 99 |
-
conn = get_db_connection()
|
| 100 |
-
reports = conn.execute("SELECT * FROM lab_tests WHERE patient_id = ?", (patient_id,)).fetchall()
|
| 101 |
-
conn.close()
|
| 102 |
-
return render_template('reports.html', reports=reports)
|
| 103 |
-
|
| 104 |
-
### 5. Billing ###
|
| 105 |
-
@app.route('/billing/<int:patient_id>')
|
| 106 |
-
def billing(patient_id):
|
| 107 |
-
conn = get_db_connection()
|
| 108 |
-
billing = conn.execute("SELECT total_amount FROM billing WHERE patient_id = ?", (patient_id,)).fetchone()
|
| 109 |
-
conn.close()
|
| 110 |
-
return render_template('billing.html', billing=billing, patient_id=patient_id)
|
| 111 |
-
|
| 112 |
-
if __name__ == "__main__":
|
| 113 |
-
app.run(debug=True)
|
|
|
|
| 1 |
# app.py
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from patient_registration import register_patient
|
| 4 |
+
from appointment_booking import book_appointment
|
| 5 |
+
from laboratory import book_lab_tests
|
| 6 |
+
from reports import get_reports
|
| 7 |
+
from billing import get_billing
|
| 8 |
+
|
| 9 |
+
def register_interface(name, age, gender, mobile):
|
| 10 |
+
return register_patient(name, age, gender, mobile)
|
| 11 |
+
|
| 12 |
+
def book_interface(patient_id, doctor, date, time_slot):
|
| 13 |
+
return book_appointment(patient_id, doctor, date, time_slot)
|
| 14 |
+
|
| 15 |
+
def lab_interface(patient_id, tests):
|
| 16 |
+
return book_lab_tests(patient_id, tests)
|
| 17 |
+
|
| 18 |
+
def report_interface(patient_id):
|
| 19 |
+
return get_reports(patient_id)
|
| 20 |
+
|
| 21 |
+
def billing_interface(patient_id):
|
| 22 |
+
return get_billing(patient_id)
|
| 23 |
+
|
| 24 |
+
# Define Gradio app interfaces
|
| 25 |
+
with gr.Blocks() as app:
|
| 26 |
+
gr.Markdown("# Healthcare App")
|
| 27 |
+
|
| 28 |
+
# Patient Registration
|
| 29 |
+
with gr.Tab("Register Patient"):
|
| 30 |
+
name = gr.Textbox(label="Name")
|
| 31 |
+
age = gr.Number(label="Age")
|
| 32 |
+
gender = gr.Dropdown(["Male", "Female", "Other"], label="Gender")
|
| 33 |
+
mobile = gr.Textbox(label="Mobile Number")
|
| 34 |
+
register_btn = gr.Button("Register")
|
| 35 |
+
register_output = gr.Textbox()
|
| 36 |
+
register_btn.click(register_interface, inputs=[name, age, gender, mobile], outputs=register_output)
|
| 37 |
+
|
| 38 |
+
# Book Appointment
|
| 39 |
+
with gr.Tab("Book Appointment"):
|
| 40 |
+
patient_id = gr.Number(label="Patient ID")
|
| 41 |
+
doctor = gr.Dropdown(["Dr. Pranay - Cardiology", "Dr. Priyanka - Gynecology", "Dr. Pavan - Physiotherapy",
|
| 42 |
+
"Dr. Pranav - Orthopedic", "Dr. Uday - General Surgery", "Dr. RajaSuri - Psychology"], label="Doctor")
|
| 43 |
+
date = gr.Textbox(label="Date (YYYY-MM-DD)")
|
| 44 |
+
time_slot = gr.Textbox(label="Time Slot (e.g., 9 AM - 10 AM)")
|
| 45 |
+
book_btn = gr.Button("Book Appointment")
|
| 46 |
+
book_output = gr.Textbox()
|
| 47 |
+
book_btn.click(book_interface, inputs=[patient_id, doctor, date, time_slot], outputs=book_output)
|
| 48 |
+
|
| 49 |
+
# Laboratory Tests
|
| 50 |
+
with gr.Tab("Laboratory Tests"):
|
| 51 |
+
patient_id_lab = gr.Number(label="Patient ID")
|
| 52 |
+
tests = gr.CheckboxGroup(["Urine Test", "Blood Test", "CBP", "Saliva Test"], label="Select Tests")
|
| 53 |
+
lab_btn = gr.Button("Book Tests")
|
| 54 |
+
lab_output = gr.Textbox()
|
| 55 |
+
lab_btn.click(lab_interface, inputs=[patient_id_lab, tests], outputs=lab_output)
|
| 56 |
+
|
| 57 |
+
# Reports
|
| 58 |
+
with gr.Tab("Reports"):
|
| 59 |
+
patient_id_reports = gr.Number(label="Patient ID")
|
| 60 |
+
report_btn = gr.Button("Get Reports")
|
| 61 |
+
report_output = gr.Textbox()
|
| 62 |
+
report_btn.click(report_interface, inputs=[patient_id_reports], outputs=report_output)
|
| 63 |
+
|
| 64 |
+
# Billing
|
| 65 |
+
with gr.Tab("Billing"):
|
| 66 |
+
patient_id_billing = gr.Number(label="Patient ID")
|
| 67 |
+
billing_btn = gr.Button("Get Billing")
|
| 68 |
+
billing_output = gr.Textbox()
|
| 69 |
+
billing_btn.click(billing_interface, inputs=patient_id_billing, outputs=billing_output)
|
| 70 |
+
|
| 71 |
+
# Launch the app
|
| 72 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|