Fix OPD FHIR submit record reference

This commit is contained in:
DevSoftTech Server 2026-06-01 13:29:10 +05:30
parent 9de803ace7
commit 33fc87ac88

View File

@ -5234,6 +5234,13 @@ class Opd_prescription extends BaseController
]);
}
$recordRefId = $sessionId > 0
? $sessionId
: (int) ($bundleRow['opd_session_id'] ?? ($bundleRow['id'] ?? 0));
if ($recordRefId <= 0) {
$recordRefId = (int) ($bundleRow['id'] ?? $opdId);
}
// Gather patient / OPD context for the push payload
$patientId = 0;
$patientName = '';
@ -5298,7 +5305,7 @@ class Opd_prescription extends BaseController
// care_context_reference must be unique per visit in ABDM spec.
// Use OPD-{id}-{session} so the reference stays stable for a specific saved record.
$ccRef = 'OPD-' . $opdId . '-' . $recordId;
$ccRef = 'OPD-' . $opdId . '-' . $recordRefId;
$pushData = [
'patient_id' => (string) $patientId,
@ -5309,7 +5316,7 @@ class Opd_prescription extends BaseController
'care_context_reference' => $ccRef,
'care_context_display' => $displayLabel,
'notes' => $displayLabel,
'queue_id' => 'OPD-' . $opdId . '-' . $recordId,
'queue_id' => 'OPD-' . $opdId . '-' . $recordRefId,
'abha_address' => $abhaId,
'record_data' => $bundle,
];