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($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['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($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']) {

View File

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