From c31022196106098e3820c6e92fdd7aad8275d42d Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 30 Jun 2026 18:49:37 +0530 Subject: [PATCH] ABDM: use configured HFR for EAtria connector and avoid submit timeout HTML 500 --- app/Controllers/Opd_prescription.php | 11 ++++++----- app/Libraries/Abdm/EAtriaBridgeConnector.php | 13 ++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Controllers/Opd_prescription.php b/app/Controllers/Opd_prescription.php index ef2f9f5..d9fc1f6 100644 --- a/app/Controllers/Opd_prescription.php +++ b/app/Controllers/Opd_prescription.php @@ -5484,7 +5484,8 @@ class Opd_prescription extends BaseController private function resolveFhirGatewayHandoffTimeoutSec(): int { - $timeout = 120; + // Keep below PHP max_execution_time to avoid shutdown fatals that return HTML instead of JSON. + $timeout = 60; if ($this->db->tableExists('hospital_setting')) { $row = $this->db->table('hospital_setting') @@ -5500,11 +5501,11 @@ class Opd_prescription extends BaseController } } - if ($timeout < 30) { - $timeout = 30; + if ($timeout < 15) { + $timeout = 15; } - if ($timeout > 240) { - $timeout = 240; + if ($timeout > 90) { + $timeout = 90; } return $timeout; diff --git a/app/Libraries/Abdm/EAtriaBridgeConnector.php b/app/Libraries/Abdm/EAtriaBridgeConnector.php index 317215b..b4191a1 100644 --- a/app/Libraries/Abdm/EAtriaBridgeConnector.php +++ b/app/Libraries/Abdm/EAtriaBridgeConnector.php @@ -18,8 +18,6 @@ namespace App\Libraries\Abdm; */ class EAtriaBridgeConnector implements AbdmConnectorInterface { - private const REQUIRED_HFR_ID = 'IN0510000870'; - private string $baseUrl; private string $token; private string $hfrId; @@ -42,7 +40,7 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface $this->tokenSourceByValue[$this->token] = 'config.eatriaBridgeToken'; $this->tokenSource = 'config.eatriaBridgeToken'; } - $this->hfrId = self::REQUIRED_HFR_ID; + $this->hfrId = ''; $this->bridgeHospitalId = ''; $this->timeoutSec = (int) ($config->eatriaBridgeTimeoutSec ?? 30); @@ -135,10 +133,11 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface ?? $dbSettings['ABDM_HOSPITAL_HFR_ID'] ?? '' )); - if ($dbHfrId !== '' && strcasecmp($dbHfrId, self::REQUIRED_HFR_ID) !== 0) { - log_message('warning', '[EAtriaBridge] Overriding configured HFR ID with mandated HFR ' . self::REQUIRED_HFR_ID . ' (found ' . $dbHfrId . ')'); + if ($dbHfrId === '') { + log_message('warning', '[EAtriaBridge] ABDM_HFR_ID is empty in hospital_setting; bridge requests may fail with hfr_id errors.'); + } else { + $this->hfrId = $dbHfrId; } - $this->hfrId = self::REQUIRED_HFR_ID; $dbBridgeHospitalId = trim((string) ( $dbSettings['ABDM_BRIDGE_HOSPITAL_ID'] @@ -424,7 +423,7 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface } $this->dbLog($method, $path, $url, $body, $httpCode, (string) $raw, $ok === 1 ? 'success' : 'error', $logErr); if (($httpCode === 401 || $httpCode === 403) && ! isset($decoded['auth_hint'])) { - $decoded['auth_hint'] = 'Verify hospital_setting.EATRIA_BRIDGE_TOKEN mapped to HFR IN0510000870. Current token source=' . $this->tokenSource . ', HFR=' . ($this->hfrId !== '' ? $this->hfrId : '(empty)'); + $decoded['auth_hint'] = 'Verify hospital_setting.EATRIA_BRIDGE_TOKEN is mapped to the same HFR as hospital_setting.ABDM_HFR_ID. Current token source=' . $this->tokenSource . ', HFR=' . ($this->hfrId !== '' ? $this->hfrId : '(empty)'); } $decoded['auth_debug'] = $authDebug;