diff --git a/app/Views/abdm/task_board.php b/app/Views/abdm/task_board.php index fe7b06a..28f08cf 100644 --- a/app/Views/abdm/task_board.php +++ b/app/Views/abdm/task_board.php @@ -50,7 +50,30 @@ - + 0); + ?> +
@@ -68,7 +91,6 @@
- @@ -76,6 +98,9 @@ + + +
@@ -87,6 +112,62 @@ +
+
+ ABDM Sandbox Actions + +
+
+
Select eligible OPD Publish task to use sandbox actions.
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+
+ +
+
+ +
Ready
+
+
+
Ready
@@ -122,8 +203,18 @@ var modalAbhaInput = document.getElementById('modalAbhaInput'); var modalTaskSummary = document.getElementById('modalTaskSummary'); var modalConfirmBtn = document.getElementById('modalConfirmBtn'); + var sandboxCard = document.getElementById('abdmSandboxCard'); + var sandboxContext = document.getElementById('abdmSandboxContext'); + var sandboxStatus = document.getElementById('abdmSandboxStatus'); + var sandboxAbhaInput = document.getElementById('tb_abha_id'); + var sandboxQrPayloadInput = document.getElementById('tb_abdm_qr_payload'); + var sandboxPurposeCodeInput = document.getElementById('tb_abdm_purpose_code'); + var sandboxConsentExpiresInput = document.getElementById('tb_abdm_consent_expires_at'); + var sandboxConsentHandleInput = document.getElementById('tb_abdm_consent_handle'); + var sandboxClaimDocumentInput = document.getElementById('tb_abdm_claim_document_id'); var selectedAction = ''; var selectedRow = null; + var sandboxRow = null; function applyFilter(filter) { var rows = document.querySelectorAll('#taskTable tbody tr'); @@ -172,6 +263,74 @@ }); } + function setSandboxStatus(msg, level) { + if (!sandboxStatus) { + return; + } + sandboxStatus.classList.remove('text-muted', 'text-success', 'text-danger', 'text-warning'); + if (level === 'success') { + sandboxStatus.classList.add('text-success'); + } else if (level === 'danger') { + sandboxStatus.classList.add('text-danger'); + } else if (level === 'warning') { + sandboxStatus.classList.add('text-warning'); + } else { + sandboxStatus.classList.add('text-muted'); + } + sandboxStatus.textContent = msg || 'Ready'; + } + + function currentSandboxContext() { + if (!sandboxRow) { + return null; + } + + return { + taskId: parseInt(sandboxRow.getAttribute('data-task-id') || '0', 10) || 0, + patientId: parseInt(sandboxRow.getAttribute('data-patient-id') || '0', 10) || 0, + opdId: parseInt(sandboxRow.getAttribute('data-opd-id') || '0', 10) || 0, + opdSessionId: parseInt(sandboxRow.getAttribute('data-opd-session-id') || '0', 10) || 0, + abhaId: (sandboxAbhaInput.value || '').trim() + }; + } + + function openSandboxForRow(row) { + if (!row || !sandboxCard) { + return; + } + if ((row.getAttribute('data-sandbox-eligible') || '0') !== '1') { + setSandboxStatus('Sandbox actions are available only for OPD Publish rows with valid ABHA and printed consult.', 'warning'); + return; + } + + sandboxRow = row; + + var taskCode = ''; + var patientName = ''; + var taskCodeEl = row.querySelector('td:nth-child(2) strong'); + var patientNameEl = row.querySelector('td:nth-child(3) div'); + if (taskCodeEl) { + taskCode = taskCodeEl.textContent.trim(); + } + if (patientNameEl) { + patientName = patientNameEl.textContent.trim(); + } + + var rowAbha = (row.getAttribute('data-abha-id') || '').trim(); + sandboxAbhaInput.value = rowAbha; + sandboxQrPayloadInput.value = ''; + sandboxPurposeCodeInput.value = sandboxPurposeCodeInput.value || 'CAREMGT'; + sandboxConsentHandleInput.value = ''; + sandboxClaimDocumentInput.value = ''; + + var opdId = row.getAttribute('data-opd-id') || '0'; + var opdSessionId = row.getAttribute('data-opd-session-id') || '0'; + sandboxContext.textContent = 'Task: ' + taskCode + ' | Patient: ' + patientName + ' | OPD: ' + opdId + ' | Session: ' + opdSessionId; + sandboxCard.classList.remove('d-none'); + setSandboxStatus('Ready'); + sandboxCard.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); + } + function runAction(row, action) { var taskId = row.getAttribute('data-task-id'); var abha = modalAbhaInput.value.trim(); @@ -220,6 +379,12 @@ }); }); + document.querySelectorAll('.sandbox-btn').forEach(function (btn) { + btn.addEventListener('click', function () { + openSandboxForRow(btn.closest('tr')); + }); + }); + applyFilter('patient_abha_create'); modalConfirmBtn.addEventListener('click', function () { @@ -254,12 +419,140 @@ setStatus(res.error_text || 'Close failed', true); return; } + if (sandboxRow === row && sandboxCard) { + sandboxCard.classList.add('d-none'); + sandboxRow = null; + } row.remove(); setStatus('Task closed'); }); }); }); + document.getElementById('btnSandboxHide').addEventListener('click', function () { + if (sandboxCard) { + sandboxCard.classList.add('d-none'); + } + sandboxRow = null; + }); + + document.getElementById('tb_btn_abdm_scan_lookup').addEventListener('click', function () { + var qrPayload = (sandboxQrPayloadInput.value || '').trim(); + if (!qrPayload) { + setSandboxStatus('Paste QR payload first.', 'warning'); + return; + } + setSandboxStatus('Queuing Scan & Share lookup...'); + post('', { + qr_payload: qrPayload + }, function (res) { + if (res.ok !== 1) { + setSandboxStatus(res.error_text || 'Scan lookup failed.', 'danger'); + return; + } + if (res.abha_id_hint) { + sandboxAbhaInput.value = (res.abha_id_hint || '').toString().trim(); + } + setSandboxStatus('Scan lookup queued. Queue ID: ' + (res.queue_id || '-'), 'success'); + }); + }); + + document.getElementById('tb_btn_abdm_validate_abha').addEventListener('click', function () { + var abha = (sandboxAbhaInput.value || '').trim(); + if (!/^\d{14}$/.test(abha)) { + setSandboxStatus('ABHA must be a 14-digit number.', 'warning'); + return; + } + setSandboxStatus('Queuing ABHA validation...'); + post('', { + abha_id: abha + }, function (res) { + if (res.ok !== 1) { + setSandboxStatus(res.error_text || 'ABHA validation queue failed.', 'danger'); + return; + } + setSandboxStatus('ABHA validation queued. Queue ID: ' + (res.queue_id || '-'), 'success'); + }); + }); + + document.getElementById('tb_btn_abdm_consent_request').addEventListener('click', function () { + var ctx = currentSandboxContext(); + if (!ctx || ctx.patientId <= 0) { + setSandboxStatus('Select an eligible OPD Publish row first.', 'warning'); + return; + } + if (!/^\d{14}$/.test(ctx.abhaId)) { + setSandboxStatus('ABHA must be a 14-digit number.', 'warning'); + return; + } + + setSandboxStatus('Requesting consent...'); + post('', { + patient_id: ctx.patientId, + abha_id: ctx.abhaId, + purpose_code: (sandboxPurposeCodeInput.value || '').trim(), + expires_at: (sandboxConsentExpiresInput.value || '').trim().replace('T', ' ') + }, function (res) { + if (res.ok !== 1) { + setSandboxStatus(res.error_text || 'Consent request failed.', 'danger'); + return; + } + if (res.consent_handle) { + sandboxConsentHandleInput.value = (res.consent_handle || '').toString(); + } + setSandboxStatus('Consent requested. Handle: ' + (res.consent_handle || '-'), 'success'); + }); + }); + + document.getElementById('tb_btn_abdm_share_fhir').addEventListener('click', function () { + var ctx = currentSandboxContext(); + if (!ctx || ctx.patientId <= 0 || ctx.opdId <= 0) { + setSandboxStatus('Select an eligible OPD Publish row first.', 'warning'); + return; + } + if (!/^\d{14}$/.test(ctx.abhaId)) { + setSandboxStatus('ABHA must be a 14-digit number.', 'warning'); + return; + } + + setSandboxStatus('Checking consent and queuing FHIR share...'); + post('', { + opd_id: ctx.opdId, + opd_session_id: ctx.opdSessionId, + patient_id: ctx.patientId, + abha_id: ctx.abhaId, + consent_handle: (sandboxConsentHandleInput.value || '').trim() + }, function (res) { + if (res.ok !== 1) { + setSandboxStatus(res.error_text || 'FHIR share queue failed.', 'danger'); + return; + } + if (res.consent_handle) { + sandboxConsentHandleInput.value = (res.consent_handle || '').toString(); + } + setSandboxStatus('FHIR share queued. Queue ID: ' + (res.queue_id || '-'), 'success'); + }); + }); + + document.getElementById('tb_btn_abdm_claim_status').addEventListener('click', function () { + var docId = parseInt((sandboxClaimDocumentInput.value || '0').toString(), 10) || 0; + if (docId <= 0) { + setSandboxStatus('Enter Claim Document ID first.', 'warning'); + return; + } + + setSandboxStatus('Queuing claim status request...'); + post('', { + document_id: docId + }, function (res) { + if (res.ok !== 1) { + setSandboxStatus(res.error_text || 'Claim status queue failed.', 'danger'); + return; + } + setSandboxStatus('Claim status queued. Queue ID: ' + (res.queue_id || '-'), 'success'); + }); + }); + document.getElementById('btnRefresh').addEventListener('click', function () { window.location.reload(); }); diff --git a/app/Views/billing/opd_appointment_list_table.php b/app/Views/billing/opd_appointment_list_table.php index 5a97927..1d3acad 100644 --- a/app/Views/billing/opd_appointment_list_table.php +++ b/app/Views/billing/opd_appointment_list_table.php @@ -21,16 +21,18 @@ if ($authUser) { - + $row) : ?> has_vitals) && (int) $row->has_vitals === 1; ?> is_confirmed_for_queue ?? 0) === 1; ?> has_prescription ?? 0) === 1; ?> + queue_no ?? 0) > 0; ?> + opd_code ?? '') ?> P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?> - queue_no ?? 0)) : '-' ?> + p_code ?? '') ?> opd_type ?? '') ?> / Amt: opd_fee_amount ?? '') ?> @@ -45,6 +47,11 @@ if ($authUser) { + + + Consult diff --git a/app/Views/billing/opd_prescription_basic.php b/app/Views/billing/opd_prescription_basic.php index 8d68422..7cd4599 100644 --- a/app/Views/billing/opd_prescription_basic.php +++ b/app/Views/billing/opd_prescription_basic.php @@ -314,48 +314,6 @@ value="abha_address ?? $patient_master[0]->abha ?? '') ?>" placeholder="Enter ABHA Address"> -
-
ABDM Sandbox Actions
-
-
- - -
-
- - -
- -
-
- -
-
- -
-
-
- - -
- -
- - -
- -
-
- -
-
- -
-
- -
Ready
-
-
OPD: opd_code ?? '') ?>
Date: apointment_date ?? '') ?>
Doctor: doc_name ?? '') ?>