devsofttech_hms_ci4/app/Views/dashboard/ipd.php
DevSoftTech Server bd9b1771a9 feat: add clinical drill-down dashboards
Add interactive OPD, IPD, and diagnosis dashboards with historical date ranges, KPI summaries, doctor and department workload, referral breakdowns, and diagnostic workflow statuses.
2026-08-10 00:21:55 +05:30

22 lines
4.6 KiB
PHP

<?php
$admissions = (int) ($totals['admissions'] ?? 0);
$discharges = (int) ($totals['discharges'] ?? 0);
$activeCases = (int) ($totals['active_cases'] ?? 0);
$currentInHouse = (int) ($totals['current_in_house'] ?? 0);
$maxDepartment = max(array_merge([1], array_map(static fn (array $row): int => (int) $row['total'], $departmentRows ?? [])));
?>
<div class="pagetitle d-flex align-items-center justify-content-between flex-wrap gap-2"><div><h1>IPD Dashboard</h1><div class="text-muted small">Admissions, discharges, current census, and care distribution</div></div><button class="btn btn-light" type="button" onclick="load_form('<?= base_url('dashboard') ?>','Dashboard');"><i class="bi bi-arrow-left"></i> Main Dashboard</button></div>
<section class="section dashboard dashboard-detail">
<div class="card dashboard-filter-card"><div class="card-body py-3"><div class="row g-2 align-items-end">
<div class="col-sm-4 col-lg-3"><label class="form-label" for="ipd_from_date">From date</label><input class="form-control" id="ipd_from_date" type="date" value="<?= esc($fromDate) ?>"></div><div class="col-sm-4 col-lg-3"><label class="form-label" for="ipd_to_date">To date</label><input class="form-control" id="ipd_to_date" type="date" value="<?= esc($toDate) ?>"></div><div class="col-sm-4 col-lg-2"><button class="btn btn-primary w-100" id="ipd_apply_range" type="button"><i class="bi bi-funnel"></i> Apply</button></div><div class="col-lg-4"><div class="btn-group w-100"><button class="btn btn-outline-secondary ipd-range" data-days="0" type="button">Today</button><button class="btn btn-outline-secondary ipd-range" data-days="6" type="button">7 days</button><button class="btn btn-outline-secondary ipd-range" data-days="29" type="button">30 days</button></div></div>
</div></div></div>
<div class="row g-3 mb-3"><?php foreach ([['Admissions', $admissions, 'bi-box-arrow-in-right', 'primary'], ['Discharges', $discharges, 'bi-box-arrow-right', 'success'], ['Still active from range', $activeCases, 'bi-activity', 'warning'], ['Current in-house', $currentInHouse, 'bi-hospital', 'info']] as [$label, $value, $icon, $tone]) : ?><div class="col-6 col-xl-3"><div class="card h-100 dashboard-kpi"><div class="card-body"><div class="dashboard-kpi-icon text-bg-<?= $tone ?>"><i class="bi <?= $icon ?>"></i></div><div><div class="dashboard-kpi-value"><?= $value ?></div><div class="text-muted small"><?= esc($label) ?></div></div></div></div></div><?php endforeach ?></div>
<div class="row g-3">
<div class="col-xl-7"><div class="card h-100"><div class="card-body"><h5 class="card-title">Admissions by department</h5><?php if (empty($departmentRows)) : ?><div class="dashboard-empty">No admissions in this period.</div><?php else : ?><div class="dashboard-bars"><?php foreach ($departmentRows as $row) : ?><div class="dashboard-bar-row"><div class="d-flex justify-content-between"><span><?= esc($row['label']) ?></span><strong><?= (int) $row['total'] ?></strong></div><div class="progress"><div class="progress-bar bg-success" style="width:<?= round(((int) $row['total'] / $maxDepartment) * 100, 1) ?>%"></div></div></div><?php endforeach ?></div><?php endif ?></div></div></div>
<div class="col-xl-5"><div class="card h-100"><div class="card-body"><h5 class="card-title">Doctor workload</h5><?= view('dashboard/partials/ranked_table', ['rows' => $doctorRows, 'labelHeading' => 'Doctor', 'showPatients' => false]) ?></div></div></div>
<div class="col-xl-6"><div class="card h-100"><div class="card-body"><h5 class="card-title">Referral source</h5><?= view('dashboard/partials/ranked_table', ['rows' => $referralRows, 'labelHeading' => 'Referral', 'showPatients' => false]) ?></div></div></div>
<div class="col-xl-6"><div class="card h-100"><div class="card-body"><h5 class="card-title">Patient category</h5><?= view('dashboard/partials/ranked_table', ['rows' => $organizationRows, 'labelHeading' => 'Category', 'showPatients' => false]) ?></div></div></div>
</div>
</section>
<?= view('dashboard/partials/detail_assets') ?>
<script>(function(){function loadRange(from,to){load_form('<?= base_url('dashboard/ipd') ?>?from_date='+encodeURIComponent(from)+'&to_date='+encodeURIComponent(to),'IPD Dashboard');}$('#ipd_apply_range').off('click.ipdDash').on('click.ipdDash',function(){loadRange($('#ipd_from_date').val(),$('#ipd_to_date').val());});$('.ipd-range').off('click.ipdDash').on('click.ipdDash',function(){var end=new Date(),start=new Date();start.setDate(end.getDate()-Number($(this).data('days')||0));function ymd(d){return d.getFullYear()+'-'+String(d.getMonth()+1).padStart(2,'0')+'-'+String(d.getDate()).padStart(2,'0');}loadRange(ymd(start),ymd(end));});})();</script>