import { Section, Note } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { Freshness } from '@/components/ui/freshness'; import { ClaimBadge } from '@/components/ui/badge'; import { SourceBadge, TableProvenance } from '@/components/ui/source-badge'; import { survivalFor } from '@/lib/queries/epidemiology'; import { loadProvenance, toInfo } from '@/lib/queries/provenance'; import { fmtInt, fmtPct, fmtNum, humanize } from '@/lib/format'; import type { CancerBundle } from '../load'; export async function SurvivalTab({ b }: { b: CancerBundle }) { const rows = await survivalFor(b.cancer.id); if (rows.length === 0) { return (
No survival observation is attached. Survival statistics require stage, staging system, diagnosis period, survival type and population — they are only imported with that full context (SEER, once credentials and terms are settled).
); } const prov = await loadProvenance(rows.map((r) => r.provenance_id)); const groups = new Map(); for (const r of rows) { const k = `${r.survival_type}|${r.stage ?? 'all stages'}|${r.geography_name ?? ''}`; if (!groups.has(k)) groups.set(k, []); groups.get(k)!.push(r); } return (
Population survival is not an individual prognosis. Figures apply to the cohort, period, stage and population declared by the source; treatment landscapes change after the diagnosis period shown. {[...groups.entries()].map(([k, rs]) => { const f = rs[0]!; const firstProv = toInfo(prov.get(f.provenance_id)) ?? { sourceSlug: f.source_slug, sourceName: f.source_name }; return (
}> {rs.length} observation{rs.length === 1 ? '' : 's'} · diagnosis period, follow-up and method as published; hover a row badge for its dataset and version.
{rs.map((r) => ( ))}
Diagnosis period Sex Age group Follow-up (months) Survival (%) 95% CI Median (months) Cohort (n) Method Source
{r.diagnosis_period ?? '—'} {humanize(r.sex)} {r.age_group === 'all' ? 'All ages' : r.age_group} {r.duration_months} {fmtPct(r.probability)} {r.lower_ci != null && r.upper_ci != null ? `${fmtPct(r.lower_ci)}–${fmtPct(r.upper_ci)}` : '—'} {r.median_months != null ? fmtNum(r.median_months, 1) : '—'} {r.cohort_size != null ? fmtInt(r.cohort_size) : '—'} {r.method ?? '—'}
); })}
); }