File size: 4,175 Bytes
0fbfbf1
 
 
 
 
 
 
 
 
 
b17f9e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0fbfbf1
 
 
 
 
 
 
 
 
b17f9e7
 
 
 
 
 
 
 
 
 
0fbfbf1
 
 
 
 
 
 
 
 
 
b17f9e7
 
 
 
 
 
 
0fbfbf1
 
 
 
b17f9e7
0fbfbf1
 
 
 
 
b17f9e7
0fbfbf1
 
 
b17f9e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0fbfbf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b17f9e7
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
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<string> {
  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 (
    <div className="search-strategy-section">
      <label className="field-label">Search strategy</label>
      <p className="form-hint">
        List the words a study must use in its <strong>title or abstract</strong>.
        Studies need at least one exposure term <strong>and</strong> at least one
        outcome term. Add synonyms and abbreviations as separate terms (e.g.{" "}
        <em>bisphenol A</em>, <em>BPA</em>). If you leave a list empty, its
        Intervention or Outcome text above is used as a single phrase.
      </p>
      <p className="form-hint">
        <strong>Exposure terms:</strong> the chemical or intervention only — its
        names, abbreviations and CAS number. <strong>Outcome terms:</strong> 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.
      </p>

      <TermListEditor
        label="Exposure search terms"
        placeholder="e.g. metformin — press Enter or Add after each term"
        terms={exposureTerms}
        onChange={(terms) => onChange({ ...draft, intervention_terms: terms })}
      />
      <TermListEditor
        label="Outcome search terms"
        placeholder="e.g. lactic acidosis — press Enter or Add after each term"
        terms={outcomeTerms}
        onChange={(terms) => onChange({ ...draft, outcome_terms: terms })}
      />

      {sharedTerms.length > 0 && (
        <div className="form-error">
          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.
        </div>
      )}
      {genericTerms.length > 0 && (
        <div className="notice notice-warn">
          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.
        </div>
      )}

      <div className="strategy-preview">
        {preview.mode === "search_terms" ? (
          <>
            Search: <code>{preview.text}</code>
          </>
        ) : (
          <>
            No search terms yet — the search will use the free text{" "}
            <code>{preview.text || "…"}</code> without title/abstract
            restriction. Adding terms is recommended.
          </>
        )}
      </div>
    </div>
  );
}