diff --git a/app/Views/abdm/opd_queue.php b/app/Views/abdm/opd_queue.php
index 22f60b8..9a2f837 100644
--- a/app/Views/abdm/opd_queue.php
+++ b/app/Views/abdm/opd_queue.php
@@ -226,6 +226,29 @@
const el = document.getElementById('abdmOpdRegisterModal');
return !!(el && el.classList.contains('show'));
}
+ function executeInjectedScripts(containerId) {
+ const container = document.getElementById(containerId);
+ if (!container) {
+ return;
+ }
+
+ const scripts = container.querySelectorAll('script');
+ scripts.forEach(function(oldScript) {
+ const newScript = document.createElement('script');
+ for (let i = 0; i < oldScript.attributes.length; i++) {
+ const attr = oldScript.attributes[i];
+ newScript.setAttribute(attr.name, attr.value);
+ }
+ if (oldScript.src) {
+ newScript.src = oldScript.src;
+ } else {
+ newScript.textContent = oldScript.textContent || oldScript.innerText || '';
+ }
+ document.head.appendChild(newScript);
+ oldScript.remove();
+ });
+ }
+
function loadOpdModalContent(url, method = 'GET', data = null) {
const targetUrl = normalizeOpdUrl(url);
opdModalCurrentUrl = targetUrl;
@@ -246,6 +269,7 @@
}
}).done(function (html) {
$('#abdmOpdRegisterBody').html(html);
+ executeInjectedScripts('abdmOpdRegisterBody');
}).fail(function (jqXHR) {
const msg = jqXHR && jqXHR.status ? ('HTTP ' + jqXHR.status) : 'Failed to load OPD form';
document.getElementById('abdmOpdRegisterBody').innerHTML = '
' + esc(msg) + '
';
@@ -291,7 +315,22 @@
$(document).on('click', '#abdmOpdRegisterBody a[href]', function (e) {
const href = $(this).attr('href') || '';
- if (!href || href.startsWith('#') || href.startsWith('javascript:') || href.startsWith('mailto:') || href.startsWith('tel:')) {
+ if (!href || href.startsWith('#')) {
+ return;
+ }
+ if (href.startsWith('javascript:')) {
+ e.preventDefault();
+ try {
+ const scriptBody = href.replace(/^javascript\s*:/i, '').trim();
+ if (scriptBody) {
+ new Function(scriptBody)();
+ }
+ } catch (err) {
+ console.warn('Unable to execute javascript href in modal', err);
+ }
+ return;
+ }
+ if (href.startsWith('mailto:') || href.startsWith('tel:')) {
return;
}
const normalizedHref = normalizeOpdUrl(href);
@@ -516,7 +555,7 @@
DOB: ${esc(m.dob || '—')} | Gender: ${genderLabel(m.gender)} | Phone: ${esc(m.mphone1 || '—')}
ABHA: ${esc(m.patient_abha || '—')} | Aadhaar: ${esc(m.patient_aadhaar || '—')}
Matched by: ${esc(reasons || 'Data match')}
- Link to This Patient
+ Link to This Patient
`;
}).join('');
@@ -525,7 +564,7 @@
None of the above — Register as New Patient
This ABHA does not belong to any listed record. A new HMS patient will be created.
-
Create New Patient
+
Create New Patient
`;
@@ -534,8 +573,8 @@
Possible matching records found in HMS. Select the correct patient to link, or register as new.
${cards}${createNewCard}
- Open Manual Patient Registration
- Close `;
+ Open Manual Patient Registration
+ Close `;
} else {
abdmQCreateNewPatient(t.id, payloadEncoded, true);
}
@@ -698,9 +737,9 @@
Profile picture upload is supported after creation from Edit Profile.
- Create Patient Now
- Open Manual Patient Registration (/billing/patient)
- Close `;
+ Create Patient Now
+ Open Manual Patient Registration (/billing/patient)
+ Close `;
}
function handleProcessResult(r) {
@@ -714,15 +753,15 @@
HMS ID: ${esc(r.p_code || '—')}
${r.saved_data ? `Saved: ${esc([r.saved_data.relation, r.saved_data.email, r.saved_data.address].filter(Boolean).join(' | ') || 'Basic fields')}
` : ''}
- Open OPD Registration →
- Open Patient Profile
- Edit Person Profile (for photo/details)
- Back to Queue `;
+ Open OPD Registration →
+ Open Patient Profile
+ Edit Person Profile (for photo/details)
+ Back to Queue `;
loadQueue();
return;
}
body.innerHTML = `${esc(r.error_text ?? r.message ?? 'Failed to process token')}
- Close `;
+ Close `;
}
document.getElementById('btnAddTokenSubmit').addEventListener('click', function () {