From bf3345b2ce87b1405063d28583030bb23fc7cd73 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 26 Jun 2026 16:59:40 +0530 Subject: [PATCH] EAtria auth: include bridge hospital id in header and records.push body --- app/Libraries/Abdm/EAtriaBridgeConnector.php | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Libraries/Abdm/EAtriaBridgeConnector.php b/app/Libraries/Abdm/EAtriaBridgeConnector.php index cb7a58d..cf8390c 100644 --- a/app/Libraries/Abdm/EAtriaBridgeConnector.php +++ b/app/Libraries/Abdm/EAtriaBridgeConnector.php @@ -21,6 +21,7 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface private string $baseUrl; private string $token; private string $hfrId; + private string $bridgeHospitalId; private int $timeoutSec; /** @var array */ private array $tokenCandidates = []; @@ -40,6 +41,7 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface $this->tokenSource = 'config.eatriaBridgeToken'; } $this->hfrId = ''; + $this->bridgeHospitalId = ''; $this->timeoutSec = (int) ($config->eatriaBridgeTimeoutSec ?? 30); // DB (Admin Panel → ABDM Gateway Config) is the authoritative source for @@ -69,6 +71,8 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface 'ABDM_HFR_ID', 'H_HFR_ID', 'ABDM_HOSPITAL_HFR_ID', + 'ABDM_BRIDGE_HOSPITAL_ID', + 'EATRIA_BRIDGE_HOSPITAL_ID', ]) ->get() ->getResultArray(); @@ -119,6 +123,15 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface if ($dbHfrId !== '') { $this->hfrId = $dbHfrId; } + + $dbBridgeHospitalId = trim((string) ( + $dbSettings['ABDM_BRIDGE_HOSPITAL_ID'] + ?? $dbSettings['EATRIA_BRIDGE_HOSPITAL_ID'] + ?? '' + )); + if ($dbBridgeHospitalId !== '') { + $this->bridgeHospitalId = $dbBridgeHospitalId; + } } catch (\Throwable $e) { log_message('warning', '[EAtriaBridge] refreshRuntimeSettingsFromDb failed: ' . $e->getMessage()); } @@ -262,6 +275,9 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface if ($tokenValue !== '') { $headers[] = 'Authorization: Bearer ' . $tokenValue; } + if ($this->bridgeHospitalId !== '') { + $headers[] = 'X-Hospital-Id: ' . $this->bridgeHospitalId; + } $maskedToken = $tokenValue !== '' ? (substr($tokenValue, 0, 6) . '***' . substr($tokenValue, -4)) : '(none)'; $tokenSource = $this->tokenSourceByValue[$tokenValue] ?? $this->tokenSource; @@ -638,6 +654,11 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface 'queue_id' => $queueId, ]; + if ($this->bridgeHospitalId !== '') { + $body['hospital_id'] = $this->bridgeHospitalId; + $body['bridge_hospital_id'] = $this->bridgeHospitalId; + } + if ($abhaAddress !== '') { $body['abha_address'] = $abhaAddress; }