import { BookOpenCheck, ExternalLink, Loader2, AlertTriangle, ChevronDown, ClipboardList } from 'lucide-react'; import { summariseEvidence, EVIDENCE_TITLE, EVIDENCE_LOADING, ACTION_PLAN_ANCHOR_ID, } from '../utils/evidenceSummary'; /** * Card B — Evidence-backed actions (v3 §1). * * What trials (or, labelled as such, cohorts) measured for an action, on a * future outcome, in their own population. It is deliberately a separate card * from Estimate drivers — its own border, accent and icon, never nested in the * SHAP card — because the two answer different questions and must not be read * together as "treat X and this patient's number falls". * * Every number shown comes from the /evidence-actions response (copied from * backend/evidence/registry.yaml); wording and classification come from * evidenceSummary.js, which the PDF uses too. * * Rendering states: loading → spinner; error → "Evidence could not be loaded" * with no numbers; empty → says nothing maps; ready → items. */ function Header() { return (

); } function ScopeNote({ text }) { return (

{text}

); } function scrollToActionPlan(event) { event.preventDefault(); document.getElementById(ACTION_PLAN_ANCHOR_ID)?.scrollIntoView({ behavior: 'smooth', block: 'center' }); } function EvidenceBadge({ effect }) { if (!effect.label) return null; const cls = effect.observational ? 'bg-amber-100 text-amber-800 border-amber-300' : 'bg-teal-100 text-teal-800 border-teal-200'; return ( {effect.label} ); } function SourceChip({ effect }) { if (!effect.url) return null; return ( {effect.citation} ); } function RuleSource({ source }) { if (!source) return null; return (
{source.locator && {source.locator}}
); } /** One-line source for the compact sections: short name, linked to the DOI. */ function CompactSource({ source }) { if (!source) return null; return ( <> {' · '} {source.compact} ); } function Item({ item }) { return (
  • {item.action}

    {item.headline &&

    {item.headline}

    } {item.reasons.length > 1 && ( )} {item.ruleLine &&

    {item.ruleLine}

    } {item.reasons.filter((r) => r.source).map((r) => )} {item.conditions.map((line) => (

    {line}

    ))} {item.outcomeLine &&

    {item.outcomeLine}

    } {item.mappedLine && (

    {item.mappedLine}{item.matchLine && ` · ${item.matchLine}`}

    )}
      {item.effects.map((effect) => (
    • {effect.text}

      {effect.showSource && (
      )}
    • ))}
    {(item.caveatLines.length > 0 || item.measurementLine || item.notes.length > 0) && (
    {item.caveatLines.map((c) => (

    ))} {item.measurementLine &&

    {item.measurementLine}

    } {item.notes.map((n) =>

    {n}

    )}
    )}
  • ); } export default function EvidenceActionsCard({ response, loading, error, supported = true }) { const ev = summariseEvidence({ response, loading, error, supported }); if (ev.state === 'unavailable') return null; return (
    {ev.state === 'loading' && (
    {EVIDENCE_LOADING}
    )} {ev.state === 'error' && (
    )} {(ev.state === 'ready' || ev.state === 'empty') && ( <> {ev.firstAction && ( )} {ev.message &&

    {ev.message}

    } {ev.sections.map((section) => ( section.collapsed ? (
    {section.title} ({section.items.length})
      {section.items.map((item) => (
    • {item.action} — {item.headline} {item.ruleLine && · {item.ruleLine}}
    • ))}
    ) : (

    {section.title}

    {section.compact ? (
      {section.items.map((item) => (
    • {item.action} — {item.headline}
    • ))}
    ) : (
      {section.items.map((item) => )}
    )}
    ) ))} {ev.associationOnly.length > 0 && (
    {ev.associationOnlyTitle} ({ev.associationOnly.length})
      {ev.associationOnly.map((a) => (
    • {a.feature} — {a.statement}
    • ))}
    )} {ev.notInModel.length > 0 && (
    {ev.notInModelTitle}:{' '} {ev.notInModel.map((n, i) => ( {i > 0 && '; '} {n.action} — {n.statement} ))}
    )} )} {ev.scopeNote && }
    ); }