DSM: add diagnosis reference mode#661
Conversation
# Conflicts: # docs/site-map.md # scripts/generate-site-map.ts # src/app/page.tsx # src/components/clinical-dashboard/ClinicalSidebar.tsx # src/components/clinical-dashboard/global-search-shell.tsx # src/components/clinical-dashboard/master-search-header.tsx # src/components/clinical-dashboard/mode-action-popup.tsx # src/lib/app-mode-icons.ts # src/lib/app-modes.ts # tests/app-modes.test.ts # tests/ui-smoke.spec.ts
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 104cb1fb4e
ℹ️ 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".
|
@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. 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. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. 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. |
CI triageCI failed on this PR. Automated classification of the 2 failed job(s):
Heuristic only — a main-side or flake label is a starting point, not a verdict. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 104cb1fb4e
ℹ️ 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".
|
@copilot resolve the merge conflicts on this branch. |
Head branch was pushed to by a user without write access
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a DSM-5 diagnosis catalogue with search, comparison, diagnosis detail, differential review, dedicated routes, shared navigation/search integration, sitemap generation, and automated validation. ChangesDSM-5 diagnosis mode
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant Dashboard
participant DsmRoute
participant DsmCatalogue
participant DsmSurface
User->>Dashboard: select DSM mode or submit query
Dashboard->>DsmRoute: navigate to /dsm/search
DsmRoute->>DsmCatalogue: list and rank diagnoses
DsmCatalogue-->>DsmRoute: diagnosis summaries
DsmRoute->>DsmSurface: render search results
User->>DsmSurface: open diagnosis or compare selection
DsmSurface->>DsmRoute: navigate to detail or comparison route
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Merge origin/main into branch (branch-review-ledger.md conflict) - Prefer DSM domain over differentials in universal search domain order - Preserve comparison IDs when navigating to Add another diagnosis - Resolve catalogue aliases (abbreviations, initialisms, slash variants) in differential matching
Merge conflict in ... All three P2 Codex review findings resolved in commit P2 — Prefer DSM hits before differential ties ( P2 — Preserve selected IDs when adding diagnoses ( P2 — Resolve catalogue aliases in differentials ( 48/48 focused tests pass (dsm, universal-search, app-modes, site-map). CodeQL and code review both clean. |
…714' into codex/dsm-main-integration-20260714
|
@copilot resolve the merge conflicts on this branch. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/lib/search-command-surface.ts (1)
81-90: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDSM cross-modes omit
specifiersdespite clinical overlap.
crossModes: ["differentials", "prescribing", "documents"]doesn't include"specifiers", even though DSM diagnoses and diagnostic specifiers are closely related content domains. This is a content/UX choice rather than a defect, and may be intentional given differing scope.🤖 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/search-command-surface.ts` around lines 81 - 90, Review the dsm configuration’s crossModes in the search command surface and decide whether diagnostic specifiers should be included alongside differentials, prescribing, and documents. If the intended UX supports this clinical overlap, add the existing "specifiers" mode while preserving the other cross-mode entries; otherwise leave the configuration unchanged and document the intentional scope decision.tests/universal-search.test.ts (1)
60-61: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winHardcoded domain-order literals have drifted from the canonical source.
Both arrays place
"dsm"after"presentations", butsrc/lib/universal-search-domains.ts's canonical array (and its comment) places"dsm"right after"forms", before"differentials"/"presentations", specifically so DSM wins tie-breaks over Differentials. These are manually duplicated literals rather than imports of the real constant, so they silently drifted when"dsm"was added.The line 60-61 filter result happens to be unaffected today, but the
mockRuntimecopy at 416-425 mocksuniversalSearchDomainsfor the live/public-path suite — if any assertion there depends on dsm-vs-differentials ordering (the exact fix this PR's commit message describes), it would be exercised against the wrong order.Prefer importing/spreading the real
universalSearchDomainsconstant (optionally re-ordered per-test via.filter/.sortif a specific subset order is needed) instead of hand-copying the array, so future domain additions can't silently desync test fixtures from production behavior.♻️ Suggested fix for the mockRuntime duplicate
+import { universalSearchDomains as realUniversalSearchDomains } from "`@/lib/universal-search-domains`"; ... vi.doMock("`@/lib/universal-search`", () => ({ runUniversalSearch, - universalSearchDomains: [ - "documents", - "medications", - "services", - "forms", - "differentials", - "presentations", - "dsm", - "tools", - ], + universalSearchDomains: realUniversalSearchDomains, }));Also applies to: 416-425
🤖 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/universal-search.test.ts` around lines 60 - 61, Replace the manually duplicated domain-order arrays in the test, including the filter near the current diff and the mockRuntime fixture, with the canonical universalSearchDomains constant imported from src/lib/universal-search-domains.ts. Preserve any test-specific subset or ordering by deriving it from that constant rather than recreating domain literals, ensuring DSM retains its canonical precedence over Differentials.src/lib/dsm.ts (1)
74-74: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winP2 context (consolidated): category filter trusts a hand-maintained count instead of deriving it.
dsmCategoriesfilters on the JSON's staticdiagnosis_countrather than computing it fromdsmDiagnoses. Current data is internally consistent (verified all 18 categories sum to 146 and match actual counts), so this isn't a live bug — but it's a duplicate source of truth: any future diagnosis addition/removal without a matching JSON count update could silently hide a populated category from/dsm/searchfilters or show one with zero real results. The dataset already carries one zero-count, zero-diagnosis category ("med" / Due to Medical Condition insrc/data/dsm-clinical-content.json) that only "disappears" because its count happens to be 0, not because it's derived.Consider computing
diagnosis_countfromdsmDiagnosesdirectly so the two can't drift.As per coding guidelines ("Automatic reviews may emit at most three inline findings... P2 context belongs in one summary"), this is folded into a single note rather than filed as a separate P1-style finding.
🤖 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/dsm.ts` at line 74, Update dsmCategories to determine category inclusion from the diagnoses in dsmDiagnoses rather than the hand-maintained category.diagnosis_count field. Ensure categories are retained only when they have at least one matching diagnosis, while preserving the existing category objects and dsmDiagnoses filtering behavior.Source: Coding guidelines
🤖 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/clinical-dashboard/master-search-header.tsx`:
- Around line 613-626: Update the dsm-compare branch in the action handler to
navigate directly to the DSM comparison UI at /dsm/compare, matching the routing
behavior used by specifiers-compare, while preserving the existing DSM mode and
query setup as appropriate.
In `@src/lib/app-modes.ts`:
- Around line 183-204: Update MasterSearchHeader’s canRunLocalSearch allowlist
to include the "dsm" search kind, preserving DSM submission when realDataReady
is false. Add a targeted test covering DSM search while document readiness is
disabled, using the existing header test patterns.
---
Nitpick comments:
In `@src/lib/dsm.ts`:
- Line 74: Update dsmCategories to determine category inclusion from the
diagnoses in dsmDiagnoses rather than the hand-maintained
category.diagnosis_count field. Ensure categories are retained only when they
have at least one matching diagnosis, while preserving the existing category
objects and dsmDiagnoses filtering behavior.
In `@src/lib/search-command-surface.ts`:
- Around line 81-90: Review the dsm configuration’s crossModes in the search
command surface and decide whether diagnostic specifiers should be included
alongside differentials, prescribing, and documents. If the intended UX supports
this clinical overlap, add the existing "specifiers" mode while preserving the
other cross-mode entries; otherwise leave the configuration unchanged and
document the intentional scope decision.
In `@tests/universal-search.test.ts`:
- Around line 60-61: Replace the manually duplicated domain-order arrays in the
test, including the filter near the current diff and the mockRuntime fixture,
with the canonical universalSearchDomains constant imported from
src/lib/universal-search-domains.ts. Preserve any test-specific subset or
ordering by deriving it from that constant rather than recreating domain
literals, ensuring DSM retains its canonical precedence over Differentials.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bc3772d0-6a68-4f19-a5a2-c1434475a8bb
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (34)
docs/branch-review-ledger.mddocs/site-map.mdscripts/generate-site-map.tssrc/app/dsm/compare/page.tsxsrc/app/dsm/diagnoses/[slug]/differentials/page.tsxsrc/app/dsm/diagnoses/[slug]/page.tsxsrc/app/dsm/layout.tsxsrc/app/dsm/loading.tsxsrc/app/dsm/page.tsxsrc/app/dsm/search/page.tsxsrc/app/page.tsxsrc/components/clinical-dashboard/ClinicalSidebar.tsxsrc/components/clinical-dashboard/global-search-shell.tsxsrc/components/clinical-dashboard/master-search-header.tsxsrc/components/clinical-dashboard/mode-action-popup.tsxsrc/components/clinical-dashboard/universal-search-command-surface.tsxsrc/components/dsm/dsm-comparison-page.tsxsrc/components/dsm/dsm-diagnosis-page.tsxsrc/components/dsm/dsm-differential-considerations-page.tsxsrc/components/dsm/dsm-home-page.tsxsrc/components/dsm/dsm-page-header.tsxsrc/components/dsm/dsm-search-page.tsxsrc/data/dsm-clinical-content.jsonsrc/lib/app-mode-icons.tssrc/lib/app-modes.tssrc/lib/dsm.tssrc/lib/search-command-surface.tssrc/lib/universal-search-domains.tssrc/lib/universal-search.tstests/app-modes.test.tstests/dsm.test.tstests/site-map.test.tstests/ui-smoke.spec.tstests/universal-search.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66a38c3162
ℹ️ 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".
|
@copilot resolve the merge conflicts on this branch. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/clinical-dashboard/mode-action-popup.tsx`:
- Around line 126-129: Update runModeAction in master-search-header.tsx to
handle specifiers-builder, specifiers-compare, and specifiers-map with their
intended mode, navigation, or workflow behavior before runActionAndClose is
invoked; alternatively remove these action entries from the mode-action popup if
they are not supported. Add focused tests covering each exposed action and its
resulting behavior.
In `@tests/ui-smoke.spec.ts`:
- Around line 2363-2370: Fix the syntax in the dashboard specifiers test
callback: remove the extra opening brace after `async ({ page }) =>` and replace
the invalid quote characters in the `getByRole` heading name with valid
JavaScript string quoting, preserving the expected heading text.
- Line 2369: Update the heading locator in the test’s getByRole assertion to use
ASCII string delimiters, while preserving the curly quotes around “anxious
distress” as string content so the JavaScript parses correctly.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
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 Plus
Run ID: b096e118-fa96-4df2-9491-e2b0d0e9b73a
📒 Files selected for processing (11)
docs/site-map.mdscripts/generate-site-map.tssrc/app/page.tsxsrc/components/clinical-dashboard/ClinicalSidebar.tsxsrc/components/clinical-dashboard/global-search-shell.tsxsrc/components/clinical-dashboard/master-search-header.tsxsrc/components/clinical-dashboard/mode-action-popup.tsxsrc/lib/app-mode-icons.tssrc/lib/app-modes.tstests/app-modes.test.tstests/ui-smoke.spec.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/lib/app-mode-icons.ts
- src/components/clinical-dashboard/ClinicalSidebar.tsx
- src/components/clinical-dashboard/global-search-shell.tsx
- src/components/clinical-dashboard/master-search-header.tsx
- docs/site-map.md
- src/lib/app-modes.ts
- scripts/generate-site-map.ts
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ❌ Cannot run autofix: This PR has merge conflicts. Please resolve the conflicts with the base branch and try again. Alternatively, use |
|
@copilot resolve the merge conflicts on this branch. |
…ation-20260714 # Conflicts: # src/components/clinical-dashboard/universal-search-command-surface.tsx # src/lib/app-modes.ts # src/lib/universal-search-domains.ts # src/lib/universal-search.ts # tests/universal-search.test.ts
Merge conflicts resolved in commit 5 conflicted files were resolved, combining both sides —
|
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 2 file(s) based on 2 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. The branch was updated while autofix was in progress. Please try again. |
Fixed 2 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Remove stale @/lib/specifiers site-map imports, restore DSM/specifier mode-context mappings, and fix the broken ui-smoke redirect test so typecheck, unit, and static PR gates can pass after the formulation workspace merge. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a85e2b4d8
ℹ️ 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06f129aa8a
ℹ️ 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".
Format the five Prettier-failing files so CI static checks pass, preserve compare selection ids when choosing diagnoses, and strip title parentheticals before building initialisms so aliases like PDD resolve correctly. Co-authored-by: Cursor <cursoragent@cursor.com>
Route Specifiers builder/compare/map actions to Formulation destinations, and include title abbreviations/initialisms in DSM search ranking so queries like MDD/PDD surface the right diagnoses. Co-authored-by: Cursor <cursoragent@cursor.com>
ESLint --max-warnings 0 failed on the unused local domain-to-mode map after universalSearchModeForDomain took over that lookup. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b367aeb084
ℹ️ 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".
The home heading uses curly quotes around the query, matching the Specifiers redirect smoke coverage, so the straight-quote assertion timed out. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep comparison ids on category filter links, and add common AU/US DSM spelling variants so queries like generalized anxiety disorder rank the catalogue record first. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e013894b2
ℹ️ 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".
Summary
Why
This recovers and completes the DSM implementation prepared in the side task, then integrates it through the current Database design system and protected-branch workflow.
Areas touched
Verification
Checks not run
Risk and governance
Summary by CodeRabbit
mode=dsmdeep-linking/redirect behavior.