Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

31 changes: 6 additions & 25 deletions scripts/build-therapies-index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,19 @@ function renderManifest(current, previous, summary) {
].join("\n");
}

// The source catalogue's `modality` is an echo of one of the record's own tags:
// all 205 records carry one, every value is also present in that record's
// `tags`, and the whole catalogue collapses to just CBT/ACT/DBT. That inference
// mislabels somatic and psychodynamic treatments — ECT and rTMS as "ACT",
// Psychoanalysis and Psychodynamic Psychotherapy as "CBT", MBT and TFP as
// "DBT" — and the value renders as a curated chip on the detail and recommend
// screens while scoring related-therapy selection. A guess presented as a
// curated fact is a clinical mislabel, so emit the field only when the source
// genuinely curates a value that is not already one of the record's tags.
// Consumers already treat `null` as "unknown" and render nothing.
function curatedModality(therapy) {
const value = therapy.modality ?? null;
if (!value) return null;
const tags = Array.isArray(therapy.tags) ? therapy.tags : [];
return tags.includes(value) ? null : value;
}

// Detail and recommend load the full catalogue (`catalogue: "full"`), not the
// index projections. Scrub tag-echo modalities there too; a raw copy of the
// source would leave the mislabel on the only path that renders the chip.
const curatedFull = therapies.map((therapy) => ({
...therapy,
modality: curatedModality(therapy),
}));
// index projections. Strip dead modality field from full catalogue outputs.
const curatedFull = therapies.map((therapy) => {
const item = { ...therapy };
delete item.modality;
return item;
});

const projected = therapies
.map((t) => ({
slug: t.slug,
name: t.name,
category: t.category ?? null,
modality: curatedModality(t),
clinicalSummary: t.clinicalSummary ?? null,
bestUsedFor: t.bestUsedFor ?? null,
targetSymptoms: t.targetSymptoms ?? null,
Expand All @@ -140,7 +122,6 @@ const browserProjected = therapies
slug: therapy.slug,
name: therapy.name,
category: therapy.category ?? null,
modality: curatedModality(therapy),
// The browser index is the browse/pathway payload, not the search corpus.
// Keep only the short subtitle the catalogue cards render. Search loads the
// full records so removing long clinical prose here cannot change recall.
Expand Down
8 changes: 4 additions & 4 deletions src/components/therapy-compass/data/generated-assets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated by scripts/build-therapies-index.mjs. Do not edit.
export const THERAPY_CATALOGUE_ASSETS = {
full: "therapies.d0358686e452b00b.json",
index: "therapies-index.8455f92cf736cbfa.json",
full: "therapies.09b25b0fff3a2b44.json",
index: "therapies-index.211dab554c4ec62d.json",
home: "therapies-home.211dab554c4ec62d.json",
} as const;

Expand All @@ -11,8 +11,8 @@ export const THERAPY_CATALOGUE_ASSETS = {
// pruned. `useTherapyData` also falls back to the unversioned alias for
// bundles that include that fallback (pre-fallback clients are best-effort).
export const THERAPY_CATALOGUE_ASSETS_PREVIOUS = {
full: "therapies.a9dc3ae40e9d29fa.json",
index: "therapies-index.4b4ee988e0ff84e2.json",
full: "therapies.d0358686e452b00b.json",
index: "therapies-index.8455f92cf736cbfa.json",
home: "therapies-home.211dab554c4ec62d.json",
} as const;

Expand Down
3 changes: 1 addition & 2 deletions src/components/therapy-compass/data/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export function relatedTherapies(all: Therapy[], therapy: Therapy, n = 4): Thera
if (t.category === therapy.category) s += 5;
const shared = t.tags.filter((tag) => therapy.tags.includes(tag)).length;
s += shared * 2;
if (t.modality && t.modality === therapy.modality) s += 1;
return { t, s };
});
scored.sort((a, b) => b.s - a.s || a.t.name.localeCompare(b.t.name));
Expand Down Expand Up @@ -236,7 +235,7 @@ export const RECOMMEND_CONSTRAINTS: RecommendConstraint[] = [
{
key: "skills",
label: "Skills",
match: (t) => lc(`${t.tags.join(" ")} ${t.modality}`).match(/skill|dbt|cbt|behav/) != null,
match: (t) => lc(t.tags.join(" ")).match(/skill|dbt|cbt|behav/) != null,
},
{
key: "psychoeducation",
Expand Down
1 change: 0 additions & 1 deletion src/components/therapy-compass/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export type Therapy = {
slug: string;
name: string;
category: string;
modality: string | null;
clinicalSummary: string | null;
bestUsedFor: string | null;
indications: string | null;
Expand Down
5 changes: 0 additions & 5 deletions src/components/therapy-compass/screens/detail-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export function DetailScreen() {
{complexityLabel(t.complexity)}
</span>
) : null}
{t.modality ? (
<span className="text-xs font-semibold py-[5px] px-[11px] rounded-md bg-[color:var(--surface-inset)] text-[color:var(--text-muted)] border border-[color:var(--border)]">
{t.modality}
</span>
) : null}
<button
type="button"
className={`${therapyBtn} ${outlineControl} ml-auto px-3 text-xs`}
Expand Down
5 changes: 0 additions & 5 deletions src/components/therapy-compass/screens/recommend-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ export function RecommendScreen() {
<span className="text-2xs font-semibold text-[color:var(--success-text)] bg-[color:var(--success-bg)] border border-[color:var(--success-border)] py-0.5 px-[9px] rounded-sm">
Strong match
</span>
{top.modality ? (
<span className="text-2xs font-semibold text-[color:var(--info-text)] bg-[color:var(--info-bg)] border border-[color:var(--info-border)] py-0.5 px-[9px] rounded-sm">
{top.modality}
</span>
) : null}
</div>
<p className="m-0 text-sm-minus leading-normal text-[color:var(--text-muted)]">
{summarise(top.clinicalSummary, 2) || top.bestUsedFor}
Expand Down
Loading
Loading