Skip to content

Clinical: forecast double count, ended legal form wording, ED 24-hour boundary (D-145) - #1621

Merged
BigSimmo merged 8 commits into
mainfrom
claude/project-thread-e15xqk-clinical
Nov 11, 2026
Merged

BigSimmo merged 8 commits into
mainfrom
claude/project-thread-e15xqk-clinical

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Requested by Josh · project thread

The clinical part of the 11 November repository review. Josh approved it as D-145 item 1, which is recorded in the thread's normal PR, #1623. Josh signed it off on 11 November 2026 at 05:51 UTC ("I approve all of them to remove labels"), so the hold label is off; the sign-off is recorded under D-145 in #1623. Synthetic data only. No signed clinical value changes.

What changes

  1. Expected occupancy no longer counts one patient twice.
    • The bug: a patient who held a named bed (through a journey or a referral) and also had a booked planned admission to the same ward was counted twice. The ward's 24, 48 and 72 hour figures went up by 2 instead of 1.
    • The network forecast had the same double count for referral holds.
    • The fix: a new patientsHoldingANamedBed helper uses the same rule as numberedReservationBeds. It feeds plannedAdmissionsStillNeedingABed from expected-occupancy.ts, beds-forecast.ts and forecast/forecast-by-kind.ts, so all the forecast views agree.
    • The helper lives in capacity/planned-admissions-reducer.ts, which is already on the D-14 patient-link allowlist for the same yes/no id comparison. Its allowlist reason in tests/ward-patient-link-default-deny.test.ts now names this use. No new file joins the allowlist.
  2. An ended legal form no longer shows a live-looking expiry.
    • The Legal forms card and row now read "Form ended; expiry as typed was 15:42", or "Form ended" if no time was typed. The time stays exactly as typed (D-93).
  3. The ED screen flags a long wait at exactly 24 hours.
    • A shared isLongWait() now does the check on the ED screen and its timeline, matching Alerts, TV, the bed meeting and statistics ("24 h or more").

Phone size limits

Route Old limit New limit Measured (CI, PR merged with main)
/ward-flow 575.4 575.7 575.4
/ward-flow/referrals 583.6 583.9 583.6
/ward-flow/ward/rph-adult-secure 613.8 614.1 613.8
/ward-flow/capacity 654.3 654.7 654.4
/ward-flow/ed 535.4 535.7 535.4 (main alone 535.2)
  • All sizes are in KB, each raise under 1 KB. Reasons in docs/script-budget-history/2026-11-11-pr1621-held-clinical-review-fixes.md.

Checks (local, not hosted CI)

  • npx vitest run on 92 related test files: 742 passed; after the helper move, 20 related files (235 tests) including tests/ward-patient-link-default-deny.test.ts passed.
  • node --max-old-space-size=8192 node_modules/typescript/bin/tsc -p tsconfig.json --noEmit --incremental false: exit 0.
  • npx eslint on changed files: clean.
  • node docs/ward-flow/journey/verify.mjs --check, node scripts/doc-facts.mjs, node scripts/ward-flow/owner-rulings-index.mjs --check: passed after merging main 3aa63c3.
  • Not run locally: the full unit suite and the browser suite (left to CI).

🤖 Generated with Claude Code

https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N

…pancy and forecasts

Per-ward expected occupancy counted a named hold in takenNow and the same
person's planned admission again, so 24/48/72h rose by 2. The network
forecast and the by-kind forecast had the same double count for a named
referral hold (and a later-stage journey hold). A shared
patientsHoldingANamedBed rule now feeds plannedAdmissionsStillNeedingABed.
Approved by Josh, 11 Nov 2026.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
legalDeadlineText showed "Form expiry ends 15:42 as typed" under "Ended".
A form recorded as ended now reads "Form ended; expiry as typed was 15:42"
(or "Form ended" with no time typed). Times stay as typed (D-93).
Approved by Josh, 11 Nov 2026.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
Adds isLongWait (>= LONG_WAIT_MINUTES) and uses it in the ED priority
flags and timeline, matching Alerts, TV, bed meeting and Statistics.
Approved by Josh, 11 Nov 2026.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
@BigSimmo BigSimmo added the hold label Nov 11, 2026 — with Claude
@BigSimmo BigSimmo self-assigned this Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 00790bab-c729-4863-8825-885b499c9760
Commits

Reviewing files that changed from the base of the PR and between 3aa63c3 and 47c27bb.

Files selected for processing: 18

  • docs/script-budget-history/2026-11-11-pr1621-held-clinical-review-fixes.md
  • docs/ward-flow/journey/MAP-INVENTORY.md
  • docs/ward-flow/journey/event-dispositions.json
  • docs/ward-flow/journey/machines.json
  • docs/ward-flow/journey/ward-journey-explorer.html
  • script-budget.json
  • src/components/ward-management/capacity/beds-forecast.ts
  • src/components/ward-management/capacity/expected-occupancy.ts
  • src/components/ward-management/capacity/planned-admissions-reducer.ts
  • src/components/ward-management/ed/ed-screen-derivations.ts
  • src/components/ward-management/ed/ed-screen-timeline.tsx
  • src/components/ward-management/forecast/forecast-by-kind.ts
  • src/components/ward-management/legal-forms/legal-forms-derivations.ts
  • src/components/ward-management/ward-operational-defaults.ts
  • tests/ward-audit-m17-legal-as-recorded.test.ts
  • tests/ward-ed-long-wait-boundary.test.ts
  • tests/ward-expected-occupancy.test.ts
  • tests/ward-patient-link-default-deny.test.ts

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

Failed Failed checks: 1 error · 2 inconclusive

Check name Status Explanation Resolution
Verification Claims Error The verification claims still lack exact check details. The PR description reports two Vitest runs and a clean ESLint run without their full commands or file lists. It reports CI budget measurements w… Add the exact commands or check names and results for both Vitest runs, ESLint, and the budget checks. If a check was not run, state that and give the reason.
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Description check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 5 passed

Check name Status Explanation
Generated And Sensitive Files Passed The PR diff contains no identified secrets or unwanted local artifacts. The changed journey documentation is intentionally tracked and refreshed for the changed source references; its generation proce…
Risky Git Or Deployment Actions Passed The diff adds no risky Git or deployment instructions. The workflow changes do not add deployment actions. The demo reset uses synthetic data and includes a confirmation step.
Supabase Project And Schema Safety Passed The diff against main changes clinical forecast and display logic, tests, and generated documentation. It does not change Supabase project settings, migrations, RLS, policies, or database operations.
Runtime And Package Manager Integrity Passed The PR does not change package manager, lockfile, runtime, or workflow configuration. The existing configuration retains Node 24, npm 11, and engine-strict=true.
Api Route Failure Handling Passed The PR changes forecast calculations, legal-form display text, and the ED wait boundary. The diff against the merged main revision contains no API route, server action, RAG, search, ingestion, or prov…
Full details: Generated And Sensitive Files

Explanation

The PR diff contains no identified secrets or unwanted local artifacts. The changed journey documentation is intentionally tracked and refreshed for the changed source references; its generation process is documented in docs/ward-flow/journey/README.md.

Full details: Api Route Failure Handling

Explanation

The PR changes forecast calculations, legal-form display text, and the ED wait boundary. The diff against the merged main revision contains no API route, server action, RAG, search, ingestion, or provider integration changes.

Full details: Verification Claims

Explanation

The verification claims still lack exact check details. The PR description reports two Vitest runs and a clean ESLint run without their full commands or file lists. It reports CI budget measurements without naming the check. The budget note identifies hosted CI builds but not the budget check. The previous failure remains unresolved.

Resolution

Add the exact commands or check names and results for both Vitest runs, ESLint, and the budget checks. If a check was not run, state that and give the reason.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copy link
Copy Markdown
Owner Author

This PR is held because it changes clinical display: bed forecast counts, legal form wording and the ED long-wait flag. It merges only after Josh has checked it. Only Josh removes the hold label.


Generated by Claude Code

@gitar-bot

gitar-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Gitar is working

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

Gitar

The named-bed check in the bed forecast and the shared ED long-wait helper
add 0.1 to 0.3 KB gzipped to routes that already load the forecast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
Booking, change, cancel and convert dispatch is unchanged; only the
bed-needed filter gained the named-bed holders, so the reviewed lines
moved by four and the file digest changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
…ducer

The D-14 patient-link guard refused ward-movement-bed-hold.ts reading patientId. The helper now
lives in planned-admissions-reducer.ts, already allowlisted for the same yes/no id comparison, and
its allowlist reason names the new use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
@BigSimmo BigSimmo removed the hold label Nov 11, 2026 — with Claude
@BigSimmo BigSimmo changed the title Held clinical: forecast double count, ended legal form wording, ED 24-hour boundary (D-145) Clinical: forecast double count, ended legal form wording, ED 24-hour boundary (D-145) Nov 11, 2026
@BigSimmo
BigSimmo marked this pull request as ready for review November 11, 2026 05:53
@BigSimmo
BigSimmo enabled auto-merge November 11, 2026 05:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T05:54:58.621704Z 47c27bb Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

BigSimmo pushed a commit that referenced this pull request Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
@BigSimmo
BigSimmo merged commit 35c7ccd into main Nov 11, 2026
24 checks passed
@BigSimmo
BigSimmo deleted the claude/project-thread-e15xqk-clinical branch November 11, 2026 06:57
BigSimmo pushed a commit that referenced this pull request Nov 11, 2026
Kept D-144 and D-145 both; regenerated FACTS, owner rulings and journey outputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J352nkwW4xTv5Ftznofb8N
BigSimmo pushed a commit that referenced this pull request Nov 11, 2026
Phone limits are main's new values plus this PR's raise. Ward gets 0.2 KB
more rounding room, because the last build measured it at exactly its
limit. Journey reader outputs are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxkWmB3aquWnS7ScPRS
BigSimmo pushed a commit that referenced this pull request Nov 11, 2026
Hosted CI measured /ward-flow/ed/arm-ed at 671.7 KB after main's shared
long-wait fix landed. Limits keep main's own raises and stay within 5 KB
per screen. Journey reader outputs regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxobiABL12fRKomRfoE
BigSimmo pushed a commit that referenced this pull request Nov 11, 2026
Hosted CI on 272e9c8 measured movement 610.0, bed meeting 593.6 and
statistics 632.9 KB, each just over its limit once PR #1621's shared
forecast code joined this PR's shared shell code. Each new limit is the
measurement plus about 0.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxnKy5cgHmGa8NdCd2U
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants