From b03eb0064a151e5cef15cd2551a37e41fa22f8f1 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Mon, 6 Apr 2026 12:47:00 +0530 Subject: [PATCH] fix: show booked queue actions in waiting list --- app/Controllers/Opd.php | 34 +++++++++++++++++++ app/Views/billing/opd_appointment_list.php | 8 +++-- .../billing/opd_appointment_list_table.php | 25 +++++++++++--- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/app/Controllers/Opd.php b/app/Controllers/Opd.php index 47f7ab1..1eba0f0 100644 --- a/app/Controllers/Opd.php +++ b/app/Controllers/Opd.php @@ -845,6 +845,7 @@ class Opd extends BaseController $opdList0 = []; $opdList1 = []; + $opdListWaitingAll = []; $opdList2 = []; $opdList3 = []; @@ -863,11 +864,13 @@ class Opd extends BaseController if ($status === 1 && ! $hasPrescription) { $opdList0[] = $row; + $opdListWaitingAll[] = $row; continue; } if ($status === 1 && $hasPrescription) { $opdList1[] = $row; + $opdListWaitingAll[] = $row; continue; } @@ -903,6 +906,36 @@ class Opd extends BaseController return ((int) ($left->opd_id ?? 0)) <=> ((int) ($right->opd_id ?? 0)); }); + usort($opdListWaitingAll, static function ($left, $right): int { + $leftHasPrescription = (int) ($left->has_prescription ?? 0); + $rightHasPrescription = (int) ($right->has_prescription ?? 0); + if ($leftHasPrescription !== $rightHasPrescription) { + return $rightHasPrescription <=> $leftHasPrescription; + } + + if ($leftHasPrescription === 1) { + $leftVitals = (int) ($left->has_vitals ?? 0); + $rightVitals = (int) ($right->has_vitals ?? 0); + if ($leftVitals !== $rightVitals) { + return $leftVitals <=> $rightVitals; + } + + $leftQueue = (int) ($left->queue_no ?? 0); + $rightQueue = (int) ($right->queue_no ?? 0); + if ($leftQueue !== $rightQueue) { + return $leftQueue <=> $rightQueue; + } + } + + $leftConfirmed = (int) ($left->is_confirmed_for_queue ?? 0); + $rightConfirmed = (int) ($right->is_confirmed_for_queue ?? 0); + if ($leftConfirmed !== $rightConfirmed) { + return $rightConfirmed <=> $leftConfirmed; + } + + return ((int) ($left->opd_id ?? 0)) <=> ((int) ($right->opd_id ?? 0)); + }); + usort($opdList2, static function ($left, $right): int { return ((int) ($left->opd_id ?? 0)) <=> ((int) ($right->opd_id ?? 0)); }); @@ -923,6 +956,7 @@ class Opd extends BaseController 'doc_master' => $docMaster, 'opd_list_0' => $opdList0, 'opd_list_1' => $opdList1, + 'opd_list_waiting_all' => $opdListWaitingAll, 'opd_list_2' => $opdList2, 'opd_list_3' => $opdList3, ]); diff --git a/app/Views/billing/opd_appointment_list.php b/app/Views/billing/opd_appointment_list.php index 6f71ea3..fb95369 100644 --- a/app/Views/billing/opd_appointment_list.php +++ b/app/Views/billing/opd_appointment_list.php @@ -33,7 +33,7 @@ - $opd_list_1, 'showQueue' => true, 'tabType' => 'waiting', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?> + $opd_list_waiting_all ?? $opd_list_1, 'showQueue' => true, 'tabType' => 'waiting', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
All waiting patients already have vitals.
@@ -158,7 +158,8 @@ $rows.each(function() { var hasVitals = parseInt($(this).attr('data-has-vitals') || '0', 10) === 1; - var show = !onlyMissing || !hasVitals; + var hasPrescription = parseInt($(this).attr('data-has-prescription') || '0', 10) === 1; + var show = !onlyMissing || (hasPrescription && !hasVitals); $(this).toggle(show); if (show) { visibleCount++; @@ -173,7 +174,8 @@ var missingCount = 0; $('#tab_waiting tbody tr[data-opd-id]').each(function() { var hasVitals = parseInt($(this).attr('data-has-vitals') || '0', 10) === 1; - if (!hasVitals) { + var hasPrescription = parseInt($(this).attr('data-has-prescription') || '0', 10) === 1; + if (hasPrescription && !hasVitals) { missingCount++; } }); diff --git a/app/Views/billing/opd_appointment_list_table.php b/app/Views/billing/opd_appointment_list_table.php index fe9f7af..b732802 100644 --- a/app/Views/billing/opd_appointment_list_table.php +++ b/app/Views/billing/opd_appointment_list_table.php @@ -22,18 +22,20 @@ if ($authUser) { - + opd_code ?? '') ?> P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?> - queue_no ?? 0)) ?> + has_prescription ?? 0) === 1 ? esc((int) ($row->queue_no ?? 0)) : '-' ?> p_code ?? '') ?> opd_type ?? '') ?> / Amt: opd_fee_amount ?? '') ?> has_vitals) && (int) $row->has_vitals === 1; ?> + is_confirmed_for_queue ?? 0) === 1; ?> + has_prescription ?? 0) === 1; ?> - + + + + + - + +