fix(dashboard): align OPD referral totals with patient list
Use patient profile referral values for the OPD dashboard, matching the report patient-list source and counts.
This commit is contained in:
parent
9ca9320fee
commit
8e80bc4a7b
|
|
@ -285,20 +285,13 @@ class Home extends BaseController
|
|||
->from('opd_master o', true)
|
||||
->groupBy('label')->orderBy('total', 'DESC')->get()->getResultArray();
|
||||
|
||||
$referralRows = $this->db->query(
|
||||
"SELECT COALESCE(NULLIF(CONCAT_WS(' ', NULLIF(r.title, ''), NULLIF(r.f_name, '')), ''), NULLIF(x.refer_name, ''), 'Not recorded') label,
|
||||
COUNT(o.opd_id) total, COUNT(DISTINCT o.p_id) patients
|
||||
FROM opd_master o
|
||||
LEFT JOIN (
|
||||
SELECT opd_code, MAX(NULLIF(refer_by_id, 0)) refer_id,
|
||||
MAX(NULLIF(NULLIF(refer_by_other, ''), '0')) refer_name
|
||||
FROM invoice_master GROUP BY opd_code
|
||||
) x ON x.opd_code = o.opd_code
|
||||
LEFT JOIN refer_master r ON r.id = x.refer_id
|
||||
WHERE o.apointment_date >= ? AND o.apointment_date < ?
|
||||
GROUP BY label ORDER BY total DESC",
|
||||
[$fromDateTime, $toExclusive]
|
||||
)->getResultArray();
|
||||
$referralRows = $this->db->table('opd_master o')
|
||||
->select("COALESCE(NULLIF(TRIM(p.referby), ''), 'Not recorded') label", false)
|
||||
->select('COUNT(o.opd_id) total, COUNT(DISTINCT o.p_id) patients', false)
|
||||
->join('patient_master p', 'p.id = o.p_id', 'left')
|
||||
->where('o.apointment_date >=', $fromDateTime)
|
||||
->where('o.apointment_date <', $toExclusive)
|
||||
->groupBy('label')->orderBy('total', 'DESC')->get()->getResultArray();
|
||||
|
||||
return view('dashboard/opd', compact('fromDate', 'toDate', 'totals', 'doctorRows', 'departmentRows', 'organizationRows', 'referralRows'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ $maxDoctor = max(array_merge([1], array_map(static fn (array $row): int => (int)
|
|||
<div class="dashboard-bars"><?php foreach ($doctorRows as $row) : ?><div class="dashboard-bar-row"><div class="d-flex justify-content-between gap-3"><span><?= esc($row['label']) ?></span><strong><?= (int) $row['total'] ?></strong></div><div class="progress"><div class="progress-bar" style="width:<?= round(((int) $row['total'] / $maxDoctor) * 100, 1) ?>%"></div></div><div class="small text-muted"><?= (int) $row['patients'] ?> unique patient<?= (int) $row['patients'] === 1 ? '' : 's' ?></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">Department distribution</h5><?= view('dashboard/partials/ranked_table', ['rows' => $departmentRows, 'labelHeading' => 'Department', 'showPatients' => true]) ?></div></div></div>
|
||||
<div class="col-xl-6"><div class="card h-100"><div class="card-body"><h5 class="card-title">Referral source</h5><div class="text-muted small mb-2">Unique patients and visits, derived from the billing referral recorded against each OPD code.</div><?= view('dashboard/partials/ranked_table', ['rows' => $referralRows, 'labelHeading' => 'Referral', 'showPatients' => true]) ?></div></div></div>
|
||||
<div class="col-xl-6"><div class="card h-100"><div class="card-body"><h5 class="card-title">Referral source</h5><div class="text-muted small mb-2">Unique patients and visits, derived from the referral recorded in each patient profile.</div><?= view('dashboard/partials/ranked_table', ['rows' => $referralRows, 'labelHeading' => 'Referral', 'showPatients' => true]) ?></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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user