# Define detailed comorbidity groups
detailed_comorbidity_groups = {
# CARDIOVASCULAR (7 groups)
"CV Essential Hypertension": ["I10"],
"CV Complicated Hypertension": ["I11", "I12", "I13", "I15"],
"CV Coronary Disease": ["I20", "I21", "I22", "I23", "I24", "I25"],
"CV Heart Failure": ["I50"],
"CV Arrhythmias": ["I44", "I45", "I46", "I47", "I48", "I49"],
"CV Cerebrovascular Disease": ["I60", "I61", "I62", "I63", "I64", "I65", "I66", "I67", "I68", "I69"],
"CV Peripheral Vascular Disease": ["I70", "I71", "I73", "I74", "I77"],
# METABOLIC (7 groups)
"MET Type1 Diabetes": ["E10"],
"MET Type2 Diabetes": ["E11"],
"MET Complicated Diabetes": ["E12", "E13", "E14"],
"MET Obesity": ["E66"],
"MET Dyslipidemia": ["E78"],
"MET Metabolic Syndrome": ["E88"],
"MET Thyroid Disorders": ["E00", "E01", "E02", "E03", "E04", "E05", "E06", "E07"],
# RESPIRATORY (7 groups)
"RESP COPD": ["J44"],
"RESP Asthma": ["J45", "J46"],
"RESP Chronic Bronchitis": ["J41", "J42"],
"RESP Emphysema": ["J43"],
"RESP Pulmonary Fibrosis": ["J84"],
"RESP Pulmonary Hypertension": ["I27"],
"RESP Sleep Apnea": ["G47"],
# RENAL (4 groups)
"REN Acute Renal Failure": ["N17"],
"REN Chronic Renal Failure": ["N18"],
"REN End Stage Renal": ["N185", "N186"],
"REN Diabetic Nephropathy": ["E102", "E112", "E122", "E132", "E142"],
# HEPATIC (4 groups)
"HEP Steatosis": ["K76"],
"HEP Alcoholic Cirrhosis": ["K70"],
"HEP NonAlcoholic Cirrhosis": ["K74"],
"HEP Viral Hepatitis": ["B15", "B16", "B17", "B18", "B19"],
# GASTROINTESTINAL (4 groups)
"GI Reflux": ["K21"],
"GI Peptic Ulcer": ["K25", "K26", "K27", "K28"],
"GI IBD": ["K50", "K51"],
"GI IBS": ["K58"],
# NEUROLOGICAL (4 groups)
"NEURO Dementia": ["F00", "F01", "F02", "F03", "G30"],
"NEURO Parkinson": ["G20", "G21", "G22"],
"NEURO Epilepsy": ["G40", "G41"],
"NEURO Stroke Sequelae": ["I69"],
# PSYCHIATRIC (3 groups)
"PSI Major Depression": ["F32", "F33"],
"PSI Bipolar": ["F30", "F31"],
"PSI Anxiety": ["F41"],
# SUBSTANCE (3 groups)
"SUST Alcohol": ["F10"],
"SUST Tobacco": ["F17", "Z72"],
"SUST Opioids": ["F11"],
# INFECTIOUS (4 groups)
"INF HIV": ["B20", "B21", "B22", "B23", "B24"],
"INF Tuberculosis": ["A15", "A16", "A17", "A18", "A19"],
"INF Hepatitis C": ["B18"],
"INF Hepatitis B": ["B18"],
}
# Create category-to-color mapping
category_colors = {
'CV': '#E74C3C', # Red
'MET': '#3498DB', # Blue
'RESP': '#2ECC71', # Green
'REN': '#F39C12', # Orange
'HEP': '#9B59B6', # Purple
'GI': '#1ABC9C', # Teal
'NEURO': '#34495E', # Dark gray
'PSI': '#E67E22', # Dark orange
'SUST': '#C0392B', # Dark red
'INF': '#16A085', # Dark teal
}
def get_comorbidity_category(comorbidity_name):
"""Extract category prefix from comorbidity name."""
return comorbidity_name.split(' ')[0]
def get_comorbidity_color(comorbidity_name):
"""Get color for a comorbidity based on its category."""
category = get_comorbidity_category(comorbidity_name)
return category_colors.get(category, '#95A5A6')
print(f"Defined {len(detailed_comorbidity_groups)} comorbidity groups")
print(f"Categories: {', '.join(sorted(set(get_comorbidity_category(c) for c in detailed_comorbidity_groups.keys())))}")