By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| PatientID | PatientMasterID | Admission | Discharge | LevelOfCare | DischargeType | AdmissionsBefore | AdmissionsAfter | NextAdmission | NextLevelOfCare |
|---|---|---|---|---|---|---|---|---|---|
| 1234-5 | aBcDD-Ecnad9-09as | 2022-09-01 | 2022-10-01 | 3 | Stepdown | 0 | 3 | 2022-10-01 | 2 |
| 123-6 | aBcDD-Ecnad9-09as | 2022-10-01 | 2022-10-31 | 2 | Gone for now, but they'll be back | 1 | 2 | 2022-12-01 | 2 |
| 123-7 | aBcDD-Ecnad9-09as | 2022-12-01 | 2022-12-02 | 2 | Step-Up | 2 | 1 | 2022-12-03 | 3 |
| 123-8 | aBcDD-Ecnad9-09as | 2022-12-03 | 2022-12-04 | 3 | True Discharge | 3 | 0 | null | null |
| 987-1 | xxxxx-yyyyyy-zzzz | 2022-09-01 | 2022-10-01 | 1 | Lateral Transfer | 0 | 1 | 2022-10-01 | 1 |
| 987-2 | xxxxx-yyyyyy-zzzz | 2022-10-01 | null | 1 | Still here? | 1 | 0 | null | null |