disease_to_keywords = {
    "obesity": [
        "obes", "overweight", "BMI", "body mass index", "adipos", "central obesity", "waist",
        "hip circ", "waist to hip", "waist-to-hip", "WHR", "body weight", "body fat", "fat mass",
        "percent body fat", "waist circumference", "hip circumference",
    ],
    "type_2_diabetes": [
        "type 2", "type-2", "T2D", "diabet", "noninsulin", "NIDDM", "hypergly", 
        "glucose", "fasting glucose", "fasting plasma glucose", "HbA1c",
        "A1c", "glycated haemoglobin", "OGTT", "oral glucose tolerance",
        "2-hour glucose", "2 hour glucose", "insulin", "HOMA", "insulin resistance",
    ],
    "diabetic_kidney_disease": [
        "diabet", "DKD", "diabetic nephrop", "diabetic kidney",
        "diabetic CKD", "chronic kidney", "CKD", "nephrop", "nephrit",
        "renal", "eGFR", "glomerular", "creatinine", "serum creatinine",
        "albuminuria", "microalbumin", "macroalbumin", "uACR",
        "albumin-to-creatinine", "albumin to creatinine", "proteinuria", "albumin",
        "dialysis", "urine albumin", "urine protein",
    ],
    "dyslipidemia": [
        "dyslipid", "hyperlipid", "hypercholesterol", "cholesterol", "ldl", "ldl-c",
        "ldl c", "hdl", "hdl-c", "hdl c", "triglycer", "apolipoprotein", "apob",
        "apoa1", "apoa-1", "lipoprotein", "lpa", "non-hdl",
        "non hdl", "vldl", "remnant",
    ],
    "cold_agglutinin_disease": [
        "autoimmune hemolytic", "hemolytic anemia", "raynaud", "hemoglobinuria",
        "bilirubin", "hemoglobin", "haemoglobin", "heart rate", "hematocrit", "erythrocyte", "rbc",
        "wbc", "hematuria", "mcv", "mch", "mchc", "corpuscular", "red blood", "white blood", "reticulocyte"
    ],
    "long_qt_syndrome": [
            "long qt", "lqts", "qt prolong", "prolonged qt", "qtc", "qt interval", "torsad",
            "channelopath", "romano", "jervell", "lange",
            "arrhythm", "ventricular tachy", "ventricular fibrill", "flutter",
            "supraventricular tachy", "paroxysmal", "polymorphic",
            "syncope", "collapse", "palpit", "cardiac arrest", "sudden",
            "ecg", "ekg", "electrocard", "qrs", "loop recorder",
            "potassium", "magnesium", "calcium", "sodium", "bicarbonate", "chloride", "anion gap",
            "heart rate", "troponin", "natriuretic",
        ],
    "hypertrophic_cardiomyopathy": [
        "cardiomyo", "hocm", "hcm", "cardiomegaly", "heart failure", "pulmonary oed", "pulmonary od",
        "diastolic", "systolic", "hfpef", "reduced ef", "preserved ef",
        "atrial fibrill", "flutter", "arrhythm", "ventricular tachy", "ventricular fibrill",
        "syncope", "palpit", "cardiac arrest", "echoc", "ecg", "ekg", "electrocard", "qrs", 
        "qt interval", "qtc", "cardioverter defibr", "defibrillator", "pacemaker", "loop recorder",
        "ablation of atr", "ablation of pulmonary", "ablation of atrioventricular", "conducting system",
        "heart rate", "troponin", "natriuretic", "creatine kinase", "heart murmur", "heart valve problem",
    ],
    "metabolic_syndrome": [
        "metabolic", "syndrome x", "glucose", "HbA1c", "haemoglobin", "hemoglobin",
        "insulin", "HOMA", "triglycer", "hdl","blood pressure", "hypertens",
        "waist", "central obes", "visceral", "BMI", "body mass index", "obes", "overweight", "adipos",
        "urate", "uric acid", "c-reactive protein", "CRP",
        "alanine aminotransf", "ALT", "aspartate aminotransf", "AST",
        "gamma glutamyl", "GGT", "alkaline phosphat",
        "liver PDFF", "fatty liver", "NAFLD", "NASH", "cholesterol", "ldl", "apolipoprotein",
    ],
    "angelman_syndrome": [
        "angelman", "happy puppet", "chromosome 15", "UBE3A", "15q11", "15q12", "chromosomal anomal",
        "epilep", "seizure", "convuls", "status epilepticus",
        "intellectual disab", "mental retard", "developmental delay",
        "speech", "language disorder", "atax", "cerebell", "gait", "movement disorder",
        "tremor", "nystagmus", "irregular eye movement",
        "scoliosis", "microceph", "sleep", "melatonin",
        "cognitive", "fluid intelligence",
    ],
    "hemophilia": [
        "hemophil", "haemophil", "coagul", "clotting", "bleeding", "hemorrhagic",
        "von willebrand", "vwf", "aptt", "prothrombin", "INR", "fibrinogen", "d-dimer", 
        "purpura", "hemarthro", "joint bleed", "platelet"
    ],
    "essential_thrombocythemia": [
        "thrombocyt", "myeloprolif", "polycyth", "myelofibro", "myelodysplas",
        "platelet", "leukocyte", "blood cell", "wbc",
        "erythrocyte", "rbc", "haemoglobin", "hemoglobin", "hematocrit", "haematocrit",
        "neutroph", "basoph", "eosinoph", "lymphocyte", "monocyte", "reticulocyte",
        "LDH", "lactate dehydrogen", "ferritin", "iron",
        "urate", "uric acid", "haptoglobin", "spleen", "splenomeg"
    ],
    "aortic_valve_stenosis": [
        "aortic", "valve", "stenos", "heart", "endocard",
        "bicuspid", "calcif", "mitral", "tricuspid", "rheumatic heart",
        "echoc", "ejection fraction", "LV end", "cardiac",
        "end systolic", "end diastolic", "cardiomegaly",
        "atrial fibrill", "arrhythm", "ecg", "ekg", "electrocard",
        "natriuretic", "NTproBNP", "bnp", "troponin",
        "heart rate", "pulse rate", "pulse wave",
        "blood pressure", "systolic", "diastolic",
        "heart failure", "aortic aneur", "aortic dissec",
        "syncope", "dyspn", "calcium", "phosphat", "alkaline phosphat", "creatinine",
    ],
    "nash": [
        "nash", "steatohepat", "nonalcohol", "nafld",         
        "fatty liver", "steatosis", "fibrosis", "cirrhosis",
        ],
    "sepsis": [
        "sepsis", "septic", "bacteremia", "sirs",
    ],
    "kidney_disease": [
        # Core disease stems (catch the long tail of subtypes)
        "kidney", "renal", "nephro", "nephri", "nephrect",
        "glomerul", "tubul", "pyelon", "polycyst",
        # Abbreviations that may appear without "kidney"/"renal"
        "CKD", "ESRD", "eGFR",
        # Quantitative biomarkers
        "creatinine", "cystatin", "albumin", "proteinur",
        "uACR", "urea", "urate", "uric acid",
        # Procedures (catches haemodialysis/hemodialysis too)
        "dialys",
        # Secondary complications
        "hyperparathyroid",
    ],
    "menopause": [
        # Core disease terms
        "menopaus", "climacter", "perimenopaus",
        # Ovarian status / surgical menopause
        "oophorect", "ovarian fail", "ovarian insuff",
        "ovarian dysfunc", "amenorrh",
        "age at menopause",
        # VMS symptoms
        "vasomotor", "hot flash", "hot flush",
        "flush", "night sweat", "sweat",
        "hyperhidr", "eccrine",
        # Hormonal biomarkers
        "oestradiol", "estradiol", "SHBG", "testosterone",
        "FSH", "progesterone",
        # HRT
        "hormone replace", "HRT",
    ],
    "noonan_syndrome": [
        # Cardiac
        "pulmon", "cardiomyop", "septal defect",
        # Growth
        "height", "stature", "IGF", "growth hormone", "failure to thrive",
        # Hematologic
        "platelet", "thrombocyt", "coagul", "bleeding", "factor VIII", "myeloid",
        # Lymphatic
        "lymphedem", "lymphoedem",
        # Skeletal
        "pectus", "scoliosis",
        # Craniofacial / ocular
        "ptosis", "strabism", "hearing",
        # Abdominal
        "spleen", "hepatomeg",
        # Genitourinary
        "cryptorch", "undescend",
    ],
}

arrowhead_disease_to_keywords = {
    # Cardiometabolic
    "familial_chylomicronemia_syndrome": [
        "familial chylomicronemia", "chylomicronemia",
        "fcs", "chylomicron", "lipoprotein lipase", "lpl",
        "triglycer", "hypertriglycer", "tg", "pancreatitis",
    ],
    "severe_hypertriglyceridemia": [
        "severe hypertriglycer", "hypertriglycer", "triglycer",
        "triglyceride", "tg", "pancreatitis",
    ],
    "homozygous_familial_hypercholesterolemia": [
        "homozygous familial hypercholesterol",
        "homozygous familial hypercholesterolemia",
        "homozygous familial hypercholesterolaemia",
        "hofh",
        "familial hypercholesterol",
        "familial hypercholesterolemia",
        "familial hypercholesterolaemia",
        "fh",
        "ldl receptor",
        "ldlr",
        # include lipid measurements because they dominate in your exports
        "cholesterol",
        "ldl",
        "ldl-c",
        "ldl c",
        "hypercholesterol",
        "hypercholesterolaemia",
    ],
    "cardiovascular_disease": [
        # disease/clinical terms (broad to hit the cardio phenos present in your exports)
        "cardiovascular",
        "cardio",
        "heart",
        "cardiac",
        "vascular",
        "artery",
        "arterial",
        "coronary",
        "coronary artery",
        "coronary heart",
        "ischemic heart",
        "myocard",
        "myocardial infarction",
        "heart attack",
        "stroke",
        "ischemic stroke",
        "angina",
        "atheroscleros",
        "arterioscleros",
        "peripheral artery",
        "revascular",
        "stent",
        "bypass",
        # major related phenotypes in these exports
        "hypertens",
        "blood pressure",
        "systolic",
        "diastolic",
        "heart failure",
        "congestive heart",
        "cardiomyopathy",
        "atrial fibrillation",
        "arrhythm",
        "tachycard",
        "bradycard",
        # clotting / thrombotic events frequently appear in phenotype catalogs
        "thromb",
        "embol",
        "venous thromboembol",
        "pulmonary embol",
        "dvt",
    ],
    "obesity": [
        "obes",
        "overweight",
        "body mass index",
        "bmi",
        "adipos",
        "central obesity",
        "waist",
        "hip",
        "waist to hip",
        "waist-to-hip",
        "whr",
        # measurements/body comp that show up in continuous trait catalogs
        "body weight",
        "#weight",
        "weight gain",
        "body fat",
        "fat mass",
        "percent body fat",
        "lean mass",
        "body composition",
        "waist circumference",
        "hip circumference",
    ],
    "mash": [
        "mash",
        "metabolic dysfunction-associated steatohepatitis",
        "metabolic associated steatohepatitis",
        "nash",
        "nonalcoholic steatohepatitis",
        "non-alcoholic steatohepatitis",
        "steatohepatitis",
        "fatty liver",
        "fatty liver disease",
        "hepatic steatosis",
        "steatosis",
        "nafld",
        "nonalcoholic fatty liver",
        "non-alcoholic fatty liver",
        "liver fibrosis",
        "fibrosis",
        "cirrhosis",
        # common liver measurements in these exports
        "alt",
        "ast",
        "ggt",
        "alp",
        "bilirubin",
        "inr",
        "platelet",
        "liver fat",
        "hepatic fat",
        "fibroscan",
        "elastography",
        "transaminase",
        "liver enzyme",
    ],

    # CNS
    "spinocerebellar_ataxia_2": [
        "spinocerebellar ataxia",
        "sca2",
        "sca 2",
        "ataxia 2",
        "ataxia",
        "cerebellar",
        "spinocerebellar",
        "atxn2",
    ],

    # Pulmonary
    "inflammatory_pulmonary_diseases": [
        "inflammatory pulmonary",
        "pulmonary inflammation",
        "lung inflammation",
        "inflammatory lung",
        "pneumonitis",
        "pulmonary",
        "lung",
        "respirat",
        "interstitial lung disease",
        "ild",
        "copd",
        "asthma",
        "bronchitis",
        "emphysema",
        "pneumonia",
        "pneumon",
        "dyspnea",
        "dyspnoea",
        "shortness of breath",
        "wheeze",
        # pulmonary function measurements that appear as continuous traits
        "fev1",
        "fvc",
        "dlco",
        "spirom",
        # gene/program hints that can appear in some catalogs
        "rage",
        "ager",
        # optional but common pulmonary phenotype bucket
        "sleep apnea",
        "sleep apnoea",
    ],
    "idiopathic_pulmonary_fibrosis": [
        "idiopathic pulmonary fibrosis",
        "ipf",
        "pulmonary fibrosis",
        "lung fibrosis",
        "fibrosis of lung",
        "fibrosing",
        "fibrosis",
        "fibrotic",
        "usual interstitial",
        "interstitial pneumon",
        "ild",
        "pulmonary",
        "lung",
        # program hint
        "mmp7",
    ],

    # Liver
    "alpha_1_liver_disease": [
        "alpha-1",
        "alpha 1",
        "alpha1",
        "alpha-1 antitrypsin",
        "alpha 1 antitrypsin",
        "antitrypsin",
        "a1at",
        "a1atd",
        "aat deficiency",
        "antitrypsin deficiency",
        # liver involvement + common liver labs
        "liver",
        "hepatic",
        "liver fibrosis",
        "cirrhosis",
        "alt",
        "ast",
        "ggt",
        "alp",
        "bilirubin",
        "inr",
        "platelet",
    ],
    "hepatitis_b": [
        "hepatitis b",
        "hbv",
        "chronic hepatitis b",
        "hep b",
        "hepatitis b virus",
        # virology measurements (often present as trait strings)
        "hbsag",
        "hbeag",
        "hbv dna",
        "viral load",
        # common liver injury labs
        "alt",
        "ast",
        "bilirubin",
        # broad safety net
        "hepatitis",
        "viral hepatitis",
    ],

    # Muscular
    "fshd": [
        "fshd",
        "facioscapulohumeral",
        "facioscapulohumeral muscular dystrophy",
        "muscular dystrophy",
        "dux4",
    ],
    "myotonic_dystrophy_type_1": [
        "myotonic dystrophy",
        "dm1",
        "dm 1",
        "dystrophia myotonica",
        "steinert",
        "steinert disease",
        "myotonia",
        "dmpk",
    ],

    # Complement Mediated Disease (ARO-C3 / ARO-CFB on pipeline page)
    "complement_mediated_disease": [
        "complement mediated",
        "complement-mediated",
        "complement",
        "alternative complement",
        "complement pathway",
        "c3",
        "complement component 3",
        "cfb",
        "factor b",
        "complement factor b",
        # common complement-mediated clinical phenos seen in catalogs
        "iga nephrop",
        "iga nephropathy",
        "c3 glomerulopathy",
        "glomerulonephritis",
        "gn",
        "ahus",
        "atypical hemolytic uremic",
        "pnh",
        "paroxysmal nocturnal hemoglobinuria",
        # kidney measurements (these dominate in your exports for this bucket)
        "egfr",
        "glomerular filtration",
        "creatinine",
        "cystatin",
        "albuminuria",
        "microalbumin",
        "proteinuria",
        "uacr",
        "albumin-to-creatinine",
        "urine albumin",
        "urine protein",
    ],
}
