Skip to content

fix(therapy-compass): re-curate mismatched pathway recommendations#692

Merged
BigSimmo merged 2 commits into
mainfrom
claude/therapy-compass-pages-rz0m5l
Jul 17, 2026
Merged

fix(therapy-compass): re-curate mismatched pathway recommendations#692
BigSimmo merged 2 commits into
mainfrom
claude/therapy-compass-pages-rz0m5l

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 17, 2026

Copy link
Copy Markdown
Owner

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-therapy tags are 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:

Pathway Initial → then
Anxiety CBT → graded exposure, applied relaxation, worry/panic/social-anxiety CBT
Crisis/risk crisis intervention → self-harm CBT, problem-solving, DBT, coping skills
Grief/loss IPT → meaning-centred, supportive, life-review, dignity therapy, EFT
Eating/body image CBT-E → FT-AN, BED guided self-help, MANTRA, SSCM
Trauma TF-CBT → EMDR, CPT, PE, NET, written exposure
Substance use MI for SUD → relapse prevention, contingency mgmt, CRA, MBRP, 12-step
Psychosis CBTp → family intervention, psychoeducation, CRT, IMR, IPS

…and Mood, Sleep, Personality, Neurodevelopmental, Pain/somatic likewise. Each step's description is regenerated from the chosen therapy's own indication text (bestUsedFor) so nothing is invented. Records keep their needs_review / incomplete flags.

tests/therapy-compass-pathways.test.ts adds 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 definition devOnly (the 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 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 devOnly to false once the sequencing is clinically approved.

Verification

  • npm run typecheck — clean
  • npm run lint — clean
  • npm run test2474 passed / 3 skipped, incl. the new pathway-integrity suite (all 72 steps resolve to a real, domain-appropriate therapy) and a devOnly-visibility guard
  • npm run format:check — clean · npm run sitemap:check — clean
  • npm 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:qualityN/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

  • Source-backed claims still require linked source verification — each step's text is regenerated from the referenced therapy's own indication field; needs_review framing preserved.
  • No patient-identifiable document workflow introduced or expanded.
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — static JSON only; no schema/RLS/service-role change.
  • Service-role keys and private document access remain server-only.
  • Demo/synthetic content remains separate — self-contained reference export.
  • Source metadata / review status / outdated behaviour remain conservative — every pathway stays incomplete: true / needs_review.
  • Deployment classification / TGA SaMD impact — addressed conservatively. Production exposure is now held via devOnly until the pathway sequencing has qualified-clinician sign-off; the tool remains available for internal/dev review in the meantime.

Notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K

Summary by CodeRabbit

  • New Features

    • Updated Therapy Compass pathways with revised therapy options, descriptions, and sequencing across multiple clinical areas.
    • Therapy Compass remains available in development while being hidden from production navigation and discovery.
  • Bug Fixes

    • Sidebar tool navigation now excludes tools that are not visible in the current app mode.
  • Tests

    • Added validation for app-mode visibility and Therapy Compass pathway data consistency.

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
@supabase

supabase Bot commented Jul 17, 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

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e3e1d91f-0622-446f-8cdb-2456614d25a9

📥 Commits

Reviewing files that changed from the base of the PR and between d7d12b5 and ec6039c.

📒 Files selected for processing (5)
  • public/therapy-compass-data/pathways.json
  • src/components/clinical-dashboard/ClinicalSidebar.tsx
  • src/lib/app-modes.ts
  • tests/app-modes.test.ts
  • tests/therapy-compass-pathways.test.ts

📝 Walkthrough

Walkthrough

Therapy 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.

Changes

Therapy Compass

Layer / File(s) Summary
Development-only mode visibility
src/lib/app-modes.ts, src/components/clinical-dashboard/ClinicalSidebar.tsx, tests/app-modes.test.ts
The therapy-compass app mode is marked devOnly, sidebar tool lists use visibility filtering, and development/production discovery is tested.
Pathway therapy data and clinical validation
public/therapy-compass-data/pathways.json, tests/therapy-compass-pathways.test.ts
Therapy selections and descriptions are updated across pathways, with tests validating catalogue references, clinical allowlists, description consistency, initial-option ordering, and known mismatches.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • BigSimmo/Database#679: Adds the Therapy Compass app mode and navigation scaffolding referenced by these visibility changes.

Suggested reviewers: claude

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/therapy-compass-pages-rz0m5l

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

…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
@BigSimmo
BigSimmo marked this pull request as ready for review July 17, 2026 04:42
@BigSimmo
BigSimmo merged commit f1f0494 into main Jul 17, 2026
16 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 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".

Comment thread src/lib/app-modes.ts
Comment on lines +316 to +320
// 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@BigSimmo
BigSimmo deleted the claude/therapy-compass-pages-rz0m5l branch July 17, 2026 05:45
Sign up for free to 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