From afd1de04bf570b733053705628db6c6eed5388b1 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Wed, 29 Jul 2026 01:55:15 +0530 Subject: [PATCH] Fix ABDM consent status showing COMPLETED before data actually arrived computeConsentSessionDetail() treated any data_fetch/hi_data_push_callback row with status=success as proof the session reached COMPLETED. But the DB 'status' column only reflects whether the underlying API call/poll succeeded (no HTTP/transport error) -- NOT whether data was actually received; that's tracked separately via workflow_state (DATA_PENDING vs DATA_RECEIVED). A data_fetch poll that succeeds at the HTTP level but returns decrypted_data=[] (bridge still processing) was incorrectly marked COMPLETED instead of staying at GRANTED. Now also require workflow_state === DATA_RECEIVED for the COMPLETED phase. --- app/Controllers/Patient.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index 17e1ac4..17cc037 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -3849,7 +3849,15 @@ class Patient extends BaseController $phase = 'REQUESTED'; $priority = 120; - if (($operation === 'DATA_FETCH' || $operation === 'HI_DATA_PUSH_CALLBACK') && $status === 'SUCCESS') { + // NOTE: the `status` column only reflects whether the underlying API + // call/poll succeeded (no HTTP/transport error) — it does NOT mean + // data was actually received (see M3HiuWorkflowService::runOperation() + // / ingestHealthInformationCallback(), which always set status=success + // for any error-free response, even one reporting decrypted_data=[] + // and consent/session status "requested"). Whether data truly arrived + // is tracked separately in workflow_state (DATA_PENDING vs + // DATA_RECEIVED), so require that here instead of the generic status. + if (($operation === 'DATA_FETCH' || $operation === 'HI_DATA_PUSH_CALLBACK') && $status === 'SUCCESS' && $state === 'DATA_RECEIVED') { $phase = 'COMPLETED'; $priority = 500; } elseif (in_array($rawConsentStatus, ['GRANTED', 'APPROVED', 'ACTIVE'], true)) {