File size: 3,487 Bytes
aefac4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad2e847
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aefac4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
MediGuard AI RAG-Helper
Shared biomarker normalization utilities
"""

from typing import Dict

# Normalization map for biomarker aliases to canonical names.
NORMALIZATION_MAP: Dict[str, str] = {
    # Glucose variations
    "glucose": "Glucose",
    "bloodsugar": "Glucose",
    "bloodglucose": "Glucose",

    # Lipid panel
    "cholesterol": "Cholesterol",
    "totalcholesterol": "Cholesterol",
    "triglycerides": "Triglycerides",
    "trig": "Triglycerides",
    "ldl": "LDL Cholesterol",
    "ldlcholesterol": "LDL Cholesterol",
    "hdl": "HDL Cholesterol",
    "hdlcholesterol": "HDL Cholesterol",

    # Diabetes markers
    "hba1c": "HbA1c",
    "a1c": "HbA1c",
    "hemoglobina1c": "HbA1c",
    "insulin": "Insulin",

    # Body metrics
    "bmi": "BMI",
    "bodymassindex": "BMI",

    # Complete Blood Count (CBC)
    "hemoglobin": "Hemoglobin",
    "hgb": "Hemoglobin",
    "hb": "Hemoglobin",
    "platelets": "Platelets",
    "plt": "Platelets",
    "wbc": "White Blood Cells",
    "whitebloodcells": "White Blood Cells",
    "whitecells": "White Blood Cells",
    "rbc": "Red Blood Cells",
    "redbloodcells": "Red Blood Cells",
    "redcells": "Red Blood Cells",
    "hematocrit": "Hematocrit",
    "hct": "Hematocrit",

    # Red blood cell indices
    "mcv": "Mean Corpuscular Volume",
    "meancorpuscularvolume": "Mean Corpuscular Volume",
    "mch": "Mean Corpuscular Hemoglobin",
    "meancorpuscularhemoglobin": "Mean Corpuscular Hemoglobin",
    "mchc": "Mean Corpuscular Hemoglobin Concentration",

    # Cardiovascular
    "heartrate": "Heart Rate",
    "hr": "Heart Rate",
    "pulse": "Heart Rate",
    "systolicbp": "Systolic Blood Pressure",
    "systolic": "Systolic Blood Pressure",
    "sbp": "Systolic Blood Pressure",
    "diastolicbp": "Diastolic Blood Pressure",
    "diastolic": "Diastolic Blood Pressure",
    "dbp": "Diastolic Blood Pressure",
    "troponin": "Troponin",

    # Inflammation and liver
    "creactiveprotein": "C-reactive Protein",
    "crp": "C-reactive Protein",
    "alt": "ALT",
    "alanineaminotransferase": "ALT",
    "ast": "AST",
    "aspartateaminotransferase": "AST",

    # Kidney
    "creatinine": "Creatinine",

    # Thyroid
    "tsh": "TSH",
    "thyroidstimulatinghormone": "TSH",
    "t3": "T3",
    "triiodothyronine": "T3",
    "t4": "T4",
    "thyroxine": "T4",

    # Electrolytes
    "sodium": "Sodium",
    "na": "Sodium",
    "potassium": "Potassium",
    "k": "Potassium",
    "calcium": "Calcium",
    "ca": "Calcium",
    "chloride": "Chloride",
    "cl": "Chloride",
    "bicarbonate": "Bicarbonate",
    "hco3": "Bicarbonate",

    # Kidney / Metabolic
    "urea": "Urea",
    "bun": "BUN",
    "bloodureanitrogen": "BUN",
    "buncreatinineratio": "BUN_Creatinine_Ratio",
    "uricacid": "Uric_Acid",

    # Liver / Protein
    "totalprotein": "Total_Protein",
    "albumin": "Albumin",
    "globulin": "Globulin",
    "agratio": "AG_Ratio",
    "albuminglobulinratio": "AG_Ratio",
    "bilirubintotal": "Bilirubin_Total",
    "bilirubin": "Bilirubin_Total",
    "alp": "ALP",
    "alkalinephosphatase": "ALP",

    # Lipids
    "vldl": "VLDL",
}


def normalize_biomarker_name(name: str) -> str:
    """
    Normalize biomarker names to standard format.

    Args:
        name: Raw biomarker name from user input

    Returns:
        Standardized biomarker name
    """
    key = name.lower().replace(" ", "").replace("-", "").replace("_", "")
    return NORMALIZATION_MAP.get(key, name)