File size: 3,731 Bytes
aacc29a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Every span kind the risk engine emits (interpreter/app/risk/engine.py).
// Anything missing here renders as a generic "item to check", which tells a
// clinician nothing -- so tests/test_risk_labels.py fails the build if the
// engine gains a kind that is not listed below.

export type RiskKind =
  | "red_flag"
  | "allergy"
  | "pregnancy"
  | "symptom_severity"
  | "drug_name"
  | "dose_number"
  | "frequency_duration"
  | "route"
  | "laterality"
  | "body_location"
  | "medical_history"
  | "negation"
  | "negation_mismatch"
  | "number_mismatch"
  | "abbreviation"
  | "subject_omission"
  | "pronoun"
  | "low_confidence";

export type RiskSeverity = "low" | "medium" | "high" | "critical";

/** Named marks from the authored icon family; never emoji. */
export type RiskIcon =
  | "alert"
  | "pill"
  | "dose"
  | "repeat"
  | "route"
  | "sides"
  | "pin"
  | "clipboard"
  | "no"
  | "speech"
  | "gauge";

export interface RiskLabel {
  /** Vietnamese label, the primary one a clinician reads. */
  vi: string;
  /** English helper text, secondary. */
  en: string;
  icon: RiskIcon;
  /**
   * "entity" is clinical content extracted from the turn and worth showing as a
   * chip. "check" is a reason the turn needs review, shown in the gate card.
   */
  group: "entity" | "check";
}

export const RISK_LABELS: Record<RiskKind, RiskLabel> = {
  red_flag: { vi: "Dấu hiệu nguy hiểm", en: "Red flag", icon: "alert", group: "entity" },
  allergy: { vi: "Dị ứng thuốc", en: "Allergy", icon: "alert", group: "entity" },
  pregnancy: { vi: "Thai kỳ", en: "Pregnancy", icon: "clipboard", group: "entity" },
  symptom_severity: {
    vi: "Mức độ triệu chứng",
    en: "Symptom severity",
    icon: "alert",
    group: "entity",
  },
  drug_name: { vi: "Tên thuốc", en: "Medication", icon: "pill", group: "entity" },
  dose_number: { vi: "Liều dùng", en: "Dose", icon: "dose", group: "entity" },
  frequency_duration: {
    vi: "Tần suất / thời gian",
    en: "Frequency",
    icon: "repeat",
    group: "entity",
  },
  route: { vi: "Đường dùng thuốc", en: "Route", icon: "route", group: "entity" },
  laterality: { vi: "Bên trái / phải", en: "Laterality", icon: "sides", group: "entity" },
  body_location: { vi: "Vị trí trên cơ thể", en: "Body location", icon: "pin", group: "entity" },
  medical_history: { vi: "Tiền sử bệnh", en: "Medical history", icon: "clipboard", group: "entity" },
  negation: { vi: "Phủ định", en: "Negation", icon: "no", group: "entity" },

  negation_mismatch: {
    vi: "Sai lệch phủ định giữa hai câu",
    en: "Negation mismatch",
    icon: "alert",
    group: "check",
  },
  number_mismatch: {
    vi: "Sai lệch con số giữa hai câu",
    en: "Number mismatch",
    icon: "alert",
    group: "check",
  },
  abbreviation: { vi: "Từ viết tắt", en: "Abbreviation", icon: "clipboard", group: "check" },
  subject_omission: { vi: "Thiếu chủ ngữ", en: "Missing subject", icon: "speech", group: "check" },
  pronoun: { vi: "Đại từ xưng hô", en: "Pronoun", icon: "speech", group: "check" },
  low_confidence: { vi: "Độ tin cậy thấp", en: "Low confidence", icon: "gauge", group: "check" },
};

export const SEVERITY_LABELS: Record<RiskSeverity, { vi: string; en: string }> = {
  low: { vi: "Thấp", en: "Low" },
  medium: { vi: "Trung bình", en: "Medium" },
  high: { vi: "Cao", en: "High" },
  critical: { vi: "Nghiêm trọng", en: "Critical" },
};

export function riskLabel(kind: string): RiskLabel {
  return (
    RISK_LABELS[kind as RiskKind] ?? {
      vi: "Thông tin cần kiểm tra",
      en: "Item to check",
      icon: "clipboard",
      group: "check",
    }
  );
}