import Link from 'next/link'; import { ExternalLink } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Breadcrumbs } from '@/components/layout/breadcrumbs'; import { Tabs } from '@/components/ui/tabs'; import { GraphLink } from '@/components/graph/graph-link'; import { CODE_SYSTEM_LABEL, codeUrl } from '@/lib/site'; import { humanize, fmtInt } from '@/lib/format'; import { TABS, type CancerBundle, type TabKey } from './load'; const PRIMARY_SYSTEMS = ['ncit', 'oncotree', 'icd10', 'icd10cm', 'doid', 'umls', 'mesh', 'mondo']; export function CancerHeader({ b, tab }: { b: CancerBundle; tab: TabKey }) { const { cancer: c, counters, codes, aliases, path } = b; const abbreviations = aliases.filter((a) => a.alias_type === 'abbreviation').map((a) => a.alias); const shown = codes.filter((k) => PRIMARY_SYSTEMS.includes(k.system)).sort((a, b2) => PRIMARY_SYSTEMS.indexOf(a.system) - PRIMARY_SYSTEMS.indexOf(b2.system)); const otherCodes = codes.length - shown.length; const badges: Array<{ label: string; tone?: 'neutral' | 'accent' | 'warn' | 'outline'; title: string }> = []; if (c.rare_cancer === true) badges.push({ label: 'Rare', tone: 'accent', title: 'Flagged rare from incidence data (rule: age-standardized incidence < 6 per 100,000)' }); if (c.pediatric_relevant) badges.push({ label: 'Pediatric', title: 'Pediatric-relevant entity (NCIt childhood neoplasm branch)' }); if (c.hematologic) badges.push({ label: 'Hematologic', title: 'Hematologic malignancy' }); if (!c.malignant) badges.push({ label: c.entity_type === 'precursor_condition' ? 'Precursor' : 'Non-malignant', tone: 'outline', title: 'Not a malignant neoplasm; kept for taxonomy completeness' }); if (c.top_level) badges.push({ label: 'Top-level', tone: 'outline', title: 'Member of the mutually exclusive global ranking set' }); if (counters) { if (counters.active_trial_count > 0) badges.push({ label: `${fmtInt(counters.active_trial_count)} active trials`, tone: 'outline', title: 'From ClinicalTrials.gov, over descendants' }); if (counters.approved_drug_count > 0) badges.push({ label: `${fmtInt(counters.approved_drug_count)} approved drugs`, tone: 'outline', title: 'Drugs with at least one approval in any jurisdiction' }); if (counters.evidence_count > 0) badges.push({ label: `${fmtInt(counters.evidence_count)} evidence items`, tone: 'outline', title: 'Accepted CIViC evidence items' }); } const crumbs = [{ label: 'Cancers', href: '/cancers' }, ...path.slice(0, -1).map((p) => ({ label: p.canonical_name, href: `/cancer/${p.slug}` })), { label: c.canonical_name }]; return (
{b.redirectedFrom ? (

{b.redirectedFrom.id} ({b.redirectedFrom.canonical_name}) was merged into this entity.

) : null} {c.status === 'deprecated' ?

Deprecated entity{c.deprecated_reason ? `: ${c.deprecated_reason}` : ''}. Kept for identifier stability.

: null}

{humanize(c.entity_type)}

{c.canonical_name}

{c.id} {c.short_name && c.short_name !== c.canonical_name ? {c.short_name} : null} {abbreviations.length ? {abbreviations.slice(0, 6).join(' ยท ')} : null}

{badges.length ? (
{badges.map((bd) => ( {bd.label} ))}
) : null}
{shown.map((k) => { const url = codeUrl(k.system, k.code); return (
{CODE_SYSTEM_LABEL[k.system] ?? k.system}
{url ? ( {k.code} ) : ( {k.code} )}
); })} {otherCodes > 0 ? (
Other
{otherCodes} more {otherCodes === 1 ? 'code' : 'codes'}
) : null} {shown.length === 0 && otherCodes === 0 ?
No cross-reference codes yet
: null}
({ key: t.key, label: t.label, href: t.key === 'overview' ? `/cancer/${c.slug}` : `/cancer/${c.slug}/${t.key}`, count: t.key === 'trials' ? counters?.trial_count : t.key === 'evidence' ? counters?.evidence_count : t.key === 'drugs' ? counters?.drug_count : t.key === 'statistics' ? counters?.epidemiology_obs_count : t.key === 'survival' ? counters?.survival_obs_count : t.key === 'genomics' ? counters?.cohort_count : null, }))} />
); }