From 55e56176aaac38151c2b853c5da1ad5671043832 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 5 Jun 2026 09:40:30 +0530 Subject: [PATCH] fix(discharge-ui): simplify preview and remove ABDM sandbox panel --- app/Views/billing/ipd/discharge_create.php | 241 -------------------- app/Views/billing/ipd/discharge_preview.php | 100 ++++---- 2 files changed, 60 insertions(+), 281 deletions(-) diff --git a/app/Views/billing/ipd/discharge_create.php b/app/Views/billing/ipd/discharge_create.php index 09fcab8..500ddaf 100644 --- a/app/Views/billing/ipd/discharge_create.php +++ b/app/Views/billing/ipd/discharge_create.php @@ -627,41 +627,6 @@ $allergyStatusNoKnown = in_array($allergyStatusNormalized, ['no known drug aller
- -
-
ABDM Sandbox Actions
-
-
- - -
-
- - -
-
- - -
-
-
- -
-
- -
-
-
- - -
-
- - -
-
Ready
-
-
@@ -3906,212 +3871,6 @@ $allergyStatusNoKnown = in_array($allergyStatusNormalized, ['no known drug aller }, { passive: true, capture: true }); syncNavOnScroll(); - // ─── ABDM Sandbox Actions (IPD Discharge) ───────────────────────────── - (function initIpdAbdmActions() { - var csrfName = ''; - var csrfHash = ''; - var ipdId = ; - var patientId = ; - - function setStatus(msg, isError) { - var el = document.getElementById('ipd_abdm_action_status'); - if (!el) { return; } - el.textContent = msg; - el.style.color = isError ? '#dc3545' : '#6c757d'; - } - - function abdmPost(url, payload, onSuccess) { - setStatus('Sending…'); - var data = Object.assign({}, payload); - data[csrfName] = csrfHash; - $.ajax({ - url: url, - type: 'POST', - data: data, - dataType: 'json' - }).done(function(resp) { - // refresh CSRF token if returned - if (resp && resp.csrf_hash) { csrfHash = resp.csrf_hash; } - if (resp && resp.csrf_token) { csrfName = resp.csrf_token; } - onSuccess(resp); - }).fail(function(xhr) { - setStatus('Request failed: ' + xhr.status + ' ' + xhr.statusText, true); - }); - } - - function pollScanLookupStatus(queueId, onTick, onDone) { - if (!queueId || queueId <= 0) { - if (typeof onDone === 'function') { - onDone({ ok: 0, status: 'unknown', error_text: 'Missing queue id' }); - } - return; - } - - var tries = 0; - var maxTries = 10; - var timer = setInterval(function() { - tries++; - $.getJSON('/' + queueId, function(resp) { - if (typeof onTick === 'function') { - onTick(resp, tries, maxTries); - } - - if (!resp || parseInt(resp.ok || 0, 10) !== 1) { - if (tries >= maxTries) { - clearInterval(timer); - if (typeof onDone === 'function') { - onDone(resp || { ok: 0, status: 'failed', error_text: 'Status lookup failed' }); - } - } - return; - } - - var status = (resp.status || '').toString().toLowerCase(); - if (parseInt(resp.done || 0, 10) === 1 || status === 'sent' || status === 'failed') { - clearInterval(timer); - if (typeof onDone === 'function') { - onDone(resp); - } - return; - } - - if (tries >= maxTries) { - clearInterval(timer); - if (typeof onDone === 'function') { - onDone(resp); - } - } - }).fail(function() { - if (tries >= maxTries) { - clearInterval(timer); - if (typeof onDone === 'function') { - onDone({ ok: 0, status: 'failed', error_text: 'Status polling failed' }); - } - } - }); - }, 3000); - } - - // Scan & Share Lookup - var btnScan = document.getElementById('btn_ipd_abdm_scan_lookup'); - if (btnScan) { - btnScan.addEventListener('click', function() { - var qrPayload = (document.getElementById('ipd_abdm_qr_payload') || {}).value || ''; - if (!qrPayload.trim()) { setStatus('Enter QR payload first.', true); return; } - abdmPost('', { - qr_payload: qrPayload, - patient_id: patientId - }, function(resp) { - if (resp && resp.abha_address) { - var addr = document.getElementById('ipd_abha_address'); - if (addr) { addr.value = resp.abha_address; } - } - - if (!resp || parseInt(resp.ok || 0, 10) !== 1) { - setStatus((resp && resp.error_text) ? resp.error_text : 'Scan lookup failed.', true); - return; - } - - var queueId = parseInt(resp.queue_id || '0', 10); - setStatus((resp && resp.message ? resp.message : 'Lookup queued.') + ' Queue ID: ' + (queueId || '-') + '. Checking status...', false); - - pollScanLookupStatus(queueId, function(scanResp, currentTry, maxTry) { - if (!scanResp || parseInt(scanResp.ok || 0, 10) !== 1) { - setStatus('Scan lookup status check (' + currentTry + '/' + maxTry + ')...', true); - return; - } - var st = (scanResp.status || 'pending').toString(); - setStatus('Scan lookup status: ' + st.toUpperCase() + ' (' + currentTry + '/' + maxTry + ')', st === 'failed'); - }, function(finalResp) { - if (!finalResp || parseInt(finalResp.ok || 0, 10) !== 1) { - setStatus((finalResp && finalResp.error_text) ? finalResp.error_text : 'Scan lookup status unresolved. Please check Bridge Log.', true); - return; - } - var fs = (finalResp.status || '').toString().toLowerCase(); - if (fs === 'sent') { - setStatus('Scan lookup sent successfully. Queue ID: ' + queueId, false); - } else if (fs === 'failed') { - setStatus('Scan lookup failed: ' + (finalResp.last_error || 'Unknown bridge error'), true); - } else { - setStatus('Scan lookup is still ' + fs.toUpperCase() + '. Please check Bridge Log.', true); - } - }); - }); - }); - } - - // Validate ABHA - var btnVal = document.getElementById('btn_ipd_abdm_validate_abha'); - if (btnVal) { - btnVal.addEventListener('click', function() { - var abhaAddr = (document.getElementById('ipd_abha_address') || {}).value || ''; - if (!abhaAddr.trim()) { setStatus('Enter ABHA Address first.', true); return; } - abdmPost('', { - abha_address: abhaAddr, - patient_id: patientId - }, function(resp) { - setStatus(resp && resp.message ? resp.message : (resp && resp.ok ? 'ABHA valid.' : 'Validation failed.'), !(resp && resp.ok)); - }); - }); - } - - // Request Consent - var btnConsent = document.getElementById('btn_ipd_abdm_consent_request'); - if (btnConsent) { - btnConsent.addEventListener('click', function() { - var abhaAddr = (document.getElementById('ipd_abha_address') || {}).value || ''; - var purpose = (document.getElementById('ipd_abdm_purpose_code') || {}).value || 'CAREMGT'; - var expiresAt = (document.getElementById('ipd_abdm_consent_expires_at') || {}).value || ''; - if (!abhaAddr.trim()) { setStatus('Enter ABHA Address first.', true); return; } - abdmPost('', { - abha_address: abhaAddr, - patient_id: patientId, - purpose_code: purpose, - expires_at: expiresAt - }, function(resp) { - if (resp && resp.consent_handle) { - var ch = document.getElementById('ipd_abdm_consent_handle'); - if (ch) { ch.value = resp.consent_handle; } - } - setStatus(resp && resp.message ? resp.message : (resp && resp.ok ? 'Consent requested.' : 'Consent request failed.'), !(resp && resp.ok)); - }); - }); - } - - // Share Discharge FHIR Bundle - var btnShare = document.getElementById('btn_ipd_abdm_share_discharge'); - if (btnShare) { - btnShare.addEventListener('click', function() { - var abhaAddr = (document.getElementById('ipd_abha_address') || {}).value || ''; - var consentHandle = (document.getElementById('ipd_abdm_consent_handle') || {}).value || ''; - if (!abhaAddr.trim()) { setStatus('Enter ABHA Address first.', true); return; } - abdmPost('', { - ipd_id: ipdId, - patient_id: patientId, - abha_id: abhaAddr, - consent_handle: consentHandle - }, function(resp) { - if (resp && resp.consent_handle) { - var ch = document.getElementById('ipd_abdm_consent_handle'); - if (ch && !ch.value) { ch.value = resp.consent_handle; } - } - setStatus(resp && resp.status ? ('Queued: ' + resp.status) : (resp && resp.message ? resp.message : 'Share request sent.'), !(resp && (resp.ok || resp.queue_id))); - }); - }); - } - - // Set default consent expiry to +30 days - (function setDefaultExpiry() { - var el = document.getElementById('ipd_abdm_consent_expires_at'); - if (!el || el.value) { return; } - var d = new Date(); - d.setDate(d.getDate() + 30); - var iso = d.toISOString().slice(0, 16); - el.value = iso; - })(); - })(); - // ─── end ABDM Sandbox Actions ────────────────────────────────────────── - })(); diff --git a/app/Views/billing/ipd/discharge_preview.php b/app/Views/billing/ipd/discharge_preview.php index 2cc7f0d..d23822e 100644 --- a/app/Views/billing/ipd/discharge_preview.php +++ b/app/Views/billing/ipd/discharge_preview.php @@ -91,7 +91,7 @@ if ($person) {
Discharge Date: str_discharge_date ?? '') ?>
-
+