import { useState } from "react"; import type { EffectDirection, EvidenceStream, StudyFeatureKey } from "../types"; import { initialConfidenceFor } from "../utils/confidence"; import { useRobReference } from "./useRobReference"; import "./review-fixes.css"; export interface ExtractionFormData { species: string | null; route: string | null; duration: string | null; noael: string | null; loael: string | null; effect_finding: string | null; notes: string | null; outcome: string | null; evidence_stream: EvidenceStream | null; direction: EffectDirection | null; controlled_exposure: boolean | null; exposure_prior_to_outcome: boolean | null; individual_outcome_data: boolean | null; comparison_group: boolean | null; klimisch_score: 1 | 2 | 3 | 4 | null; klimisch_justification: string | null; guideline_followed: string | null; glp_compliant: boolean | null; substance_identity_reported: boolean | null; controls_reported: boolean | null; doses_group_sizes_reported: boolean | null; methods_source: "full_text" | "abstract_only" | null; } interface ExtractionFormProps { reviewer: string; busy: boolean; /** Pre-filled outcome (the protocol's outcome). */ defaultOutcome?: string; onCancel: () => void; onSubmit: (data: ExtractionFormData) => void; } const FEATURE_HELP: Record = { controlled_exposure: "Investigators assigned the exposure (experimental animal study or human trial).", exposure_prior_to_outcome: "Exposure was measured before the outcome developed (rules out reverse causation).", individual_outcome_data: "Outcomes were recorded per individual, not only as group or population averages.", comparison_group: "There was an unexposed or lower-exposed group to compare with.", }; type YesNo = "" | "yes" | "no"; type KlimischScore = 1 | 2 | 3 | 4; type MethodsSource = "" | "full_text" | "abstract_only"; const KLIMISCH_LABELS: Record = { 1: "1 – reliable without restriction", 2: "2 – reliable with restrictions", 3: "3 – not reliable", 4: "4 – not assignable", }; function toBool(value: YesNo): boolean | null { return value === "" ? null : value === "yes"; } /** A suggestion only. The reviewer decides and must justify the final score. */ function suggestKlimisch(input: { methods: MethodsSource; guideline: string; glp: YesNo; identity: YesNo; controls: YesNo; doses: YesNo; }): { score: KlimischScore; reason: string } | null { if (input.methods === "abstract_only") { return { score: 4, reason: "Only the abstract was available, so the methods cannot be assessed." }; } if (input.methods === "") return null; const core = [input.identity, input.controls, input.doses]; if (core.includes("no")) { const missing = [ input.identity === "no" ? "substance identity/purity" : null, input.controls === "no" ? "controls" : null, input.doses === "no" ? "doses or group sizes" : null, ].filter(Boolean); return { score: 3, reason: `Key method details are missing: ${missing.join(", ")}.` }; } if (core.includes("")) return null; if (input.guideline.trim() && input.glp === "yes") { return { score: 1, reason: "Guideline followed, GLP compliant, and key details reported." }; } return { score: 2, reason: "Key details reported, but not both a guideline and GLP." }; } export function ExtractionForm({ reviewer, busy, defaultOutcome = "", onCancel, onSubmit }: ExtractionFormProps) { const { reference } = useRobReference(); const [species, setSpecies] = useState(""); const [route, setRoute] = useState(""); const [duration, setDuration] = useState(""); const [noael, setNoael] = useState(""); const [loael, setLoael] = useState(""); const [effectFinding, setEffectFinding] = useState(""); const [notes, setNotes] = useState(""); const [outcome, setOutcome] = useState(defaultOutcome); const [stream, setStream] = useState(""); const [direction, setDirection] = useState(""); const [features, setFeatures] = useState>({ controlled_exposure: false, exposure_prior_to_outcome: false, individual_outcome_data: false, comparison_group: false, }); const [methods, setMethods] = useState(""); const [guideline, setGuideline] = useState(""); const [glp, setGlp] = useState(""); const [identity, setIdentity] = useState(""); const [controls, setControls] = useState(""); const [doses, setDoses] = useState(""); const [klimisch, setKlimisch] = useState<"" | "1" | "2" | "3" | "4">(""); const [klimischNote, setKlimischNote] = useState(""); const [error, setError] = useState(null); const conf = reference?.confidence; const count = Object.values(features).filter(Boolean).length; const suggestion = suggestKlimisch({ methods, guideline, glp, identity, controls, doses }); function submit() { setError(null); if (!outcome.trim()) return setError("Enter the outcome these data are for."); if (!stream) return setError("Choose the evidence stream (human, animal or in vitro)."); if (!direction) return setError("Choose the direction of the finding."); if (klimisch && !klimischNote.trim()) { return setError("Explain the Klimisch score you chose."); } onSubmit({ species: species || null, route: route || null, duration: duration || null, noael: noael || null, loael: loael || null, effect_finding: effectFinding || null, notes: notes || null, outcome: outcome.trim(), evidence_stream: stream, direction, ...features, klimisch_score: klimisch ? (Number(klimisch) as KlimischScore) : null, klimisch_justification: klimisch ? klimischNote.trim() : null, guideline_followed: guideline.trim() || null, glp_compliant: toBool(glp), substance_identity_reported: toBool(identity), controls_reported: toBool(controls), doses_group_sizes_reported: toBool(doses), methods_source: methods || null, }); } const yesNoOptions = ( <> ); return (

Fill these from what this paper reports, for one outcome. Leave a field empty or write "Not reported" rather than guessing. You can add another extraction for each further outcome.

setOutcome(e.target.value)} /> setSpecies(e.target.value)} /> setRoute(e.target.value)} /> setDuration(e.target.value)} /> setNoael(e.target.value)} /> setLoael(e.target.value)} /> setEffectFinding(e.target.value)} />
OHAT key study-design features (set the initial confidence for this study) {(conf?.features ?? []).map((f) => ( ))}
{count} of 4 features → initial confidence{" "} {conf?.levels.find((l) => l.value === initialConfidenceFor(count))?.label ?? initialConfidenceFor(count)}
Study reliability (Klimisch) — optional
Answer from the paper's methods. Leave a question as "Not answered" if the paper does not say.
setGuideline(e.target.value)} />
{suggestion ? (
Suggested: {KLIMISCH_LABELS[suggestion.score]} — {suggestion.reason}{" "}
) : (
Answer the method questions to get a suggestion. A suggestion is only a starting point.
)} {klimisch && (