Discharge and capacity: 11 features (delay reasons, date drift, extend pull, follow-up replies, weekend review, 72 h forecast, leave page, transport delays, readmission, discharge checklist, heatmap)
Merged
BI
3d ago+8482+8482+0123456789012345678901234567890123456789-1742-1742-0123456789012345678901234567890123456789
Requested by Josh · project thread
One combined PR for items 5, 6, 11, 13, 14, 21, 23, 25, 29, 37 and 42 of Josh's 9 Nov feature list. It takes slot 8 in the merge order. The review page shows before and after on desktop and phone: https://claude.ai/artifact/AVrSJp7Zrsn1AHk1qZS1WC
All data is synthetic.
What changes
- 5 Delayed discharge reasons (D-101, Josh 9 Nov):
SET_CLINICALLY_READYrecords "Clinically ready since" and one reason fromDISCHARGE_BARRIERS(all except "Clinical / Treatment").- The bed board gets a record control and a "Ready since … · reason · N days" line.
- Weekly gets a "Delayed bed days by reason" card.
- The unused
DISCHARGE_DELAY_REASONSlist is removed.
- 6 Discharge date drift: an append-only trail keeps the first expected discharge date and every revision. It feeds the existing drift badge and a "Discharge dates slipping" list on Discharges. The flag shows when the date slips by more than 3 days.
- 11 Extend pull:
EXTEND_PULLadds 1, 2 or 4 hours to a pull, up to 12 hours in total. It uses the configured pull limit. The movement record and ward arrivals show the change. - 13 Community follow-up replies:
RECORD_FOLLOW_UP_REPLYlets the community team record Awaiting reply, Accepted or Declined. A decline takes a reason from a fixed list. The ward sees the reply. - 14 Weekend discharge review: a Weekend discharges card lists people expected to go Saturday to Monday, allowing for public holidays. A Reviewed tick records
MARK_WEEKEND_DISCHARGE_REVIEWED. The card comes first on Thursday and Friday. - 21 72 h forecast: adds an "In 3 days" horizon. A lazy-loaded Expected occupancy table shows each ward now and at 24, 48 and 72 hours.
- 23 Leave page: a new
/ward-flow/leaveroute. It shares one calculation with the Tools › Leave due panel, which gains a "See all leave" link. It uses only values already signed. - 25 Transport delays: records the booked time. The officer Jobs list gets a Delayed tag and filter, on desktop and phone. A job is delayed when it is past its arrival time, or not accepted within 30 minutes.
- 29 Readmission: the existing 28-day badge now also shows on board bed tiles. Weekly Supporting figures gains a count. The rule is unchanged.
- 37 Discharge checklist:
RECORD_DISCHARGE_CHECKcovers follow-up, medicines, carer told (dischargeChecks.carer_told) and GP letter. Discharges shows a "Checklist n/4" tag. Recording a discharge with unticked items shows a warning but never blocks. - 42 Bed blocking heatmap: a ward-by-day grid of bed days lost on Statistics › Weekly, with a compact grid on phone. Its total matches the Pressure tile.
Clinical values
Josh signed three new values on 9 Nov 2026, on the decision card on the review page:
- Pull limit: 12 hours in total.
- Transport not accepted: 30 minutes.
- Discharge date slip: 3 days.
docs/ward-flow/clinical-values.md is regenerated.
Phone size limits (raised, within the 5 KB rule)
- Why they grew: the new engine records load on every page, with their synthetic seed data. These are the ready date and reason, Extend pull, weekend review, discharge checklist, follow-up reply and date trail.
- Trim: moving the Extend pull rule out of the shared chunk saved about 0.3 KB.
- How measured: a local webpack build of the branch after merging main b29dfaa76 (#1581 page tops and #1588), each at its own fixed path, in KB gzipped.
- New limits: each is the measured size plus 0.2 KB. Capacity is under its limit and unchanged.
- Referrals: most of its 7.5 KB growth is webpack regrouping, not this PR's code (a 5.7 KB duplicate Next.js runtime chunk, the follow-up #1581 noted). Its limit rises 2.6 KB.
- Detail:
docs/script-budget-history/2026-11-09-pr1583-discharge-and-capacity.md.
| Route | Main measured | Old limit | This PR measured | New limit |
|---|---|---|---|---|
| home | 567.3 | 565.6 | 569.8 | 570.0 |
| referrals | 575.7 | 580.8 | 583.2 | 583.4 |
| ED | 527.2 | 527.9 | 529.2 | 529.4 |
| ward | 606.4 | 607.5 | 609.0 | 609.2 |
| movement | 602.1 | 602.6 | 604.6 | 604.8 |
| capacity | 647.1 | 651.1 | 648.8 | 651.1 |
| ED Armadale | 662.9 | 663.0 | 664.3 | 664.5 |
| bed meeting | 582.0 | 583.0 | 583.9 | 584.1 |
| statistics | 621.8 | 623.1 | 626.2 | 626.4 |
Line caps
- The weekend review, discharge checklist and follow-up reply share one dispatcher in the lazy slices file.
- Main's reducer is at 2,550 lines after #1578; this PR's 6 dispatch lines take its cap to 2,560. The reason is recorded in
eslint-rules/max-lines-baseline.mjs. - The discharge board's day chart moved to
discharge-chart-days.ts, keeping the board at its 1,500-line limit.
Checks (local, offline)
- After merging main b29dfaa76 (#1581, #1588): tsc, knip, lint, the journey check, docs facts, 126 focused test files (1,365 tests), the webpack build and
check-script-budget.mjspass. Main took D-118 and D-119, so the signed values are recorded as D-120 (values unchanged). - After merging main 1cad868ae (#1584, #1586): tsc, knip, the journey check, docs facts, the tests those PRs touched, the webpack build and
check-script-budget.mjspass. - After merging main 3eb843f38 (#1578):
- tsc, knip, lint on the merged files, the journey
verify.mjs --checkand docs facts pass. - 212 focused test files (1,800 tests) pass: discharge, engine, storage, fuzz, events, journey, history, leave, capacity and pull.
- The storage verdicts fixture was re-recorded with both PRs' cases.
- The webpack build passes, and
check-script-budget.mjspasses on every route with the limits above.
- tsc, knip, lint on the merged files, the journey
- Earlier, after merging #1579: the full vitest suite passed apart from one test this PR's AWOL demo patient broke, which is fixed (22,026 tests).
- CI: two unit shards hit the 20-minute job limit right after every test passed (0 failures), and were re-run.
- CI fixes after merges: permission matrix, the D-115 downtime test, the lazy slices guard, the chart-window allow-list, and a 90 s timeout for the ready-beds fuzz replay (9 s locally, over 30 s on a loaded CI shard).
- Earlier: a browser check at 1280 and 400 px, in light and dark.
- Not verified: the live site.
Generated by Claude Code
https://claude.ai/code/session_01J352nkHVLLUZH8YwaxdYkY
Generated by Claude Code