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").
Adapter for syncing Kipu data into v2.
Differences from legacy:
@repo/dbrepo singletons rather than per-call Supabase clients.getPatientWithLatestAdmissionis replaced by the privategetPatientAndAdmissionhelper (codified during the LightningStep / Sunwave ports).idsToDeletealongside its documents;fetchPatientDocumentsaggregates them and the manager runs the delete viapatientChartsRepo.deleteByIds. (PR2B refactor — Kipu is the first adapter to populateidsToDeletewith non-empty content.)payor_nameonly; the manager resolvespayor_name → payor_idin bulk before insert.fetchIntegrationFacilitieswarns and returns{ facility: null }when the configuredlocation_idisn'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.admitted_atare dropped (incorporates legacy HF commits cc73696f / 71fc8af3 — "Remove Patient With No Admission").