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 their name
((facility_id, name)) — the EMR's program/LOC external id churns across syncs and is not the
catalog key. The service upserts the referenced programs/LOCs into the catalog
(facility_programs / facility_levels_of_care) and maps each stay's FK by name from the returned
rows — so a source whose catalog can't be synced separately (e.g. Sunwave) still resolves its FKs.
A LOC is only upserted when BOTH its level_of_care_external_id and level_of_care_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 their
name((facility_id, name)) — the EMR's program/LOC external id churns across syncs and is not the catalog key. The service upserts the referenced programs/LOCs into the catalog (facility_programs/facility_levels_of_care) and maps each stay's FK by name from the returned rows — so a source whose catalog can't be synced separately (e.g. Sunwave) still resolves its FKs. A LOC is only upserted when BOTH itslevel_of_care_external_idandlevel_of_care_nameare present; there is no name-only fallback.