Healthcare encounter snapshot
Model a patient-encounter accumulating snapshot with admit/discharge milestones, joined to a Type 2 provider dimension.
Concept
fact-table-grain
The primary modeling idea this problem reinforces.
Requirements
4
Business needs the model must satisfy.
A hospital wants length-of-stay analytics and provider performance, attributed to the provider’s specialty and affiliation as they were at admission. An encounter moves through admission and discharge; provider attributes change over time.
This combines an accumulating snapshot (milestone timing) with Type 2 history (point-in-time provider context). Either alone gives wrong attribution or no timing.
- Create an encounter fact as an accumulating snapshot.
- Add admitted-at and discharged-at milestone columns and a grain key on the encounter id.
- Floor: make the provider dimension Type 2 with an effective-from and reference patient and provider by surrogate key.
- Grade up: bound each provider version with an effective-to so the admission-time window is explicit.
Template
Healthcare synthesis starter
The model users start from in the full workspace.
Entities
2
Seeded tables visible in the public preview.
Dialect
postgresql
Generated SQL target for this starter model.
This preview is read-only. Open the workspace to edit and verify; saving needs a free account.
Open workspaceTry the question first.
The discussion has other people's approaches and solutions. Give it a real attempt before you read them.