/** * Structured radiology report display with section parsing and copy button. */ import { useState } from "react"; import { motion } from "framer-motion"; import { FileText, Copy, Check, Clock } from "lucide-react"; interface Props { report: string; inferenceTimeMs: number; modelVersion: string; } function parseReport(report: string): Record { const sections: Record = {}; const sectionPattern = /^(FINDINGS|IMPRESSION|RECOMMENDATION):\s*$/gm; const parts = report.split(sectionPattern); for (let i = 1; i < parts.length; i += 2) { sections[parts[i].trim()] = parts[i + 1]?.trim() ?? ""; } if (Object.keys(sections).length === 0) sections["REPORT"] = report; return sections; } const SECTION_COLORS: Record = { FINDINGS: "text-blue-400 border-blue-500/30", IMPRESSION: "text-purple-400 border-purple-500/30", RECOMMENDATION: "text-amber-400 border-amber-500/30", REPORT: "text-slate-400 border-slate-500/30", }; export default function ReportViewer({ report, inferenceTimeMs, modelVersion }: Props) { const [copied, setCopied] = useState(false); const sections = parseReport(report); const handleCopy = () => { navigator.clipboard.writeText(report); setCopied(true); setTimeout(() => setCopied(false), 2000); }; return ( {/* Header */}

Radiology Report

AI-generated · v{modelVersion}
{inferenceTimeMs.toFixed(0)}ms
{/* Disclaimer */}
⚠️ This report is AI-generated for research purposes only. Not a substitute for radiologist interpretation.
{/* Report sections */}
{Object.entries(sections).map(([section, content]) => (

{section}

{content}

))}
); }