File size: 12,614 Bytes
5091a04 dcc1b84 f8fe972 dcc1b84 5091a04 dcc1b84 5091a04 dcc1b84 5091a04 dcc1b84 f8fe972 dcc1b84 5091a04 dcc1b84 f8fe972 dcc1b84 f8fe972 dcc1b84 f8fe972 dcc1b84 f8fe972 dcc1b84 5091a04 f8fe972 5091a04 dcc1b84 5091a04 dcc1b84 5091a04 dcc1b84 5091a04 dcc1b84 5091a04 dcc1b84 f8fe972 5091a04 dcc1b84 5091a04 dcc1b84 5091a04 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | 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<StudyFeatureKey, string> = {
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<KlimischScore, string> = {
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<EvidenceStream | "">("");
const [direction, setDirection] = useState<EffectDirection | "">("");
const [features, setFeatures] = useState<Record<StudyFeatureKey, boolean>>({
controlled_exposure: false,
exposure_prior_to_outcome: false,
individual_outcome_data: false,
comparison_group: false,
});
const [methods, setMethods] = useState<MethodsSource>("");
const [guideline, setGuideline] = useState("");
const [glp, setGlp] = useState<YesNo>("");
const [identity, setIdentity] = useState<YesNo>("");
const [controls, setControls] = useState<YesNo>("");
const [doses, setDoses] = useState<YesNo>("");
const [klimisch, setKlimisch] = useState<"" | "1" | "2" | "3" | "4">("");
const [klimischNote, setKlimischNote] = useState("");
const [error, setError] = useState<string | null>(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 = (
<>
<option value="">Not answered</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</>
);
return (
<div className="extraction-form">
<p className="form-hint">
Fill these from what this paper reports, for <strong>one outcome</strong>. Leave a field empty or
write "Not reported" rather than guessing. You can add another extraction for each further outcome.
</p>
<div className="extraction-grid">
<input placeholder="Outcome" value={outcome} onChange={(e) => setOutcome(e.target.value)} />
<select value={stream} onChange={(e) => setStream(e.target.value as EvidenceStream)} aria-label="Evidence stream">
<option value="">Evidence stream…</option>
{(conf?.streams ?? [
{ value: "human", label: "Human" },
{ value: "animal", label: "Animal" },
{ value: "in_vitro", label: "In vitro" },
]).map((s) => (
<option key={s.value} value={s.value}>
{s.label}
</option>
))}
</select>
<input placeholder="Species" value={species} onChange={(e) => setSpecies(e.target.value)} />
<input placeholder="Exposure route" value={route} onChange={(e) => setRoute(e.target.value)} />
<input placeholder="Duration" value={duration} onChange={(e) => setDuration(e.target.value)} />
<input placeholder="NOAEL" value={noael} onChange={(e) => setNoael(e.target.value)} />
<input placeholder="LOAEL" value={loael} onChange={(e) => setLoael(e.target.value)} />
<input
placeholder="Effect / finding (direction, size, 95% CI)"
value={effectFinding}
onChange={(e) => setEffectFinding(e.target.value)}
/>
<select value={direction} onChange={(e) => setDirection(e.target.value as EffectDirection)} aria-label="Direction">
<option value="">Direction of the finding…</option>
{(conf?.directions ?? []).map((d) => (
<option key={d.value} value={d.value}>
{d.label}
</option>
))}
</select>
</div>
<div className="feature-box">
<strong>OHAT key study-design features</strong> (set the initial confidence for this study)
{(conf?.features ?? []).map((f) => (
<label key={f.key} className="feature-option" title={FEATURE_HELP[f.key]}>
<input
type="checkbox"
checked={features[f.key]}
onChange={() => setFeatures({ ...features, [f.key]: !features[f.key] })}
/>
{f.label} <span className="rob-bias-type">— {FEATURE_HELP[f.key]}</span>
</label>
))}
<div className="form-hint">
{count} of 4 features → initial confidence{" "}
<strong>{conf?.levels.find((l) => l.value === initialConfidenceFor(count))?.label ?? initialConfidenceFor(count)}</strong>
</div>
</div>
<div className="feature-box klimisch-box">
<strong>Study reliability (Klimisch) — optional</strong>
<div className="form-hint">
Answer from the paper's methods. Leave a question as "Not answered" if the paper does not say.
</div>
<div className="extraction-grid">
<select value={methods} onChange={(e) => setMethods(e.target.value as MethodsSource)} aria-label="Methods available">
<option value="">Methods available…</option>
<option value="full_text">Full text</option>
<option value="abstract_only">Abstract only</option>
</select>
<input
placeholder="Test guideline followed (e.g. OECD 471), if any"
value={guideline}
onChange={(e) => setGuideline(e.target.value)}
/>
<label>
GLP compliant{" "}
<select value={glp} onChange={(e) => setGlp(e.target.value as YesNo)}>
{yesNoOptions}
</select>
</label>
<label>
Substance identity and purity reported{" "}
<select value={identity} onChange={(e) => setIdentity(e.target.value as YesNo)}>
{yesNoOptions}
</select>
</label>
<label>
Controls reported{" "}
<select value={controls} onChange={(e) => setControls(e.target.value as YesNo)}>
{yesNoOptions}
</select>
</label>
<label>
Doses and group sizes reported{" "}
<select value={doses} onChange={(e) => setDoses(e.target.value as YesNo)}>
{yesNoOptions}
</select>
</label>
</div>
{suggestion ? (
<div className="form-hint">
Suggested: <strong>{KLIMISCH_LABELS[suggestion.score]}</strong> — {suggestion.reason}{" "}
<button
type="button"
className="change-btn"
onClick={() => setKlimisch(String(suggestion.score) as "1" | "2" | "3" | "4")}
>
Use suggestion
</button>
</div>
) : (
<div className="form-hint">
Answer the method questions to get a suggestion. A suggestion is only a starting point.
</div>
)}
<select value={klimisch} onChange={(e) => setKlimisch(e.target.value as "" | "1" | "2" | "3" | "4")} aria-label="Klimisch score">
<option value="">Klimisch score (your decision)…</option>
{([1, 2, 3, 4] as KlimischScore[]).map((s) => (
<option key={s} value={String(s)}>
{KLIMISCH_LABELS[s]}
</option>
))}
</select>
{klimisch && (
<textarea
placeholder="Why this score? (required)"
value={klimischNote}
onChange={(e) => setKlimischNote(e.target.value)}
/>
)}
</div>
<textarea placeholder="Notes" value={notes} onChange={(e) => setNotes(e.target.value)} />
{error && <div className="form-error">{error}</div>}
<div className="form-actions">
<button className="secondary-btn" onClick={onCancel}>
Cancel
</button>
<button className="primary-btn" disabled={busy || !reviewer.trim()} onClick={submit}>
Save extraction
</button>
</div>
</div>
);
}
|