A program / level-of-care enrollment window for one episode. external_id must be present,
deterministic across syncs, and unique per integration (it backs the
program_stays (integration_id, external_id) partial unique index): LightningStep uses the
stable admission.id; Kipu/Sunwave synthesize a casefile/admission-scoped composite.
The referenced program and level of care are each identified by name + external_id (when
known). The service upserts the referenced programs/LOCs into the catalog
(facility_programs / facility_levels_of_care, conflict key (integration_id, external_id))
and maps each stay's FK from the returned upserted rows — so a source whose catalog can't be
synced separately (e.g. Sunwave) still resolves its FKs. A program/LOC is only upserted when
BOTH its *_external_id and *_name are present; there is no name-only fallback.
A program / level-of-care enrollment window for one episode.
external_idmust be present, deterministic across syncs, and unique per integration (it backs theprogram_stays (integration_id, external_id)partial unique index): LightningStep uses the stableadmission.id; Kipu/Sunwave synthesize a casefile/admission-scoped composite.The referenced program and level of care are each identified by
name+external_id(when known). The service upserts the referenced programs/LOCs into the catalog (facility_programs/facility_levels_of_care, conflict key(integration_id, external_id)) and maps each stay's FK from the returned upserted rows — so a source whose catalog can't be synced separately (e.g. Sunwave) still resolves its FKs. A program/LOC is only upserted when BOTH its*_external_idand*_nameare present; there is no name-only fallback.