This function computes unweighted Elixhauser Comorbidity Index for both data.frame and remote table input. The ICD codes used to identify the 31 disease categories is from Quan et al. (2005).
Arguments
- data
Data.frames or remote tables (e.g., from
dbplyr::tbl_sql())- vars
An expression passing to
dplyr::select(). It can be quoted/unquoted column names, or helper functions, such asdplyr::starts_with().- icd_ver
One of
c("ICD-10", "ICD-9-CM-3digits", "ICD-9-CM-5digits"). Specify the ICD code version used indata. The ICD-10 and ICD-9-CM 5 digits version are from Quan et al. (2005). The ICD-9-CM 3 digits version is adopted from Manitoba Centre for Health Policy. It uses BOTH 3-digit and 5-digit codes in search. See their web page for cautions and limitations of the 3 digit version if your data only has 3-digit codes (http://mchp-appserv.cpe.umanitoba.ca/viewConcept.php?printer=Y&conceptID=1436#CAUTIONS). For all versions, the codes in the lists are at the category/subcategory level and cover all their subdivisions (the ".x" notation in Quan et al. (2005)). Therefore, matching is done by prefix: a diagnosis value indatamatches a listed code if its leading characters equal the code. For example, "E1152" indatawould be captured by ICD-10 "E115" (Diabetes Complicated), and "4280" by ICD-9 "428" (Congestive Heart Failure). This reproduces the reference SAS implementation, which compares every code with the SASIN:(starts-with) operator (see http://mchp-appserv.cpe.umanitoba.ca/Upload/SAS/_ElixhauserICD9CM.sas.txt and http://mchp-appserv.cpe.umanitoba.ca/Upload/SAS/_ElixhauserICD10.sas.txt). See the exported dataset elix_codes for the code lists and matching lengths. Codes indatamust not contain dots (e.g., use "E1152" not "E11.52", and "4280" not "428.0"); otherwise, codes may not be matched correctly. Codes should also be upper case (e.g., "E1152" not "e1152"): the comparison is case-sensitive for data.frame input and on most database backends (including SQLite and PostgreSQL), but follows the database collation on SQL Server, which is commonly case-insensitive. Note that some codes belong to multiple categories in Quan et al. (2005), e.g., I11.0 indicates both Congestive Heart Failure (I099, I110, ...) and Hypertension Complicated (I11.x); records with such codes are counted in all the categories they match.- clnt_id
Grouping variable (quoted/unquoted).
- uid
Variable name for a unique row identifier. It is necessary for SQL to produce consistent result based on sorting.
- sum_by
One of "row" or "clnt". The "row" option computes total score for each row (default), and the "clnt" option summarizes total score by
clnt_id. Each disease categories will be counted only once in the calculation regardless of multiple records in a category.- excl
A character vector of disease categories labels that should be excluded in the total score calculation. This is useful when some of the categories are the exposure/outcome of interest, and the goal is to measure comorbidity excluding these disease. See detail for a list of the categories and labels.
Details
List of disease categories - labels (in quote):
Congestive Heart Failure - "chf"
Cardiac Arrhythmia - "arrhy"
Valvular Disease - "vd"
Pulmonary Circulation Disorders - "pcd"
Peripheral Vascular Disorders - "pvd"
Hypertension Uncomplicated - "hptn_nc"
Hypertension Complicated - "hptn_c"
Paralysis - "para"
Other Neurological Disorders - "othnd"
Chronic Pulmonary Disease - "copd"
Diabetes Uncomplicated - "diab_nc"
Diabetes Complicated - "diab_c"
Hypothyroidism - "hptothy"
Renal Failure - "rf"
Liver Disease - "ld"
Peptic Ulcer Disease excluding bleeding - "pud_nb"
AIDS/HIV - "hiv"
Lymphoma - "lymp"
Metastatic Cancer - "mets"
Solid Tumor without Metastasis - "tumor"
Rheumatoid Arthritis/collagen - "rheum_a"
Coagulopathy - "coag"
Obesity - "obesity"
Weight Loss - "wl"
Fluid and Electrolyte Disorders - "fluid"
Blood Loss Anemia - "bla"
Deficiency Anemia - "da"
Alcohol Abuse - "alcohol"
Drug Abuse - "drug"
Psychoses - "psycho"
Depression - "dep"
The full ICD code lists defining these categories, including the matching rule for each code (prefix vs. exact), are available in the exported dataset elix_codes.
References
Quan H, Sundararajan V, Halfon P, Fong A, Burnand B, Luthi JC, Saunders LD, Beck CA, Feasby TE, Ghali WA. Coding algorithms for defining comorbidities in ICD-9-CM and ICD-10 administrative data. Med Care 2005;43(11):1130-1139.
Examples
# make ICD-9 toy data
df <- data.frame(
uid = 1:10, clnt_id = sample(1:3, 10, replace = TRUE),
diagx_1 = c("193", "2780", "396", "4254", "4150", "401", "401", "0932", "5329", "2536"),
diagx_2 = c(NA, NA, "72930", "V6542", "493", "405", "5880", "2409", "714", NA)
)
# compute Elixhauser Comorbidity Index by row
# uid is needed for by row calculation
# 3 categories were excluded in total_eci
compute_comorbidity(df,
vars = starts_with("diagx"),
icd_ver = "ICD-9-CM-5digits",
clnt_id = clnt_id, uid = uid,
excl = c("drug", "psycho", "dep")
)
#> # A tibble: 10 × 34
#> clnt_id uid chf arrhy vd pcd pvd hptn_nc hptn_c para othnd copd
#> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 0 0 0 0 0 0 0 0 0 0
#> 2 1 4 1 0 0 0 0 0 0 0 0 0
#> 3 1 10 0 0 0 0 0 0 0 0 0 0
#> 4 2 5 0 0 0 1 0 0 0 0 0 1
#> 5 2 9 0 0 0 0 0 0 0 0 0 0
#> 6 3 2 0 0 0 0 0 0 0 0 0 0
#> 7 3 3 0 0 1 0 0 0 0 0 0 0
#> 8 3 6 0 0 0 0 0 1 1 0 0 0
#> 9 3 7 0 0 0 0 0 1 0 0 0 0
#> 10 3 8 0 0 1 0 0 0 0 0 0 0
#> # ℹ 22 more variables: diab_nc <dbl>, diab_c <dbl>, hptothy <dbl>, rf <dbl>,
#> # ld <dbl>, pud_nb <dbl>, hiv <dbl>, lymp <dbl>, mets <dbl>, tumor <dbl>,
#> # rheum_a <dbl>, coag <dbl>, obesity <dbl>, wl <dbl>, fluid <dbl>, bla <dbl>,
#> # da <dbl>, alcohol <dbl>, drug <dbl>, psycho <dbl>, dep <dbl>,
#> # total_eci <dbl>
# compute ECI by person
compute_comorbidity(df,
vars = starts_with("diagx"),
icd_ver = "ICD-9-CM-5digits",
clnt_id = clnt_id,
sum_by = "clnt"
)
#> # A tibble: 3 × 33
#> clnt_id chf arrhy vd pcd pvd hptn_nc hptn_c para othnd copd diab_nc
#> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 0 0 0 0 0 0 0 0 0 0
#> 2 2 0 0 0 1 0 0 0 0 0 1 0
#> 3 3 0 0 1 0 0 1 1 0 0 0 0
#> # ℹ 21 more variables: diab_c <dbl>, hptothy <dbl>, rf <dbl>, ld <dbl>,
#> # pud_nb <dbl>, hiv <dbl>, lymp <dbl>, mets <dbl>, tumor <dbl>,
#> # rheum_a <dbl>, coag <dbl>, obesity <dbl>, wl <dbl>, fluid <dbl>, bla <dbl>,
#> # da <dbl>, alcohol <dbl>, drug <dbl>, psycho <dbl>, dep <dbl>,
#> # total_eci <dbl>
