36247-vm/prescription_view.php
Flatlogic Bot c8d83e1d5c version 2
2025-11-25 08:14:18 +00:00

135 lines
4.5 KiB
PHP

<?php
require_once 'auth.php';
require_once 'db/config.php';
if (!isset($_GET['id'])) {
die("No prescription ID provided.");
}
$prescription_id = $_GET['id'];
// Fetch prescription details along with patient and doctor info
$stmt = db()->prepare(
"SELECT
pr.*,
p.patient_name, p.patient_id as patient_system_id, p.address, p.phone_number,
u.username as doctor_name
FROM prescriptions pr
JOIN patients p ON pr.patient_id = p.id
JOIN users u ON pr.doctor_id = u.id
WHERE pr.id = ?"
);
$stmt->execute([$prescription_id]);
$prescription = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$prescription) {
die("Prescription not found.");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prescription for <?= htmlspecialchars($prescription['patient_name']) ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { background-color: #f8f9fa; }
.prescription-container {
max-width: 800px;
margin: 40px auto;
padding: 30px;
background-color: #fff;
border: 1px solid #dee2e6;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}
.prescription-header, .prescription-footer {
text-align: center;
margin-bottom: 30px;
}
.prescription-header h2 { font-weight: 600; }
.patient-details, .doctor-details {
margin-bottom: 20px;
padding: 15px;
border: 1px solid #eee;
border-radius: 5px;
}
.medication-details { margin-top: 30px; }
@media print {
body { background-color: #fff; }
.prescription-container {
margin: 0;
border: none;
box-shadow: none;
max-width: 100%;
}
.no-print { display: none; }
}
</style>
</head>
<body>
<div class="prescription-container">
<div class="prescription-header">
<h2>Prescription</h2>
<p class="text-muted">Date: <?= date("F j, Y", strtotime($prescription['prescription_date'])) ?></p>
</div>
<div class="row">
<div class="col-6">
<h5>Patient Details</h5>
<div class="patient-details">
<strong>Name:</strong> <?= htmlspecialchars($prescription['patient_name']) ?><br>
<strong>Patient ID:</strong> <?= htmlspecialchars($prescription['patient_system_id']) ?><br>
<strong>Address:</strong> <?= htmlspecialchars($prescription['address']) ?><br>
</div>
</div>
<div class="col-6">
<h5>Prescribing Doctor</h5>
<div class="doctor-details">
<strong>Dr. <?= htmlspecialchars($prescription['doctor_name']) ?></strong><br>
ClinicFlow Medical Center<br>
</div>
</div>
</div>
<div class="medication-details">
<h4><i class="bi bi-file-medical"></i> Rx</h4>
<table class="table table-bordered">
<thead class="table-light">
<tr>
<th>Medication</th>
<th>Dosage</th>
<th>Frequency</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><?= htmlspecialchars($prescription['medication']) ?></strong></td>
<td><?= htmlspecialchars($prescription['dosage']) ?></td>
<td><?= htmlspecialchars($prescription['frequency']) ?></td>
</tr>
</tbody>
</table>
<?php if (!empty($prescription['notes'])) : ?>
<div class="mt-3">
<strong>Notes:</strong>
<p class="text-muted"><?= nl2br(htmlspecialchars($prescription['notes'])) ?></p>
</div>
<?php endif; ?>
</div>
<div class="prescription-footer mt-5">
<p class="text-muted small">This is a computer-generated prescription and does not require a physical signature.</p>
</div>
<div class="text-center mt-4 no-print">
<button onclick="window.print();" class="btn btn-primary">Print Prescription</button>
<a href="patient_profile.php?id=<?= $prescription['patient_id'] ?>" class="btn btn-secondary">Back to Profile</a>
</div>
</div>
</body>
</html>