ABDM: use configured HFR for EAtria connector and avoid submit timeout HTML 500

This commit is contained in:
DevSoftTech Server 2026-06-30 18:49:37 +05:30
parent 3072639cd5
commit c310221961
2 changed files with 12 additions and 12 deletions

View File

@ -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;

View File

@ -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;