From 0e8cc1fd41e57e37aceb662937142c979730d62f Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 8 Oct 2026 12:59:32 +0530 Subject: [PATCH] fix(abdm): fix abdm_work_tasks column selection in hipPatientCareContexts --- app/Controllers/AbdmGateway.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Controllers/AbdmGateway.php b/app/Controllers/AbdmGateway.php index 803a629..13c29b7 100644 --- a/app/Controllers/AbdmGateway.php +++ b/app/Controllers/AbdmGateway.php @@ -13315,19 +13315,21 @@ class AbdmGateway extends BaseController // Also merge completed abdm_work_tasks if ($this->db->tableExists('abdm_work_tasks') && $patientId > 0) { $wtRows = $this->db->table('abdm_work_tasks') - ->select('care_context_reference, last_action_result') + ->select('last_action_result, payload_json') ->where('patient_id', $patientId) ->where('status', 'completed') ->get() ->getResultArray(); foreach ($wtRows as $wt) { - $ref = trim((string) ($wt['care_context_reference'] ?? '')); - if ($ref !== '') { - $linkedRefs[] = $ref; - } if (preg_match('/(OPD|LAB|RAD|DISCHARGE|INVOICE|WELLNESS|IMM|DOC)-[A-Za-z0-9_-]+/i', (string) ($wt['last_action_result'] ?? ''), $m)) { $linkedRefs[] = $m[0]; } + if (! empty($wt['payload_json'])) { + $pData = json_decode((string) $wt['payload_json'], true); + if (! empty($pData['care_context_reference'])) { + $linkedRefs[] = trim((string) $pData['care_context_reference']); + } + } } }