import Link from 'next/link'; import { Section, Note } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { ClaimBadge, ConfidenceBadge } from '@/components/ui/badge'; import { JsonView } from '@/components/ui/json-view'; import { rankingsForCancer } from '@/lib/queries/rankings'; import { fmtDate, fmtInt, fmtValue, scopeLabel, unitLabel } from '@/lib/format'; import { latestYearPerScope } from '@/lib/rankings-util'; import { CancerGapCard } from '@/components/research-gap/cancer-gap-card'; import type { CancerBundle } from '../load'; function Delta({ rank, prev }: { rank: number; prev: number | null }) { if (prev == null) return new; const d = prev - rank; if (d === 0) return =; return ( 0 ? 'text-ok' : 'text-danger'} title={`Previous rank ${prev}`}> {d > 0 ? '▲' : '▼'} {Math.abs(d)} ); } export async function RankingsTab({ b }: { b: CancerBundle }) { const allRows = await rankingsForCancer(b.cancer.id); // One row per (metric, geography, sex, age, level): the latest year only. Historical years stay on the ranking pages. const { rows, hidden: hiddenYears } = latestYearPerScope(allRows); if (rows.length === 0) { return (
This entity appears in no current ranking snapshot. Rankings are computed per metric and scope (geography, sex, age, year, entity level) once the underlying counters or licensed observations exist; an entity with a zero counter is ranked only when the metric admits zeros.
); } return (
0 ? `; ${fmtInt(hiddenYears)} earlier yearly snapshots are on the ranking pages` : ''}). Each row lists the scope, the formula version, the value and the exact inputs that produced it.`}>
{rows.map((r) => ( ))}
Metric Scope Rank / eligible Δ Value Percentile Confidence Formula Generated Inputs
{r.metric_name} {scopeLabel(r.scope_key)} #{r.rank} / {fmtInt(r.eligible_entities)} {fmtValue(r.value, r.unit)} {unitLabel(r.unit)} {r.percentile} {r.formula_version} {fmtDate(r.generated_at)}
show

formula: {r.formula}

inputs hash {r.inputs_hash}

Trace lineage (admin)

Ranks are competition ranks (ties share a rank). Percentile = share of eligible entities ranked at or below this one in the ranking direction.

"Deadliest" is ambiguous: annual deaths, age-standardized mortality rate, mortality-to-incidence ratio and 5-year survival rank cancers differently. CancerIndex publishes each as a separate metric.
); }