diff --git a/app/Views/abdm/task_board.php b/app/Views/abdm/task_board.php
index 3be78d4..11dae00 100644
--- a/app/Views/abdm/task_board.php
+++ b/app/Views/abdm/task_board.php
@@ -297,13 +297,32 @@
CHECKING
HTTP -
-
+
+
+
+
+
@@ -936,13 +955,58 @@
var fhirPreviewModal = new bootstrap.Modal(fhirPreviewModalEl);
var fhirModalTitle = document.getElementById('fhirModalTitle');
var fhirModalMeta = document.getElementById('fhirModalMeta');
+ var fhirModalQuality = document.getElementById('fhirModalQuality');
var fhirModalJson = document.getElementById('fhirModalJson');
var fhirModalDataBadge = document.getElementById('fhirModalDataBadge');
var fhirModalHttpBadge = document.getElementById('fhirModalHttpBadge');
+ function fhirCodeQuality(bundle) {
+ var entries = (bundle && bundle.entry) ? bundle.entry : [];
+ var complaints = [], diagnoses = [], services = [], obs = [], meds = [];
+ entries.forEach(function(e) {
+ var r = e.resource;
+ if (!r) return;
+ if (r.resourceType === 'Observation') { obs.push(r); return; }
+ if (r.resourceType === 'MedicationRequest') { meds.push(r); return; }
+ if (r.resourceType === 'ServiceRequest') { services.push(r); return; }
+ if (r.resourceType === 'Condition') {
+ var cats = r.category || [];
+ var isComplaint = cats.some(function(c) { return (c.text || '').toLowerCase().includes('complaint'); });
+ if (isComplaint) complaints.push(r); else diagnoses.push(r);
+ }
+ });
+ function hasSnomedCoding(r) {
+ return (((r.code || {}).coding) || []).some(function(c) { return c.code && c.code !== ''; });
+ }
+ function hasLoincCoding(r) {
+ return (((r.code || {}).coding) || []).some(function(c) { return (c.system || '').includes('loinc') && c.code; });
+ }
+ var items = [];
+ if (complaints.length) {
+ var n = complaints.filter(hasSnomedCoding).length;
+ items.push('Complaints ' + n + '/' + complaints.length + ' SNOMED');
+ }
+ if (diagnoses.length) {
+ var n = diagnoses.filter(hasSnomedCoding).length;
+ items.push('Diagnoses ' + n + '/' + diagnoses.length + ' SNOMED');
+ }
+ if (obs.length) {
+ items.push('Vitals ' + obs.length + ' LOINC');
+ }
+ if (services.length) {
+ var n = services.filter(hasLoincCoding).length;
+ items.push('Investigations ' + n + '/' + services.length + ' LOINC');
+ }
+ if (meds.length) {
+ items.push('Medications ' + meds.length + '');
+ }
+ return items.length ? 'Code quality:' + items.join('') : '';
+ }
+
function openFhirModal(url, title) {
if (fhirModalTitle) fhirModalTitle.textContent = title || 'FHIR Preview';
if (fhirModalMeta) { fhirModalMeta.textContent = 'Loading...'; fhirModalMeta.className = 'px-3 py-2 small text-muted'; }
+ if (fhirModalQuality) { fhirModalQuality.innerHTML = ''; fhirModalQuality.style.display = 'none'; }
if (fhirModalJson) fhirModalJson.textContent = '{\n "loading": true\n}';
if (fhirModalDataBadge) { fhirModalDataBadge.className = 'badge bg-warning text-dark'; fhirModalDataBadge.textContent = 'CHECKING'; }
if (fhirModalHttpBadge) { fhirModalHttpBadge.className = 'badge bg-warning text-dark'; fhirModalHttpBadge.textContent = 'HTTP ...'; }
@@ -953,11 +1017,16 @@
.then(function (res) {
var parsed = null;
try { parsed = JSON.parse(res.body || '{}'); } catch (e) { parsed = { raw: res.body || '' }; }
- var hasFhir = parsed && (parsed.resourceType === 'Bundle' || (parsed.status === 'ok' && parsed.bundle));
+ var bundle = (parsed && parsed.resourceType === 'Bundle') ? parsed : ((parsed && parsed.bundle) ? parsed.bundle : null);
+ var hasFhir = bundle !== null;
if (fhirModalJson) fhirModalJson.textContent = JSON.stringify(parsed, null, 2);
if (fhirModalMeta) { fhirModalMeta.textContent = res.ok ? 'Loaded (' + res.status + ')' : 'Error (' + res.status + ')'; fhirModalMeta.className = 'px-3 py-2 small ' + (res.ok ? 'text-success' : 'text-danger'); }
if (fhirModalDataBadge) { fhirModalDataBadge.className = 'badge ' + (hasFhir ? 'bg-success' : 'bg-danger'); fhirModalDataBadge.textContent = hasFhir ? 'HAS FHIR' : 'NOT GENERATED'; }
if (fhirModalHttpBadge) { fhirModalHttpBadge.className = 'badge ' + (res.ok ? 'bg-success' : 'bg-danger'); fhirModalHttpBadge.textContent = 'HTTP ' + res.status; }
+ if (fhirModalQuality && hasFhir) {
+ var qs = fhirCodeQuality(bundle);
+ if (qs) { fhirModalQuality.innerHTML = qs; fhirModalQuality.style.display = 'block'; }
+ }
})
.catch(function (e) {
if (fhirModalMeta) { fhirModalMeta.textContent = 'Request failed: ' + e.message; fhirModalMeta.className = 'px-3 py-2 small text-danger'; }
@@ -966,6 +1035,28 @@
});
}
+ // Update Codes dropdown — navigate to master workspaces
+ (function () {
+ function navTo(url, label) {
+ fhirPreviewModal.hide();
+ if (typeof window.load_form === 'function') {
+ window.load_form(url, label);
+ } else {
+ window.location.href = url;
+ }
+ }
+ var btnInvest = document.getElementById('btnGoInvestMaster');
+ var btnClinical = document.getElementById('btnGoClinicalMaster');
+ if (btnInvest) btnInvest.addEventListener('click', function(e) {
+ e.preventDefault();
+ navTo('= base_url('Opd_prescription/opd_invest_master') ?>', 'Investigation Master');
+ });
+ if (btnClinical) btnClinical.addEventListener('click', function(e) {
+ e.preventDefault();
+ navTo('= base_url('Opd_prescription/clinical_master_workspace') ?>', 'Clinical Master');
+ });
+ })();
+
document.getElementById('btnCopyFhirModal').addEventListener('click', function () {
var btn = this;
var jsonText = fhirModalJson ? (fhirModalJson.textContent || '{}') : '{}';