import type { ProtocolDraft } from "../types"; import { describeSearchStrategy } from "../utils/searchStrategy"; import { TermListEditor } from "./TermListEditor"; import "./review-fixes.css"; interface SearchStrategyEditorProps { draft: ProtocolDraft; onChange: (draft: ProtocolDraft) => void; } /** Words so common in abstracts that, used alone as search terms, they pull * in large numbers of unrelated records. A warning only; saving is allowed. */ const GENERIC_TERMS = new Set([ "oral", "inhalation", "dermal", "exposure", "study", "studies", "effect", "effects", "risk", "safety", "human", "humans", "animal", "animals", "in vitro", "in vivo", "assay", "test", "review", "analysis", ]); function lowerSet(terms: string[]): Set { return new Set(terms.map((t) => t.trim().toLowerCase()).filter(Boolean)); } /** Shared by the new-protocol form and the draft edit view. */ export function SearchStrategyEditor({ draft, onChange }: SearchStrategyEditorProps) { const preview = describeSearchStrategy( draft.intervention, draft.outcome, draft.intervention_terms, draft.outcome_terms ); const exposureTerms = draft.intervention_terms ?? []; const outcomeTerms = draft.outcome_terms ?? []; const exposureSet = lowerSet(exposureTerms); const outcomeSet = lowerSet(outcomeTerms); const sharedTerms = [...exposureSet].filter((t) => outcomeSet.has(t)).sort(); const genericTerms = [...new Set([...exposureSet, ...outcomeSet])] .filter((t) => GENERIC_TERMS.has(t)) .sort(); return (

List the words a study must use in its title or abstract. Studies need at least one exposure term and at least one outcome term. Add synonyms and abbreviations as separate terms (e.g.{" "} bisphenol A, BPA). If you leave a list empty, its Intervention or Outcome text above is used as a single phrase.

Exposure terms: the chemical or intervention only — its names, abbreviations and CAS number. Outcome terms: the endpoints or effects only. Don't put the same word in both lists, and keep route or study-design words (such as oral or inhalation) in the inclusion criteria instead.

onChange({ ...draft, intervention_terms: terms })} /> onChange({ ...draft, outcome_terms: terms })} /> {sharedTerms.length > 0 && (
These terms are in both lists: {sharedTerms.join(", ")}. A paper could match on that one word alone, so the search would return unrelated records. Keep each term in one list only. The protocol can't be saved until this is fixed.
)} {genericTerms.length > 0 && (
Very broad words: {genericTerms.join(", ")}. Words like these appear in a large share of abstracts and can bring in unrelated records. Consider removing them, or put them in the inclusion criteria instead.
)}
{preview.mode === "search_terms" ? ( <> Search: {preview.text} ) : ( <> No search terms yet — the search will use the free text{" "} {preview.text || "…"} without title/abstract restriction. Adding terms is recommended. )}
); }