initController($request, $response, $logger); $res = $gateway->hipPatientCareContexts(); $body = $res->getBody(); $data = json_decode($body, true); if (empty($data['ok'])) { CLI::error('Error: ' . ($data['error_text'] ?? 'Unknown error')); return; } $contexts = $data['care_contexts'] ?? []; CLI::write("Total Care Contexts: " . count($contexts), 'green'); CLI::newLine(); $table = []; foreach ($contexts as $cc) { $table[] = [ 'Reference' => $cc['ref'], 'HI Type' => $cc['hi_type'], 'FHIR' => $cc['is_fhir_ready'] ? 'Ready' : 'Draft', 'Status' => $cc['is_linked'] ? 'LINKED' : 'UNLINKED', 'Display' => $cc['display'], ]; } CLI::table($table, ['Reference', 'HI Type', 'FHIR', 'Status', 'Display']); } }