Fix ABDM consent modal showing all HI types as DENIED when granted via async data push

When a consent session's overall phase resolves to GRANTED/COMPLETED via a data_fetch or hi_data_push_callback row (proof data was actually fetched), but no consent_reconcile/consent_status row in that session ever recorded which hi_types were granted (e.g. data arrives via async push before any reconcile poll runs), grantedHiTypes stayed empty and every requested HI type was incorrectly marked DENIED. Fall back to treating the full requested set as granted when we have positive proof of GRANTED/COMPLETED but no negative evidence of per-type denial.
This commit is contained in:
DevSoftTech Server 2026-07-29 01:44:17 +05:30
parent 0a19ccb425
commit 67daaf8894

View File

@ -3961,6 +3961,17 @@ class Patient extends BaseController
}
}
// If this session's overall phase is GRANTED/COMPLETED but no row ever
// recorded WHICH hi_types were granted (e.g. data arrived via an async
// hi_data_push_callback before any consent_reconcile/consent_status poll
// ran and stored a hi_types-bearing response), do not mark every
// requested type as DENIED for lack of evidence — a COMPLETED/GRANTED
// phase is itself proof the consent covers at least the requested
// types, so fall back to treating the full requested set as granted.
if ($grantedHiTypes === [] && $requestedHiTypes !== [] && in_array($phase, ['GRANTED', 'COMPLETED'], true)) {
$grantedHiTypes = $requestedHiTypes;
}
$revokedOn = trim((string) ($best['revoked_at'] ?? ''));
$expiredOn = trim((string) ($best['expired_at'] ?? ''));
if (in_array($phase, ['GRANTED', 'COMPLETED'], true) && $grantedOn === '') {