diff --git a/app/Views/abdm/opd_queue.php b/app/Views/abdm/opd_queue.php index cdd12ea..2483548 100644 --- a/app/Views/abdm/opd_queue.php +++ b/app/Views/abdm/opd_queue.php @@ -182,6 +182,12 @@ function esc(s) { return String(s ?? '').replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } + function encodePayload(obj) { + return btoa(unescape(encodeURIComponent(JSON.stringify(obj)))); + } + function decodePayload(payload) { + return JSON.parse(decodeURIComponent(escape(atob(String(payload || ''))))); + } function loadQueue() { const date = document.getElementById('queueDate').value; @@ -255,12 +261,12 @@ actions += ``; } if (!isLinked && (isPend || isCalled)) { - const pl = JSON.stringify({ + const pl = encodePayload({ id: t.id, abha_number: t.abha_number ?? '', abha_address: t.abha_address ?? '', aadhaar_number: t.aadhaar_number ?? t.aadhar_number ?? t.udai ?? '', patient_name: t.patient_name ?? '', phone: t.phone ?? '', gender: t.gender ?? '', dob: t.dob ?? '' - }).replace(/'/g, '''); + }); actions += ``; } @@ -301,8 +307,8 @@ window.abdmQComplete = id => setStatus(id, 'COMPLETED'); window.abdmQCancel = id => { if (confirm('Cancel token #' + id + '?')) setStatus(id, 'CANCELLED'); }; - window.abdmQRegister = function (payloadJson) { - const t = JSON.parse(payloadJson); + window.abdmQRegister = function (payloadEncoded) { + const t = decodePayload(payloadEncoded); const body = document.getElementById('abdmProcessTokenBody'); body.innerHTML = `
Processing ABHA Scan token for:
@@ -341,7 +347,7 @@Linking token to selected patient…
'; @@ -381,7 +387,7 @@ }; window.abdmQCreateNewPatient = function (tokenId, encodedPayload, skipConfirm) { - const t = JSON.parse(decodeURIComponent(encodedPayload)); + const t = decodePayload(encodedPayload); const body = document.getElementById('abdmProcessTokenBody'); if (!skipConfirm && !confirm('Create a new patient record for this token?')) { return;