pvthosipital / laboratory.py
Pranay25's picture
Create laboratory.py
6b9928d verified
raw
history blame contribute delete
662 Bytes
# laboratory.py
import sqlite3
def book_lab_tests(patient_id, tests):
test_prices = {"Urine Test": 200, "Blood Test": 500, "CBP": 300, "Saliva Test": 150}
total_amount = sum(test_prices[test] for test in tests)
conn = sqlite3.connect('healthcare.db')
for test in tests:
conn.execute("INSERT INTO lab_tests (patient_id, test_name, amount) VALUES (?, ?, ?)",
(patient_id, test, test_prices[test]))
conn.execute("INSERT INTO billing (patient_id, total_amount) VALUES (?, ?)", (patient_id, total_amount))
conn.commit()
conn.close()
return f"Lab tests booked successfully! Total amount: {total_amount}"