diff --git a/app/Controllers/AbdmGateway.php b/app/Controllers/AbdmGateway.php index b5e650e..63f22af 100644 --- a/app/Controllers/AbdmGateway.php +++ b/app/Controllers/AbdmGateway.php @@ -2190,13 +2190,13 @@ class AbdmGateway extends BaseController foreach ($this->ipdRows('ipd_discharge_1_b', ['short_head', 'rdata'], $ipdId, 'ipd_d_id') as $row) { $label = trim((string) ($row['short_head'] ?? '')); $value = trim((string) ($row['rdata'] ?? '')); - if ($label === '' || $value === '') { + if ($label === '' || ! $this->isMeaningfulClinicalValue($value)) { continue; } $observations[] = [ 'text' => $label, 'value' => $value, - 'category' => 'vital-signs', + 'category' => 'Condition on Admission Time', 'category_code' => 'vital-signs', 'effective_at' => $this->toIsoDateTimeOrNow($admissionRaw), ]; @@ -2204,13 +2204,13 @@ class AbdmGateway extends BaseController foreach ($this->ipdRows('ipd_discharge_1_b_final', ['short_head', 'rdata'], $ipdId, 'ipd_d_id') as $row) { $label = trim((string) ($row['short_head'] ?? '')); $value = trim((string) ($row['rdata'] ?? '')); - if ($label === '' || $value === '') { + if ($label === '' || ! $this->isMeaningfulClinicalValue($value)) { continue; } $observations[] = [ - 'text' => 'Discharge ' . $label, + 'text' => $label, 'value' => $value, - 'category' => 'vital-signs', + 'category' => 'Condition on Discharge Time', 'category_code' => 'vital-signs', 'effective_at' => $this->toIsoDateTimeOrNow($dischargeRaw), ]; @@ -2220,22 +2220,22 @@ class AbdmGateway extends BaseController foreach ($this->ipdRows('ipd_discharge_1_d', ['short_head', 'rdata'], $ipdId, 'ipd_d_id') as $row) { $label = trim((string) ($row['short_head'] ?? '')); $value = trim((string) ($row['rdata'] ?? '')); - if ($label === '') { + if ($label === '' || ! $this->isMeaningfulClinicalValue($value)) { continue; } $investigations[] = [ - 'text' => $value !== '' ? ($label . ': ' . $value) : $label, + 'text' => $label . ': ' . $value, 'authored_on' => $this->toIsoDateTimeOrNow($admissionRaw), ]; } foreach ($this->ipdRows('ipd_discharge_1_e', ['short_head', 'rdata'], $ipdId, 'ipd_d_id') as $row) { $label = trim((string) ($row['short_head'] ?? '')); $value = trim((string) ($row['rdata'] ?? '')); - if ($label === '') { + if ($label === '' || ! $this->isMeaningfulClinicalValue($value)) { continue; } $investigations[] = [ - 'text' => $value !== '' ? ($label . ': ' . $value) : $label, + 'text' => $label . ': ' . $value, 'authored_on' => $this->toIsoDateTimeOrNow($admissionRaw), ]; } @@ -2394,6 +2394,16 @@ class AbdmGateway extends BaseController return is_array($decoded) ? $decoded : []; } + private function isMeaningfulClinicalValue(string $value): bool + { + $normalized = strtolower(trim($value)); + if ($normalized === '') { + return false; + } + + return ! in_array($normalized, ['-', '--', 'na', 'n/a', 'nil', 'none', 'not done'], true); + } + private function normalizeFhirGender(string $gender): string { $value = strtolower(trim($gender)); diff --git a/app/Views/abdm/task_board.php b/app/Views/abdm/task_board.php index 0d5024c..83ca91f 100644 --- a/app/Views/abdm/task_board.php +++ b/app/Views/abdm/task_board.php @@ -1853,6 +1853,21 @@ var loincLabel = { '8867-4':'HR','59408-5':'SpO₂','8480-6':'BP Sys','8462-4':'BP Dia','8310-5':'Temp','9279-1':'RR','8302-2':'Height','29463-7':'Weight' }; var vitalLoincCodes = { '8867-4':1, '59408-5':1, '8480-6':1, '8462-4':1, '8310-5':1, '9279-1':1, '8302-2':1, '29463-7':1 }; + function meaningfulText(v) { + var s = String(v || '').trim().toLowerCase(); + if (!s) return false; + return ['-', '--', 'na', 'n/a', 'nil', 'none', 'not done'].indexOf(s) === -1; + } + + function getObservationCategoryText(o) { + var categories = o.category || []; + for (var i = 0; i < categories.length; i++) { + var t = (categories[i] || {}).text || ''; + if (t && String(t).trim() !== '') return String(t).trim(); + } + return ''; + } + function isVitalObservation(o) { var categories = o.category || []; for (var ci = 0; ci < categories.length; ci++) { @@ -1881,7 +1896,7 @@ if (!items.length) { return; } - html += '