Circle V2 API Docs
    Preparing search index...
    listGroupedByPatient: QueryProcedure<
        {
            input: {
                createdAtDateRange?: { from: string; to: string };
                cursor?: number;
                entityIds?: number[];
                limit?: number;
                offset?: number;
                patientIds?: string[];
                search?: string;
                sources?: string[];
                statuses?: string[];
                syncTypes?: string[];
                type: "extend" | "rpa";
            };
            meta: object;
            output: | PaginatedResponse<
                {
                    completed_at: string & { __brand: "DbDate" }
                    | null;
                    created_at: DbDate;
                    current_step: string | null;
                    document_count: number | null;
                    dry_run: boolean;
                    entity_id: number & { __brand: "EntityId" } | null;
                    external_run_id: string | null;
                    facility_id: string & { __brand: "FacilityId" } | null;
                    failure_reason: string | null;
                    id: RpaRunId;
                    integration_id: string & { __brand: "IntegrationId" } | null;
                    last_step_at: string & { __brand: "DbDate" } | null;
                    live_view_url: string | null;
                    patient_first_name: string | null;
                    patient_id: string & { __brand: "PatientId" } | null;
                    patient_last_name: string | null;
                    raw_payload: Record<string, unknown> | null;
                    started_at: string & { __brand: "DbDate" } | null;
                    status: "success" | "failed" | "pending" | "running" | "stopped";
                    step_history: { at: string; step: string }[] | null;
                    sync_type: string | null;
                    treatment_episode_id: string & { __brand: "TreatmentEpisodeId" } | null;
                    triggered_by: string & { __brand: "UserId" } | null;
                },
            >
            | PaginatedResponse<
                {
                    completed_at: string & { __brand: "DbDate" }
                    | null;
                    created_at: DbDate;
                    entity_id: number & { __brand: "EntityId" } | null;
                    external_run_id: string | null;
                    facility_id: string & { __brand: "FacilityId" } | null;
                    failure_reason: string | null;
                    file_name: string | null;
                    id: ExtendRunId;
                    integration_id: string & { __brand: "IntegrationId" } | null;
                    patient_chart_id: string & { __brand: "PatientChartId" } | null;
                    patient_first_name: string | null;
                    patient_id: string & { __brand: "PatientId" } | null;
                    patient_last_name: string | null;
                    raw_payload: Record<string, unknown> | null;
                    rpa_run_id: string & { __brand: "RpaRunId" } | null;
                    source: string | null;
                    status:
                        | "processing"
                        | "failed"
                        | "rejected"
                        | "needs_review"
                        | "pending"
                        | "completed";
                    treatment_episode_id: string & { __brand: "TreatmentEpisodeId" }
                    | null;
                    workflow_id: string | null;
                },
            >;
        },
    > = ...

    Automation runs paginated by distinct patient rather than by run: a page contains every (filtered) run for its patients, so the client can group rows by patient without a group spanning pages. Runs without a patient form a single "no patient" group. total counts patient groups, not runs.