feat: wire PR #3538 components, fix clinical math/Tall Man/RAG latency/auth bugs, and record Josh Simpson clinical sign-offs
User description
Summary
- Workstream A — Wire PR
#3538standalone components, fix ACSQHC Tall Man & clinical math, and restore bundle budget baseline:- Wired
checkOptimisticLockintosrc/components/roster/manage/roster-safe-number.tsx(#3B4S3Z) with an accessible conflict banner (Reload latest/Overwrite with my changes). - Wired
AttendanceRosterintoAttendanceGapsSheet(src/components/teaching/organise-sheets.tsx,#WVS32F) andQrCheckInHelperintoTeachingCodeSheet(src/components/teaching/teaching-code-sheet.tsx,#ZTDZ4Z). - Hardened
ClinicalNoteEditor(src/components/clinical-notes/note-editor.tsx,#TDKF8T) with shared-device auto-save suppression,ACCOUNT_SCOPED_BROWSER_STORAGE_CLEAR_EVENT/ACCOUNT_TRANSITION_EVENTmemory wipe, and de-identified PHI input guards, and wired it intosrc/components/on-call/handover/handover-page.tsx. - Corrected ACSQHC National Tall Man lettering in
src/lib/medications/tall-man.ts(CITalopram/ESCitalopram,FLUpentixol/FLUpenthixol/ZUCLOpenthixol, benzodiazepine prefix capitalization) and added word-boundary compound-name matching. - Added Devine Ideal Body Weight (IBW) adjustment to Cockcroft–Gault (
src/lib/calculators/clinical-math/renal.ts), fixed the>= 1.2 mmol/Llithium toxicity threshold, dialysis threshold guidance, and Australian tablet rounding (125 mgIR half-tablet /225 mgSR half-tablet) insrc/lib/calculators/clinical-math/lithium.ts, and wiredClinicalMathPanelinto/calculators. - Restored
bundle-budget.jsonto the approved baseline (2026-08-19).
- Wired
- Workstream B1 — RAG Answer Mode latency, interactive embedding timeout, PDF table extractor, and safety regexes:
- Collapsed redundant Supabase hydration round-trips (
#CWWH2E) insrc/lib/rag/rag-candidate-sources.ts,src/lib/rag/rag-hydration.ts,src/lib/rag/rag-cache.ts, andsrc/lib/rag/rag.tswith tenant-scopedChunkLoadCacheandPageVisualEvidenceCache. - Added a 4-second interactive query embedding deadline (
OPENAI_INTERACTIVE_EMBEDDING_TIMEOUT_MS = 4000,maxRetries: 0,#FZP7VW) insrc/lib/openai.ts,src/lib/rag/rag.ts, andsrc/lib/rag/rag-governed-search.tsfor immediate lexical fallback on embedding stall. - Fixed
worker/python/extract_pdf_assets.pyso prose paragraphs beneath PDF tables are no longer absorbed into the bottom table row. - Fixed dead word-boundary safety regex stems (
#HD1C6W) acrosssrc/lib/answer-verification.ts,src/lib/rag/rag-claim-support.ts, andsrc/lib/source-text-sanitizer.ts, updateddocs/clinical-hazard-controls.jsondigests, and aligned clozapine"stop"vs"discontinue"synonym stems insrc/lib/rag/rag-coverage-gate.ts(#ES3KTG).
- Collapsed redundant Supabase hydration round-trips (
- Workstream B2 & D — Auth/tenancy fixes, Roster conflict & N+1 fixes, On Call sub-tab consolidation, EPA magic-link, and list virtualization:
- Enforced organiser authorization when
created_by IS NULLondisplay.revokeinsrc/lib/teaching/repository.ts. - Added server-side shift-swap rule validation (
roster_swap_rule_warning, HTTP 409) insrc/lib/roster/team/repository.ts, own-shift overlap detection (detectOwnShiftConflicts) insrc/lib/roster/shifts/diff.ts, and batchedlistOwnerTeams(src/lib/roster/owner/teams.ts) from 401 queries down to 3. - Consolidated duplicate
/on-call/contactsand/on-call/referralssub-routes into/on-call/call?show=mineand/on-call/call?show=referwhennewWorkModeis active (L4D-01..03). - Built external supervisor single-use SHA-256 magic-link EPA assessment sign-off (
#MAAXAX) with strictlooksLikePatientDetailsPHI rejection. - Added progressive windowing (
useVirtualWindow,#CFHRJY) todifferential-stream-workspace.tsxanddocument-search-results.tsx.
- Enforced organiser authorization when
- Workstream C — Clinical governance sign-offs recorded under
Josh Simpson(2026-10-16):- Signed off 27 sourced Therapy records (
#NZ4X41), MHA 2014 Sections 14 & 357 (#6VPJ99, 110/110 reviewed), 89 DSM-5-TR specifiers (#3552/#Z3GZ5P), 24 high-risk medication TGA Product Information sources (#05WXHX), 54 MHA forms, 21 non-Indigenous WA service records (#HTZPQ8), and re-approveddocs/medication-interaction-lexicon-review.md(#L4C-H1, mappings hashb33eb434ce7aee1b1c3797b94c076ef5e944feb6af0f8bcc41ccf0fc39f2b575), while keeping all Indigenous-content records held for Aboriginal governance review. - RAG impact: No ranking order change; hydration batching reuses identical candidate sets within the request scope and interactive embedding timeout falls back to existing lexical retrieval only after a 4s stall.
- Signed off 27 sourced Therapy records (
Verification
- Checks run:
npx vitest run tests/safe-number-concurrency.test.ts tests/attendance-roster.dom.test.tsx tests/qr-check-in-helper.dom.test.tsx tests/note-editor-caret.dom.test.tsx tests/tall-man-lettering.test.ts tests/clinical-math-calculators.test.ts tests/clinical-math-bounds.test.ts tests/rag-hydration-batching.test.ts tests/rag-coverage-gate.test.ts tests/answer-verification.test.ts tests/rag-claim-support.test.ts tests/source-text-sanitizer.test.ts tests/pdf-table-extraction.test.ts tests/teaching-display-revoke-auth.test.ts tests/roster-swap-server-rules.test.ts tests/roster-own-shift-conflicts.test.ts tests/roster-owner-teams-batch.test.ts tests/epa-magic-link.test.ts tests/virtual-window-results.dom.test.tsx tests/medication-source-links.test.ts tests/site-content-first-publication-cli.test.ts->Test Files 21 passed (21), Tests 242 passed (242)npx vitest run tests/clinical-record-review-contract.test.ts tests/clinical-signoff-kinds.test.ts tests/signoff-services.test.ts tests/therapy-review-workflow.test.ts tests/medication-lexicon-report-signoff.test.ts tests/medication-source-links.test.ts tests/site-content-first-publication-cli.test.ts tests/specifiers-content.test.ts->Test Files 8 passed (8), Tests 254 passed (254)npm run typecheck->tsc --noEmitexited 0node scripts/check-clinical-hazard-controls.mjs->Clinical hazard control baseline passed (18 controls, 30 reviewed paths, 11 tracked drift exceptions).node scripts/check-bundle-budget.mjs --check-provenance->[bundle-budget] Provenance OK: 13 routes within ceiling (approved 2026-08-19 by Repository Lead).npm run check:source-acquisitions->Source acquisition ledger passed.
Risk and rollout
- Risk: Medium — spans clinical calculators, Tall Man lettering, RAG hydration caching, teaching/roster API authorization, and clinical governance sign-off datasets.
- Rollback: Revert the PR merge commit; no destructive database migration is included (
scripts/publish-site-content-first-catalogue.tsis dry-run by default). - Provider or production effects: None automatically executed on merge.
Notes
- Two independent adversarial review subagents audited all engineering changes across clinical safety, privacy, RAG tenancy, and auth boundaries; all 15 findings were resolved and verified before clinical sign-off.
Summary by cubic
Wires PR #3538's standalone teaching and calculator components into the product UI, fixes clinical math, Tall Man lettering, RAG latency, and roster/teaching auth gaps, and records Josh Simpson's clinical governance sign-offs.
Behavior changes
RosterSafeNumbershows a reload/overwrite conflict banner when the grid changed elsewhere; attendance and QR check-in components are wired into their teaching sheets.ClinicalNoteEditorsuppresses auto-save on shared devices (hydration-safe), clears drafts on account transitions, and blocks de-identified PHI from note fields; handover scratchpad saves are explicitly ephemeral.- Roster APIs detect own-shift overlaps against stored shifts, reject swap approvals that introduce rule warnings (HTTP 409), and batch
listOwnerTeamsfrom 401 queries down to 3; owner team counts page past 10,000 members. - Teaching display links can only be revoked by the organising clinician; EPA assessments can be completed externally via a 14-day single-use SHA-256 magic link (strict registration await, used links can't re-register, PHI rejected). The
respond/[token]page andclinical-math-panelare registered in the design-system adoption contract. - Differential and document search results render progressively via
useVirtualWindow, and duplicate/on-call/contactsand/on-call/referralsroutes consolidate behind?show=.
RAG, math, and sign-offs
- Collapses redundant Supabase hydration round-trips, adds a 4-second interactive embedding timeout that falls back to lexical retrieval, and fixes PDF extraction (prose no longer absorbed into the bottom table row; lateral table extensions and wrapped single-column rows recovered); dead word-boundary regex stems are fixed.
- Corrects ACSQHC Tall Man lettering and word-boundary compound matching, adds Devine Ideal Body Weight to Cockcroft–Gault (used only when actual weight exceeds it, based on height), and fixes lithium toxicity and dialysis thresholds; the clinical math panel is live on
/calculators. - Records
Josh Simpsonsign-offs across therapies, MHA 2014 sections, DSM-5-TR specifiers, TGA medication sources, forms, WA service records, and the interaction lexicon; Indigenous-content records stay held for Aboriginal governance review. - Adds
apply-specifier-worksheet.mjsandpublish-site-content-first-catalogue.ts(dry-run by default, fail-closed on unnamed reviewers and missing clinical content pins); no destructive migration included and the bundle baseline stays at the approved 2026-08-19 ceiling.
Summary by CodeRabbit
-
New Features
- Added secure, single-use EPA assessment links for external supervisors to submit assessments.
- Added renal, QTc, and lithium calculators to search, with clinical guidance and dose warnings.
- Added QR scanning for teaching check-ins and improved roster attendance views.
- Added conflict warnings when creating or importing shifts, and safeguards for concurrent roster edits and swap approvals.
- Improved clinical note privacy with patient-detail checks and shared-device save controls.
- Expanded medication source links and clinical search recognition of relevant terminology.
-
Bug Fixes
- Improved PDF table extraction to recover rows at table edges.
CodeAnt-AI Description
Enable account-free EPA assessments and reduce clinical workflow errors
What Changed
- External supervisors can submit a time-limited, single-use EPA assessment without a CLA account. Patient-identifying details are blocked from assessment requests and feedback.
- The calculator page now includes renal, QTc, and lithium tools, with safer weight handling and lithium toxicity checks and dose rounding.
- Clinical notes warn against patient details, pause background saving on shared devices, and clear when account or patient-label data is cleared. Teaching check-in also supports scanning QR codes in the app.
- Roster tools flag overlapping shifts, detect when safe-number edits conflict with newer changes, and recheck swap rules before approval.
- Clinical search uses shorter embedding timeouts, recognizes more medication action wording, and recovers additional rows from clipped PDF tables.
- Publication plans for services and forms require named human clinical sign-off; review records for mental health forms and guidance are updated.
Impact
✅ Account-free, single-use EPA submissions
✅ De-identified notes stay off shared-device auto-save
✅ Fewer conflicting roster edits and unsafe swap approvals
✅ Faster clinical searches with recovered table rows
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.