fix(therapy-compass): re-curate mismatched pathway recommendations#692
Conversation
The imported pathway dataset mapped clinical problems to unrelated therapies — Crisis/risk led with ERP for tics, Grief/loss listed eating-disorder therapies, Pain/somatic pointed at tic ERP. The per-therapy tags are auto-generated and far too broad to distinguish these, so tag-based validation treated the mismatches as valid. Re-curate all 12 pathways to evidence-based, domain-appropriate therapies drawn from the catalogue, ordered initial → alternative → follow-up, with each step's description regenerated from the chosen therapy's own indication text so it stays source-grounded. Records remain flagged needs_review — the sequencing still wants qualified clinician sign-off. Add tests/therapy-compass-pathways.test.ts: an independent per-problem allowlist asserts every step references a real catalogue therapy that is clinically indexed to that pathway's problem, descriptions stay source-grounded, and the known cross-domain mismatches cannot return. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughTherapy Compass is marked development-only and filtered from production sidebar navigation. Its pathway therapy selections are replaced across multiple clinical problems, with new tests validating therapy references, domain appropriateness, descriptions, ordering, and known mismatches. ChangesTherapy Compass
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…n sign-off The pathway recommendations are now clinically sane, but the sequencing has not received qualified-clinician sign-off, so gate the mode devOnly: it stays available in the development switcher and its route still works, but it is hidden from the production sidebar and MODE dropdown. - app-modes.ts: mark the therapy-compass definition devOnly (existing isAppModeVisible / visibleAppModeDefinitions machinery hides it in production; the MODE dropdown already filters on that). - ClinicalSidebar.tsx: the sidebar renders a hardcoded tool list, so filter out dev-only app modes there too. Non-mode entries (answer, documents, prescribing, tools) are query-param destinations, not app modes, and always stay. - app-modes.test.ts: guard the intended state so promoting the mode to production is a deliberate, reviewed act (remove devOnly + update this). Flip devOnly to false once the pathway sequencing is clinically approved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec6039c510
ℹ️ 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".
| // Held out of production discovery until the re-curated therapy pathways | ||
| // receive qualified-clinician sign-off. Stays available in the dev switcher; | ||
| // hidden from the production sidebar and MODE dropdown. Flip to false (or | ||
| // remove) once the sequencing is clinically approved. | ||
| devOnly: true, |
There was a problem hiding this comment.
Block the unreviewed tool’s production route
In production, devOnly only removes this mode from discovery UI; a visitor can still request /therapy-compass directly, where src/app/therapy-compass/page.tsx unconditionally renders TherapyCompassPage and proxy.ts blocks only /mockups. Thus the explicitly unapproved therapy sequencing remains publicly usable despite this gate, including deep-linked searches. Add a server-side route/proxy guard (or remove the production route/data) until clinician sign-off, and cover a production-route request in the test.
Useful? React with 👍 / 👎.
Summary
Two related fixes to the Therapy Compass tool, which shipped with its imported mockup data live in the production mode.
1. Re-curate the mismatched pathway recommendations
The pathway dataset (
public/therapy-compass-data/pathways.json) mapped each clinical problem to unrelated therapies — Crisis/risk led with ERP for tics, Grief/loss listed vocational rehab and eating-disorder therapies, Pain/somatic pointed at ERP for tics. CodeRabbit flagged this as a Major functional-correctness issue; it's a real clinical-safety concern in a decision-support surface. The per-therapytagsare auto-generated and far too broad to distinguish these (ACT is tagged with nearly every domain), so tag-based checks treated the mismatches as valid.All 12 pathways are re-curated to evidence-based, domain-appropriate therapies from the existing catalogue, ordered initial → alternative → follow-up:
…and Mood, Sleep, Personality, Neurodevelopmental, Pain/somatic likewise. Each step's
descriptionis regenerated from the chosen therapy's own indication text (bestUsedFor) so nothing is invented. Records keep theirneeds_review/incompleteflags.tests/therapy-compass-pathways.test.tsadds an independent per-problem allowlist that fails if any step references a therapy not clinically indexed to that problem, keeps descriptions source-grounded, and blocks the known mismatches from returning.2. Hold the mode out of production until clinician sign-off
The mappings are now clinically sane, but the sequencing has not had qualified-clinician sign-off, so the mode is gated
devOnly: true: it stays in the development switcher and its route still works, but it's hidden from the production sidebar and MODE dropdown.app-modes.ts— mark the definitiondevOnly(the existingisAppModeVisible/visibleAppModeDefinitionsmachinery hides it in production; the MODE dropdown already filters on that).ClinicalSidebar.tsx— the sidebar renders a hardcoded tool list, so dev-only app modes are filtered out there too; non-mode entries (answer, documents, prescribing, tools) always stay.app-modes.test.ts— guards the intended state so promoting the mode later is a deliberate, reviewed act.Flip
devOnlytofalseonce the sequencing is clinically approved.Verification
npm run typecheck— cleannpm run lint— cleannpm run test— 2474 passed / 3 skipped, incl. the new pathway-integrity suite (all 72 steps resolve to a real, domain-appropriate therapy) and a devOnly-visibility guardnpm run format:check— clean ·npm run sitemap:check— cleannpm run verify:pr-local/verify:ui— not run in-sandbox; the only UI change is dropping one nav entry in production (no styling/routing/behaviour change)npm run eval:retrieval:quality— N/A. Self-contained static JSON; no retrieval/ranking/selection/chunking/scoring path touched.npm run check:production-readiness— not run here (provider-confirmation boundary).Clinical Governance Preflight
needs_reviewframing preserved.Clinical KB Database(sjrfecxgysukkwxsowpy) — static JSON only; no schema/RLS/service-role change.incomplete: true/needs_review.devOnlyuntil the pathway sequencing has qualified-clinician sign-off; the tool remains available for internal/dev review in the meantime.Notes
main.🤖 Generated with Claude Code
https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
Summary by CodeRabbit
New Features
Bug Fixes
Tests