From acb8917854927bfe4b1958d2c8581cb65aa9f84f Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 8 Oct 2026 17:55:58 +0530 Subject: [PATCH] Add test-doc-filter CLI flag --- app/Commands/TestAbdmInspect.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/Commands/TestAbdmInspect.php b/app/Commands/TestAbdmInspect.php index dceb44e..71f84bc 100644 --- a/app/Commands/TestAbdmInspect.php +++ b/app/Commands/TestAbdmInspect.php @@ -146,5 +146,35 @@ class TestAbdmInspect extends BaseCommand CLI::table($docTable, ['ID', 'Pat', 'Ref', 'Title', 'Org', 'ArtID', 'Date']); } } + + if (CLI::getOption('test-doc-filter')) { + $filterRef = CLI::getOption('filter-ref') ?? '7f3ca078-c426-42ca-96cb-9e02a05ca19b'; + CLI::newLine(); + CLI::write("=== TESTING abdm_documents FILTER FOR REF: {$filterRef} ===", 'cyan'); + + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_GET['consent_request_id'] = $filterRef; + $_GET['limit'] = '200'; + + $patientController = new \App\Controllers\Patient(); + $patientController->initController($request, $response, $logger); + $res = $patientController->abdm_documents($patientId); + $data = json_decode((string) $res->getBody(), true); + + CLI::write("Response ok: " . ($data['ok'] ?? 0) . ", items count: " . count($data['items'] ?? []), 'green'); + $testTable = []; + foreach (($data['items'] ?? []) as $it) { + $testTable[] = [ + 'ID' => $it['id'] ?? 0, + 'Org' => substr((string) ($it['organization_name'] ?? 'N/A'), 0, 25), + 'Title' => substr((string) ($it['document_title'] ?? 'N/A'), 0, 25), + 'CareContext' => substr((string) ($it['care_context_reference'] ?? 'N/A'), 0, 25), + 'ConsentReqId' => substr((string) ($it['consent_request_id'] ?? 'N/A'), 0, 16), + ]; + } + if (! empty($testTable)) { + CLI::table($testTable, ['ID', 'Org', 'Title', 'CareContext', 'ConsentReqId']); + } + } } }