fix: move confirmed opd appointments into waiting
This commit is contained in:
parent
ca4b4195aa
commit
67664ab8ff
|
|
@ -861,12 +861,12 @@ class Opd extends BaseController
|
||||||
$isConfirmedForQueue = $paymentStatus === 1 || $isConfirmedZeroAmount || !empty($row->confirm_pay_opd);
|
$isConfirmedForQueue = $paymentStatus === 1 || $isConfirmedZeroAmount || !empty($row->confirm_pay_opd);
|
||||||
$row->is_confirmed_for_queue = $isConfirmedForQueue ? 1 : 0;
|
$row->is_confirmed_for_queue = $isConfirmedForQueue ? 1 : 0;
|
||||||
|
|
||||||
if ($status === 1 && ! $hasPrescription) {
|
if ($status === 1 && ! $hasPrescription && ! $isConfirmedForQueue) {
|
||||||
$opdList0[] = $row;
|
$opdList0[] = $row;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status === 1 && $hasPrescription) {
|
if ($status === 1 && ($hasPrescription || $isConfirmedForQueue)) {
|
||||||
$opdList1[] = $row;
|
$opdList1[] = $row;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -886,6 +886,12 @@ class Opd extends BaseController
|
||||||
});
|
});
|
||||||
|
|
||||||
usort($opdList1, static function ($left, $right): int {
|
usort($opdList1, static function ($left, $right): int {
|
||||||
|
$leftHasPrescription = (int) ($left->has_prescription ?? 0);
|
||||||
|
$rightHasPrescription = (int) ($right->has_prescription ?? 0);
|
||||||
|
if ($leftHasPrescription !== $rightHasPrescription) {
|
||||||
|
return $leftHasPrescription <=> $rightHasPrescription;
|
||||||
|
}
|
||||||
|
|
||||||
$leftVitals = (int) ($left->has_vitals ?? 0);
|
$leftVitals = (int) ($left->has_vitals ?? 0);
|
||||||
$rightVitals = (int) ($right->has_vitals ?? 0);
|
$rightVitals = (int) ($right->has_vitals ?? 0);
|
||||||
if ($leftVitals !== $rightVitals) {
|
if ($leftVitals !== $rightVitals) {
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@
|
||||||
<label class="form-check-label" for="toggle_missing_vitals_only">Only Missing Vitals</label>
|
<label class="form-check-label" for="toggle_missing_vitals_only">Only Missing Vitals</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?= view('billing/opd_appointment_list_table', ['rows' => $opd_list_1, 'showQueue' => true, 'tabType' => 'waiting', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
|
<?= view('billing/opd_appointment_list_table', ['rows' => $opd_list_1, 'showQueue' => true, 'tabType' => 'waiting', 'tableId' => 'opdWaitingTable', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
|
||||||
<div id="waitingNoRowsHint" class="small text-muted mt-2 d-none">All waiting patients already have vitals.</div>
|
<div id="waitingNoRowsHint" class="small text-muted mt-2 d-none">All waiting patients already have vitals.</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="tab_visited">
|
<div class="tab-pane fade" id="tab_visited">
|
||||||
<?= view('billing/opd_appointment_list_table', ['rows' => $opd_list_2, 'showQueue' => true, 'tabType' => 'visited', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
|
<?= view('billing/opd_appointment_list_table', ['rows' => $opd_list_2, 'showQueue' => true, 'tabType' => 'visited', 'tableId' => 'opdVisitedTable', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="tab_cancelled">
|
<div class="tab-pane fade" id="tab_cancelled">
|
||||||
<?= view('billing/opd_appointment_list_table', ['rows' => $opd_list_3, 'showQueue' => true, 'tabType' => 'cancelled', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
|
<?= view('billing/opd_appointment_list_table', ['rows' => $opd_list_3, 'showQueue' => true, 'tabType' => 'cancelled', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?>
|
||||||
|
|
@ -101,6 +101,8 @@
|
||||||
var modalObj = modalEl ? new bootstrap.Modal(modalEl) : null;
|
var modalObj = modalEl ? new bootstrap.Modal(modalEl) : null;
|
||||||
var vitalsModalEl = document.getElementById('vitalsModal');
|
var vitalsModalEl = document.getElementById('vitalsModal');
|
||||||
var vitalsModalObj = vitalsModalEl ? new bootstrap.Modal(vitalsModalEl) : null;
|
var vitalsModalObj = vitalsModalEl ? new bootstrap.Modal(vitalsModalEl) : null;
|
||||||
|
var waitingDataTable = null;
|
||||||
|
var visitedDataTable = null;
|
||||||
|
|
||||||
function getCsrfPair() {
|
function getCsrfPair() {
|
||||||
var input = document.querySelector('input[name="<?= csrf_token() ?>"]');
|
var input = document.querySelector('input[name="<?= csrf_token() ?>"]');
|
||||||
|
|
@ -120,6 +122,128 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function destroyDataTable(selector) {
|
||||||
|
if (!window.jQuery || !$.fn || !$.fn.DataTable || !$.fn.DataTable.isDataTable(selector)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $(selector).DataTable().destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasActualRows(selector) {
|
||||||
|
var $table = $(selector);
|
||||||
|
if ($table.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $rows = $table.find('tbody tr');
|
||||||
|
if ($rows.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $table.find('tbody tr td:not([colspan])').length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerWaitingVitalsFilter() {
|
||||||
|
if (!window.jQuery || !$.fn || !$.fn.dataTable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.opdWaitingVitalsFilter) {
|
||||||
|
var existingIndex = $.fn.dataTable.ext.search.indexOf(window.opdWaitingVitalsFilter);
|
||||||
|
if (existingIndex >= 0) {
|
||||||
|
$.fn.dataTable.ext.search.splice(existingIndex, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.opdWaitingVitalsFilter = function(settings, data, dataIndex) {
|
||||||
|
if (!settings || !settings.nTable || settings.nTable.id !== 'opdWaitingTable') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$('#toggle_missing_vitals_only').is(':checked')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rowNode = settings.aoData && settings.aoData[dataIndex] ? settings.aoData[dataIndex].nTr : null;
|
||||||
|
if (!rowNode) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt($(rowNode).attr('data-has-prescription') || '0', 10) !== 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseInt($(rowNode).attr('data-has-vitals') || '0', 10) !== 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.dataTable.ext.search.push(window.opdWaitingVitalsFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeOpdTable(selector, options) {
|
||||||
|
if (!window.jQuery || !$.fn || !$.fn.DataTable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyDataTable(selector);
|
||||||
|
|
||||||
|
if (!hasActualRows(selector)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $(selector).DataTable($.extend({
|
||||||
|
paging: true,
|
||||||
|
lengthChange: false,
|
||||||
|
searching: true,
|
||||||
|
ordering: true,
|
||||||
|
info: true,
|
||||||
|
autoWidth: false,
|
||||||
|
responsive: true,
|
||||||
|
pageLength: 25
|
||||||
|
}, options || {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncWaitingHintAndBadge() {
|
||||||
|
var $rows = $('#tab_waiting tbody tr[data-opd-id]');
|
||||||
|
var missingCount = 0;
|
||||||
|
var visibleCount = 0;
|
||||||
|
|
||||||
|
$rows.each(function() {
|
||||||
|
var hasVitals = parseInt($(this).attr('data-has-vitals') || '0', 10) === 1;
|
||||||
|
var hasPrescription = parseInt($(this).attr('data-has-prescription') || '0', 10) === 1;
|
||||||
|
if (hasPrescription && !hasVitals) {
|
||||||
|
missingCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(this).is(':visible')) {
|
||||||
|
visibleCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var $badge = $('#waitingMissingBadge');
|
||||||
|
$badge.text(String(missingCount));
|
||||||
|
$badge.toggleClass('d-none', missingCount <= 0);
|
||||||
|
|
||||||
|
$('#waitingNoRowsHint').toggleClass('d-none', !($('#toggle_missing_vitals_only').is(':checked') && $rows.length > 0 && visibleCount === 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeOpdTables() {
|
||||||
|
registerWaitingVitalsFilter();
|
||||||
|
|
||||||
|
waitingDataTable = initializeOpdTable('#opdWaitingTable', {
|
||||||
|
order: [[2, 'asc']],
|
||||||
|
drawCallback: function() {
|
||||||
|
syncWaitingHintAndBadge();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
visitedDataTable = initializeOpdTable('#opdVisitedTable', {
|
||||||
|
order: [[2, 'asc']]
|
||||||
|
});
|
||||||
|
|
||||||
|
syncWaitingHintAndBadge();
|
||||||
|
}
|
||||||
|
|
||||||
function reloadAppointmentList() {
|
function reloadAppointmentList() {
|
||||||
load_form('/Opd/get_appointment_list/<?= esc((int) ($doc_id ?? 0)) ?>/<?= esc($opd_date ?? date('Y-m-d')) ?>', 'OPD Appointment List');
|
load_form('/Opd/get_appointment_list/<?= esc((int) ($doc_id ?? 0)) ?>/<?= esc($opd_date ?? date('Y-m-d')) ?>', 'OPD Appointment List');
|
||||||
}
|
}
|
||||||
|
|
@ -152,6 +276,11 @@
|
||||||
|
|
||||||
function applyMissingVitalsFilter() {
|
function applyMissingVitalsFilter() {
|
||||||
// Filter waiting rows to optionally show only patients whose vitals are still missing.
|
// Filter waiting rows to optionally show only patients whose vitals are still missing.
|
||||||
|
if (waitingDataTable) {
|
||||||
|
waitingDataTable.draw();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var onlyMissing = $('#toggle_missing_vitals_only').is(':checked');
|
var onlyMissing = $('#toggle_missing_vitals_only').is(':checked');
|
||||||
var $rows = $('#tab_waiting tbody tr[data-opd-id]');
|
var $rows = $('#tab_waiting tbody tr[data-opd-id]');
|
||||||
var visibleCount = 0;
|
var visibleCount = 0;
|
||||||
|
|
@ -170,17 +299,7 @@
|
||||||
|
|
||||||
function updateMissingVitalsBadge() {
|
function updateMissingVitalsBadge() {
|
||||||
// Count waiting rows missing vitals and show badge only when count > 0.
|
// Count waiting rows missing vitals and show badge only when count > 0.
|
||||||
var missingCount = 0;
|
syncWaitingHintAndBadge();
|
||||||
$('#tab_waiting tbody tr[data-opd-id]').each(function() {
|
|
||||||
var hasVitals = parseInt($(this).attr('data-has-vitals') || '0', 10) === 1;
|
|
||||||
if (!hasVitals) {
|
|
||||||
missingCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var $badge = $('#waitingMissingBadge');
|
|
||||||
$badge.text(String(missingCount));
|
|
||||||
$badge.toggleClass('d-none', missingCount <= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).off('click.opdscanopen', '.btn-opd-scan').on('click.opdscanopen', '.btn-opd-scan', function() {
|
$(document).off('click.opdscanopen', '.btn-opd-scan').on('click.opdscanopen', '.btn-opd-scan', function() {
|
||||||
|
|
@ -372,6 +491,9 @@
|
||||||
$vitalBtn.removeClass('btn-warning text-dark btn-outline-warning').addClass('btn-success');
|
$vitalBtn.removeClass('btn-warning text-dark btn-outline-warning').addClass('btn-success');
|
||||||
$vitalBtn.attr('title', 'Vitals Filled');
|
$vitalBtn.attr('title', 'Vitals Filled');
|
||||||
}
|
}
|
||||||
|
if (waitingDataTable) {
|
||||||
|
waitingDataTable.rows().invalidate().draw(false);
|
||||||
|
}
|
||||||
updateMissingVitalsBadge();
|
updateMissingVitalsBadge();
|
||||||
applyMissingVitalsFilter();
|
applyMissingVitalsFilter();
|
||||||
}
|
}
|
||||||
|
|
@ -401,6 +523,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeOpdTables();
|
||||||
updateMissingVitalsBadge();
|
updateMissingVitalsBadge();
|
||||||
applyMissingVitalsFilter();
|
applyMissingVitalsFilter();
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ if ($authUser) {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-sm table-striped align-middle mb-0">
|
<table class="table table-sm table-striped align-middle mb-0"<?= !empty($tableId) ? ' id="' . esc((string) $tableId, 'attr') . '"' : '' ?>>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>OPD No.</th>
|
<th>OPD No.</th>
|
||||||
|
|
@ -22,18 +22,17 @@ if ($authUser) {
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if (!empty($rows)) : ?>
|
<?php if (!empty($rows)) : ?>
|
||||||
<?php foreach ($rows as $row) : ?>
|
<?php foreach ($rows as $row) : ?>
|
||||||
<tr data-opd-id="<?= esc((int) ($row->opd_id ?? 0)) ?>" data-has-vitals="<?= esc((int) ($row->has_vitals ?? 0)) ?>">
|
<?php $hasVitals = isset($row->has_vitals) && (int) $row->has_vitals === 1; ?>
|
||||||
|
<?php $isBookedTab = ($tabType ?? '') === 'booking'; ?>
|
||||||
|
<?php $isConfirmedForQueue = (int) ($row->is_confirmed_for_queue ?? 0) === 1; ?>
|
||||||
|
<?php $hasPrescription = (int) ($row->has_prescription ?? 0) === 1; ?>
|
||||||
|
<tr data-opd-id="<?= esc((int) ($row->opd_id ?? 0)) ?>" data-has-vitals="<?= esc((int) ($row->has_vitals ?? 0)) ?>" data-has-prescription="<?= esc((int) ($row->has_prescription ?? 0)) ?>">
|
||||||
<td><?= esc($row->opd_code ?? '') ?></td>
|
<td><?= esc($row->opd_code ?? '') ?></td>
|
||||||
<td><?= esc(($row->P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?></td>
|
<td><?= esc(($row->P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?></td>
|
||||||
<?php if (!empty($showQueue)) : ?><td><?= esc((int) ($row->queue_no ?? 0)) ?></td><?php endif; ?>
|
<?php if (!empty($showQueue)) : ?><td><?= $hasPrescription ? esc((int) ($row->queue_no ?? 0)) : '-' ?></td><?php endif; ?>
|
||||||
<td><?= esc($row->p_code ?? '') ?></td>
|
<td><?= esc($row->p_code ?? '') ?></td>
|
||||||
<td><?= esc($row->opd_type ?? '') ?> / Amt: <?= esc($row->opd_fee_amount ?? '') ?></td>
|
<td><?= esc($row->opd_type ?? '') ?> / Amt: <?= esc($row->opd_fee_amount ?? '') ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php $hasVitals = isset($row->has_vitals) && (int) $row->has_vitals === 1; ?>
|
|
||||||
<?php $isBookedTab = ($tabType ?? '') === 'booking'; ?>
|
|
||||||
<?php $isConfirmedForQueue = (int) ($row->is_confirmed_for_queue ?? 0) === 1; ?>
|
|
||||||
<?php $hasPrescription = (int) ($row->has_prescription ?? 0) === 1; ?>
|
|
||||||
|
|
||||||
<?php if ($isBookedTab) : ?>
|
<?php if ($isBookedTab) : ?>
|
||||||
<?php if ($isConfirmedForQueue) : ?>
|
<?php if ($isConfirmedForQueue) : ?>
|
||||||
<button type="button" class="btn btn-outline-success btn-sm btn-opd-create-queue" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>" title="Queue">
|
<button type="button" class="btn btn-outline-success btn-sm btn-opd-create-queue" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>" title="Queue">
|
||||||
|
|
@ -45,14 +44,21 @@ if ($authUser) {
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<?php if ($canOpenPrescription) : ?>
|
<?php if (! $hasPrescription && $isConfirmedForQueue) : ?>
|
||||||
|
<button type="button" class="btn btn-outline-success btn-sm btn-opd-create-queue" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>" title="Queue">
|
||||||
|
Queue
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($canOpenPrescription && $hasPrescription) : ?>
|
||||||
<a class="btn btn-outline-primary btn-sm" title="Consult" href="javascript:load_form('/Opd_prescription/Prescription/<?= esc((int) ($row->opd_id ?? 0)) ?>','Consult');">
|
<a class="btn btn-outline-primary btn-sm" title="Consult" href="javascript:load_form('/Opd_prescription/Prescription/<?= esc((int) ($row->opd_id ?? 0)) ?>','Consult');">
|
||||||
Consult
|
Consult
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<button type="button" class="btn <?= $hasVitals ? 'btn-success' : 'btn-warning text-dark' ?> btn-sm btn-opd-vitals" title="<?= $hasVitals ? 'Vitals Filled' : 'Vitals' ?>" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>" data-patient="<?= esc(($row->P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?>">
|
<?php if ($hasPrescription) : ?>
|
||||||
<?= $hasVitals ? 'Vitals ✓' : 'Vitals' ?>
|
<button type="button" class="btn <?= $hasVitals ? 'btn-success' : 'btn-warning text-dark' ?> btn-sm btn-opd-vitals" title="<?= $hasVitals ? 'Vitals Filled' : 'Vitals' ?>" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>" data-patient="<?= esc(($row->P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?>">
|
||||||
</button>
|
<?= $hasVitals ? 'Vitals ✓' : 'Vitals' ?>
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
<button type="button" class="btn btn-outline-info btn-sm btn-opd-scan" title="Scan" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
|
<button type="button" class="btn btn-outline-info btn-sm btn-opd-scan" title="Scan" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
|
||||||
Scan
|
Scan
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -64,7 +70,7 @@ if ($authUser) {
|
||||||
</button>
|
</button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (($tabType ?? '') === 'waiting') : ?>
|
<?php if (($tabType ?? '') === 'waiting' && $hasPrescription) : ?>
|
||||||
<button type="button" class="btn btn-outline-success btn-sm btn-opd-status" data-opd-id="<?= esc((int) ($row->opd_id ?? 0)) ?>" data-opd-status="2" title="Visit Done">
|
<button type="button" class="btn btn-outline-success btn-sm btn-opd-status" data-opd-id="<?= esc((int) ($row->opd_id ?? 0)) ?>" data-opd-status="2" title="Visit Done">
|
||||||
Visit Done
|
Visit Done
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user