import Link from 'next/link'; import { Section, Note } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { Freshness } from '@/components/ui/freshness'; import { Badge } from '@/components/ui/badge'; import { ApprovalsTable } from '@/components/data/approvals-table'; import { approvalsForCancer } from '@/lib/queries/drugs'; import { therapyMentionsForCancer } from '@/lib/queries/evidence'; import { loadProvenance } from '@/lib/queries/provenance'; import { fmtInt } from '@/lib/format'; import type { CancerBundle } from '../load'; export async function DrugsTab({ b, jurisdiction, aPage = 1 }: { b: CancerBundle; jurisdiction: string | null; aPage?: number }) { // Therapies mentioned in curated evidence (not approvals) — aggregated in SQL (no evidence rows // are shipped to the page), listed separately and never called "approved". const [approvals, therapies] = await Promise.all([approvalsForCancer(b.descendants), therapyMentionsForCancer(b.descendants)]); const jurisdictions = [...new Set(approvals.map((a) => a.jurisdiction))].sort(); const selected = jurisdiction && jurisdictions.includes(jurisdiction) ? jurisdiction : null; const shownApprovals = selected ? approvals.filter((a) => a.jurisdiction === selected) : approvals; if (approvals.length === 0 && therapies.length === 0) { return (
No regulatory approval or evidence-linked therapy is recorded for this entity or its descendants. Approvals are always shown with jurisdiction, authority and indication text — a drug is never marked simply "approved".
); } const prov = await loadProvenance(approvals.map((a) => a.provenance_id)); return (
{approvals.length ? ( <> `/cancer/${b.cancer.slug}/drugs?${new URLSearchParams({ ...(selected ? { jurisdiction: selected } : {}), ...(p > 1 ? { aPage: String(p) } : {}) }).toString()}#approvals`} /> (a.updated_at > m ? a.updated_at : m), approvals[0]!.updated_at)} /> ) : ( No regulatory approval recorded for this entity yet. )}
{therapies.length ? (
{therapies.map((t) => ( ))}
Therapy Evidence items (count) Sensitivity / response Resistance
{t.name} {fmtInt(t.n)} {fmtInt(t.sensitivity)} {fmtInt(t.resistance)}
) : ( No therapy appears in curated evidence for this entity. )}

Curated Items are counted regardless of level or direction; see the evidence tab for the detail.

Regulatory status is jurisdiction-specific and changes over time. This page is not treatment guidance.
); }