import { useMemo } from "react";
import type { GalleryItem, HCCCandidate, MEATEvidence } from "../lib/types";
import { cn } from "../lib/cn";
interface Props {
noteText: string;
onChange: (text: string) => void;
gallery: GalleryItem[];
onPickGalleryItem: (item: GalleryItem) => void;
onCode: () => void;
loading: boolean;
selectedCandidate: HCCCandidate | null;
}
export function NotePanel(props: Props) {
const { noteText, onChange, gallery, onPickGalleryItem, onCode, loading, selectedCandidate } =
props;
const highlights = useMemo(() => buildHighlights(selectedCandidate, noteText), [
selectedCandidate,
noteText,
]);
return (
Clinical note
);
}
function buildHighlights(
candidate: HCCCandidate | null,
text: string,
): React.ReactNode {
if (!candidate)
return Preview;
const spans: { start: number; end: number; cat: string; ev: MEATEvidence }[] = [];
for (const ev of candidate.meat_evidence) {
if (!ev.verified) continue;
spans.push({ start: ev.start, end: ev.end, cat: ev.category, ev });
}
spans.sort((a, b) => a.start - b.start);
const out: React.ReactNode[] = [];
let cursor = 0;
spans.forEach((s, i) => {
if (s.start < cursor) return; // overlap; skip
if (s.start > cursor)
out.push({text.slice(cursor, s.start)});
out.push(
{text.slice(s.start, s.end)}
,
);
cursor = s.end;
});
if (cursor < text.length) out.push({text.slice(cursor)});
return <>{out}>;
}
function GalleryDropdown({
gallery,
onPick,
}: {
gallery: GalleryItem[];
onPick: (i: GalleryItem) => void;
}) {
if (!gallery.length)
return (gallery loading…);
return (
);
}