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

@ -12499,12 +12499,21 @@ class AbdmGateway extends BaseController
} }
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($body['care_contexts']) && is_array($body['care_contexts'])) {
$body['patient_ref'] = (string) $patientRow['p_code']; $firstCc = $body['care_contexts'][0];
} elseif ($patientId > 0) { $cRef = trim((string) ($firstCc['ref'] ?? $firstCc['referenceNumber'] ?? $firstCc['reference_number'] ?? ''));
$body['patient_ref'] = 'P-' . $patientId; if ($cRef !== '') {
} else { $body['patient_ref'] = $cRef;
$body['patient_ref'] = $body['abha_address']; }
}
if (empty($body['patient_ref']) || $body['patient_ref'] === $body['abha_address']) {
if (! empty($patientRow['p_code'])) {
$body['patient_ref'] = (string) $patientRow['p_code'];
} elseif ($patientId > 0) {
$body['patient_ref'] = 'P-' . $patientId;
} else {
$body['patient_ref'] = $body['abha_address'];
}
} }
} }
if (empty($body['display']) || $body['display'] === $body['patient_ref']) { if (empty($body['display']) || $body['display'] === $body['patient_ref']) {

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