Circle V2 API Docs
    Preparing search index...

    Type Alias RunChartReviewOptions

    Multi-template orchestrator. Fans out one runChartReviewSingleTemplate call per template under Promise.allSettled so a single template failure does not abort the rest. Constructs the shared ChatOpenAI instance internally — callers only provide the resolved ChartReviewSettings plus the supabase client and authenticated user id.

    Returns the successful audit run ids alongside any per-template errors. Mapping these to a transport-level error (e.g. TRPCError) is the caller's responsibility.

    type RunChartReviewOptions = {
        auditRunIds?: Partial<Record<AuditTemplateId, AuditRunId>>;
        createdBy: UserId | null;
        createRunner: CreateQuestionRunner;
        logger?: BaseLogger;
        patientId: PatientId;
        sessionId?: SessionId;
        sessionNoteContext?: string;
        settings: ChartReviewSettings;
        supabase: SupabaseClient<Database>;
        templateIds: AuditTemplateId[];
        trace?: {
            runMode?: ChartReviewRunMode;
            triggerId?: ChartReviewTriggerId | null;
        };
        treatmentEpisodeId?: string;
    }
    Index

    Properties

    auditRunIds?: Partial<Record<AuditTemplateId, AuditRunId>>

    Map of templateId -> pre-created auditRunId. When provided, the worker reuses existing rows instead of creating new ones.

    createdBy: UserId | null

    Authenticated user id (auth runs at the trpc middleware layer), or null for trigger-sourced runs that have no attributable user.

    createRunner: CreateQuestionRunner

    Factory for the question runner, injected by the caller (jobbable). The runner choice is encoded by which job ran — no discriminator is serialized onto the job.

    logger?: BaseLogger
    patientId: PatientId
    sessionId?: SessionId

    When set, audit responses produced by this run are stamped with this sessionId so the session-note chart-review badge can surface them via auditRunsRepo.listIdsBySessionId. Omit for patient-level reviews.

    sessionNoteContext?: string

    When set, the run uses ONLY this (already HTML-cleaned) session-note text as the AI context, bypassing EMR/patient_charts and Pinecone retrieval. Set by the session-note trigger path; unset for patient-level reviews.

    supabase: SupabaseClient<Database>
    templateIds: AuditTemplateId[]
    trace?: {
        runMode?: ChartReviewRunMode;
        triggerId?: ChartReviewTriggerId | null;
    }

    LangSmith trace context. Identifies the modality (manual vs automated) and the source trigger so each run's trace is filterable. Optional — when omitted the run mode is inferred from the run shape (e.g. session-note context implies a session-note validation).

    treatmentEpisodeId?: string

    When set, scope every template's run to a single treatment episode — the EMR runner's candidate charts are filtered to this episode. Unset for unscoped patient-level reviews.