Circle V2 API Docs
    Preparing search index...

    Function toFacilityLevelOfCareUpserts

    • Build the facility_levels_of_care upsert rows referenced by stays. A stay contributes a row only when it carries both a level_of_care_external_id and a level_of_care_name. Identity is the LOC NAME ((facility_id, name), matching facility_programs): the EMR's LOC external id churns across syncs, so it is NOT stored here (external_id: null) — persisting it made the same name reappear under a new external id violate the (facility_id, name) unique. Rows are deduped by trimmed name; synced LOCs are type: "clinical" (UR-derived LOCs are sourced elsewhere).

      Parameters

      Returns (
          {
              entity_id: number & { __brand: "EntityId" };
              facility_id: string;
              name: string;
              type: "clinical" | "ur";
          } & {
              created_at?: DbDate;
              external_id?: string
              | null;
              id?: FacilityLevelOfCareId;
              integration_id?: string | null;
              updated_at?: DbDate;
          }
      )[]