feat(abdm): send care context reference in patient reference field for PHR app clarity

This commit is contained in:
DevSoftTech Server 2026-10-08 09:48:15 +05:30
parent 24abc51dea
commit e8a2cf2cf3
2 changed files with 17 additions and 7 deletions

View File

@ -12498,6 +12498,14 @@ class AbdmGateway extends BaseController
} }
} }
if (empty($body['patient_ref']) || $body['patient_ref'] === $body['abha_address']) {
if (! empty($body['care_contexts']) && is_array($body['care_contexts'])) {
$firstCc = $body['care_contexts'][0];
$cRef = trim((string) ($firstCc['ref'] ?? $firstCc['referenceNumber'] ?? $firstCc['reference_number'] ?? ''));
if ($cRef !== '') {
$body['patient_ref'] = $cRef;
}
}
if (empty($body['patient_ref']) || $body['patient_ref'] === $body['abha_address']) { if (empty($body['patient_ref']) || $body['patient_ref'] === $body['abha_address']) {
if (! empty($patientRow['p_code'])) { if (! empty($patientRow['p_code'])) {
$body['patient_ref'] = (string) $patientRow['p_code']; $body['patient_ref'] = (string) $patientRow['p_code'];
@ -12507,6 +12515,7 @@ class AbdmGateway extends BaseController
$body['patient_ref'] = $body['abha_address']; $body['patient_ref'] = $body['abha_address'];
} }
} }
}
if (empty($body['display']) || $body['display'] === $body['patient_ref']) { if (empty($body['display']) || $body['display'] === $body['patient_ref']) {
$pName = $this->patientDisplayName($patientRow); $pName = $this->patientDisplayName($patientRow);
if ($pName !== '' && $pName !== 'Patient') { if ($pName !== '' && $pName !== 'Patient') {

View File

@ -1027,12 +1027,13 @@
// Step 2: Link Care Contexts // Step 2: Link Care Contexts
csrf = getCsrfData(); csrf = getCsrfData();
var primaryRef = (selectedContexts && selectedContexts.length > 0 && selectedContexts[0].ref) ? selectedContexts[0].ref : '';
var linkPayload = { var linkPayload = {
patient_id: currentPatientId, patient_id: currentPatientId,
abha_address: abhaAddress, abha_address: abhaAddress,
abha_number: abhaNumber, abha_number: abhaNumber,
link_token_id: linkTokenId, link_token_id: linkTokenId,
patient_ref: abhaAddress, patient_ref: primaryRef || abhaAddress,
display: name, display: name,
care_contexts: selectedContexts, care_contexts: selectedContexts,
csrf_hms: csrf.hash csrf_hms: csrf.hash