From fd0d571f9b50dd2fa325c6bdd98aaf4918fd7b5b Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 28 Jul 2026 23:14:20 +0530 Subject: [PATCH] Add diagnostic spark command abdm:hiu-reconcile-by-request to test consent_reconcile by consent_request_id --- app/Commands/AbdmHiuReconcileByRequest.php | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 app/Commands/AbdmHiuReconcileByRequest.php diff --git a/app/Commands/AbdmHiuReconcileByRequest.php b/app/Commands/AbdmHiuReconcileByRequest.php new file mode 100644 index 0000000..761130e --- /dev/null +++ b/app/Commands/AbdmHiuReconcileByRequest.php @@ -0,0 +1,56 @@ + --abha_address + */ +class AbdmHiuReconcileByRequest extends BaseCommand +{ + protected $group = 'ABDM'; + protected $name = 'abdm:hiu-reconcile-by-request'; + protected $description = 'Manually run consent_reconcile using an ABDM consent_request_id.'; + protected $usage = 'abdm:hiu-reconcile-by-request --consent_request_id --abha_address '; + protected $options = [ + '--consent_request_id' => 'ABDM consent_request_id (umbrella id) to reconcile.', + '--abha_address' => 'Patient ABHA address, e.g. someone@sbx.', + '--hfr_id' => 'Optional HFR id override.', + ]; + + public function run(array $params) + { + $consentRequestId = trim((string) (CLI::getOption('consent_request_id') ?? '')); + $abhaAddress = trim((string) (CLI::getOption('abha_address') ?? '')); + $hfrId = trim((string) (CLI::getOption('hfr_id') ?? '')); + + if ($consentRequestId === '' || $abhaAddress === '') { + CLI::error('Both --consent_request_id and --abha_address are required.'); + return; + } + + $payload = [ + 'abdm_consent_request_id' => $consentRequestId, + 'abha_address' => $abhaAddress, + ]; + if ($hfrId !== '') { + $payload['hfr_id'] = $hfrId; + } + + $service = new M3HiuWorkflowService(); + $result = $service->runOperation('consent_reconcile', $payload); + + CLI::write('=== consent_reconcile result ===', 'yellow'); + CLI::write(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + } +}