fix(abdm): preserve GRANTED status for completed consent sessions on reopen
This commit is contained in:
parent
31352156c9
commit
92acaee56f
|
|
@ -5572,10 +5572,10 @@ class Patient extends BaseController
|
|||
} elseif ($rawConsentStatus === 'DENIED') {
|
||||
$phase = 'DENIED';
|
||||
$priority = 300;
|
||||
} elseif ($state === 'DATA_RECEIVED') {
|
||||
$phase = 'COMPLETED';
|
||||
} elseif (in_array($state, ['DATA_RECEIVED', 'COMPLETED'], true)) {
|
||||
$phase = 'GRANTED';
|
||||
$priority = 480;
|
||||
} elseif ($state === 'GRANTED') {
|
||||
} elseif (in_array($state, ['GRANTED', 'APPROVED', 'ACTIVE'], true)) {
|
||||
$phase = 'GRANTED';
|
||||
$priority = 420;
|
||||
} elseif ($state === 'REVOKED') {
|
||||
|
|
@ -5797,14 +5797,24 @@ class Patient extends BaseController
|
|||
}
|
||||
}
|
||||
|
||||
// A status stamped directly onto this request row by a live status check
|
||||
// is authoritative: it names this exact consent request, unlike separate
|
||||
// reconcile rows that have to be correlated back to a session.
|
||||
// A status stamped directly onto this request row by a live status check or workflow completion
|
||||
// is authoritative: it names this exact consent request.
|
||||
$anchorState = strtoupper(trim((string) (is_array($consentRequestRow) ? ($consentRequestRow['workflow_state'] ?? '') : '')));
|
||||
if (in_array($anchorState, ['EXPIRED', 'DENIED', 'REVOKED'], true)) {
|
||||
if (in_array($anchorState, ['GRANTED', 'APPROVED', 'ACTIVE', 'COMPLETED'], true)) {
|
||||
$phase = 'GRANTED';
|
||||
} elseif (in_array($anchorState, ['EXPIRED', 'DENIED', 'REVOKED'], true)) {
|
||||
$phase = $anchorState;
|
||||
}
|
||||
|
||||
// If documents have already been fetched and saved in abdm_hiu_documents for this session,
|
||||
// the consent is definitively granted and active.
|
||||
if (! in_array($phase, ['GRANTED', 'COMPLETED', 'EXPIRED', 'DENIED', 'REVOKED'], true)) {
|
||||
$lookupRef = $consentRequestId !== '' ? $consentRequestId : $consentId;
|
||||
if ($lookupRef !== '' && $this->countAbdmDocumentsForPatient((int) ($patientRow['id'] ?? 0), $lookupRef) > 0) {
|
||||
$phase = 'GRANTED';
|
||||
}
|
||||
}
|
||||
|
||||
// A short, human-friendly identifier for this session (the "Request ID"
|
||||
// guid is too long to display in a table column) -- use the underlying
|
||||
// abdm_hiu_workflows row id of this session's own CONSENT_REQUEST row
|
||||
|
|
|
|||
|
|
@ -421,10 +421,10 @@ class ConsentSessionListService
|
|||
} elseif ($rawConsentStatus === 'DENIED') {
|
||||
$phase = 'DENIED';
|
||||
$priority = 300;
|
||||
} elseif ($state === 'DATA_RECEIVED') {
|
||||
$phase = 'COMPLETED';
|
||||
} elseif (in_array($state, ['DATA_RECEIVED', 'COMPLETED'], true)) {
|
||||
$phase = 'GRANTED';
|
||||
$priority = 480;
|
||||
} elseif ($state === 'GRANTED') {
|
||||
} elseif (in_array($state, ['GRANTED', 'APPROVED', 'ACTIVE'], true)) {
|
||||
$phase = 'GRANTED';
|
||||
$priority = 420;
|
||||
} elseif ($state === 'REVOKED') {
|
||||
|
|
@ -564,7 +564,9 @@ class ConsentSessionListService
|
|||
}
|
||||
|
||||
$anchorState = strtoupper(trim((string) (is_array($consentRequestRow) ? ($consentRequestRow['workflow_state'] ?? '') : '')));
|
||||
if (in_array($anchorState, ['EXPIRED', 'DENIED', 'REVOKED'], true)) {
|
||||
if (in_array($anchorState, ['GRANTED', 'APPROVED', 'ACTIVE', 'COMPLETED'], true)) {
|
||||
$phase = 'GRANTED';
|
||||
} elseif (in_array($anchorState, ['EXPIRED', 'DENIED', 'REVOKED'], true)) {
|
||||
$phase = $anchorState;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user