Skip to content

feat(medications): patient details dock pill and drug-interaction alerting - #1874

Merged
BigSimmo merged 22 commits into
mainfrom
claude/patient-interactions-drug-alerts-3tztvw
Aug 13, 2026
Merged

feat(medications): patient details dock pill and drug-interaction alerting#1874
BigSimmo merged 22 commits into
mainfrom
claude/patient-interactions-drug-alerts-3tztvw

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Docked "Patient details" pill on the prescribing results view. It portals into a new phone-dock addon slot inside the search composer's <form>, so it inherits the dock's fixed positioning, z-index, safe-area padding and scroll-hide transform rather than adding a second scroll owner or any bottom-offset arithmetic. Single 48px row (the --spacing-tap floor), quiet while the profile is empty and accent-filled with a count once it is populated. Tapping it opens the existing Sheet around PatientProfilePanel.
  • data-footer-addon is now derived from an addon kind instead of being hardcoded to "differentials-compare" whenever any slot id was present, which would have silently mislabelled a second claimant's dock. The two claimants are mutually exclusive by surface (differentials vs prescribing) and tests/phone-dock-addon-contract.test.ts pins that, along with the four coupled numbers each kind needs: clearance tokens, reserve constant and resolver branches, backdrop scrim heights, and the hide-transform overshoot.
  • Current-medication list on the patient profile. PatientProfile.medications (catalogue slugs only) in the same session-scoped sessionStorage store, with a search-and-add picker in the panel. Slugs are shape-validated in the storage layer rather than against the catalogue, deliberately, so the medication catalogue is not pulled into the global shell bundle via PatientProfileProvider.
  • Drug-interaction data layer. The catalogue's 523 Key Interactions rows are prose, not structured pairs ("CRITICAL — MAOIs, Tramadol, Tapentadol, St John's Wort."), and only ~58% name a catalogue drug literally. scripts/build-medication-interaction-index.ts (npm run medications:interactions) resolves them through the curated src/lib/medication-interaction-lexicon.ts into the generated data/medication-interaction-index.json, staleness-gated by npm run check:medication-interactions. 400 of 523 rows resolve; the remaining 123 are recorded as unresolved rather than dropped, because dropping them would manufacture a false all-clear.
  • Interaction evaluation and verdicts. src/lib/medication-interactions.ts matches the index against the entered medication list. composeMedicationVerdict folds it together with the existing physiology engine into the single tone a result row wears, taking the highest tone across both — with one override that is the point of the function: if either engine left anything unassessed or unresolved, a would-be green degrades to a neutral "needs manual review". Green is unreachable on incomplete data.
  • Red/amber/green/grey edges on prescribing result rows, plus an "Interactions with this patient's medications" block on the medication detail page rendering the verbatim catalogue row text and naming the counterparty.

Two notes on things found while building, rather than assumed:

  • The phone cards' verdict edge is set from unlayered CSS (.medication-mobile-result[data-verdict="…"]), not a Tailwind utility. The existing [data-selected="true"] rule is unlayered and pins border-color, so a utility lost to it on exactly the top hit — the row most likely to be prescribed would have rendered its interaction warning with a neutral edge. Desktop rows keep ring-*, matching the mechanism that surface already used, so no surface mixes border-* and ring-*.
  • /medications and /medications/[slug] deliberately do not claim the addon. /medications is a standalone mode home with the composer in the hero and no dock to portal into, and the detail route already opens the same patient sheet from its own nav header — a pill there would be a second entry point to one destination, and claiming the addon would inflate the dock reserve for a pill that never mounts.

Verification

  • npm run verify:pr-local — all 16 stages green: completed: check:runtime, check:installed-lock-parity, format:changed, check:npm-ci-dry-run, sitemap:check, docs:check-index, docs:check-inventory, docs:check-scripts, docs:check-links, check:branch-review-ledger, check:outstanding-issues, lint, typecheck, test, build, check:rag:fixtures / failed: (none).
  • Full unit suite: Test Files 567 passed (567), Tests 6206 passed | 4 skipped.
  • New coverage: tests/medication-interactions.test.ts, tests/medication-interaction-lexicon-coverage.test.ts, tests/medication-interaction-surfaces.dom.test.tsx, tests/patient-details-dock-action.dom.test.tsx, tests/patient-profile-medications.dom.test.tsx, tests/phone-dock-addon-contract.test.ts — 96 assertions across the six.
  • Phone-chrome static contract stage run directly: Test Files 9 passed (9), Tests 129 passed (129).
  • npm run check:bundle-budgetproduction (what users download, 101 routes): 1314.1 KiB gzip — baseline 1279.1 KiB, within tolerance. The interaction index costs ~15 KiB gzip; it was restructured mid-build from 661 KB to 249 KB raw by dropping the row text and counterparty names, both of which every consumer already holds.

UI verification not run: npm run verify:phone-chrome cannot complete its browser stages in this environment — the image ships Chromium 1194 while Playwright 1.62.1 wants 1234 (the drift tracked as /issues #255), and docs/testing.md says not to force a mismatched browser path. Its static contract stage passed as above; the Chromium journeys are delegated to CI Production UI.

Manual phone-viewport proof was captured against a local dev server at 390×844 instead, confirming: the pill renders at 48px above the composer with data-footer-addon="patient-details"; the sheet opens and the picker adds medications; result rows take red edges with "2 interactions" / "1 interaction" badges; and on scroll down the dock takes data-scroll-hidden="true" and the pill moves from y=729 to y=860 (off-screen) and back on scroll up, with no peep strip at the viewport edge.

  • npm run check:production-readiness — run; the two FAILs are the documented offline-Cloud provider gap (Missing server environment variables: NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, Missing OPENAI_API_KEY), not introduced by this diff. The two PASS lines (Node runtime, query-hash HMAC boot guard) are unaffected.

RAG impact: no retrieval behaviour change — nothing under src/lib/rag/**, clinical-search, retrieval-selection, ranking-config, answer-ranking, the eval harness or the golden fixture is touched. The change is confined to the medication catalogue surfaces and phone dock chrome; check:rag:fixtures passed unchanged (36 golden cases, 23 suites).

Risk and rollout

  • Risk: the lexicon is hand-curated, so a missed term is a false negative. It is fail-safe by construction — an unresolved row forces the neutral "needs manual review" state rather than green — but the resolution rate is 400/523, not 100%. tests/medication-interaction-lexicon-coverage.test.ts ratchets that figure so it cannot silently regress, and pins the two class-matching traps by name: clozapine and olanzapine must never resolve as benzodiazepines (their subclasses are SGA / Dibenzodiazepine and SGA / Thienobenzodiazepine), and naltrexone must never resolve as an opioid (Opioid Antagonist). The secondary risk is alert fatigue from over-matching; counterparty resolution is therefore restricted to the first sentence after the severity token, so mitigation advice later in a row ("cover with PPI if combined") cannot flag a patient's PPI as interacting.
  • Rollback: revert the commit. The generated index and the two new lib modules have no other consumers, and the addon-kind prop defaults to "differentials-compare", so the dock returns to its prior single-claimant behaviour.
  • Provider or production effects: None. Everything here is a committed JSON artefact, pure TypeScript, Vitest and local Chromium — no Supabase, no OpenAI, no migrations, no schema change.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use — every interaction renders the verbatim catalogue row text rather than a paraphrase, and the existing "Decision support, not medical advice" disclaimer is unchanged and still shown on the panel.
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval — the medication list is catalogue slugs on the existing anonymous, session-scoped profile that clears on tab close; no identifiers, no free text, no persistence beyond the tab, and nothing is sent to a server.
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — no Supabase file, migration, env value or client call is touched by this change.
  • Service-role keys and private document access remain server-only — no auth, owner-scope, query-privacy or API-route code is modified; the new modules are pure functions over a committed JSON artefact.
  • Demo/synthetic content remains clearly separated from real clinical sources — the interaction index is generated solely from the committed data/medications-snapshot.json catalogue export and carries provenance (slug, rowKey, rowIndex) back to it for every row; no demo corpus is involved.
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative — this is the central design decision. Green means "no interaction found among the medications you entered", never "safe", and is unreachable whenever any row on that medication could not be machine-resolved. Unknown severity tokens map to neutral rather than success, non-drug counterparties (alcohol, grapefruit, smoking, dietary timing) can never produce a patient-medication match, and the picker accepts catalogue drugs only so a clinician cannot enter a drug the tool has no data for and read the resulting silence as an all-clear.
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed — docs/samd-classification-medication-considerations.md is updated in this PR to record that interaction alerting materially widens the surface its OPEN question covers. Interaction checking is a canonical clinical-decision-support function, and unlike the physiology considerations it produces an alert about a specific combination the clinician has entered. The note's status is unchanged and this PR does not resolve it; the reviewer's open questions now need answering for this surface too, and a named clinical + regulatory reviewer is still required.

Notes

  • Colour is never the only channel: every verdict carries an icon and a text label alongside the edge, which is also what keeps forced-colors mode readable.
  • The new dock pill portals at 639px to match .phone-footer-layer's sm:fixed, deliberately not the 1023px the two existing Compare bars use — between 640px and 1023px those portal into a slot on a form that is not fixed. That pre-existing mismatch is left alone here rather than fixed in passing, but is called out in docs/search-chrome-behaviour.md so it is not copied again.
  • The three new unlayered CSS classes carry style-contract exemptions rather than rendered-effect contracts, matching the sibling Compare FAB. A real contract needs a phone-viewport route with the medication catalogue loaded, and the tap floor (min-height: 3rem) is the regression worth catching there — worth a follow-up rather than an unverifiable browser assertion added blind.

Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added medication interaction checking to medication records and prescribing results.
    • Displays severity-based verdicts, interaction summaries, matched medication details, and manual-review warnings.
    • Added catalogue-based medication selection to patient profiles, with search, removal, persistence, and validation.
    • Added a mobile Patient Details action with profile completion count and bottom-sheet access.
    • Improved mobile dock behavior and spacing for patient details and comparison actions.
  • Documentation

    • Expanded guidance covering medication interaction behavior, patient context, mobile dock interactions, and regulatory classification.
  • Tests

    • Added coverage for interaction evaluation, medication selection, verdict displays, and mobile Patient Details behavior.

…rting

Adds a docked "Patient details" pill to the prescribing results view and
cross-checks each medication against the patient's current medication list,
surfacing red/amber/green/grey verdicts on result rows and matched
interactions on the medication detail page.

The patient-considerations engine already existed (physiology only, session
-scoped). This extends the same profile with a medication list and adds a
second engine beside it:

- `data/medication-interaction-index.json` (generated) resolves the
  catalogue's prose `Key Interactions` rows to catalogue targets using the
  curated `medication-interaction-lexicon.ts`. 400 of 523 rows resolve; the
  rest are recorded as unresolved rather than dropped.
- `medication-interactions.ts` matches those rows against the entered list.
- `composeMedicationVerdict` folds both engines into one tone, and makes
  green unreachable whenever either engine left something unassessed or
  unresolved — those degrade to a neutral "needs manual review" state.

The pill portals into a new phone-dock addon slot, inheriting the composer's
fixed positioning, safe area and scroll-hide transform rather than adding a
second scroll owner. `data-footer-addon` is now derived from an addon kind
instead of hardcoding the differentials claimant.

Regulatory status is unchanged and still open: this materially widens the
surface tracked in docs/samd-classification-medication-considerations.md,
which is updated to say so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X12okkARLhFQ2zgcPoFp54
@supabase

supabase Bot commented Aug 12, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 35 minutes

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

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4322661a-dbde-488d-8747-aea7bfbff367

📥 Commits

Reviewing files that changed from the base of the PR and between 101acc0 and 550b986.

📒 Files selected for processing (1)
  • tests/ui-stress.spec.ts
📝 Walkthrough

Walkthrough

This change adds catalogue-based medication interaction indexing, bounded patient medication profiles, fail-safe verdict composition, prescribing-result and medication-detail interaction surfaces, and a mobile patient-details dock action.

Changes

Patient interaction alerts

Layer / File(s) Summary
Interaction index and lexicon
scripts/build-medication-interaction-index.ts, src/lib/medication-interaction-lexicon.ts, package.json, scripts/verify-pr-local.mjs, tests/medication-interaction-lexicon-coverage.test.ts
The interaction lexicon and deterministic index builder now resolve catalogue counterparties, preserve unresolved rows, record severity and audit data, and support build and check commands with verification coverage.
Patient medication profile and mobile dock
src/lib/patient-profile-storage.ts, src/components/clinical-dashboard/patient-profile-context.tsx, src/components/clinical-dashboard/patient-profile-panel.tsx, src/components/clinical-dashboard/patient-details-dock-action.tsx, src/components/ClinicalDashboard.tsx, src/app/globals.css, tests/patient-*, tests/phone-dock-addon-contract.test.ts
Patient profiles store sanitized medication slugs. The mobile patient-details action opens a bottom sheet, portals into the phone dock, tracks responsive dock state, and updates composer reserve and styling contracts.
Interaction evaluation and prescribing surfaces
src/lib/medication-interactions.ts, src/components/clinical-dashboard/medication-prescribing-workspace.tsx, src/components/clinical-dashboard/medication-considerations.tsx, src/components/clinical-dashboard/medication-record-page.tsx, src/components/clinical-dashboard/medication-nav-header.tsx, tests/medication-interactions.test.ts, tests/medication-interaction-surfaces.dom.test.tsx
Interaction results are matched in both directions, deduplicated, sorted, and composed with physiology alerts. The UI renders verdict badges, rings, callouts, detail blocks, counterparty links, manual-review states, and interaction-tab navigation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Mergeability Score: 🟠 High · up to 101ac

The interaction alert can currently display “No interaction found” even when some interaction data remains unresolved, which could cause clinicians to interpret incomplete data as a clean result. Merge should be blocked until the clear-result message is suppressed for incomplete evaluations.

Sequence Diagram(s)

sequenceDiagram
  participant PatientProfilePanel
  participant PatientProfileContext
  participant MedicationPrescribingWorkspace
  participant MedicationInteractionCallout
  PatientProfilePanel->>PatientProfileContext: select catalogue medication
  PatientProfileContext->>MedicationPrescribingWorkspace: persist medication profile
  MedicationPrescribingWorkspace->>MedicationInteractionCallout: provide composed verdict
  MedicationInteractionCallout->>PatientProfilePanel: open patient details or interaction section
Loading

Possibly related PRs

  • BigSimmo/Database#454: Adds the verification workflow that this change extends with medication-interaction checks.
  • BigSimmo/Database#473: Modifies the shared mobile dock and composer placement infrastructure used by the patient-details addon.
  • BigSimmo/Database#477: Modifies medication prescribing result rendering where this change adds composed safety verdicts.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two primary changes: the patient-details dock pill and medication interaction alerting.
Description check ✅ Passed The description completes the required sections, documents verification and risks, and provides the required clinical governance details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/patient-interactions-drug-alerts-3tztvw

Comment @coderabbitai help to get the list of available commands.

Comment thread src/lib/medication-interactions.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d87f7b115d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/build-medication-interaction-index.ts Outdated
Comment thread scripts/build-medication-interaction-index.ts Outdated
Comment thread src/lib/medication-interactions.ts Outdated
Comment thread scripts/build-medication-interaction-index.ts Outdated
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Production UI (3)needs investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #10297 (cancelled).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds patient-context-driven UI and data plumbing to the medications/prescribing surfaces: a docked “Patient details” pill on phone, a session-scoped current-medications list, and a generated interaction index + runtime evaluation to surface drug–drug interaction alerts and conservative “needs manual review” states.

Changes:

  • Introduces a phone dock addon registry (PhoneDockAddonKind) and wires a new “patient-details” addon through the dashboard/shell/header reserve + CSS contracts.
  • Adds patient profile medication-list storage + UI picker, plus a docked pill that portals into the phone dock and opens the existing patient details sheet.
  • Adds a generated medication-interaction index (build script + checks) and runtime interaction evaluation, integrating verdict tones into prescribing result rows and the medication detail page.

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/phone-dock-addon-contract.test.ts New contract test pinning addon registry, exclusivity, and coupled CSS/TS reserve wiring.
tests/patient-profile-medications.dom.test.tsx New DOM tests for the current-medications picker, storage sanitisation, and profile-emptiness semantics.
tests/patient-details-dock-action.dom.test.tsx New DOM tests ensuring the dock pill portals correctly, respects breakpoint, and opens the sheet accessibly.
tests/medication-interactions.test.ts New unit tests for interaction evaluation, naming, unresolved-row behavior, and verdict composition.
tests/medication-interaction-surfaces.dom.test.tsx New DOM tests for interaction rendering on detail page and verdict presentation contracts across surfaces.
tests/medication-interaction-lexicon-coverage.test.ts New ratchet-style coverage tests + deny-list pins for lexicon resolution safety.
tests/helpers/style-contracts.ts Adds style-contract exemption entries for new unlayered CSS classes.
src/lib/patient-profile-storage.ts Extends persisted patient profile with medications, adds slug sanitisation + max-list cap.
src/lib/mode-home-composer.ts Adds the PhoneDockAddonKind registry and new addon slot id for patient details.
src/lib/medication-patient-alerts.ts Extends PatientProfile type + emptiness check to treat medications as “profile populated”.
src/lib/medication-interactions.ts New runtime interaction evaluation + verdict composition utilities backed by generated index JSON.
src/lib/medication-interaction-lexicon.ts New curated lexicon mapping prose interaction counterparties to catalogue targets with explicit traps/denylists.
src/components/ClinicalDashboard.tsx Wires prescribing mode to claim the patient-details addon slot/kind and reserve behavior.
src/components/clinical-dashboard/patient-profile-panel.tsx Adds medication picker UI into the patient profile panel.
src/components/clinical-dashboard/patient-profile-context.tsx Adds toggleMedication to context and ensures clear includes medications.
src/components/clinical-dashboard/patient-details-dock-action.tsx New dock pill that portals into the phone dock addon slot and opens the patient details sheet.
src/components/clinical-dashboard/mobile-composer-reserve.ts Adds patient-details reserve constant and resolver branches for dashboard/shell.
src/components/clinical-dashboard/medication-prescribing-workspace.tsx Integrates interaction evaluation + composed verdict into prescribing result rows and phone/desktop styling.
src/components/clinical-dashboard/medication-considerations.tsx Adds interaction block on medication detail page and verdict helper exports for rows/badges.
src/components/clinical-dashboard/master-search-header.tsx Derives data-footer-addon from addon kind (with fallback), and accepts addon kind prop.
src/components/clinical-dashboard/global-search-shell.tsx Ensures shell only claims the differentials addon and passes addon kind consistently.
src/app/globals.css Adds unlayered CSS for patient details pill, verdict borders for phone cards, and addon-kind dock wiring.
scripts/build-medication-interaction-index.ts New build/check script producing the interaction index artefact from snapshot + lexicon.
package.json Adds medications:interactions and check:medication-interactions scripts.
docs/search-chrome-behaviour.md Documents the phone dock addon slot rules, registry, and coupled constants/contracts.
docs/scripts-index.md Updates script/file counts after adding the new script and package entries.
docs/samd-classification-medication-considerations.md Notes that interaction alerting widens the clinical decision-support scope under review.
docs/design-system/COMPONENTS.md Updates generated design-system component inventory count.
docs/design-system/adoption-manifest.json Adds the new component to the design-system adoption manifest snapshot.
docs/codebase-index.md Updates architecture index with the new patient-context/interaction subsystem.
docs/branch-review-ledger.md Appends a branch review ledger entry for this PR’s work.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/clinical-dashboard/patient-profile-panel.tsx
Comment thread src/components/clinical-dashboard/patient-details-dock-action.tsx
…ery verdict

Three follow-ups on the interaction work.

Interactions are now stated on the medication page itself, not only behind
the patient sheet. `MedicationInteractionCallout` renders above the record
when the entered profile matches: the three highest-severity interactions,
each naming the counterparty as a link to its own record, the verbatim
catalogue wording, a "+N more" count, and buttons through to the full Key
Interactions section and the patient sheet. Arriving from a result row
flagged "2 interactions" no longer means hunting for them.

The counterparty is also linked from each row of the in-sheet block.

The tab the "See Key Interactions" control switches to is derived from the
section-type table via `medicationTabForSectionType` rather than hardcoded,
so a section that moves between tabs cannot leave the control pointing at
the tab it used to be in.

Every verdict tone now carries its own glyph on the result cards — shield
-check for "no interaction found", help-circle for "needs manual review",
alongside the existing ban and triangle. `ClinicalBadge` only auto-ices
danger and warning to keep ordinary badges quiet; that default is right in
general and wrong for a safety verdict, where "checked, nothing found" and
"could not check" have to be told apart without reading the border colour.
Overridden for this badge only, not in the shared default.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X12okkARLhFQ2zgcPoFp54

Copy link
Copy Markdown
Owner Author

@codex Address all currently unresolved inline review comments on this PR against the current GitHub head. Treat the interaction findings as clinical-safety defects: absence of index data must never produce green, preserve relevant later interaction clauses, keep mixed unresolved mechanisms incomplete, evaluate pair edges bidirectionally, make the stale-index check formatting-stable, remove render-phase state reset, and scope the dock MutationObserver to phone mode. Add focused regressions for methadone+diazepam, cetirizine+diazepam, reverse naltrexone/buprenorphine-naloxone, missing index data, and UI state/observer behavior. Run proportionate verification and push minimal fixes. Do not merge, close, rebase, force-push, deploy, or alter auto-merge. Please report the exact commit SHA and test results.

Copy link
Copy Markdown
Owner Author

@codex Work PR #1874 from current head 76a22e4a1106a205fe9c3055541c3404bf1021a2 and resolve every unresolved review thread as a clinical-safety pass. Required outcomes: missing interaction-index data must force manual review, never green; preserve clinically relevant later interaction clauses (including methadone + diazepam); unresolved mechanism terms in mixed rows must remain incomplete (including cetirizine + diazepam); evaluate medication-pair edges bidirectionally (including reverse naltrexone / buprenorphine-naloxone); make the generated-index staleness check formatting-stable; move MedicationPicker reset out of render phase; and create/disconnect the dock MutationObserver only while phone media matches. Add focused failing regressions for all named cases and UI lifecycle behaviour, regenerate the index deterministically, run interaction/index/DOM/dock tests plus proportionate lint/typecheck/format and local verification, push only to claude/patient-interactions-drug-alerts-3tztvw, verify the PR head, reply with the exact SHA, and resolve all seven threads. Do not merge, close, rebase, force-push, deploy, trigger live providers, or alter auto-merge.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76a22e4a11

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/medication-interactions.ts Outdated
Comment thread src/components/clinical-dashboard/patient-profile-panel.tsx
Comment thread src/components/clinical-dashboard/patient-details-dock-action.tsx Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • node scripts/run-vitest.mjs run tests/medication-interactions.test.ts tests/medication-interaction-lexicon-coverage.test.ts tests/patient-profile-medications.dom.test.tsx tests/patient-details-dock-action.dom.test.tsx --reporter=dot — 4 files and 56 tests passed.
  • npm run check:medication-interactions — the formatted generated index is current across all 523 rows.
  • npm run workflow:clinical-proof -- --write-evidence --paths scripts/build-medication-interaction-index.ts,src/lib/medication-interaction-lexicon.ts,src/lib/medication-interactions.ts,src/components/clinical-dashboard/patient-profile-panel.tsx,src/components/clinical-dashboard/patient-details-dock-action.tsx
  • npm run format
  • git diff --check
  • ⚠️ npm run verify:pr-local — runtime, lock parity, formatting, npm dry-run, documentation checks, ledger checks, lint, and typecheck passed; the full suite reached 566 passing files and 6,211 passing tests, but four unrelated tests/pr-handoff-stop.test.ts cases timed out. Build and RAG-fixture stages were consequently not reached.
  • ⚠️ node scripts/run-vitest.mjs run tests/pr-handoff-stop.test.ts --reporter=dot — isolated retry also hung in the same jq-unavailable hook cases and was terminated; no changed medication or UI test failed.
  • git push -u origin codex/pr-interaction-review-fixes — failed with could not read Username for 'https://github.com'.
  • ⚠️ gh auth status — confirmed that no GitHub host is authenticated, so PR creation was unavailable.

View task →

Copy link
Copy Markdown
Owner Author

@copilot Fix all seven currently unresolved review comments on this PR at current head 76a22e4a1106a205fe9c3055541c3404bf1021a2 in one clinical-safety pass. Missing interaction-index data must force manual review, never green. Preserve relevant later interaction clauses, including methadone + diazepam. Keep mixed unresolved mechanisms incomplete, including cetirizine + diazepam. Evaluate medication-pair edges bidirectionally, including reverse naltrexone / buprenorphine-naloxone. Make the stale-index check formatting-stable. Move MedicationPicker reset out of render phase. Create and disconnect the dock MutationObserver only while phone media matches. Add focused regressions for every named case and UI lifecycle behavior, regenerate the index deterministically, run the affected interaction/index/DOM/dock tests plus lint, typecheck, and format, and push only to claude/patient-interactions-drug-alerts-3tztvw. Reply with the exact pushed SHA and test results. Do not merge, close, rebase, force-push, deploy, trigger live providers, or alter auto-merge.

Agent-Logs-Url: https://github.com/BigSimmo/Database/sessions/7cbf3386-3bdf-4ffd-bf65-c3ee5f5322f5

Co-authored-by: BigSimmo <87357024+BigSimmo@users.noreply.github.com>
auto-merge was automatically disabled August 12, 2026 20:38

Head branch was pushed to by a user without write access

@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 20:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🧹 Nitpick comments (3)
src/lib/medication-interaction-lexicon.ts (1)

84-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Exclude opioid antagonists by rule, not only by slug.

subclassIncludes: ["Opioid"] also matches the subclass "Opioid Antagonist". Only the two current antagonist slugs are denied. If the catalogue adds another antagonist, it becomes an "opioid" counterparty silently.

Add a negative subclass condition, for example subclassExcludes: ["Antagonist"], and keep denySlugs for one-off traps.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/medication-interaction-lexicon.ts` around lines 84 - 93, Update the
opioids catalogue entry’s select configuration to add a subclassExcludes rule
for “Antagonist” alongside subclassIncludes: ["Opioid"]. Retain denySlugs for
the existing naltrexone and naloxone exceptions.
tests/medication-interaction-lexicon-coverage.test.ts (1)

51-57: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add the named clinical regressions the PR comments request.

The PR comments require focused regressions for methadone with diazepam, cetirizine with diazepam, and reverse naltrexone with buprenorphine-naloxone. This suite pins counts and deny-lists but none of those pairs. Ratchet counts do not fail when a specific pair is lost.

Do you want me to draft these three pinned cases?

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/medication-interaction-lexicon-coverage.test.ts` around lines 51 - 57,
Add focused regression tests to the “interaction lexicon coverage” suite for
methadone with diazepam, cetirizine with diazepam, and reverse naltrexone with
buprenorphine-naloxone. Assert each pair resolves as expected and is not
excluded by the suite’s deny-list logic, while preserving the existing
resolvedRows and sourceRowCount ratchets.
tests/medication-interaction-surfaces.dom.test.tsx (1)

125-134: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Compare the last occurrence of the selected-row rule.

indexOf finds the first [data-selected="true"] rule only. A duplicate of that rule placed after the verdict rule keeps this test green while the cascade regresses. Use lastIndexOf for the selected rule.

♻️ Proposed change
-    const selectedAt = css.indexOf('.medication-mobile-result[data-selected="true"]');
+    const selectedAt = css.lastIndexOf('.medication-mobile-result[data-selected="true"]');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/medication-interaction-surfaces.dom.test.tsx` around lines 125 - 134,
Update the selected-row rule lookup in the test to use lastIndexOf instead of
indexOf, while leaving the verdict rule lookup and source-order assertion
unchanged. This ensures the assertion compares the verdict rule against the
final occurrence of the [data-selected="true"] selector.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/build-medication-interaction-index.ts`:
- Around line 127-142: Update counterpartySegment to retain counterparties named
in later sentences instead of truncating body to the first clause, while
continuing to exclude mitigation-advice clauses by identifying and filtering
clauses that begin with mitigation language. Preserve severityToken extraction
and ensure examples such as methadone with diazepam remain indexed without
treating mitigation mentions as counterparties.
- Around line 166-179: Update the surface-length filtering in the drugSurfaces
construction to address the four-character floor: either document its
intentional false-negative tradeoff where both filters are applied, or lower the
minimum length and rely on mentions for boundary safety. Keep the existing
deduplication, dosage-form stripping, and sorting behavior unchanged.
- Around line 288-302: Update the checkOnly branch around serialised and current
so staleness is determined by comparing parsed JSON values rather than
byte-for-byte text, while preserving the existing stale-file error, success
message, and exit behavior.
- Around line 188-255: Update the interaction consumer around
evaluateMedicationInteractions to match both directions: retain direct
INDEX.bySlug[slug] counterparties and also include records whose rows list the
evaluated slug as a counterparty. Deduplicate the resulting interactions and
preserve existing severity, term, and unresolved-row handling, so evaluating
either medication finds the same relationship.

In `@src/app/globals.css`:
- Around line 2468-2471: Update the patient-details hidden-state selector to
target the dashboard dock class `.dashboard-composer-edge` instead of
`.document-mobile-search-edge`, while preserving the existing patient-details
attributes and overshoot transform.

In `@src/components/clinical-dashboard/medication-considerations.tsx`:
- Around line 86-117: Update verdictSummaryBadge so that when findings are
present and verdict.incomplete is true, the returned label also communicates
that manual review is needed; preserve the existing interaction and alert
counts, and keep the current zero-findings incomplete behavior unchanged.

In `@src/components/clinical-dashboard/patient-profile-context.tsx`:
- Around line 58-63: Update toggleMedication to sanitize the computed next
medication list with sanitizeMedicationSlugs before passing it to
writePatientProfile, ensuring the persisted profile never exceeds the
40-selection cap. Add a regression test that toggles 41 distinct medications and
verifies the persisted/evaluated selection remains capped at 40.

In `@src/components/clinical-dashboard/patient-profile-panel.tsx`:
- Around line 3-4: Update the React import used by MedicationPicker to include
useEffect alongside useId and useState, so its existing useEffect call resolves
during TypeScript compilation.

In `@src/lib/medication-interactions.ts`:
- Around line 166-175: Update the missing-entry branch in
medication-interactions.ts around INDEX.bySlug and composeMedicationVerdict so
absent index data is explicitly reported and treated as incomplete, preventing a
success verdict. Add or update the unknown/unindexed slug assertion in
tests/medication-interactions.test.ts lines 69-74, and add the
missing-medication rendering case in
tests/medication-interaction-surfaces.dom.test.tsx lines 41-81 to expect the
manual-review notice instead of the clear notice.

In `@tests/medication-interaction-lexicon-coverage.test.ts`:
- Around line 65-70: Strengthen the test around the unresolved-row assertion by
selecting a row whose termIds are all mechanism terms and whose counterparties
are empty, then assert that specific row is unresolved. Use the existing
mechanism-term classification symbols from the test or implementation rather
than accepting any unresolved row.

In `@tests/medication-interaction-surfaces.dom.test.tsx`:
- Around line 41-81: Add a test in the interactions block for a medication
absent from the interaction index, using seedProfile and renderFor with an
appropriate unknown medication. Assert the UI shows the intended manual-review
message from the medication-interactions flow and does not present the
medication as clear.

In `@tests/medication-interactions.test.ts`:
- Around line 69-74: Extend the unknown-slug test around
evaluateMedicationInteractions and composeMedicationVerdict to assert that an
unindexed medication does not produce a success verdict. Keep the existing
empty-result and zero-count assertions unchanged, and verify the verdict is any
non-success status.

---

Nitpick comments:
In `@src/lib/medication-interaction-lexicon.ts`:
- Around line 84-93: Update the opioids catalogue entry’s select configuration
to add a subclassExcludes rule for “Antagonist” alongside subclassIncludes:
["Opioid"]. Retain denySlugs for the existing naltrexone and naloxone
exceptions.

In `@tests/medication-interaction-lexicon-coverage.test.ts`:
- Around line 51-57: Add focused regression tests to the “interaction lexicon
coverage” suite for methadone with diazepam, cetirizine with diazepam, and
reverse naltrexone with buprenorphine-naloxone. Assert each pair resolves as
expected and is not excluded by the suite’s deny-list logic, while preserving
the existing resolvedRows and sourceRowCount ratchets.

In `@tests/medication-interaction-surfaces.dom.test.tsx`:
- Around line 125-134: Update the selected-row rule lookup in the test to use
lastIndexOf instead of indexOf, while leaving the verdict rule lookup and
source-order assertion unchanged. This ensures the assertion compares the
verdict rule against the final occurrence of the [data-selected="true"]
selector.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a10e83be-78a5-4700-96b7-6613a7459727

📥 Commits

Reviewing files that changed from the base of the PR and between 5ff9b76 and 7b658ce.

📒 Files selected for processing (36)
  • data/medication-interaction-index.json
  • docs/branch-review-ledger.md
  • docs/codebase-index.md
  • docs/design-system/COMPONENTS.md
  • docs/design-system/adoption-manifest.json
  • docs/samd-classification-medication-considerations.md
  • docs/scripts-index.md
  • docs/search-chrome-behaviour.md
  • package.json
  • scripts/build-medication-interaction-index.ts
  • src/app/globals.css
  • src/components/ClinicalDashboard.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/clinical-dashboard/medication-considerations.tsx
  • src/components/clinical-dashboard/medication-nav-header.tsx
  • src/components/clinical-dashboard/medication-prescribing-workspace.tsx
  • src/components/clinical-dashboard/medication-record-page.tsx
  • src/components/clinical-dashboard/mobile-composer-reserve.ts
  • src/components/clinical-dashboard/patient-details-dock-action.tsx
  • src/components/clinical-dashboard/patient-profile-context.tsx
  • src/components/clinical-dashboard/patient-profile-panel.tsx
  • src/lib/medication-interaction-lexicon.ts
  • src/lib/medication-interactions.ts
  • src/lib/medication-patient-alerts.ts
  • src/lib/mode-home-composer.ts
  • src/lib/patient-profile-storage.ts
  • tests/helpers/style-contracts.ts
  • tests/in-page-nav-route-sections.dom.test.tsx
  • tests/medication-interaction-lexicon-coverage.test.ts
  • tests/medication-interaction-surfaces.dom.test.tsx
  • tests/medication-interactions.test.ts
  • tests/medication-record-page.dom.test.tsx
  • tests/patient-details-dock-action.dom.test.tsx
  • tests/patient-profile-medications.dom.test.tsx
  • tests/phone-dock-addon-contract.test.ts

Comment thread scripts/build-medication-interaction-index.ts
Comment thread scripts/build-medication-interaction-index.ts
Comment thread scripts/build-medication-interaction-index.ts Outdated
Comment thread scripts/build-medication-interaction-index.ts Outdated
Comment thread src/app/globals.css
Comment thread src/components/clinical-dashboard/patient-profile-panel.tsx
Comment thread src/lib/medication-interactions.ts Outdated
Comment thread tests/medication-interaction-lexicon-coverage.test.ts
Comment thread tests/medication-interaction-surfaces.dom.test.tsx
Comment thread tests/medication-interactions.test.ts Outdated

Copy link
Copy Markdown
Owner Author

@claude Address every currently unresolved inline review thread on this PR against the current GitHub head. First distinguish outdated duplicate threads from still-live findings and resolve outdated duplicates only after verifying their underlying fix remains present. For live findings: (1) document or safely lower the four-character drug-surface floor without increasing false positives; (2) fix the patient-details hidden-state selector so the prescribing/dashboard dock receives the required overshoot; (3) when findings exist but the interaction verdict is incomplete, surface the manual-review caveat alongside the counts; (4) enforce the 40-medication cap before persistence using the existing sanitizer and add a 41-selection regression; (5) strengthen the mechanism-only unresolved-row test to prove the specific mechanism condition. Preserve all prior clinical-safety fixes including missing-index fail-safe behavior, later-clause parsing, mixed mechanism incompleteness, bidirectional edges, formatting-stable staleness checks, post-render picker reset, and phone-only MutationObserver lifecycle. Run focused interaction/profile/dock tests plus typecheck/format as proportionate, push only minimal fixes to this PR branch, reply with exact pushed SHA and verification, and resolve every satisfied thread. Do not merge, close, rebase, force-push, deploy, alter auto-merge, or call live providers.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @BigSimmo — thanks for the @claude mention.

Open this in Claude Code on the web to continue here: https://claude.ai/code

Context: BigSimmo/Database · #1874

Automated backlink from the Claude backlink workflow. Claude Code can pick up the mention and push a scoped fix to the branch.

The committed `data/medication-interaction-index.json` no longer matched the
lexicon and build script on this branch — several commits changed both
without regenerating the artefact the UI actually reads, so the app was
serving safety verdicts derived from an older resolution pass.

Nothing caught it: I added `check:medication-interactions` when the artefact
was introduced but never wired it into `verify:pr-local`, so a stale index
sailed through a green gate. It now runs on every executable scope,
alongside `check:rag:fixtures`, with the plan self-test updated to match.

Regenerating moves two numbers in opposite directions, and both are
improvements:

- `resolvedRows` 400 → 355, because a row carrying any unenumerated
  mechanism is now unresolved even when it also matched a named drug.
  "CYP3A4 inhibitors (Clarithromycin, Ketoconazole)" used to resolve on
  clarithromycin and count as fully read, implying the whole class had been
  checked. More medications now hold at grey.
- `rowsWithCatalogueTarget` 381 → 417, from the shorter catalogue-name
  matching floor.

The coverage ratchet is re-anchored accordingly and now pins both numbers,
because a single "resolved rows" figure conflates coverage with resolution
strictness and would otherwise fight a legitimate tightening.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X12okkARLhFQ2zgcPoFp54
@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 21:24
@BigSimmo
BigSimmo disabled auto-merge August 12, 2026 21:25

Copy link
Copy Markdown
Owner Author

@claude This PR is currently mergeable_state: dirty against current main at head ff417052ada202f1db7da358fb2ef35e43a5f04b, with all inline review threads already resolved. Fetch current main and merge it into this PR branch without rebasing or force-pushing. Resolve only the merge conflicts, preserving the medication-interaction safety fixes already verified on this branch and all newer main changes. Run conflict-adjacent format/typecheck plus focused medication interaction tests, push the merge-resolution commit to this PR branch, and report the pushed SHA and verification. Do not merge or close the PR, deploy, alter auto-merge, or broaden scope.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @BigSimmo — thanks for the @claude mention.

Open this in Claude Code on the web to continue here: https://claude.ai/code

Context: BigSimmo/Database · #1874

Automated backlink from the Claude backlink workflow. Claude Code can pick up the mention and push a scoped fix to the branch.

@claude

claude Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 21:41
@BigSimmo
BigSimmo disabled auto-merge August 12, 2026 21:51
@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 21:54
@BigSimmo
BigSimmo disabled auto-merge August 12, 2026 22:05
@BigSimmo
BigSimmo enabled auto-merge (squash) August 12, 2026 22:07
@BigSimmo
BigSimmo disabled auto-merge August 12, 2026 22:48
@BigSimmo
BigSimmo enabled auto-merge (squash) August 12, 2026 23:07
@BigSimmo
BigSimmo disabled auto-merge August 12, 2026 23:17
@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 23:38
@BigSimmo
BigSimmo disabled auto-merge August 12, 2026 23:51
@BigSimmo
BigSimmo enabled auto-merge August 13, 2026 00:07
@BigSimmo
BigSimmo disabled auto-merge August 13, 2026 00:17
@BigSimmo
BigSimmo enabled auto-merge August 13, 2026 00:37
@BigSimmo
BigSimmo disabled auto-merge August 13, 2026 01:07
@BigSimmo
BigSimmo enabled auto-merge August 13, 2026 01:07
@BigSimmo
BigSimmo disabled auto-merge August 13, 2026 01:08
@BigSimmo
BigSimmo enabled auto-merge August 13, 2026 01:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/clinical-dashboard/medication-considerations.tsx (1)

404-408: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not show a clear result for incomplete interaction data.

If result.dataAvailable is false or result.unresolvedRowCount is positive, this branch still states “No interaction found.” Lines 442-453 then state that the result needs manual review. Suppress the clear-result notice unless all rows were evaluated.

Proposed fix
-      ) : result.interactions.length === 0 ? (
+      ) : result.interactions.length === 0 && result.dataAvailable && result.unresolvedRowCount === 0 ? (
         <InlineNotice tone={result.unresolvedRowCount > 0 ? "neutral" : "success"}>
           No interaction found between this medication and the {medicationCount}{" "}
           {medicationCount === 1 ? "medication" : "medications"} entered. Always confirm against source.
         </InlineNotice>
+      ) : result.interactions.length === 0 ? null : (
-      ) : (
         <div className="space-y-2">
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/clinical-dashboard/medication-considerations.tsx` around lines
404 - 408, Update the zero-interactions branch in the medication interaction
result rendering so the “No interaction found” InlineNotice is shown only when
result.dataAvailable is true and result.unresolvedRowCount is zero. Preserve the
existing manual-review path for incomplete or unresolved results, including when
interactions.length is zero.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/components/clinical-dashboard/medication-considerations.tsx`:
- Around line 404-408: Update the zero-interactions branch in the medication
interaction result rendering so the “No interaction found” InlineNotice is shown
only when result.dataAvailable is true and result.unresolvedRowCount is zero.
Preserve the existing manual-review path for incomplete or unresolved results,
including when interactions.length is zero.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aa1d9280-c3b4-42c3-b050-4a87ccdff599

📥 Commits

Reviewing files that changed from the base of the PR and between 7b658ce and 101acc0.

📒 Files selected for processing (24)
  • data/medication-interaction-index.json
  • docs/design-system/COMPONENTS.md
  • docs/design-system/adoption-manifest.json
  • docs/scripts-index.md
  • package.json
  • scripts/build-medication-interaction-index.ts
  • scripts/verify-pr-local.mjs
  • src/app/globals.css
  • src/components/ClinicalDashboard.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/clinical-dashboard/medication-considerations.tsx
  • src/components/clinical-dashboard/medication-nav-header.tsx
  • src/components/clinical-dashboard/medication-prescribing-workspace.tsx
  • src/components/clinical-dashboard/patient-details-dock-action.tsx
  • src/components/clinical-dashboard/patient-profile-context.tsx
  • src/components/clinical-dashboard/patient-profile-panel.tsx
  • src/lib/medication-interaction-lexicon.ts
  • src/lib/medication-interactions.ts
  • tests/in-page-nav-route-sections.dom.test.tsx
  • tests/medication-interaction-lexicon-coverage.test.ts
  • tests/medication-interaction-surfaces.dom.test.tsx
  • tests/medication-interactions.test.ts
  • tests/patient-details-dock-action.dom.test.tsx
  • tests/patient-profile-medications.dom.test.tsx
🚧 Files skipped from review as they are similar to previous changes (16)
  • docs/scripts-index.md
  • tests/in-page-nav-route-sections.dom.test.tsx
  • package.json
  • tests/patient-profile-medications.dom.test.tsx
  • src/components/clinical-dashboard/medication-nav-header.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/ClinicalDashboard.tsx
  • docs/design-system/COMPONENTS.md
  • tests/medication-interaction-lexicon-coverage.test.ts
  • src/components/clinical-dashboard/patient-profile-context.tsx
  • tests/medication-interactions.test.ts
  • tests/medication-interaction-surfaces.dom.test.tsx
  • src/lib/medication-interactions.ts
  • src/app/globals.css
  • src/components/clinical-dashboard/patient-profile-panel.tsx
  • src/components/clinical-dashboard/medication-prescribing-workspace.tsx

@BigSimmo
BigSimmo merged commit 67db5a1 into main Aug 13, 2026
27 checks passed
@BigSimmo
BigSimmo deleted the claude/patient-interactions-drug-alerts-3tztvw branch August 13, 2026 01:59

Copy link
Copy Markdown
Owner Author

Final post-merge review-and-fix summary

Final state

  • PR feat(medications): patient details dock pill and drug-interaction alerting #1874 is merged and closed. It merged at 2026-08-13 01:59:09 UTC.
  • Final PR head: 550b986b5fc6b17dd7e00992c69e5b5a06b06131
  • Base snapshot recorded by the PR: 72bf435840ce22911001088c02b383c638b110dc
  • Merge commit: 67db5a1d5ada98bbd22cc386ca6ea373b693107a
  • main currently points exactly to that merge commit.
  • No sync, rebase, force-push, merge, close, auto-merge change, deployment, release, Lighthouse run, or production/provider-backed evaluation was performed in this verification pass. Because the PR had already merged, there is no remaining pre-merge merge-tree or live PR state to modify.

Issues and review threads

The completed review cycle addressed or dispositioned the high-confidence PR-introduced findings, including:

  • absent interaction-index data incorrectly permitting a green result
  • later-sentence counterparties being dropped
  • mixed unresolved mechanism rows being treated as complete
  • one-direction-only interaction matching
  • formatting-sensitive generated-index staleness checks
  • render-phase MedicationPicker state reset and the missing useEffect import
  • a desktop/tablet MutationObserver that should exist only in phone mode
  • the medication-list cap before persistence
  • focused regression coverage for missing index data, methadone–diazepam, cetirizine–diazepam, reverse naltrexone/buprenorphine-naloxone, mechanism-only unresolved rows, and the relevant UI lifecycle paths

Final thread snapshot: 22/22 review threads resolved and no actionable thread remains open.

Independent review coverage came from Codex, Copilot, CodeRabbit, and Sentry passes. A new post-merge adversarial pass was not started because the repository protocol requires stopping code review activity once the PR is already merged. CodeRabbit's last incremental pass was rate-limited, which is retained as a review-tool limitation rather than described as a clean fresh pass.

Verification evidence

Recorded local evidence in the PR before hosted finalisation:

  • npm run verify:pr-local: all 16 stages green
  • full unit suite: 567 files, 6,206 passed, 4 skipped
  • six new focused suites: 96 assertions
  • phone-chrome static contracts: 129 passed
  • production bundle budget: 1,314.1 KiB gzip, within tolerance

I did not rerun local commands during this post-merge verification because no code was changed and no local checkout was used. The final head was instead verified against GitHub's exact-head checks.

Exact-head required CI

All repository-required checks completed successfully on 550b986b5fc6b17dd7e00992c69e5b5a06b06131:

  • Gitleakssuccess
  • PR requiredsuccess
  • PR policysuccess

Selected Production UI matrix:

  • Production UI (1)success
  • Production UI (2)success
  • Production UI (3)success

Advisory checks and residual risk

  • The exact-head CI, Secret Scan, SAST, PR mergeability, and auto-merge-maintenance workflows completed successfully.
  • Conditional jobs such as Refresh Lighthouse baseline (dispatch only) were skipped as designed. No required check was missing, pending, skipped, cancelled, or failed.
  • PR policy succeeded with one advisory warning that operational-risk changes were bundled with clinical and UI changes and should be split where practical for independent rollback.
  • The interaction lexicon remains curated rather than complete. Unresolved data is designed to fail safe to manual review, but clinical and regulatory review remains relevant for this patient-specific decision-support surface.

Ledger

  • CI's branch-ledger integrity and ledger write-discipline steps passed on the final head.
  • An earlier legacy-table review row was created for initial head d87f7b115deae465617b9748d05fd94619c26158, but no matching immutable review record for final head 550b986b5fc6b17dd7e00992c69e5b5a06b06131 was found in the final tree.
  • No post-merge ledger-only commit was created because repository policy forbids pushing a tip whose sole delta is a babysit record. This remains a documented process gap rather than a hidden code change.

I did not merge or close this PR. GitHub shows that it had already merged before this final verification pass.

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.

4 participants