Skip to content

fix(medications): polish the interaction note text - #1898

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

fix(medications): polish the interaction note text#1898
BigSimmo merged 23 commits into
mainfrom
claude/patient-interactions-drug-alerts-3tztvw

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Summary

Follow-up to #1874 (merged). The interaction warning read as an unformatted dump rather than something designed. Three causes, all fixed without touching the clinical wording.

  • Every note opened with a shouty CRITICAL — . That token is the same value already shown as the severity badge beside it, so it was redundant and it made each paragraph start with an all-caps word and a dangling dash. New interactionNoteBody() strips only that prefix. It is deliberately not a summariser: no sentence is dropped, reordered or reworded, because the wording is the clinical claim and this surface promises it verbatim. A row that carries no prefix is returned untouched.
  • line-clamp-2 cut mid-word with an ellipsis. The block sits behind a tap since feat(medications): patient details dock pill and drug-interaction alerting #1874, so there was no space to reclaim by truncating a safety note. Now unclamped.
  • The notes ran together as muted small type on the tinted wash. Each interaction is now its own card on the panel's own surface — body text on a same-hue fill is the readability trap already recorded on the hero tiles (#659) — carrying the drug-name link plus a per-row severity chip. The disclosure trigger only reports the worst severity, so a HIGH sitting under a CRITICAL was previously unlabelled.

The in-sheet block gets the same treatment so the two surfaces agree.

What I deliberately did not do: split each note into "which drugs" and "what happens" halves. The catalogue is not consistent enough for it — some rows lead with the counterparties (CRITICAL — NSAIDs and Aspirin. SSRIs deplete platelet serotonin…), others lead with the mechanism (HIGH — Blocks the cardioprotective effect of low-dose Aspirin…). A heuristic that mangles a clinical sentence is worse than leaving it whole.

Note on branching: #1874 merged and its branch was deleted while this was in progress, so this is a fresh change off current main, not a continuation of that history.

Verification

  • npm run verify:pr-localcompleted: check:runtime, check:installed-lock-parity, format:changed, lint, typecheck, test, build, check:rag:fixtures, check:medication-interactions / failed: (none), exit 0. Dependencies were reinstalled first (npm ci) because main's lockfile had moved on.
  • Six new cases in tests/medication-interactions.test.ts pin the parser: prefix removal across em-dash, en-dash and hyphen; a no-prefix row left alone; an all-caps word mid-sentence not eaten; and — the one that matters — an assertion that the original string still ends with the returned body, so nothing but the prefix can ever be removed.
  • Visually confirmed at 390×844 on /medications/sertraline with tramadol-ir + ibuprofen in the session profile: two white cards inside the tinted callout, each with the drug name, a Critical / High chip, and clean unclipped prose.
  • The skipped pre-commit hook's checks were run explicitly afterwards (docs:check-inventory, docs:check-index, check:design-system-adoption) — all current, tree clean.

UI verification not run: npm run verify:phone-chrome cannot complete its browser stages in this environment (Chromium 1194 vs Playwright 1.62.1's 1234 — the drift tracked as /issues #255), and docs/testing.md says not to force a mismatched browser. No chrome token, reserve or dock ownership moved here, so the phone-chrome journeys are unaffected by this diff; Chromium coverage is delegated to CI.

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. check:rag:fixtures passed unchanged (36 golden cases, 23 suites).

Risk and rollout

  • Risk: low, and bounded by the parser. The only way interactionNoteBody() can alter a clinical claim is by removing more than the severity prefix, which the "original ends with body" assertion makes impossible. Presentation-only otherwise.
  • Rollback: revert the commit. interactionNoteBody and severityLabel have no other consumers.
  • Provider or production effects: None. No Supabase, no OpenAI, no migrations, no generated-artefact change.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use — the catalogue wording is still rendered verbatim; only the redundant severity token, already shown as a badge, is not repeated inside the paragraph.
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval — no change to the profile, its storage, or its scope; this diff is presentation only.
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — no Supabase file, migration, env value or client call is touched.
  • Service-role keys and private document access remain server-only — no auth, owner-scope, query-privacy or API-route code is modified.
  • Demo/synthetic content remains clearly separated from real clinical sources — the text still comes solely from the committed data/medications-snapshot.json catalogue export, addressed by rowIndex.
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative — unchanged. Green is still unreachable on incomplete analysis, unresolved rows still hold a medication at grey, and the per-row severity chip makes a HIGH under a CRITICAL visible rather than implicitly inheriting the headline severity.
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed — no behaviour change, so the determination recorded in docs/samd-classification-medication-considerations.md is unaffected. That note remains OPEN and still needs its named clinical + regulatory reviewer.

Notes

  • The prefix regex mirrors the one the index build script already uses to parse severity, so the two cannot disagree about what counts as a prefix.

Generated by Claude Code

The warning read as an unformatted dump. Three causes, all addressed
without touching the clinical wording:
Every note opened with a shouty `CRITICAL — `. That token is the same
value already shown as the severity badge beside it, so it was redundant
and it made each paragraph start with an all-caps word and a dangling
dash. `interactionNoteBody()` strips only that prefix; a row that does
not carry one is returned untouched, and a test asserts the original
string still ends with the returned body, so nothing else can ever be
removed. It is not a summariser: no sentence is dropped, reordered or
reworded, because the wording is the clinical claim.
The text was `line-clamp-2`'d, cutting mid-word with an ellipsis. The
block sits behind a tap now, so there was no space to reclaim by
truncating a safety note.
The notes ran together as muted small type on the tinted wash. Each
interaction is now its own card on the panel's own surface — body text on
a same-hue fill is the readability trap recorded on the hero tiles
(#659) — carrying the drug-name link plus a per-row severity chip. The
trigger only reports the worst severity, so a HIGH sitting under a
CRITICAL was previously unlabelled.
Rebased onto main after PR #1874 merged; this is a fresh change, not a
continuation of that branch's history.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X12okkARLhFQ2zgcPoFp54
@supabase

supabaseBot commented Aug 13, 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

coderabbitaiBot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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:30 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: 712dc675-465f-467a-bde9-e90033bcda17

📥 Commits

Reviewing files that changed from the base of the PR and between 5886c32 and b901d1a.

📒 Files selected for processing (16)
  • data/medication-interaction-index.json
  • docs/branch-review-records/43d12e14e914d36f453a41694d38cd76fa9d83f8ffe3a3b7768fb27108c8d377.record.md
  • docs/branch-review-records/89ef6892ffb66555f7f243204381cf9669f9683b3056177942eafa88f5014e62.record.md
  • docs/medication-interaction-lexicon-review.md
  • docs/samd-classification-medication-considerations.md
  • docs/scripts-index.md
  • package.json
  • scripts/build-medication-interaction-index.ts
  • scripts/build-medication-lexicon-report.ts
  • scripts/verify-pr-local.mjs
  • src/components/clinical-dashboard/medication-considerations.tsx
  • src/lib/medication-interaction-lexicon.ts
  • src/lib/medication-interactions.ts
  • tests/medication-interaction-callout-tap-target.dom.test.tsx
  • tests/medication-interaction-lexicon-coverage.test.ts
  • tests/medication-interactions.test.ts

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

@BigSimmo
BigSimmo enabled auto-merge August 13, 2026 02:37

@chatgpt-codex-connectorchatgpt-codex-connectorBot 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:807d13f4ab

ℹ️ 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 threadsrc/lib/medication-interactions.ts Outdated
Comment threadsrc/components/clinical-dashboard/medication-considerations.tsx Outdated
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. The only repository destination is BigSimmo/Database, and the only branch destination is the pull request head branch claude/patient-interactions-drug-alerts-3tztvw at starting commit 91a164f; never publish fixes to a detached or synthetic work branch and never create a stacked pull request. Use the authenticated GitHub connector to commit each approved fix to BigSimmo/Database:claude/patient-interactions-drug-alerts-3tztvw, then verify that the pull request head contains the published commit before reporting success. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. For a fixed thread, reply with as the first line and as the second line. For a no-code disposition, use followed by . These result markers authorize the workflow to close that exact thread only after it verifies a fixed commit is the pull request head; a local-only commit is not a fix. If publication or verification fails, do not use either result marker, do not claim success, and leave the thread open with the blocker. If human input or new authorization is required, do the same. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@BigSimmoChatGPT Codex Connector

Copy link
Copy Markdown
OwnerAuthor

@claude Please fix both unresolved review findings on exact head 91a164fd7fcc9acc50c860141eef2410d743014b, commit and push one focused change to this PR branch, and do not merge, rebase, force-push, close the PR, alter auto-merge, or touch unrelated files.

  1. In src/lib/medication-interactions.ts, make interactionNoteBody strip only a recognised interaction severity prefix (critical, high, moderate, caution, low, none, safe, beneficial, unknown, case-insensitive if desired) followed by an em/en/hyphen separator. It must preserve clinical wording such as NSAID-induced renal injury and NEVER-combine with MAOIs exactly. Add regression assertions for both examples in tests/medication-interactions.test.ts, while retaining the existing severity-prefix cases.
  2. In src/components/clinical-dashboard/medication-considerations.tsx, restore the production phone tap-height floor on the counterparty medication Link by adding the repository’s min-h-tap class without otherwise restyling it. Add/adjust the narrowest existing DOM/static contract if one already covers this link; do not create broad UI churn.
  3. Run the focused medication interaction tests and the narrowest applicable component/static contract, then report exact commands and outcomes.

@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 · #1898

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

@claude

claudeBot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@BigSimmoChatGPT Codex Connector

Copy link
Copy Markdown
OwnerAuthor

@copilot Fix the two still-unresolved exact-head defects on current head ef6afd212d514dd6d9e889418bb79929adfd4236 and push one focused commit to claude/patient-interactions-drug-alerts-3tztvw. Do not merge, close, rebase, force-push, deploy, alter auto-merge, or touch unrelated files.

The current head already added the correct failing regressions but did not change production code:

  1. Replace SEVERITY_PREFIX in src/lib/medication-interactions.ts with a case-insensitive regex that matches only these recognised tokens followed by an em/en/hyphen separator: critical|high|moderate|caution|low|none|safe|beneficial|unknown. It must leave NSAID-induced renal injury and NEVER-combine with MAOIs unchanged while still stripping CRITICAL —, HIGH -, and MODERATE –.
  2. Add min-h-tap to the counterparty medication Link inside MedicationInteractionCallout in src/components/clinical-dashboard/medication-considerations.tsx, with no other restyling.
  3. Run tests/medication-interactions.test.ts and tests/medication-interaction-callout-tap-target.dom.test.tsx, plus format/typecheck if required. Report the pushed 40-character SHA and exact outcomes. Do not modify the already-correct regression tests.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Publication blocker

The fixes could not be published or marked resolved:

  • git push origin HEAD:refs/heads/claude/patient-interactions-drug-alerts-3tztvw failed because this environment has no authenticated GitHub credentials.
  • gh auth status confirms that no GitHub host is authenticated.
  • The remote PR branch has independently advanced to ef6afd212d514dd6d9e889418bb79929adfd4236, while the requested starting commit was 91a164fd7fcc9acc50c860141eef2410d743014b.
  • No thread-resolution markers were emitted because the local commit is not the verified PR head.
  • No new or stacked pull request was created, as expressly prohibited by the trigger. The requested authenticated GitHub connector and make_pr tool were not available in this environment.

Testing

  • npm run ensure — verified the Database app at http://localhost:3131.
  • npm run format
  • node scripts/run-vitest.mjs run tests/medication-interactions.test.ts tests/medication-interaction-surfaces.dom.test.tsx --reporter=dot — 2 files and 41 tests passed.
  • npm run check:medication-interactions — the 523-row generated interaction index is current.
  • git diff --check
  • ⚠️npm run test — the broad suite was stopped after more than ten minutes to release the repository test lease; the narrower tests directly covering both fixes passed afterward.
  • git push origin HEAD:refs/heads/claude/patient-interactions-drug-alerts-3tztvw — GitHub authentication was unavailable, so the commit remains local.
  • ⚠️gh auth status — confirmed that no GitHub hosts are authenticated.

View task →

@BigSimmoChatGPT Codex Connector

Copy link
Copy Markdown
OwnerAuthor

@copilot On current head 58240a85306336847a6d1a6521ceed7cd8a59b4e, make exactly one production-code fix and push it to claude/patient-interactions-drug-alerts-3tztvw: add the existing min-h-tap utility to the counterparty medication Link inside MedicationInteractionCallout in src/components/clinical-dashboard/medication-considerations.tsx. Do not change any other styling or file unless formatting requires it.

Run tests/medication-interaction-callout-tap-target.dom.test.tsx and the narrowest format/type check. Report the pushed 40-character SHA and exact outcomes. Do not merge, close, rebase, force-push, deploy, alter auto-merge, or broaden scope.

BigSimmoand others added 4 commits August 13, 2026 11:07
…everse matches their wording
Two safety gaps in the interaction feature, both about a clinician being able
to act on what the tool shows them.
1. The lexicon had never been reviewed and was not readable enough to review.
`scripts/build-medication-lexicon-report.ts` generates
`docs/medication-interaction-lexicon-review.md`: every term expanded to the
drugs it actually resolves to, with how many CRITICAL/HIGH rows depend on
it, sorted by severe usage, carrying a sign-off block. Marked UNREVIEWED
until a clinician fills that block in. `check:medication-lexicon-report`
fails when the sheet and the lexicon disagree, so a sign-off cannot end up
covering a different lexicon.
The sheet immediately found two defects:
- `subclassIncludes: ["ARB"]` matched "C-ARB-apenem", putting ertapenem and
meropenem in the angiotensin-receptor-blocker class across 16
CRITICAL/HIGH rows. Fixed with a new exact-match `subclassEquals`
selector, pinned by name and by a systemic whole-word check that would
catch the next one.
- Two catalogue records are both named "Warfarin" and share no interaction
rows at all, so which one a clinician opens decides which warnings they
see. That is a catalogue data defect, not a lexicon fault, so it is
reported rather than silently patched — merging the records is a clinical
content decision that needs an owner.
2. A reverse-direction match rendered a drug name and a severity chip with no
text underneath. The counterparty's row lives on the patient's medication,
whose record the caller does not hold, so its wording was passed as "".
Row text is carried in the index again and used as the fallback; the live
record still wins when present, and the two are kept identical by
`check:medication-interactions`. Index cost 249KB -> 333KB raw
(15KB -> 39KB gzip).
Both freshness checks are wired into `verify:pr-local` so neither artefact can
go stale unnoticed, and the generator formats its own output so a tree-wide
`npm run format` cannot make a current report look stale.
…-alerts-3tztvw' into claude/patient-interactions-drug-alerts-3tztvw
@BigSimmoChatGPT Codex Connector

Copy link
Copy Markdown
OwnerAuthor

Fixed the exact current-head static CI failure by formatting tests/medication-interactions.test.ts with the repository formatter. No behavioural changes were made; auto-merge remains enabled and fresh CI is pending.

BigSimmoand others added 5 commits August 13, 2026 11:14
Preserve the corrected severity parser, restored phone tap target, focused regressions, and immutable review record on top of the current Services-filter main.
…-alerts-3tztvw' into claude/patient-interactions-drug-alerts-3tztvw
Commit 92bcdf4 reflowed `tests/medication-interactions.test.ts` to 80 columns.
The repo's `.prettierrc` sets `printWidth: 120`, so that pass ran with a
default config rather than this project's, and `format:changed` and the
exact-commit pre-push guard would both have gone red on the pushed blob.
`npm run format` reverts it.
@BigSimmoChatGPT Codex Connector

Copy link
Copy Markdown
OwnerAuthor

@copilot Fix the exact-head CI format failure on 1020175f2234fa73d71db4c58428860f733a0bff and push one focused commit to claude/patient-interactions-drug-alerts-3tztvw. Run Prettier with write mode on onlytests/medication-interactions.test.ts; do not change test semantics or any production file. Then run npm run format:changed (or the exact targeted Prettier check) and report the pushed 40-character SHA and outcome. Do not merge, close, rebase, force-push, deploy, alter auto-merge, or broaden scope.

@github-actions

Copy link
Copy Markdown
Contributor

CI triage

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

  • Production UI (1)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 #10410 (cancelled).

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

@BigSimmo
BigSimmo merged commit 9b001f1 into mainAug 13, 2026
26 checks passed
@BigSimmo
BigSimmo deleted the claude/patient-interactions-drug-alerts-3tztvw branch August 13, 2026 06:23
Sign up for freeto 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

@BigSimmo@claude