163 lines
6.8 KiB
PHP
163 lines
6.8 KiB
PHP
<?php
|
|
require_once 'auth.php';
|
|
require_once 'db/config.php';
|
|
|
|
// Check if patient ID is provided
|
|
if (!isset($_GET['id'])) {
|
|
header("Location: reception.php");
|
|
exit();
|
|
}
|
|
|
|
$patient_id = $_GET['id'];
|
|
|
|
// Fetch patient details
|
|
$stmt = db()->prepare("SELECT * FROM patients WHERE id = ?");
|
|
$stmt->execute([$patient_id]);
|
|
$patient = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$patient) {
|
|
die("Patient not found.");
|
|
}
|
|
|
|
// Now, fetch all visits for this patient using their patient_id
|
|
$history_stmt = db()->prepare(
|
|
"SELECT p.*, d.username as doctor_name
|
|
FROM patients p
|
|
LEFT JOIN users d ON p.doctor_id = d.id
|
|
WHERE p.patient_id = ?
|
|
ORDER BY p.created_at DESC"
|
|
);
|
|
$history_stmt->execute([$patient['patient_id']]);
|
|
$visit_history = $history_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Patient Profile - <?= htmlspecialchars($patient['patient_name']) ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="d-flex">
|
|
<!-- Sidebar -->
|
|
<div class="sidebar vh-100 d-flex flex-column p-3">
|
|
<a href="reception.php" class="sidebar-brand d-flex align-items-center mb-4">
|
|
<i class="bi bi-heart-pulse-fill me-2"></i>
|
|
<span class="fs-5 fw-bold">ClinicSystem</span>
|
|
</a>
|
|
<ul class="nav flex-column mb-auto">
|
|
<li class="nav-item">
|
|
<a href="reception.php" class="nav-link active">
|
|
<i class="bi bi-person-circle me-2"></i>
|
|
<span>Patients</span>
|
|
</a>
|
|
</li>
|
|
<!-- Add other nav items here -->
|
|
</ul>
|
|
<hr>
|
|
<div class="dropdown">
|
|
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="bi bi-person-circle me-2"></i>
|
|
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
|
</a>
|
|
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
|
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="main-content flex-grow-1 p-4">
|
|
<header class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3 mb-0 text-gray-800">Patient Profile</h1>
|
|
<a href="reception.php" class="btn btn-sm btn-outline-primary">
|
|
<i class="bi bi-arrow-left me-2"></i>Back to Dashboard
|
|
</a>
|
|
</header>
|
|
|
|
<!-- Patient Details Card -->
|
|
<div class="card shadow-sm mb-4">
|
|
<div class="card-header py-3">
|
|
<h6 class="m-0 font-weight-bold text-primary">
|
|
<i class="bi bi-person-badge me-2"></i>
|
|
<?= htmlspecialchars($patient['patient_name']) ?>
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<p><strong>Phone:</strong> <?= htmlspecialchars($patient['phone_number']) ?></p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<p><strong>Address:</strong> <?= htmlspecialchars($patient['address']) ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Visit History -->
|
|
<div class="card shadow-sm">
|
|
<div class="card-header py-3">
|
|
<h6 class="m-0 font-weight-bold text-primary">
|
|
<i class="bi bi-clock-history me-2"></i>
|
|
Visit History
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Visit Date</th>
|
|
<th>Assigned Doctor</th>
|
|
<th>Status</th>
|
|
<th>Consultation Notes</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($visit_history)): ?>
|
|
<tr>
|
|
<td colspan="4" class="text-center">No visit history found.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($visit_history as $visit): ?>
|
|
<tr>
|
|
<td><?= date("d M, Y h:i A", strtotime($visit['created_at'])) ?></td>
|
|
<td><?= htmlspecialchars($visit['doctor_name'] ?? 'N/A') ?></td>
|
|
<td>
|
|
<?php
|
|
$status = htmlspecialchars($visit['status']);
|
|
$badge_class = 'bg-secondary';
|
|
if ($status == 'Pending') {
|
|
$badge_class = 'bg-warning text-dark';
|
|
} elseif ($status == 'In Progress') {
|
|
$badge_class = 'bg-info text-dark';
|
|
} elseif ($status == 'Completed') {
|
|
$badge_class = 'bg-success';
|
|
}
|
|
?>
|
|
<span class="badge <?= $badge_class ?>"><?= $status ?></span>
|
|
</td>
|
|
<td><?= nl2br(htmlspecialchars($visit['notes'] ?? 'No notes added.')) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|