Circle V2 API Docs
    Preparing search index...

    Variable patientChartPreprocessingTableConst

    patientChartPreprocessingTable: Omit<
        PgTableWithColumns<
            {
                columns: {
                    createdAt: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgTimestampString";
                            data: Generated;
                            dataType: "string";
                            driverParam: string;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: true;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "created_at";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: Generated },
                    >;
                    entityId: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgInteger";
                            data: EntityId
                            | null;
                            dataType: "number";
                            driverParam: string | number;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "entity_id";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: EntityId
                        | null },
                    >;
                    errorMessage: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: string;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "error_message";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {},
                    >;
                    id: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgUUID";
                            data: Generated;
                            dataType: "string";
                            driverParam: string;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: true;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: true;
                            name: "id";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: Generated },
                    >;
                    metadata: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgJsonb";
                            data: {
                                authorship: {
                                    authoredAt: string
                                    | null;
                                    signatures: {
                                        role: (...) | (...);
                                        signedAt: (...) | (...);
                                        signer: (...) | (...);
                                    }[];
                                    signatureSource: "extractor"
                                    | "unavailable";
                                };
                                externalFormId?: string
                                | null;
                                structure: { characterCount: number; sectionHeadings: string[] };
                                tagRationales: Partial<
                                    Record<
                                        | "admission"
                                        | "insurance"
                                        | "diagnosis"
                                        | "biopsychosocial"
                                        | "asam_assessment"
                                        | "level_of_care_determination"
                                        | "history_and_physical"
                                        | "psychiatric_evaluation"
                                        | "nursing_intake"
                                        | "screening_instrument"
                                        | "alcohol_withdrawal_assessment"
                                        | "benzodiazepine_withdrawal_assessment"
                                        | "opioid_withdrawal_assessment"
                                        | "treatment_plan"
                                        | "safety_plan"
                                        | "continuing_care_plan"
                                        | "progress_note"
                                        | "group_note"
                                        | "individual_therapy_note"
                                        | "family_session_note"
                                        | "case_management_note"
                                        | "restraint_seclusion"
                                        | "consent_form"
                                        | "discharge_summary"
                                        | "discharge_instructions"
                                        | "transfer_note"
                                        | "program_history"
                                        | "appointment"
                                        | "utilization_review"
                                        | "vital_signs"
                                        | "lab_result"
                                        | "glucose_log"
                                        | "clinical_orders"
                                        | "medication_administration_record"
                                        | "medication_reconciliation"
                                        | "other",
                                        string,
                                    >,
                                >;
                                tags: (
                                    | "admission"
                                    | "insurance"
                                    | "diagnosis"
                                    | "biopsychosocial"
                                    | "asam_assessment"
                                    | "level_of_care_determination"
                                    | "history_and_physical"
                                    | "psychiatric_evaluation"
                                    | "nursing_intake"
                                    | "screening_instrument"
                                    | "alcohol_withdrawal_assessment"
                                    | "benzodiazepine_withdrawal_assessment"
                                    | "opioid_withdrawal_assessment"
                                    | "treatment_plan"
                                    | "safety_plan"
                                    | "continuing_care_plan"
                                    | "progress_note"
                                    | "group_note"
                                    | "individual_therapy_note"
                                    | "family_session_note"
                                    | "case_management_note"
                                    | "restraint_seclusion"
                                    | "consent_form"
                                    | "discharge_summary"
                                    | "discharge_instructions"
                                    | "transfer_note"
                                    | "program_history"
                                    | "appointment"
                                    | "utilization_review"
                                    | "vital_signs"
                                    | "lab_result"
                                    | "glucose_log"
                                    | "clinical_orders"
                                    | "medication_administration_record"
                                    | "medication_reconciliation"
                                    | "other"
                                )[];
                                units?: | {
                                    charEnd: number;
                                    charStart: number;
                                    index: number;
                                    serviceDate: (...)
                                    | (...);
                                    title: string;
                                }[]
                                | null;
                            };
                            dataType: "json";
                            driverParam: unknown;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "metadata";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {
                            $type: {
                                authorship: {
                                    authoredAt: string
                                    | null;
                                    signatures: {
                                        role: (...) | (...);
                                        signedAt: (...) | (...);
                                        signer: (...) | (...);
                                    }[];
                                    signatureSource: "extractor"
                                    | "unavailable";
                                };
                                externalFormId?: string
                                | null;
                                structure: { characterCount: number; sectionHeadings: string[] };
                                tagRationales: Partial<
                                    Record<
                                        | "admission"
                                        | "insurance"
                                        | "diagnosis"
                                        | "biopsychosocial"
                                        | "asam_assessment"
                                        | "level_of_care_determination"
                                        | "history_and_physical"
                                        | "psychiatric_evaluation"
                                        | "nursing_intake"
                                        | "screening_instrument"
                                        | "alcohol_withdrawal_assessment"
                                        | "benzodiazepine_withdrawal_assessment"
                                        | "opioid_withdrawal_assessment"
                                        | "treatment_plan"
                                        | "safety_plan"
                                        | "continuing_care_plan"
                                        | "progress_note"
                                        | "group_note"
                                        | "individual_therapy_note"
                                        | "family_session_note"
                                        | "case_management_note"
                                        | "restraint_seclusion"
                                        | "consent_form"
                                        | "discharge_summary"
                                        | "discharge_instructions"
                                        | "transfer_note"
                                        | "program_history"
                                        | "appointment"
                                        | "utilization_review"
                                        | "vital_signs"
                                        | "lab_result"
                                        | "glucose_log"
                                        | "clinical_orders"
                                        | "medication_administration_record"
                                        | "medication_reconciliation"
                                        | "other",
                                        string,
                                    >,
                                >;
                                tags: (
                                    | "admission"
                                    | "insurance"
                                    | "diagnosis"
                                    | "biopsychosocial"
                                    | "asam_assessment"
                                    | "level_of_care_determination"
                                    | "history_and_physical"
                                    | "psychiatric_evaluation"
                                    | "nursing_intake"
                                    | "screening_instrument"
                                    | "alcohol_withdrawal_assessment"
                                    | "benzodiazepine_withdrawal_assessment"
                                    | "opioid_withdrawal_assessment"
                                    | "treatment_plan"
                                    | "safety_plan"
                                    | "continuing_care_plan"
                                    | "progress_note"
                                    | "group_note"
                                    | "individual_therapy_note"
                                    | "family_session_note"
                                    | "case_management_note"
                                    | "restraint_seclusion"
                                    | "consent_form"
                                    | "discharge_summary"
                                    | "discharge_instructions"
                                    | "transfer_note"
                                    | "program_history"
                                    | "appointment"
                                    | "utilization_review"
                                    | "vital_signs"
                                    | "lab_result"
                                    | "glucose_log"
                                    | "clinical_orders"
                                    | "medication_administration_record"
                                    | "medication_reconciliation"
                                    | "other"
                                )[];
                                units?: | {
                                    charEnd: number;
                                    charStart: number;
                                    index: number;
                                    serviceDate: (...)
                                    | (...);
                                    title: string;
                                }[]
                                | null;
                            };
                        },
                    >;
                    model: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: string;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "model";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {},
                    >;
                    patientChartId: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgBigInt53";
                            data: PatientChartId;
                            dataType: "number";
                            driverParam: string
                            | number;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "patient_chart_id";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: PatientChartId },
                    >;
                    patientId: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgBigInt53";
                            data: PatientId;
                            dataType: "number";
                            driverParam: string
                            | number;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "patient_id";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: PatientId },
                    >;
                    processedAt: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgTimestampString";
                            data: DbDate
                            | null;
                            dataType: "string";
                            driverParam: string;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "processed_at";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: DbDate
                        | null },
                    >;
                    promptCommitHash: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: string;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "prompt_commit_hash";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {},
                    >;
                    promptName: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: string;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "prompt_name";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {},
                    >;
                    schemaVersion: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgInteger";
                            data: Generated;
                            dataType: "number";
                            driverParam: string
                            | number;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: true;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "schema_version";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: Generated },
                    >;
                    serviceDate: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgTimestampString";
                            data: DbDate
                            | null;
                            dataType: "string";
                            driverParam: string;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "service_date";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: DbDate
                        | null },
                    >;
                    sourceHash: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: string;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "source_hash";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {},
                    >;
                    status: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgEnumColumn";
                            data: "processing"
                            | "failed"
                            | "completed"
                            | "skipped";
                            dataType: "string";
                            driverParam: string;
                            enumValues: ["processing", "completed", "failed", "skipped"];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "status";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: "processing"
                        | "failed"
                        | "completed"
                        | "skipped" },
                    >;
                    summary: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: string;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "summary";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {},
                    >;
                    textSource: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgText";
                            data: | "formatter"
                            | "extraction"
                            | "notes_fields"
                            | "parsed_content"
                            | "formatter_error"
                            | "no_content"
                            | null;
                            dataType: "string";
                            driverParam: string;
                            enumValues: [string, ...string[]];
                            generated: undefined;
                            hasDefault: false;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "text_source";
                            notNull: false;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        {
                            $type: | "formatter"
                            | "extraction"
                            | "notes_fields"
                            | "parsed_content"
                            | "formatter_error"
                            | "no_content"
                            | null;
                        },
                    >;
                    updatedAt: PgColumn<
                        {
                            baseColumn: never;
                            columnType: "PgTimestampString";
                            data: Generated;
                            dataType: "string";
                            driverParam: string;
                            enumValues: undefined;
                            generated: undefined;
                            hasDefault: true;
                            hasRuntimeDefault: false;
                            identity: undefined;
                            isAutoincrement: false;
                            isPrimaryKey: false;
                            name: "updated_at";
                            notNull: true;
                            tableName: "patient_chart_preprocessing";
                        },
                        {},
                        { $type: Generated },
                    >;
                };
                dialect: "pg";
                name: "patient_chart_preprocessing";
                schema: undefined;
            },
        >,
        "enableRLS",
    > = ...

    One pre-processing record per chart: the type we assigned it from our own vocabulary, a summary, and the date/authorship signals pulled out of it.

    A separate 1:1 table rather than a column on patient_charts because upsertExternalDocument rewrites raw_document and circle_metadata wholesale on every EMR sync, so derived data stored there does not survive re-sync.

    A row only exists once pre-processing has started — "never pre-processed" is the absence of a row, not a status — so every writer inserts on conflict rather than updating.