fix: restore legacy OPD queue workflow

This commit is contained in:
DevSoftTech Server 2026-04-06 12:40:34 +05:30
parent f8cbaacfb0
commit 44cb24c4e1
5 changed files with 103 additions and 19 deletions

View File

@ -501,6 +501,7 @@ $routes->get('opd_print/opd_Cont_print/(:num)', 'Opd::opd_cont_print/$1');
$routes->get('opd_print/opd_blank_print/(:num)', 'Opd::opd_blank_print/$1');
$routes->get('Opd_prescription/Prescription/(:num)', 'Opd_prescription::Prescription/$1');
$routes->match(['get', 'post'], 'Opd_prescription/create_opd_queue/(:num)', 'Opd_prescription::create_opd_queue/$1');
$routes->get('Opd_prescription/opd_prescription_print/(:num)/(:num)', 'Opd_prescription::opd_prescription_print/$1/$2');
$routes->get('Opd_prescription/opd_prescription_print/(:num)/(:num)/(:num)', 'Opd_prescription::opd_prescription_print/$1/$2/$3');
$routes->post('Opd_prescription/opd_prescription_save', 'Opd_prescription::opd_prescription_save');

View File

@ -811,8 +811,17 @@ class Opd extends BaseController
$sql = "select o.opd_id,o.opd_code,o.opd_no,o.opd_status,
p.id,p.p_code,p.p_fname as P_name,p.p_rname,
o.opd_fee_desc,o.opd_fee_amount,o.payment_status,
if(o.payment_mode=4,'Credit to ECHS',if(o.payment_mode=1,'Cash','Pending')) as opd_type,
o.opd_fee_desc,o.opd_fee_amount,o.payment_status,o.opd_fee_type,
coalesce(o.running_opd,0) as running_opd,
o.confirm_pay_opd,
(case
when (coalesce(o.running_opd,0)=1 or o.opd_fee_type=3 or upper(coalesce(o.opd_fee_desc,'')) like '%RUNNING%') then 'Running'
when o.payment_mode=4 then 'Credit to ECHS'
when o.payment_status=1 and o.payment_mode=0 then 'No Cost'
when o.payment_mode=1 then 'Cash'
when o.payment_mode=2 then 'Bank Card'
else 'Pending'
end) as opd_type,
if(pr.id is null, 0, 1) as has_prescription,
if(
coalesce(trim(pr.pulse),'')<>''
@ -842,6 +851,15 @@ class Opd extends BaseController
foreach ($allRows as $row) {
$status = (int) ($row->opd_status ?? 0);
$hasPrescription = (int) ($row->has_prescription ?? 0) === 1;
$paymentStatus = (int) ($row->payment_status ?? 0);
$runningOpd = (int) ($row->running_opd ?? 0) === 1;
$opdFeeType = (int) ($row->opd_fee_type ?? 0);
$opdFeeAmount = (float) ($row->opd_fee_amount ?? 0);
$opdFeeDesc = strtoupper(trim((string) ($row->opd_fee_desc ?? '')));
$isRunningVisit = $runningOpd || $opdFeeType === 3 || str_contains($opdFeeDesc, 'RUNNING');
$isConfirmedZeroAmount = $isRunningVisit && $opdFeeAmount <= 0;
$isConfirmedForQueue = $paymentStatus === 1 || $isConfirmedZeroAmount || !empty($row->confirm_pay_opd);
$row->is_confirmed_for_queue = $isConfirmedForQueue ? 1 : 0;
if ($status === 1 && ! $hasPrescription) {
$opdList0[] = $row;

View File

@ -6021,6 +6021,24 @@ class Opd_prescription extends BaseController
return (int) $this->db->insertID();
}
public function create_opd_queue(int $opdId)
{
if (! $this->canAccessPrescription()) {
return $this->response->setStatusCode(403)->setBody('Access denied');
}
if ($opdId <= 0) {
return $this->response->setBody('Invalid OPD ID');
}
$sessionId = $this->ensurePrescriptionSession($opdId, 0);
if ($sessionId <= 0) {
return $this->response->setBody('Unable to create queue');
}
return $this->response->setBody('Queue Created');
}
private function isValidAbhaAddress(string $value): bool
{
$validation = service('validation');

View File

@ -120,6 +120,10 @@
}
}
function reloadAppointmentList() {
load_form('/Opd/get_appointment_list/<?= esc((int) ($doc_id ?? 0)) ?>/<?= esc($opd_date ?? date('Y-m-d')) ?>', 'OPD Appointment List');
}
function setVitalMessage(type, text) {
var $msg = $('#vital_msg');
$msg.removeClass('text-muted text-success text-danger');
@ -257,7 +261,35 @@
}
$.post('/Opd/opd_status/' + opdId + '/' + opdStatus, {}, function() {
load_form('/Opd/get_appointment_list/<?= esc((int) ($doc_id ?? 0)) ?>/<?= esc($opd_date ?? date('Y-m-d')) ?>', 'OPD Appointment List');
reloadAppointmentList();
});
});
$(document).off('click.opdcreatequeue', '.btn-opd-create-queue').on('click.opdcreatequeue', '.btn-opd-create-queue', function() {
var opdId = parseInt($(this).data('opdid') || '0', 10);
if (!opdId) {
return;
}
var $btn = $(this);
$btn.prop('disabled', true).text('Queueing...');
$.post('/Opd_prescription/create_opd_queue/' + opdId, {}, function(resp) {
var message = (resp || '').toString().trim();
if (message !== 'Queue Created') {
window.alert(message || 'Unable to create queue');
$btn.prop('disabled', false).text('Queue');
return;
}
reloadAppointmentList();
}).fail(function(xhr) {
var message = 'Unable to create queue';
if (xhr && xhr.responseText) {
message = xhr.responseText;
}
window.alert(message);
$btn.prop('disabled', false).text('Queue');
});
});

View File

@ -30,23 +30,38 @@ if ($authUser) {
<td><?= esc($row->opd_type ?? '') ?> / Amt: <?= esc($row->opd_fee_amount ?? '') ?></td>
<td>
<?php $hasVitals = isset($row->has_vitals) && (int) $row->has_vitals === 1; ?>
<?php if ($canOpenPrescription) : ?>
<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
</a>
<?php $isBookedTab = ($tabType ?? '') === 'booking'; ?>
<?php $isConfirmedForQueue = (int) ($row->is_confirmed_for_queue ?? 0) === 1; ?>
<?php if ($isBookedTab) : ?>
<?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">
Queue
</button>
<?php else : ?>
<a class="btn btn-outline-primary btn-sm" title="Go For Payment" href="javascript:load_form('/Opd/invoice/<?= esc((int) ($row->opd_id ?? 0)) ?>','OPD Invoice');">
Go For Payment
</a>
<?php endif; ?>
<?php else : ?>
<?php if ($canOpenPrescription) : ?>
<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
</a>
<?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 ?? '') . ' }') ?>">
<?= $hasVitals ? 'Vitals ✓' : 'Vitals' ?>
</button>
<button type="button" class="btn btn-outline-info btn-sm btn-opd-scan" title="Scan" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
Scan
</button>
<button type="button" class="btn btn-outline-secondary btn-sm btn-opd-scan" title="Upload Scan" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
Upload
</button>
<button type="button" class="btn btn-outline-dark btn-sm btn-opd-scan-list" title="Scan Document List" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
Scan Doc List
</button>
<?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 ?? '') . ' }') ?>">
<?= $hasVitals ? 'Vitals ✓' : 'Vitals' ?>
</button>
<button type="button" class="btn btn-outline-info btn-sm btn-opd-scan" title="Scan" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
Scan
</button>
<button type="button" class="btn btn-outline-secondary btn-sm btn-opd-scan" title="Upload Scan" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
Upload
</button>
<button type="button" class="btn btn-outline-dark btn-sm btn-opd-scan-list" title="Scan Document List" data-opdid="<?= esc((int) ($row->opd_id ?? 0)) ?>">
Scan Doc List
</button>
<?php if (($tabType ?? '') === 'waiting') : ?>
<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