import { useState } from 'react'; import { CheckCircle, XCircle, Loader2, Brain } from 'lucide-react'; import { api } from '../api'; import { useAuth } from '../context/AuthContext'; const LABEL_ROLES = ['doctor', 'nurse', 'super_admin', 'admin']; /** * Human-in-the-loop control for the patient view. Rendered only when the * screening was queued for review (the predict response carries `review_id`) * and the signed-in user holds a clinical role. The clinician's label is the * ground truth the next retraining cycle reads. */ export default function ReviewLabelBox({ reviewId }) { const { user } = useAuth(); const [busy, setBusy] = useState(false); const [done, setDone] = useState(null); const [error, setError] = useState(''); const [notes, setNotes] = useState(''); const roles = (user?.roles ?? []).map((r) => (typeof r === 'string' ? r : r?.name)); if (!reviewId || !roles.some((r) => LABEL_ROLES.includes(r))) return null; async function submit(label) { setBusy(true); setError(''); try { await api.annotateReview(reviewId, label, notes.trim() || null); setDone(label); } catch (e) { setError(e.message || 'Could not save the label.'); } finally { setBusy(false); } } return (
Model is unsure about this patient
Recorded as {done === 1 ? 'Positive' : 'Negative'}. Thank you — this label feeds the next retraining cycle.
) : ( <>If you have confirmed the diagnosis, label this case. Leave it unlabeled if you are not sure.