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 = {
        auditQuestionIds?: AuditQuestionId[];
        auditRunIds?: Partial<Record<AuditTemplateId, AuditRunId>>;
        createdBy: UserId | null;
        createRunner: CreateQuestionRunner;
        logger?: BaseLogger;
        patientChartIds?: number[];
        patientId: PatientId;
        questionTextOverrides?: Record<number, string>;
        referenceInstant?: Date;
        sessionId?: SessionId;
        sessionNoteContext?: string;
        settings: LegacyChartReviewSettings;
        supabase: SupabaseClient<Database>;
        templateIds: AuditTemplateId[];
        trace?: {
            noteModality?: string | null;
            noteTemplateId?: TemplateId | null;
            noteTemplateName?: string | null;
            runMode?: ChartReviewRunMode;
            triggerId?: ChartReviewTriggerId | null;
        };
        treatmentEpisodeId?: string;
        useEvalNamespaces?: boolean;
    }
    Index

    Properties

    auditQuestionIds?: AuditQuestionId[]

    When set, scope every template's run to these questions only — the scoped run skips summary regeneration + markAsComplete. Unset for full template runs.

    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
    patientChartIds?: number[]

    Reviewer-selected charts; when set they are the entire candidate set.

    patientId: PatientId
    questionTextOverrides?: Record<number, string>
    referenceInstant?: Date

    Reference instant for all date reasoning; defaults to now. Eval runs freeze it.

    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?: {
        noteModality?: string | null;
        noteTemplateId?: TemplateId | null;
        noteTemplateName?: string | null;
        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.

    useEvalNamespaces?: boolean