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, ClaimBadge, StatusBadge } from '@/components/ui/badge'; import { SourceBadge } from '@/components/ui/source-badge'; import { countryTrialTotals, countrySitesByCancer, countrySitesByPhase, jurisdictionApprovalSummary, latestJurisdictionApprovals } from '@/lib/queries/country-activity'; import { fmtDate, fmtInt, fmtPct, phaseLabel, truncate } from '@/lib/format'; /** ISO 3166-1 alpha-2 codes that are also `drug_approvals.jurisdiction` codes. */ const JURISDICTIONS: Record = { US: 'US', CA: 'CA', GB: 'UK', AU: 'AU', JP: 'JP', CH: 'CH' }; /** * Country research & regulatory activity (SPEC §22): trial sites in the country from ClinicalTrials.gov * locations (derived, formula ci-trial-sites-v1) and approval records for the country's regulator. * Rendered on every country page, including those without epidemiology observations. */ export async function CountryActivity({ iso2, iso3, name, kind }: { iso2: string | null; iso3: string | null; name: string; kind: string }) { if (kind !== 'country' || !iso3) return null; const jurisdiction = iso2 ? JURISDICTIONS[iso2] ?? null : null; const [totals, byCancer, byPhase, approvalSummary, latest] = await Promise.all([countryTrialTotals(iso3), countrySitesByCancer(iso3, 25), countrySitesByPhase(iso3), jurisdiction ? jurisdictionApprovalSummary(jurisdiction) : Promise.resolve([]), jurisdiction ? latestJurisdictionApprovals(jurisdiction, 10) : Promise.resolve([])]); return ( <>
Trial map →}> {totals ? ( <>
{[ ['Sites', totals.sites], ['Studies with a site here', totals.trials], ['Recruiting sites', totals.recruiting_sites], ['Recruiting studies', totals.recruiting_trials], ].map(([k, v]) => (
{k}
{fmtInt(v as number)}
))}
{byCancer.map((r) => ( ))}
Top-level cancers by sites in {name} (descendants included)
Cancer Sites Studies Recruiting studies Share of sites
{r.canonical_name} {fmtInt(r.sites)} {fmtInt(r.trials)} {fmtInt(r.recruiting_trials)} {fmtPct(r.sites / totals.sites, 1)}
{byPhase.map((p) => ( ))}
By phase (a Phase II/III study counts in both)
Phase Sites Studies Recruiting
{phaseLabel(p.phase)} {fmtInt(p.sites)} {fmtInt(p.trials)} {fmtInt(p.recruiting_trials)}

formula ci-trial-sites-v1 · source: clinicaltrials · shares are of sites, not of studies

) : ( Country aggregates exist for every country named in ClinicalTrials.gov locations; none names {name} yet, or the aggregate has not been computed. )}
{jurisdiction ? (
All records →}> {approvalSummary.length ? ( <>

{approvalSummary.map((s) => ( {s.authority} · {s.status}: {fmtInt(s.n)} records / {fmtInt(s.drugs)} drugs ))}

) : ( Regulatory connectors are live for the FDA (US), Health Canada (CA) and the EMA (EU). Other regulators are not yet ingested. )}
) : ( Regulatory records are ingested per jurisdiction (US, CA, EU so far); {name} has no connected regulator yet. )} ); }