Add patient-info medication considerations/alerts#620
Conversation
Surface per-patient prescribing considerations from the patient-match metadata already carried on medication records (factors, action, severity, structured match criteria, source-backed notes) in the catalogue snapshot. Previously this data was only rendered as static badges; there was no way to evaluate it against a specific patient. - New pure engine (medication-patient-alerts.ts) evaluates a PatientProfile against a medication's rows: age/eGFR/CrCl/serum creatinine/QTc/hepatic gates plus pregnancy, breastfeeding, and allergy-class factors, with safety-first "unassessed" reporting for contraindication gates the profile did not supply. - Shared, sessionStorage-backed profile (external-store pattern) via a provider mounted in GlobalSearchShellClient, so the profile carries between the prescribing search and medication detail pages. Anonymous physiology only; no PHI, cleared on tab close. - Reusable PatientProfilePanel form (age, renal function with unit toggle, hepatic severity, QTc, pregnancy/breastfeeding, allergies) reusing existing field/toggle/badge primitives. - Detail page renders tone-coded considerations via InlineNotice with factor + reason badges and an all-clear/empty state; prescribing result rows show a per-row alert badge. - Unit tests cover every match key, unit conversion, factor triggers, factor/match dedupe, partial/empty profiles, sort order, and a full-corpus smoke test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JBemWnYhqdGXBzwJUTQAqe
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughAdds session-scoped patient profiles, medication alert evaluation, editable profile UI, and patient-specific considerations across medication search and detail views, with dashboard provider wiring and evaluator tests. ChangesPatient considerations
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: one or more packages not found in the registry. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JBemWnYhqdGXBzwJUTQAqe
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Record that the patient-info medication considerations feature (PR #620) is a new patient-specific decision-support surface whose formal TGA SaMD classification is an open decision for a human/regulatory reviewer. Captures existing mitigations and open questions; asserts no classification. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JBemWnYhqdGXBzwJUTQAqe
Summary
Brings the Medications app's "fill in a patient → see prescribing considerations" feature into the Database app, on both medication surfaces.
The catalogue snapshot (exported from the Medications app) already carries per-row patient-match metadata (
factors,action,severity, structuredmatchcriteria, and source-backednote) on 754 rows across 321/328 records — previously only rendered as static badges. This PR adds the missing interactive layer:src/lib/medication-patient-alerts.ts(pure, framework-free): evaluates aPatientProfileagainst a medication's rows —age/egfr/crcl/scr/qtc/hepaticgates (OR across keys) plus pregnancy, breastfeeding, and allergy-class factors — returning tone-coded considerations with human-readable reasons, plus a safety-firstunassessedlist for contraindication gates the profile didn't supply (a blank field is never read as an all-clear). Amatchkey is authoritative for the factors it covers, so a numeric gate and its factor never double-report.patient-profile-storage.ts+patient-profile-context.tsx: asessionStorage-backed external store (same pattern asuse-theme/use-sidebar-collapsed), provider mounted inGlobalSearchShellClientso the profile carries between the prescribing search and detail pages. Anonymous physiology only — no PHI, cleared on tab close.patient-profile-panel.tsx: age, renal function (eGFR/CrCl/serum creatinine + µmol/L↔mg/dL toggle), hepatic severity, QTc, pregnancy/breastfeeding, allergy classes — reusing existingfieldControl*/ToggleSwitch/badge primitives.medication-record-page.tsx): a "Considerations for this patient" block above the tabs — considerations viaInlineNoticewith factor + reason badges, an all-clear success state, and an empty-state prompt.medication-prescribing-workspace.tsx): a compact panel above the filter strip and a per-row "N alerts" badge tone-coded to the highest-severity consideration.Verification
npm run lint— cleannpm run typecheck— clean for changed files (3 pre-existing errors intests/ui-accessibility.spec.tsfrom a missing@axe-core/playwrightdev dependency, unrelated to this change)npm run test— 2045 passed / 3 skipped, including newtests/medication-patient-alerts.test.ts(19 tests: every match key + inclusive edges, mg/dL→µmol/L conversion, factor triggers, factor/match dedupe, partial/empty profiles +unassessed, severity sort, and a full-corpus smoke test)brand:check/check:type-scale/check:icon-scale— passnpm run verify:pr-local— not run (production build step) in this environment; equivalent sub-checks run individually abovenpm run verify:ui— ran a targeted Chromium script instead of the full Playwright suiteNo retrieval/ranking/selection/chunking/answer-generation changes, so the RAG/answer eval gates are not applicable.
Clinical Governance Preflight
This adds a patient-specific decision-support view over existing source-backed medication data (client-side only; no ingestion/answer/privacy/Supabase changes).
noteand a "Decision support, not medical advice" disclaimerClinical KB Database(sjrfecxgysukkwxsowpy) — no Supabase/schema changesNotes
BigSimmo/Medicationswas blocked by an approval this environment couldn't grant, so the engine was built to the shared exported data contract (authoritative, since Database's snapshot is the Medications export). Three heuristic thresholds —RENAL_IMPAIRMENT_EGFR = 60,QTC_PROLONGED_MS = 450, elderly ≥ 65 / paediatric < 18 — apply only to bare factors that carry no numericmatch, and are named constants for one-edit tuning if the reference app uses different cut-offs.patientBadgesforegfr/crcl/qtc/hepatic) was intentionally left out to keep the diff additive.🤖 Generated with Claude Code
https://claude.ai/code/session_01JBemWnYhqdGXBzwJUTQAqe
Generated by Claude Code
Summary by CodeRabbit
New Features
Tests