import Link from 'next/link'; import { Section } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { Freshness } from '@/components/ui/freshness'; import { Badge, ClaimBadge } from '@/components/ui/badge'; import { SourceBadge } from '@/components/ui/source-badge'; import { getGeographyBySlug, topCancersFor, yearsFor, type TopCancersResult } from '@/lib/queries/geography'; import { EPI_METRIC_LABEL } from '@/lib/queries/epidemiology'; import { fmtInt, fmtValue, unitLabel, toDate } from '@/lib/format'; /** * Home module "Cancer burden in the United States (latest year)" (§105, §328): top 5 by deaths and top 5 by * age-standardized incidence, straight from observations, with year and source on every row. */ export async function BurdenModule({ slug = 'united-states' }: { slug?: string }) { const geo = await getGeographyBySlug(slug); const years = geo ? await yearsFor(geo.id) : []; const latest = years[0]; const [deaths, asir] = geo && latest ? await Promise.all([topCancersFor(geo, 'mortality_count', latest, 'all', 5), topCancersFor(geo, 'as_incidence_rate', latest, 'all', 5)]) : [null, null]; const has = !!(deaths?.rows.length || asir?.rows.length); const freshest = [...(deaths?.rows ?? []), ...(asir?.rows ?? [])].map((r) => toDate(r.updated_at)).filter((d): d is Date => !!d).sort((a, b) => b.getTime() - a.getTime())[0] ?? null; return (
Country page → } > {!has ? ( Burden figures appear once a licensed registry connector has ingested observations for the United States. IARC / GLOBOCAN remains under license review; SEER awaits credentials.
Countries with data
) : ( <>
{[deaths, asir].map((res) => (res ? : null))}
)}
); } function TopFive({ res, sex, slug }: { res: TopCancersResult; sex: string; slug: string }) { const first = res.rows[0]; if (!first) { return (

{EPI_METRIC_LABEL[res.metric] ?? res.metric}

No {EPI_METRIC_LABEL[res.metric]?.toLowerCase() ?? res.metric} observation for {res.requestedYear}.
); } const allObserved = res.rows.every((r) => r.estimate_type === 'observed'); return (

Top 5 · {EPI_METRIC_LABEL[res.metric] ?? res.metric} {res.year} {res.year !== res.requestedYear ? ` (latest available; ${res.requestedYear} not yet published)` : ''} · {unitLabel(first.unit)}

{res.rows.map((r, i) => ( ))}
# Cancer {unitLabel(first.unit)} Type
{r.rank ?? i + 1} {r.canonical_name} {fmtValue(r.value, r.unit)} {r.estimate_type}
{/* div, not p: the SourceBadge popover contains a
, which the HTML parser would use to close a

(hydration mismatch). */}

{first.standard_population ? standard: {first.standard_population} : null} {res.rows.some((r) => r.rank == null) ? rank = position in this table when no snapshot covers the year : rank from snapshot {first.rank_scope_key ? {first.rank_scope_key} : null}} {!allObserved ? includes estimated values : null} full table ({fmtInt(res.rows.length)} shown) →
); }