feat: redesign medication search results with semantic badges and safety-aware actions#477
Conversation
…ety-aware actions - Derive actionTone (danger/warning/neutral) from the source field that supplies the prescribing action; render Ban/TriangleAlert icons with sr-only prefixes so contraindications carry visual + a11y weight - Surface per-row identity badges (S8, PBS, TGA, Reviewed) through the existing ClinicalBadge/medicationIdentityBadges system - Show the match-quality badge only when it differentiates rows - Add icons + live counts to the Best/Indication/Safety/Monitor chips; Safety/Monitor now also match on actionTone (regex missed "Contraindicated..." text) - Add empty states for zero-result filters (with reset) and no-match searches; gate the desktop table on non-empty results - Highlight the query token in medication names; micro-caps table header; hover chevron affordance; tabular numerals on doses - Add firstClinicalSentence so action/dose text no longer truncates at abbreviations like "e.g." or decimals Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughMedication search results now derive structured action tones and clinical sentence text, use governance metadata for badges, expose filter counts, and render richer desktop/mobile result states with highlighting and contextual empty states. ChangesMedication search and prescribing workspace
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant MedicationCatalogResponse
participant MedicationResults
participant FilterStrip
participant ClinicalBadge
MedicationCatalogResponse->>MedicationResults: provide medication results and governance metadata
MedicationResults->>FilterStrip: provide filtered rows and per-filter counts
FilterStrip->>MedicationResults: select active filter
MedicationResults->>ClinicalBadge: render identity and match badge data
🚥 Pre-merge checks | ✅ 10 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (10 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 300701299f
ℹ️ 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".
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/clinical-dashboard/medication-prescribing-workspace.tsx (1)
63-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse the shared
MedicationActionTone/MedicationResultTonetypes instead of redeclaring them.
actionTone/toneare redefined here as inline literal unions that must exactly mirrorMedicationActionTone/MedicationResultToneinsrc/lib/medications.ts. Since this file already imports from@/lib/medications(line 33), importing the two type aliases directly would remove the duplication and prevent drift if the tone set changes later (it's a brand-new type introduced in this very PR, so duplication risk is immediate).♻️ Proposed fix
-import { medicationIdentityBadges, type MedicationRecord } from "`@/lib/medications`"; +import { + medicationIdentityBadges, + type MedicationActionTone, + type MedicationRecord, + type MedicationResultTone, +} from "`@/lib/medications`";action: string; - actionTone: "danger" | "warning" | "neutral"; - tone: "teal" | "blue" | "slate"; + actionTone: MedicationActionTone; + tone: MedicationResultTone; href?: string;🤖 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-prescribing-workspace.tsx` around lines 63 - 66, Replace the inline literal unions for actionTone and tone in the relevant props/type definition with the shared MedicationActionTone and MedicationResultTone aliases from `@/lib/medications`, adding them to the existing import and removing the duplicated declarations.
🤖 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.
Nitpick comments:
In `@src/components/clinical-dashboard/medication-prescribing-workspace.tsx`:
- Around line 63-66: Replace the inline literal unions for actionTone and tone
in the relevant props/type definition with the shared MedicationActionTone and
MedicationResultTone aliases from `@/lib/medications`, adding them to the existing
import and removing the duplicated declarations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0a8324e1-5e19-489c-a837-e1fc68cd9605
📒 Files selected for processing (4)
src/components/clinical-dashboard/medication-prescribing-workspace.tsxsrc/components/clinical-dashboard/use-medication-catalog.tssrc/lib/medications.tstests/medications.test.ts
Records whose avoid/contraindication field explicitly says NONE or 'no absolute contraindication' (naloxone, acetylcysteine, nystatin, ...) no longer render the Ban icon and 'Do not use' prefix: downgrade to warning when the displayed sentence still carries a caution, else neutral. Adds synthetic + naloxone snapshot coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07de31ee82
ℹ️ 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".
Avoid rows that are pure cautionary guidance (Pregnancy Category B2, pharmacist review / dose reduction) now render the warning tone instead of the Ban icon. Condition-list and setting-based hard stops (severe respiratory depression; unmonitored environments) keep danger — the downgrade is keyed to explicit caution phrasing with no hard-stop keyword, so under-warning stays the avoided failure mode. Adds synthetic coverage plus fexofenadine/loratadine snapshot regressions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@tests/medications.test.ts`:
- Around line 195-200: Update the test using getMedicationRecord and
medicationActionDetail so each caution snapshot record explicitly asserts tone
is "warning" instead of merely asserting it is not "danger"; retain the existing
fexofenadine and loratadine coverage.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 53b69833-3693-4a87-bb69-757f317598e6
📒 Files selected for processing (2)
src/lib/medications.tstests/medications.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/medications.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb528367db
ℹ️ 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".
…pshot assertions Warning-toned avoid guidance (Pregnancy Category B2, pharmacist review/dose reduction) now matches the Safety chip — any row rendering a safety icon is reachable through it. Snapshot tests assert the exact warning tone instead of merely not-danger. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
actionTone(danger/warning/neutral) rendered as a quiet Ban/TriangleAlert icon with a screen-reader prefix, per the badge governance guide (red stays reserved for true contraindications).ClinicalBadge/medicationIdentityBadgesvocabulary; the match-quality badge renders only when it differentiates rows (kills the N× "Exact clinical fit" repetition).actionTone(the old regex missed "Contraindicated…" text entirely — the Safety chip showed 0 while every row displayed a contraindication).<mark>highlight in medication names, hover chevron affordance (motion-safe), stronger top-match accent bar, tabular numerals on doses.firstClinicalSentencehelper stops action/dose text truncating at abbreviations ("Any hepatic impairment (e" → "Any hepatic impairment (e.g. cirrhosis)") or decimals.actionTonederivation and sentence truncation (tests/medications.test.ts).Note: this branch also carries a pre-existing commit from another session (
docs: align readiness runtime version); its content has since landed on main independently, so the net PR diff is exactly the four files above.Verification
npm run verify:pr-localequivalent run as individual gates post-merge:format:check,lint,typecheck,test(full vitest), plusverify:cheapearlier in the session — all green. Under heavy machine load some unrelated RAG tests (e.g.rag-cache-invalidation) flake on the 15s default timeout; they pass with--testTimeout=60000and are untouched by this diff.npm run verify:uiwhen UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changed — Chromium suite green post-merge (also 124/124 pre-merge). Manual Playwright QA: desktop/mobile × light/dark, filter counts, empty states, hover states.npm run verify:releasebefore release or handoff confidence claims — not run (not a release).npm run eval:retrieval:quality— not run: no retrieval, ranking, selection, chunking, or scoring behavior changed (rankMedicationRecordsuntouched; the new filters are client-side display predicates on already-ranked results).npm run eval:rag -- --limit 15+npm run eval:quality -- --rag-only— not run: answer generation, synthesis prompt, and post-processing unchanged.npm run check:production-readiness— not run: no clinical workflow/privacy/env/Supabase/governance/deployment behavior change (display-layer only).npm run check:deployment-readiness— not run: no deployment behavior change.Clinical Governance Preflight
Completed because the change touches clinical output presentation (medication search results display).
Clinical KB Database(sjrfecxgysukkwxsowpy) — no env/config changeNotes
MedicationSearchResult.actionToneplus threading the existing per-sluggovernancemap through the catalog hook type.medication-result-{slug}-desktop/-phonetestids, desktop row stays an<a href="/medications/{slug}">, mobile action text stays in a<p>.🤖 Generated with Claude Code