From 67daaf8894e56d9e37f03ca4ac4943b673990f0c Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Wed, 29 Jul 2026 01:44:17 +0530 Subject: [PATCH] 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. --- app/Controllers/Patient.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index 20498d2..17e1ac4 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -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 === '') {