From 1c41b4555b4d824651e4b587d8b74e24ac138a30 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 1 Oct 2026 20:46:38 +0530 Subject: [PATCH] refactor(abdm): remove opd_fhir_documents fallback from recordsFetch and bind strictly to health_records --- app/Controllers/AbdmGateway.php | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/app/Controllers/AbdmGateway.php b/app/Controllers/AbdmGateway.php index b750f71..0dbdb5a 100644 --- a/app/Controllers/AbdmGateway.php +++ b/app/Controllers/AbdmGateway.php @@ -5015,36 +5015,6 @@ class AbdmGateway extends BaseController } } - // Strategy A.2: Check if opd_fhir_documents has stored FHIR bundle - if ($db->tableExists('opd_fhir_documents')) { - $targetPatientId = 0; - $targetSessionId = 0; - if (preg_match('/(?:OPD|PRESCRIPTION)-(\d+)(?:-S(\d+))?/i', $ref, $m)) { - $targetPatientId = (int) $m[1]; - $targetSessionId = (int) ($m[2] ?? 0); - } - if ($targetSessionId > 0 || $targetPatientId > 0) { - $docBuilder = $db->table('opd_fhir_documents'); - if ($targetSessionId > 0) { - $docBuilder->where('opd_session_id', $targetSessionId); - } else { - $docBuilder->where('opd_id', $targetPatientId); - } - $docRow = $docBuilder->orderBy('id', 'DESC')->get(1)->getRowArray(); - if (! empty($docRow['bundle_json'])) { - $bundleData = json_decode((string) $docRow['bundle_json'], true); - if (is_array($bundleData)) { - $records[] = [ - 'careContextReference' => $ref, - 'hiType' => $docRow['bundle_type'] ?? 'OPConsultRecord', - 'display' => 'Consultation Record - ' . date('d M Y', strtotime($docRow['generated_at'] ?? 'now')), - 'bundle' => $bundleData, - ]; - continue; - } - } - } - } // Strategy B: Build compliant FHIR Document Bundle from patient_master & OPD $bundle = $this->assembleFhirBundleForCareContext($ref);