Skip to content

Link differentials diagnosis terms to info pages - #1768

Merged
BigSimmo merged 7 commits into
mainfrom
cursor/differentials-diagnosis-links-9f18
Aug 9, 2026
Merged

Link differentials diagnosis terms to info pages#1768
BigSimmo merged 7 commits into
mainfrom
cursor/differentials-diagnosis-links-9f18

Conversation

@BigSimmo

@BigSimmoBigSimmo commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a shared differentials diagnosis-term resolver (exact cleaned title + curated aliases, no fuzzy matching) and SSR termLinks on diagnosis detail context.
  • Introduce tone-aware DiagnosisTermChip / DiagnosisTermInline components and wire them into diagnosis Watch for / clinical-review items and presentation Safety Snapshot tags, highest-urgency rows, comparison cells, and mobile “Open diagnosis record”.
  • Leave non-diagnosis risks (e.g. aspiration, falls) as unlinked chips; reject CLINICAL HINGE: noise; suppress self-links.

Test plan

  • npx vitest run tests/differential-diagnosis-links.test.ts tests/differential-detail.test.ts tests/differential-section-nav.dom.test.tsx tests/differentials-route.test.ts — 58 passed
  • npm run verify:pr-local — completed: check:runtime, check:installed-lock-parity, format:changed, lint, typecheck, test (542 files / 5812 passed), build, check:rag:fixtures
  • npm run ensure spot-check at http://localhost:4461: Dementia Watch-for Superimposed delirium/differentials/diagnoses/delirium; acute-confusion Safety tags link Delirium / Substance intoxication / Substance withdrawal

Notes

  • RAG impact: no retrieval behaviour change — differentials UI/catalog cross-links only; no src/lib/rag/** or ranking surfaces touched.
Open in WebOpen in Cursor

Summary by CodeRabbit

  • New Features

    • Added links from diagnosis terms, aliases, and composite labels to relevant diagnosis records.
    • Added linked diagnosis chips across differential detail and presentation pages.
    • Added non-linked styling for terms without matching records or for clinical hinge labels.
    • Improved accessibility and visual treatment for diagnosis links.
  • Bug Fixes

    • Prevented invalid, unavailable, and self-referencing links.
    • Improved composite-term handling, including spaced-slash labels.
  • Tests

    • Added coverage for matching, aliases, routing, segmentation, and link validation.

Add a shared exact-title plus curated-alias resolver and tone-aware chips so Watch for tags, clinical-review items, presentation safety tags, urgency rows, and comparison-cell diagnosis names navigate to catalog diagnosis pages while non-diagnosis risks stay unlinked.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@coderabbitai

coderabbitaiBot commented Aug 9, 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: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: f8de53d8-dc38-4cf6-87e9-d0ab74b53873

📥 Commits

Reviewing files that changed from the base of the PR and between ba590f9 and 384b80d.

📒 Files selected for processing (1)
  • docs/branch-review-ledger.md
📝 Walkthrough

Walkthrough

Added shared diagnosis-term resolution with curated aliases and routability checks. Differential detail context now exposes termLinks. Detail and presentation pages render resolved terms as accessible links and retain unresolved terms as plain text. Tests cover resolution, segmentation, context wiring, and rendering.

Changes

Diagnosis term linking

Layer / File(s)Summary
Term resolution and segmentation
src/lib/differential-diagnosis-links.ts
Added exact title and alias resolution, clinical-hinge filtering, composite-label segmentation, URL generation, and SSR link-map construction.
Detail-context term-link wiring
src/lib/differentials.ts, src/lib/differential-detail.ts
Added termLinks to differential detail context. Derived overlapLinks from resolvable terms.
Linked diagnosis page rendering
src/components/differentials/diagnosis-term-link.tsx, src/components/differentials/differential-detail-page.tsx, src/components/differentials/differential-presentation-workflow-page.tsx
Added diagnosis chips and inline links. Applied them to section items, safety tags, criteria, and candidate records.
Resolution and integration validation
tests/differential-diagnosis-links.test.ts, tests/differential-detail.test.ts, tests/differential-section-nav.dom.test.tsx, tests/differentials-route.test.ts, docs/branch-review-ledger.md
Added coverage for aliases, exclusions, composite labels, context links, safety tags, duplicate titles, and updated fixtures. Added review-ledger records.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant DifferentialDetailContext
participant buildTermLinkMap
participant resolveDiagnosisTerm
participant DifferentialDetailPage
participant DiagnosisTermChip
DifferentialDetailContext->>buildTermLinkMap: collect safety and section labels
buildTermLinkMap->>resolveDiagnosisTerm: resolve cleaned diagnosis term
resolveDiagnosisTerm-->>buildTermLinkMap: return routable diagnosis href
buildTermLinkMap-->>DifferentialDetailContext: return termLinks
DifferentialDetailContext-->>DifferentialDetailPage: provide detailContext.termLinks
DifferentialDetailPage->>DiagnosisTermChip: render resolved safety or overlap term
DiagnosisTermChip-->>DifferentialDetailPage: render linked or plain chip
Loading

Possibly related PRs

  • BigSimmo/Database#461: Modifies the differential presentation workflow with diagnosis-selection and linking behavior.
  • BigSimmo/Database#483: Introduces differential detail components and context wiring extended by this change.
  • BigSimmo/Database#1758: Also modifies Safety Snapshot tags and rendering on the differential detail page.

Suggested reviewers:cursoragent, claude

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check nameStatusExplanationResolution
Description check⚠️ WarningThe description includes a clear summary and verification results but omits required risk, rollout, provider-effects, and clinical-governance sections.Add the required Risk and rollout and Clinical Governance Preflight sections, and document UI verification or explain why it was not run.
Docstring Coverage⚠️ WarningDocstring coverage is 46.15% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary change: linking differential diagnosis terms to information pages.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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 cursor/differentials-diagnosis-links-9f18

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

@supabase

supabaseBot commented Aug 9, 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 ↗︎.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo marked this pull request as ready for review August 9, 2026 04:07
@BigSimmo
BigSimmo requested a balanced review from CopilotAugust 9, 2026 04:08

CopilotAI 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 diagnosis-term links across differential detail and presentation workflows using exact-title and curated-alias resolution.

Changes:

  • Adds shared diagnosis-term resolution and SSR link maps.
  • Introduces linked chips and inline diagnosis links across differential views.
  • Adds focused resolver, route, context, and navigation tests.

Reviewed changes

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

Show a summary per file
FileDescription
src/lib/differential-diagnosis-links.tsImplements term resolution and alias mapping.
src/lib/differentials.tsBuilds diagnosis-detail term-link context.
src/lib/differential-detail.tsExtends the detail context contract.
src/components/differentials/diagnosis-term-link.tsxAdds reusable linked term components.
src/components/differentials/differential-detail-page.tsxLinks diagnosis terms in detail sections.
src/components/differentials/differential-presentation-workflow-page.tsxLinks presentation tags, rows, and comparison terms.
tests/differential-diagnosis-links.test.tsTests aliases, resolution, and context links.
tests/differential-detail.test.tsValidates generated term links.
tests/differential-section-nav.dom.test.tsxUpdates context fixtures.
tests/differentials-route.test.tsVerifies API term-link output.
docs/branch-review-ledger.mdRecords implementation verification.

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

Comment threadsrc/components/differentials/differential-detail-page.tsx Outdated
Comment threadsrc/lib/differential-diagnosis-links.ts Outdated
Comment threadsrc/components/differentials/differential-presentation-workflow-page.tsx Outdated

@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:03cb6a8f35

ℹ️ 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/differential-diagnosis-links.ts
…snapshot
- differential-diagnosis-links.ts: Change SEGMENT_SPLIT to only split on
commas and semicolons, not slashes. Slashes within compound clinical phrases
(e.g. "alcohol/benzo withdrawal") must be preserved; splitting on them and
rejoining with commas via DiagnosisTermInlineList changes clinical meaning.
Semicolons are now handled so lists like "Primary psychosis; dementia" are
correctly split into linkable segments.
- differential-detail-page.tsx: Guard both termLinks pass-throughs with ?? {}
so older API deployments that pre-date the termLinks field do not cause a
crash when SafetySnapshot or SectionItems perform termLinks[cleaned] lookups
during version skew.
- differential-presentation-workflow-page.tsx: Wrap the inner segments.map()
in a keyed Fragment so the outer tags.map() always returns a single keyed
root element, satisfying React's list-key requirement.
Co-authored-by: BigSimmo <87357024+BigSimmo@users.noreply.github.com>

@coderabbitaicoderabbitaiBot 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: 2

🤖 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 `@src/components/differentials/differential-detail-page.tsx`:
- Around line 151-159: Use cleaned section-item keys consistently in all three
affected sites: src/components/differentials/differential-detail-page.tsx lines
151-159, 170-173, and 188-201. In each rendering path, clean item before looking
it up in termLinks and use the cleaned value when rendering DiagnosisTermInline
or DiagnosisTermChip, while preserving the existing list rendering behavior.
In `@src/lib/differential-diagnosis-links.ts`:
- Around line 137-164: Update SEGMENT_SPLIT so resolveDiagnosisTermSegments also
separates slash-delimited diagnosis terms, including “Delirium / medical
psychosis.” Preserve the existing whole-label resolution before splitting so
curated slash aliases continue resolving as a single term.
🪄 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: 110aa206-5f95-4980-badd-1aebbdf0e92e

📥 Commits

Reviewing files that changed from the base of the PR and between 883e725 and d0b148d.

📒 Files selected for processing (11)
  • docs/branch-review-ledger.md
  • src/components/differentials/diagnosis-term-link.tsx
  • src/components/differentials/differential-detail-page.tsx
  • src/components/differentials/differential-presentation-workflow-page.tsx
  • src/lib/differential-detail.ts
  • src/lib/differential-diagnosis-links.ts
  • src/lib/differentials.ts
  • tests/differential-detail.test.ts
  • tests/differential-diagnosis-links.test.ts
  • tests/differential-section-nav.dom.test.tsx
  • tests/differentials-route.test.ts

Comment threadsrc/components/differentials/differential-detail-page.tsx
Comment threadsrc/lib/differential-diagnosis-links.ts Outdated
BigSimmoand others added 3 commits August 9, 2026 13:29
Preserve unspaced clinical compounds like alcohol/benzo while still
segmenting discrete spaced-slash lists such as Delirium / medical psychosis.
Co-authored-by: Cursor <cursoragent@cursor.com>
Append heavy-scope review of tip 0daa9e2 after main sync and spaced-slash segment fix.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo enabled auto-merge (squash) August 9, 2026 06:23
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@cursoragent Unblock the current open PR. Confirm the PR number and GitHub head first from context. If more than one open PR could apply, stop and say which one you would use and why.

Fetch and start from the remote tip that matches that GitHub head. If the named branch ref is missing or stale, use the PR head ref. Preserve unrelated local WIP; do not discard dirty work; do not treat a local-ahead commit as the reviewed tip. Do not merge the PR, force-push, rebase, or arm auto-merge. No provider-backed gates without approval. If you cannot push or resolve threads, diagnose and comment only; if inline replies fail, resolve when possible and put blocker dispositions in the summary comment. If auto-merge is already armed, push only for a real blocker and avoid cancelling in-flight required CI unless the push clears that blocker.

If the PR is already merged or closed: confirm outcome, post one summary, and stop.

Primary job: clear mergeability and required-CI blockers on this tip. Do a full product review only if needed to explain or fix a blocker. Stay light otherwise—no broad verification suites or Playwright unless needed to prove one concrete unblock fix.

Snapshot the GitHub head: tip, behind/ahead, mergeable state, merge-tree versus origin/main (real conflict versus behind-but-clean), required checks on that tip including Production UI when selected, and unresolved threads that block merge or required CI. Missing checks while dirty are not green. Tip moved → re-snapshot.

Ledger-lookup against that GitHub head under an unblock/fix scope for this PR. If already handled at this head for unblock work, merge-tree clean, required checks green, and no blocking threads: summarize, comment, stop.

Unblock once: real conflict → merge origin/main with the smallest correct resolution (prefer main’s shared queues; keep this PR’s notes); behind-but-clean → one sync, late if required CI is in flight; clean → leave. skip-branch-sync and similar labels do not block a manual sync needed to clear a real blocker. No sync thrash. After any sync or push, re-snapshot tip, merge-tree, and required checks before declaring done. Dedupe the ledger if a merge touched it.

Fix only what blocks required checks or mergeability on this tip. Ignore advisory red unless it reveals a real required failure. Prefer the smallest safe fix; if a bot/autofix commit caused the break, prefer revert. Prove with the smallest targeted check only. Format and commit before push.

Push only blocker-fix commits. Append ledger for the final GitHub head under the unblock scope. Never push a ledger-only tip.

One PR comment: tip, sync/merge-tree, what blocked and what you fixed or dispositioned, required CI status, residual risks; merge left to me.

Stop when merge-tree is clean on the current GitHub tip, no blocking threads remain for merge/required CI, and required checks are green or clearly in progress.

@cursor

cursorBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR #1768 — tip 384b80d61008fb2a3b2ac2f19a46cdf62d8e8cfb (was ba590f9).

Blocker: GitHub DIRTY/CONFLICTING after main moved. merge-tree was clean (behind 1) — staleness, not a content conflict.

Fix: Merged origin/main once and pushed. Now merge-tree clean, mergeable: MERGEABLE, PR mergeability pass. Auto-merge left armed. No force-push/rebase/merge.

Threads: 0 unresolved.
Required CI: re-running on the new tip (in progress). Merge left to you.

Open in WebOpen in Cursor

…diagnosis-links-9f18
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@cursor

cursorBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Unblock summary (PR #1768)

Tip:384b80d61008fb2a3b2ac2f19a46cdf62d8e8cfb (was ba590f9ceb3815bf8384123df7859cbff90677a8)

Sync / merge-tree

  • GitHub reported mergeable: CONFLICTING / DIRTY after main advanced to 644dd089.
  • git merge-tree --write-tree origin/main ba590f9 was clean (behind-but-clean staleness, not a content conflict): behind 1 / ahead 6.
  • Merged origin/main once and pushed. Post-sync: merge-tree clean, ahead 7 / behind 0, mergeable: MERGEABLE (state BLOCKED only while required checks finish).
  • Auto-merge was already armed (squash); left armed. No force-push, rebase, or PR merge.

What blocked / what I did

  • Blocker: PR mergeability fail from dirty merge ref (missing refs/pull/1768/merge CI path).
  • Fix: one git merge origin/main + push. No product code changes in this unblock.
  • Review threads: 0 unresolved (prior Copilot/Sentry/CodeRabbit items already resolved on the previous tip).

Required CI

  • On prior tip ba590f9: required suite had been green (PR required, Production UI shards, Build, Static PR, etc.).
  • On new tip 384b80d6: in progress after sync — PR mergeability already pass; Build / Static PR / Unit coverage / Production UI critical / Semgrep pending. Merge left to you once green.

Residual risks

  • Unblock ledger row in the tip still names pre-amend merge SHA f784e81… (same sync content); did not push a ledger-only follow-up (would cancel in-flight CI with auto-merge armed).
  • No provider-backed gates run.

@BigSimmo
BigSimmo merged commit 7aaf934 into mainAug 9, 2026
26 checks passed
@BigSimmo
BigSimmo deleted the cursor/differentials-diagnosis-links-9f18 branch August 9, 2026 06:38
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.

4 participants

@BigSimmo@cursoragent