Billing
Manage outstanding payments.
Pending Payments
| Patient Name | Doctor | Service Rendered | Total Bill | Action |
|---|---|---|---|---|
| Dr. | $ | Invoice | ||
| No pending payments. | ||||
prepare("UPDATE patient_visits SET payment_status = 'paid' WHERE visit_id = ?"); $stmt->execute([$visit_id_to_update]); header("Location: billing.php"); exit; } catch (PDOException $e) { // Log error } } } // Fetch unpaid visits and calculate total cost try { $pdo = db(); $stmt = $pdo->prepare( "SELECT pv.visit_id, pv.cost as consultation_fee, p.patient_name, p.id as patient_id, u.username as doctor_name, pv.service_rendered, COALESCE((SELECT SUM(lt.cost) FROM ordered_tests ot JOIN lab_tests lt ON ot.test_id = lt.test_id WHERE ot.visit_id = pv.visit_id AND ot.test_type = 'lab'), 0) as lab_tests_cost, COALESCE((SELECT SUM(it.cost) FROM ordered_tests ot JOIN imaging_tests it ON ot.test_id = it.test_id WHERE ot.visit_id = pv.visit_id AND ot.test_type = 'imaging'), 0) as imaging_tests_cost FROM patient_visits pv JOIN patients p ON pv.patient_id = p.id JOIN users u ON pv.doctor_id = u.id WHERE pv.status = 'Completed' AND pv.payment_status = 'unpaid' ORDER BY pv.visit_time DESC" ); $stmt->execute(); $unpaid_visits = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $unpaid_visits = []; // You should log the error in a real application // error_log($e->getMessage()); } ?>
Manage outstanding payments.
| Patient Name | Doctor | Service Rendered | Total Bill | Action |
|---|---|---|---|---|
| Dr. | $ | Invoice | ||
| No pending payments. | ||||