Mini Kabibi Habibi

Current Path : C:/xampp/htdocs/clinic/
Upload File :
Current File : C:/xampp/htdocs/clinic/completed_consultations.php

<?php
session_start();
include 'includes/db.php';

// Ensure admin is logged in
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header("Location: login.php");
    exit();
}

$page_title = "Completed Consultations";

$today = date('Y-m-d');

// Fetch completed consultations for today, including physical examination & assessment
$stmt = $pdo->prepare("
    SELECT 
        l.id,
        l.patient_name,
        l.school,
        l.age,
        hr.date,
        hr.chief_complaint,
        hr.findings_bp,
        hr.findings_cr,
        hr.findings_rr,
        hr.findings_o2sat,
        hr.findings_temp,
        hr.physical_examination,
        hr.diagnosis,
        hr.treatment
    FROM logs l
    JOIN health_records hr ON hr.log_id = l.id
    WHERE l.log_date = :today
    ORDER BY hr.date DESC
");
$stmt->execute([':today' => $today]);
$completed_consultations = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title><?= htmlspecialchars($page_title) ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" />
     <style>
        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            background-color: #f8f9fa;
        }
        .sidebar {
            width: 250px;
            background-color: #2c3e50;
            color: white;
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
        }
        .sidebar a {
            color: #ccc;
            text-decoration: none;
            padding: 15px;
            display: block;
            transition: 0.3s;
        }
        .sidebar a:hover {
            background-color: #34495e;
            color: #fff;
        }
        .sidebar .collapse a {
            font-size: 0.95rem;
            padding-left: 30px;
        }
        .main-content {
            margin-left: 250px;
            padding: 40px;
            flex: 1;
        }
        .form-card {
            background-color: #fff;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 0 15px rgba(0,0,0,0.05);
        }
        h2.page-title {
            font-weight: 600;
            margin-bottom: 30px;
        }
    </style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
</head>
<body>

    <!-- Sidebar -->
    <?php include 'sidebar.php'; ?>

    <!-- Main Content -->
    <div class="main-content">
        <h2><?= htmlspecialchars($page_title) ?></h2>
        <?php if (count($completed_consultations) > 0): ?>
            <div class="table-responsive">
                <table class="table table-bordered table-striped align-middle">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>School</th>
                            <th>Age</th>
                            <th>Date</th>
                            <th>Chief Complaint</th>
                            <th>Findings (with physical examination & Assessment)</th>
                            <th>Treatment / Recommendation</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($completed_consultations as $consultation): ?>
                            <tr>
                                <td><?= htmlspecialchars($consultation['patient_name']) ?></td>
                                <td><?= htmlspecialchars($consultation['school']) ?></td>
                                <td><?= htmlspecialchars($consultation['age']) ?></td>
                                <td><?= htmlspecialchars(date('m/d/Y', strtotime($consultation['date']))) ?></td>
                                <td><?= nl2br(htmlspecialchars($consultation['chief_complaint'])) ?></td>
                                <td>
                                    <strong>BP:</strong> <?= htmlspecialchars($consultation['findings_bp']) ?><br>
                                    <strong>CR:</strong> <?= htmlspecialchars($consultation['findings_cr']) ?><br>
                                    <strong>RR:</strong> <?= htmlspecialchars($consultation['findings_rr']) ?><br>
                                    <strong>O₂ Sat:</strong> <?= htmlspecialchars($consultation['findings_o2sat']) ?><br>
                                    <strong>Temp:</strong> <?= htmlspecialchars($consultation['findings_temp']) ?><br>
                                    <strong>Physical_Examination:</strong> <?= nl2br(htmlspecialchars($consultation['physical_examination'])) ?><br>
                                    <strong>Diagnosis:</strong> <?= nl2br(htmlspecialchars($consultation['diagnosis'])) ?><br>

                                </td>
                                <td><?= nl2br(htmlspecialchars($consultation['treatment'])) ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        <?php else: ?>
            <div class="alert alert-info">No completed consultations found for today.</div>
        <?php endif; ?>
    </div>

</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</html>