abdm: add Dreamsoft URL/token/sourceCode to AbdmConnector config + config-file fallback in BridgeSyncService::readSetting
This commit is contained in:
parent
38a63a628b
commit
6d6dad5ca0
|
|
@ -25,6 +25,51 @@ class AbdmConnector extends BaseConfig
|
|||
*/
|
||||
public string $connector = 'dreamsoft';
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// DreamsoftConnector settings
|
||||
// These are used by BridgeSyncService when routing through the
|
||||
// Dreamsoft bridge middleware.
|
||||
//
|
||||
// Priority order for each setting (highest wins):
|
||||
// 1. Environment variable (.env or server env)
|
||||
// 2. PHP constant (define() in a bootstrap file)
|
||||
// 3. This config file (edit values below)
|
||||
// 4. hospital_setting DB (runtime admin panel)
|
||||
//
|
||||
// Override via .env:
|
||||
// BRIDGE_SYNC_URL = https://your-dreamsoft-server.com/api/bridge
|
||||
// BRIDGE_SYNC_TOKEN = your-bearer-token
|
||||
// BRIDGE_SOURCE_CODE = HOSP001
|
||||
// BRIDGE_SYNC_PROVIDER = bridge
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Dreamsoft bridge server URL.
|
||||
* Example: https://bridge.dreamsofttech.in/api/v1/bridge
|
||||
* Set in .env: BRIDGE_SYNC_URL = https://...
|
||||
*/
|
||||
public string $dreamsoftBridgeUrl = '';
|
||||
|
||||
/**
|
||||
* Bearer token for Dreamsoft bridge authentication.
|
||||
* Set in .env: BRIDGE_SYNC_TOKEN = your-token
|
||||
* Do NOT commit real tokens to source control.
|
||||
*/
|
||||
public string $dreamsoftBridgeToken = '';
|
||||
|
||||
/**
|
||||
* Hospital/source code sent to the Dreamsoft bridge with every event.
|
||||
* Identifies this HMS instance on the bridge server.
|
||||
* Set in .env: BRIDGE_SOURCE_CODE = HOSP001
|
||||
*/
|
||||
public string $dreamsoftSourceCode = '';
|
||||
|
||||
/**
|
||||
* HTTP timeout in seconds for Dreamsoft bridge calls.
|
||||
* Set in .env: BRIDGE_SYNC_TIMEOUT = 20
|
||||
*/
|
||||
public int $dreamsoftTimeoutSec = 20;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// DirectAbdmConnector settings
|
||||
// Unused when $connector = 'dreamsoft'.
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ class BridgeSyncService
|
|||
|
||||
private function readSetting(string $name): string
|
||||
{
|
||||
// 1. Environment variable (highest priority — .env or server env)
|
||||
$envValue = getenv($name);
|
||||
if ($envValue !== false) {
|
||||
$value = trim((string) $envValue);
|
||||
|
|
@ -282,6 +283,7 @@ class BridgeSyncService
|
|||
}
|
||||
}
|
||||
|
||||
// 2. PHP constant
|
||||
if (defined($name)) {
|
||||
$value = trim((string) constant($name));
|
||||
if ($value !== '') {
|
||||
|
|
@ -289,6 +291,25 @@ class BridgeSyncService
|
|||
}
|
||||
}
|
||||
|
||||
// 3. Config\AbdmConnector PHP config file (editable without DB access)
|
||||
static $dreamsoftConfigMap = null;
|
||||
if ($dreamsoftConfigMap === null) {
|
||||
try {
|
||||
$cfg = config('AbdmConnector');
|
||||
$dreamsoftConfigMap = [
|
||||
'BRIDGE_SYNC_URL' => trim((string) ($cfg->dreamsoftBridgeUrl ?? '')),
|
||||
'BRIDGE_SYNC_TOKEN' => trim((string) ($cfg->dreamsoftBridgeToken ?? '')),
|
||||
'BRIDGE_SOURCE_CODE' => trim((string) ($cfg->dreamsoftSourceCode ?? '')),
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
$dreamsoftConfigMap = [];
|
||||
}
|
||||
}
|
||||
if (isset($dreamsoftConfigMap[$name]) && $dreamsoftConfigMap[$name] !== '') {
|
||||
return $dreamsoftConfigMap[$name];
|
||||
}
|
||||
|
||||
// 4. hospital_setting DB table (lowest priority — runtime admin panel)
|
||||
if (! $this->db->tableExists('hospital_setting')) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user