prepare(" SELECT p.*, u.username as doctor_name FROM patients p JOIN users u ON p.doctor_id = u.id WHERE p.id = ? AND p.status = 'Completed' ORDER BY p.updated_at DESC LIMIT 1 "); $stmt->execute([$patient_id]); $visit = $stmt->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { $visit = null; // Log error } if (!$visit) { die("No completed visit found for this patient or an error occurred."); } ?> Invoice - <?php echo htmlspecialchars($visit['patient_id']); ?>
ClinicFlow

Invoice

Billed To:

Invoice #: INV-

Date:

Status:

Consultation Details:

Consulting Doctor: Dr.

Service Rendered Cost
$

Total: $

Back to Billing