Circle V2 API Docs
    Preparing search index...

    Adapter for syncing Kipu data into v2.

    Differences from legacy:

    • DB access goes through @repo/db repo singletons rather than per-call Supabase clients.
    • getPatientWithLatestAdmission is replaced by the private getPatientAndAdmission helper (codified during the LightningStep / Sunwave ports).
    • Per-document-type chart deletes are no longer inline. Each fetcher returns idsToDelete alongside its documents; fetchPatientDocuments aggregates them and the manager runs the delete via patientChartsRepo.deleteByIds. (PR2B refactor — Kipu is the first adapter to populate idsToDelete with non-empty content.)
    • Insurance records carry payor_name only; the manager resolves payor_name → payor_id in bulk before insert.
    • fetchIntegrationFacilities warns and returns { facility: null } when the configured location_id isn't returned by Kipu — matches legacy behavior. Facility-name sync is a soft enrichment, not a sync prerequisite; failing loud here would block syncs over a recoverable creds mismatch.
    • Admissions with no admitted_at are dropped (incorporates legacy HF commits cc73696f / 71fc8af3 — "Remove Patient With No Admission").

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • integration: {
            created_at: DbDate;
            created_by: string | null;
            credentials:
                | {
                    access_id: string;
                    app_id: string;
                    location_id: number;
                    location_name?: string;
                    secret_key: string;
                }
                | { bearer_token: string; location_ids: number[]; location_name?: string }
                | {
                    api_id: string;
                    api_secret: string;
                    location_name?: string;
                    realm_id: string;
                    service_facility_id: number;
                    sunwave_email: string;
                }
                | {
                    base_url: string;
                    client_id: string;
                    rpa_vault_user_id: string;
                    rpa_workflow_id: string;
                    secret_key: string;
                };
            entity_id: number & { __brand: "EntityId" };
            facility_id: FacilityId | null;
            id: IntegrationId;
            label: string | null;
            last_sync: string | null;
            status: "error" | "active" | "inactive";
            type: "kipu" | "lightningstep" | "sunwave" | "qualifacts_insync";
            updated_at: DbDate;
        }
      • Optionaloptions: KipuAdapterOptions

      Returns KipuAdapter

    Properties

    integration: {
        created_at: DbDate;
        created_by: string | null;
        credentials:
            | {
                access_id: string;
                app_id: string;
                location_id: number;
                location_name?: string;
                secret_key: string;
            }
            | { bearer_token: string; location_ids: number[]; location_name?: string }
            | {
                api_id: string;
                api_secret: string;
                location_name?: string;
                realm_id: string;
                service_facility_id: number;
                sunwave_email: string;
            }
            | {
                base_url: string;
                client_id: string;
                rpa_vault_user_id: string;
                rpa_workflow_id: string;
                secret_key: string;
            };
        entity_id: number & { __brand: "EntityId" };
        facility_id: FacilityId | null;
        id: IntegrationId;
        label: string | null;
        last_sync: string | null;
        status: "error" | "active" | "inactive";
        type: "kipu" | "lightningstep" | "sunwave" | "qualifacts_insync";
        updated_at: DbDate;
    }
    logger: ConsoleLogger = ...

    Methods

    • Parameters

      • startDate: Date
      • endDate: Date

      Returns Promise<FetchEpisodesInRangeResult>

    • Returns Promise<FetchFacilityLevelsOfCareResult>

    • Returns Promise<FetchFacilityProgramsResult>

    • Parameters

      Returns Promise<FetchTreatmentEpisodesResult>