Audit plan: ruling guards and audits 1 to 8 (patient safety and access)

Merged
BI
3d ago
+3327-275

Requested by Josh · project thread

Closes #1572, #1564, #1565, #1566, #1567, #1568, #1569, #1570 and #1571 (audit plan items 9 and 1 to 8).

What changes

Ruling guards (#1572)

  • tests/ward-downtime-pack-device-storage.dom.test.tsx guards D-72 item 2: no downtime pack data reaches browser storage.
  • tests/ward-ruling-guardrails.test.ts registers D-93, D-71, D-72 and R-2026-09-04-A. Each must keep its entry and a live guard test.

1. Wrong-patient binding (#1564), D-113

  • Tests for bed move, discharge, accept in principle and Mark done: each action stays with the patient it was opened for.
  • Per D-113: the Ward home accept dialog shows the UMRN, and the bed meeting actions card names the patient.

2. Live re-sort (#1565)

  • On the ED, Referrals, ward and Discharges boards, a live update mid-gesture never retargets the action.
  • No bug found.

3. Search look-alikes (#1566)

  • Fix: an exact name or UMRN ranks first in the People group (ward-smart-search.ts).
  • Initials search stays off (D-113).

4. One number across screens (#1567), D-115

  • Shared figures are compared across Home, the boards, TV, Statistics and print.
  • D-115 items 1 and 2 (built): the ward TV and service TV now count "Coming in" as beds pulled or waitlisted, and "Going out" as confirmed discharges only, matching the ward board (bed-meeting/tv-derivations.ts).
  • Item 3 (deferred): beds ready after an accept into a named bed are still not taken off on Home, the board and Statistics. The fix needs board/ward-board.tsx, which #1581 and #1583 hold. It is pinned as it.todo.

5. Silent connection (#1568)

  • A silent connection turns the board visibly stale at 6 s.
  • No bug found.

6. Missing patient reaches every screen (#1569), D-115

  • The absence shows in alerts, coordinator Home, Tasks, Ward home, the ward screen bed board, the census, the patient page and the ward TV.
  • Fix (D-38): the Statistics ward rosters say "Absent without leave", not "On leave".
  • D-115 item 5 (built): the downtime pack names each person absent without leave per ward. It stays print or saved file only.
  • Items 4 and 6 (deferred): the red flag on /board tiles and the separate count in executive statistics. They need files held by #1581, #1583 and #1578, and are pinned as it.todo.

7. Permission matrix (#1570)

  • A generated 181 × 10 matrix covers the screen, engine, backend and database layers.
  • No disagreements found.

8. Permission drift mid-shift (#1571)

  • Losing a role or scope ends the screen, cached lists and queued saves within one poll.
  • Fix: the in-memory downtime pack now clears too.

Docs

  • D-111, D-113 and D-115 are recorded, and the generated indexes are refreshed.
  • OWNER-RULINGS.md and FACTS.md are regenerated.

Scope

  • Synthetic data only. No provider calls.
  • No signed clinical value changes.
  • Screen changes are those approved in D-113 and D-115, plus the D-38 label fix.

Checks run locally (Node 24)

  • New and affected tests pass, including 12 files and 147 tests on the D-115 changes.
  • npm run typecheck, check:knip, the journey check, docs:check-links and docs:facts pass.
  • Not run locally: the full suite and the phone size budget.
  • Hosted CI is pending on this head.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J352nkGwqhGKGGfnJb2zMa