comorbidity {comorbidity}R Documentation

Compute comorbidity scores.

Description

Computes comorbidity scores such as the weighted Charlson score and the Elixhauser comorbidity score.

Usage

comorbidity(x, id, code, score, icd = "icd10", assign0,
  factorise = FALSE, labelled = TRUE, tidy.codes = TRUE)

Arguments

x

A tidy data frame with one column containing an individual ID and a column containing all diagnostic codes.

id

Column of x containing the individual ID.

code

Column of x containing diagnostic codes. Codes must be in upper case with no punctuation in order to be properly recognised.

score

The comorbidity score to compute. Possible choices are the weighted Charlson score (charlson) and the weighted Elixhauser score (elixhauser). Values are case-insensitive.

icd

The version of ICD coding to use. Possible choices are ICD-9-CM (icd9) or ICD-10 (icd10). Defaults to icd10, and values are case-insensitive.

assign0

Apply a hierarchy of comorbidities. If TRUE, should a comorbidity be present in a patient with different degrees of severity, then the milder form will be assigned to 0 and therefore not counted. By doing this, a type of comorbidity is not counted more than once in each patient. In particular, the comorbidities that are affected by this argument are:

  • "Mild liver disease" (mld) and "Moderate/severe liver disease" (msld) for the Charlson score;

  • "Diabetes" (diab) and "Diabetes with complications" (diabwc) for the Charlson score;

  • "Cancer" (canc) and "Metastatic solid tumour" (metacanc) for the Charlson score;

  • "Hypertension, uncomplicated" (hypunc) and "Hypertension, complicated" (hypc) for the Elixhauser score;

  • "Diabetes, uncomplicated" (diabunc) and "Diabetes, complicated" (diabc) for the Elixhauser score;

  • "Solid tumour" (solidtum) and "Metastatic cancer" (metacanc) for the Elixhauser score.

factorise

Return comorbidities as factors rather than numeric, where (1 = presence of comorbidity, 0 = otherwise). Defaults to FALSE.

labelled

Attach labels to each comorbidity, compatible with the RStudio viewer via the utils::View() function. Defaults to TRUE.

tidy.codes

Tidy diagnostic codes? If TRUE, all codes are converted to upper case and all non-alphanumeric characters are removed using the regular expression [^[:alnum:]]. Defaults to TRUE.

Details

The ICD-10 and ICD-9-CM coding for the Charlson and Elixhauser scores is based on work by Quan et al. (2005). Weights for the Charlson score are based on the original formulation by Charlson et al. in 1987, while weights for the Elixhauser score are based on work by Moore et al. and van Walraven et al. Finally, the categorisation of scores and weighted scores is based on work by Menendez et al. See vignette("comorbidityscores", package = "comorbidity") for further details on the comorbidity scores and the weighting algorithm. ICD-10 and ICD-9 codes must be in upper case and with alphanumeric characters only in order to be properly recognised; set tidy.codes = TRUE to properly tidy the codes automatically. As a convenience, a message is printed to the R console when non-alphanumeric characters are found.

Value

A data frame with id, columns relative to each comorbidity domain, comorbidity score, weighted comorbidity score, and categorisations of such scores, with one row per individual.

For the Charlson score, the following variables are included in the dataset:

Conversely, for the Elixhauser score the dataset contains the following variables:

Labels are presented to the user when using the RStudio viewer (e.g. via the utils::View() function) for convenience.

References

Quan H, Sundararajan V, Halfon P, Fong A, Burnand B, Luthi JC, et al. Coding algorithms for defining comorbidities in ICD-9-CM and ICD-10 administrative data. Medical Care 2005; 43(11):1130-1139.

Charlson ME, Pompei P, Ales KL, et al. A new method of classifying prognostic comorbidity in longitudinal studies: development and validation. Journal of Chronic Diseases 1987; 40:373-383.

Moore BJ, White S, Washington R, Coenen N, and Elixhauser A. Identifying increased risk of readmission and in-hospital mortality using hospital administrative data: the AHRQ Elixhauser comorbidity index. Medical Care 2017; 55(7):698-705.

van Walraven C, Austin PC, Jennings A, Quan H and Forster AJ. A modification of the Elixhauser comorbidity measures into a point system for hospital death using administrative data. Medical Care 2009; 47(6):626-633.

Menendez ME, Neuhaus V, van Dijk CN, Ring D. The Elixhauser comorbidity method outperforms the Charlson index in predicting inpatient death after orthopaedic surgery. Clinical Orthopaedics and Related Research 2014; 472(9):2878-2886.

Examples

set.seed(1)
x <- data.frame(
  id = sample(1:15, size = 200, replace = TRUE),
  code = sample_diag(200),
  stringsAsFactors = FALSE
)

# Charlson score based on ICD-10 diagnostic codes:
comorbidity(x = x, id = "id", code = "code", score = "charlson", assign0 = FALSE)

# Elixhauser score based on ICD-10 diagnostic codes:
comorbidity(x = x, id = "id", code = "code", score = "elixhauser", assign0 = FALSE)

[Package comorbidity version 0.5.0 Index]