fix(abdm): save enrolment mobile on ABHA-created patients
ABDM does not echo the alternate mobile in aadhaar/verify-otp, so patients created from that response were saved without a phone number. Fall back to the enrolment mobile ABDM accepted, flag its origin via mobile_source, and state the origin in the wizard.
This commit is contained in:
parent
8be64239d5
commit
7ae9a77d29
|
|
@ -111,7 +111,10 @@ class Abha extends BaseController
|
|||
|
||||
$abhaNum = (string) ($profile['ABHANumber'] ?? $profile['abha_id'] ?? $payload['ABHANumber'] ?? $payload['abha_id'] ?? '');
|
||||
$aadhaarVerifiedAbha = preg_replace('/\D/', '', $abhaNum);
|
||||
if ($newTxnId && strlen($aadhaarVerifiedAbha) === 14) {
|
||||
// ABDM v3 creates/returns the ABHA inside Aadhaar verify-otp when an alternate
|
||||
// mobile is supplied, so no further mobile OTP step may run for this person.
|
||||
$abhaCreated = strlen($aadhaarVerifiedAbha) === 14;
|
||||
if ($newTxnId && $abhaCreated) {
|
||||
session()->set('abha_enrol_identity_' . $newTxnId, $aadhaarVerifiedAbha);
|
||||
}
|
||||
$abhaAddress = (string) (
|
||||
|
|
@ -125,9 +128,14 @@ class Abha extends BaseController
|
|||
);
|
||||
$name = $this->extractAbhaProfileName($profile, $payload);
|
||||
$photo = $this->extractAbhaProfilePhoto($profile, $payload);
|
||||
// A different communication number is not verified until Step 3 succeeds.
|
||||
// Never persist the operator-entered number merely because Aadhaar OTP passed.
|
||||
$mobile = (string) ($profile['mobile'] ?? $payload['mobile'] ?? $payload['mobileNumber'] ?? '');
|
||||
$mobileSource = $mobile === '' ? '' : 'abdm';
|
||||
$enrolMobile = preg_replace('/\D/', '', $requestMobile);
|
||||
// ABDM accepted this number while creating the ABHA but does not always echo it back.
|
||||
if ($mobile === '' && $abhaCreated && strlen($enrolMobile) === 10) {
|
||||
$mobile = $enrolMobile;
|
||||
$mobileSource = 'enrolment';
|
||||
}
|
||||
$profileGender = (string) ($profile['gender'] ?? $payload['gender'] ?? '');
|
||||
$profileDob = (string) ($profile['dob'] ?? $profile['date_of_birth'] ?? $payload['dob'] ?? $payload['date_of_birth'] ?? '');
|
||||
$verifiedStatus = (string) (($payload['gateway_abha_profile']['status'] ?? '') ?: ($profile['verifiedStatus'] ?? '') ?: ($profile['status'] ?? '') ?: ($payload['verifiedStatus'] ?? '') ?: ($payload['status'] ?? ''));
|
||||
|
|
@ -161,10 +169,6 @@ class Abha extends BaseController
|
|||
|
||||
$patientInfo = $this->tryAutoLinkByDirectMatch($abhaNum, $name, $mobile, $profileGender, $profileDob, $abhaMeta);
|
||||
|
||||
// ABDM v3 creates/returns the ABHA inside Aadhaar verify-otp when an alternate
|
||||
// mobile is supplied, so no further mobile OTP step may run for this person.
|
||||
$abhaCreated = strlen($aadhaarVerifiedAbha) === 14;
|
||||
|
||||
$responseBase = [
|
||||
'ok' => 1,
|
||||
'txn_id' => $newTxnId,
|
||||
|
|
@ -178,6 +182,7 @@ class Abha extends BaseController
|
|||
'name' => $name,
|
||||
'photo' => $photo,
|
||||
'mobile' => $mobile,
|
||||
'mobile_source' => $mobileSource,
|
||||
'gender' => $profileGender,
|
||||
'dob' => $profileDob,
|
||||
'abha_address' => $abhaAddress,
|
||||
|
|
|
|||
|
|
@ -405,12 +405,16 @@ window.AbhaCreateModal = (function () {
|
|||
return;
|
||||
}
|
||||
var maskedComm = escapeHtml(maskMobile(communicationMobile));
|
||||
if (digits(response.mobile).slice(-10) === communicationMobile) {
|
||||
alertBox('success', created + '<br>Alternate mobile <strong>' + maskedComm + '</strong> is attached to this ABHA as the communication number. No separate mobile OTP is needed.');
|
||||
if (response.mobile_source === 'abdm' && digits(response.mobile).slice(-10) === communicationMobile) {
|
||||
alertBox('success', created + '<br>ABDM confirmed mobile <strong>' + maskedComm + '</strong> as the ABHA communication number. It will be saved on the patient record. No separate mobile OTP is needed.');
|
||||
return;
|
||||
}
|
||||
alertBox('warning', created + '<br>The alternate mobile <strong>' + maskedComm + '</strong> was sent with the Aadhaar verification, but ABDM did not confirm it in the response, so treat it as <strong>not yet attached</strong>.'
|
||||
+ '<br>HMS deliberately did not send a second mobile OTP: that check returns whichever ABHA already owns this number (for example a parent\'s ABHA) and would overwrite this record. Attach or change the number from the ABHA app/portal instead.');
|
||||
if (response.mobile_source === 'enrolment') {
|
||||
alertBox('success', created + '<br>Alternate mobile <strong>' + maskedComm + '</strong> was submitted with the Aadhaar verification that created this ABHA and will be saved on the patient record. ABDM did not echo it back in the response, so confirm it in the ABHA app if the beneficiary reports missing notifications.'
|
||||
+ '<br>HMS does not send a second mobile OTP: that check returns whichever ABHA already owns this number (for example a parent\'s ABHA) and would overwrite this record.');
|
||||
return;
|
||||
}
|
||||
alertBox('warning', created + '<br>The alternate mobile <strong>' + maskedComm + '</strong> could not be attached, and ABDM returned <strong>' + (escapeHtml(maskMobile(response.mobile)) || 'no number') + '</strong> instead. Attach or change the number from the ABHA app/portal.');
|
||||
}
|
||||
|
||||
function requestMobileOtp() {
|
||||
|
|
@ -459,8 +463,8 @@ window.AbhaCreateModal = (function () {
|
|||
$('#abhaCreateProfileDob').text(profile.dob || '-');
|
||||
$('#abhaCreateProfileGender').text(genderText(profile.gender));
|
||||
$('#abhaCreateProfileMobile').text(profile.mobile
|
||||
? maskMobile(profile.mobile)
|
||||
: (communicationMobile ? maskMobile(communicationMobile) + ' (sent at enrolment, unconfirmed)' : '-'));
|
||||
? maskMobile(profile.mobile) + (profile.mobile_source === 'enrolment' ? ' (submitted at enrolment)' : '')
|
||||
: '-');
|
||||
$('#abhaCreateProfileFullAddress').text([profile.address, profile.district, profile.state, profile.zip].filter(Boolean).join(', ') || '-');
|
||||
$('#abhaCreateStatusText').text(profile.abha_number ? 'ABHA Ready' : 'ABHA Verified');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user