109 lines
5.5 KiB
PHP
109 lines
5.5 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
require_once __DIR__ . '/queue_bootstrap.php';
|
||
qh_boot();
|
||
qh_doctor_handle_request();
|
||
|
||
$doctors = qh_fetch_doctors();
|
||
$selectedDoctorId = isset($_GET['doctor_id']) ? (int) $_GET['doctor_id'] : ($doctors[0]['id'] ?? 0);
|
||
$selectedDoctor = $selectedDoctorId ? qh_fetch_doctor($selectedDoctorId) : null;
|
||
$doctorQueue = $selectedDoctorId ? qh_fetch_tickets(['ready_for_doctor', 'called', 'in_progress'], $selectedDoctorId, 20) : [];
|
||
|
||
qh_page_start('doctor', 'Doctor room control', 'Doctor queue page for calling patients, starting visits, and closing tickets.');
|
||
?>
|
||
<div class="container-xxl px-3 px-lg-4">
|
||
<section class="page-header-panel mb-4">
|
||
<div>
|
||
<span class="section-kicker">Doctor / الطبيب</span>
|
||
<h1 class="section-title-xl mt-2">Call the next patient and update status.</h1>
|
||
<p class="section-copy mb-0">The display page announces called tickets in English and Arabic using the browser’s text-to-speech engine.</p>
|
||
</div>
|
||
</section>
|
||
|
||
<div class="panel-card mb-4">
|
||
<form method="get" class="row g-3 align-items-end">
|
||
<div class="col-lg-5">
|
||
<label class="form-label">Doctor room / غرفة الطبيب</label>
|
||
<select class="form-select" name="doctor_id" onchange="this.form.submit()">
|
||
<?php foreach ($doctors as $doctor): ?>
|
||
<option value="<?= qh_h((string) $doctor['id']) ?>" <?= (int) $doctor['id'] === $selectedDoctorId ? 'selected' : '' ?>><?= qh_h($doctor['name_en']) ?> · <?= qh_h($doctor['clinic_name_en'] ?? '') ?> · Room <?= qh_h($doctor['room_number']) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<?php if ($selectedDoctor): ?>
|
||
<div class="col-lg-7">
|
||
<div class="doctor-spotlight">
|
||
<div>
|
||
<div class="fw-semibold"><?= qh_h($selectedDoctor['name_en']) ?></div>
|
||
<div class="small text-secondary" lang="ar" dir="rtl"><?= qh_h($selectedDoctor['name_ar']) ?></div>
|
||
</div>
|
||
<span class="room-badge">Room <?= qh_h($selectedDoctor['room_number']) ?></span>
|
||
</div>
|
||
</div>
|
||
<?php endif; ?>
|
||
</form>
|
||
</div>
|
||
|
||
<div class="panel-card">
|
||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
|
||
<div>
|
||
<h2 class="section-title mb-1">Doctor queue / طابور الطبيب</h2>
|
||
<p class="section-copy mb-0">Ready patients, live calls, and in-room consultations for the selected doctor.</p>
|
||
</div>
|
||
<a class="btn btn-sm btn-outline-dark" href="display.php" target="_blank" rel="noopener">Preview public display</a>
|
||
</div>
|
||
|
||
<?php if ($doctorQueue): ?>
|
||
<div class="vstack gap-3">
|
||
<?php foreach ($doctorQueue as $ticket): ?>
|
||
<div class="queue-row">
|
||
<div class="queue-row-head">
|
||
<div>
|
||
<div class="ticket-code"><?= qh_h($ticket['ticket_number']) ?></div>
|
||
<div class="fw-semibold"><?= qh_h($ticket['patient_name']) ?></div>
|
||
<div class="small text-secondary">Vitals: <?= qh_h($ticket['vitals_notes'] ?: 'Not recorded / غير مسجل') ?></div>
|
||
</div>
|
||
<div class="d-flex flex-column align-items-end gap-2">
|
||
<?= qh_status_badge($ticket['status']) ?>
|
||
<a class="btn btn-sm btn-outline-dark" href="ticket.php?id=<?= qh_h((string) $ticket['id']) ?>">Ticket detail</a>
|
||
</div>
|
||
</div>
|
||
<div class="d-flex flex-wrap gap-2 mt-3">
|
||
<form method="post">
|
||
<input type="hidden" name="ticket_id" value="<?= qh_h((string) $ticket['id']) ?>">
|
||
<input type="hidden" name="doctor_id" value="<?= qh_h((string) $selectedDoctorId) ?>">
|
||
<input type="hidden" name="action" value="call_ticket">
|
||
<button class="btn btn-dark btn-sm" type="submit">Call patient</button>
|
||
</form>
|
||
<form method="post">
|
||
<input type="hidden" name="ticket_id" value="<?= qh_h((string) $ticket['id']) ?>">
|
||
<input type="hidden" name="doctor_id" value="<?= qh_h((string) $selectedDoctorId) ?>">
|
||
<input type="hidden" name="action" value="start_visit">
|
||
<button class="btn btn-outline-dark btn-sm" type="submit">Start visit</button>
|
||
</form>
|
||
<form method="post">
|
||
<input type="hidden" name="ticket_id" value="<?= qh_h((string) $ticket['id']) ?>">
|
||
<input type="hidden" name="doctor_id" value="<?= qh_h((string) $selectedDoctorId) ?>">
|
||
<input type="hidden" name="action" value="complete_ticket">
|
||
<button class="btn btn-outline-success btn-sm" type="submit">Mark done</button>
|
||
</form>
|
||
<form method="post">
|
||
<input type="hidden" name="ticket_id" value="<?= qh_h((string) $ticket['id']) ?>">
|
||
<input type="hidden" name="doctor_id" value="<?= qh_h((string) $selectedDoctorId) ?>">
|
||
<input type="hidden" name="action" value="mark_no_show">
|
||
<button class="btn btn-outline-danger btn-sm" type="submit">No-show</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php else: ?>
|
||
<div class="empty-state">
|
||
<strong>No patients in this doctor queue.</strong>
|
||
<span>Issue a ticket at reception or complete vitals in nursing to fill this room.</span>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
<?php qh_page_end(); ?>
|