Circle V2 API Docs
    Preparing search index...
    listEpisodes: QueryProcedure<
        {
            input: { patientId: string };
            meta: object;
            output: {
                admission_start_source:
                    | "episode_start_date"
                    | "first_program_start"
                    | null;
                discharge_date: string
                | null;
                episode_start: string | null;
                external_id: string | null;
                facility_level_of_care_id:
                    | string & { __brand: "FacilityLevelOfCareId" }
                    | null;
                facility_name: string | null;
                facility_timezone: string | null;
                id: TreatmentEpisodeId;
                integration_id: string | null;
                integration_status: "error" | "active" | "inactive" | null;
                integration_type:
                    | "kipu"
                    | "lightningstep"
                    | "sunwave"
                    | "qualifacts_insync"
                    | "synthetic"
                    | null;
                last_synced_documents: string
                | null;
                level_of_care_name: string | null;
                mrn: string | null;
                status: string | null;
            }[];
        },
    > = ...

    Every treatment episode for a patient that has a non-null episode_start (active and discharged), facility name joined, newest episode_start first. The shared read behind the episode selector and episode pill — visibility-scoped via canAccessPatient, not gated on the sync feature flag, so callers other than the sync menu can reuse it.