Circle V2 API Docs
    Preparing search index...

    Function runQuestionsWithImmediateSave

    • Runs each question through the AgentQuestionRunner and persists each response to audit_response immediately, so partial progress survives even if a later question fails or times out.

      Per-question failures are logged but do not throw — Promise.allSettled collects them, and any successful results are returned in results.

      Runner-agnostic: accepts any QuestionRunner (the v2 AgentQuestionRunner or the v1-faithful SessionNoteAuditRunner); only .run() is used.

      Parameters

      • options: {
            auditResponsesRepo: AuditResponsesRepo;
            auditRunId: AuditRunId;
            auditTemplateId: string | number;
            context?: QuestionRunContext;
            logger: BaseLogger;
            patient: {
                address_city: string | null;
                address_state: string | null;
                address_street1: string | null;
                address_street2: string | null;
                address_zipcode: string | null;
                created_at: string;
                created_by: string | null;
                dob: string | null;
                email: string | null;
                entity_id: number | null;
                external_patient_id: string | null;
                external_source:
                    | "kipu"
                    | "lightningstep"
                    | "sunwave"
                    | "qualifacts_insync"
                    | null;
                facility_id: string
                | null;
                first_name: string | null;
                gender: string | null;
                intake_notes: string | null;
                last_name: string | null;
                last_updated_summary: string | null;
                patient_id: number;
                phone_mobile: string | null;
                primary_provider_id: number | null;
                status: number | null;
                summary: Json;
            };
            questions: Pick<
                {
                    created_at: string;
                    created_by: string
                    | null;
                    id: number;
                    manual: boolean;
                    org_id: number | null;
                    question: string | null;
                    question_order: number | null;
                    question_type: "pass_fail" | "summary";
                    share_with_org: boolean | null;
                    shared_by: string | null;
                    shared_with_entity_id: number | null;
                    template_id: number | null;
                    updated_at: string | null;
                },
                "id"
                | "question"
                | "question_type",
            >[];
            runner: QuestionRunner;
            sessionId?: SessionId;
            summaryInstructions?: string | null;
        }
        • auditResponsesRepo: AuditResponsesRepo
        • auditRunId: AuditRunId
        • auditTemplateId: string | number

          Template the questions belong to. Stamped onto each per-question LangSmith span so a question is filterable on its own (template -> run -> question).

        • Optionalcontext?: QuestionRunContext

          Run-scoped context hoisted once by the orchestrator and forwarded to every question, so runners reuse a single chart/admission/level-of-care fetch instead of re-fetching per question. Undefined for the session-note path (whose runner uses only the injected note).

        • logger: BaseLogger
        • patient: {
              address_city: string | null;
              address_state: string | null;
              address_street1: string | null;
              address_street2: string | null;
              address_zipcode: string | null;
              created_at: string;
              created_by: string | null;
              dob: string | null;
              email: string | null;
              entity_id: number | null;
              external_patient_id: string | null;
              external_source:
                  | "kipu"
                  | "lightningstep"
                  | "sunwave"
                  | "qualifacts_insync"
                  | null;
              facility_id: string
              | null;
              first_name: string | null;
              gender: string | null;
              intake_notes: string | null;
              last_name: string | null;
              last_updated_summary: string | null;
              patient_id: number;
              phone_mobile: string | null;
              primary_provider_id: number | null;
              status: number | null;
              summary: Json;
          }
        • questions: Pick<
              {
                  created_at: string;
                  created_by: string
                  | null;
                  id: number;
                  manual: boolean;
                  org_id: number | null;
                  question: string | null;
                  question_order: number | null;
                  question_type: "pass_fail" | "summary";
                  share_with_org: boolean | null;
                  shared_by: string | null;
                  shared_with_entity_id: number | null;
                  template_id: number | null;
                  updated_at: string | null;
              },
              "id"
              | "question"
              | "question_type",
          >[]
        • runner: QuestionRunner
        • OptionalsessionId?: SessionId

          When set, each persisted audit_response row is stamped with this sessionId so the session-note chart-review badge can surface the run via auditRunsRepo.listIdsBySessionId.

        • OptionalsummaryInstructions?: string | null

      Returns Promise<AuditQuestionResult[]>