# Comorbidity scores

#### Alessandro Gasparini

#### 2019-08-20

`comorbidity` is an R package for computing comorbidity scores based on ICD codes data. As of version `0.1.0`, `comorbidity` can calculate the Charlson comorbidity score and the Elixhauser comorbidity score, using either the ICD-9 or ICD-10 coding system. Details on each score supported by this package are presented in this vignette, along with examples on how to compute the different scores with this software.

# Charlson comorbidity score

The Charlson comorbidity index was first developed by Charlson et al. in 1987 to predict one-year mortality for patients who may have a range of comorbid conditions. Each condition is assigned a score depending on the risk of dying associated with each one, and consequently scores are summed to provide a total score to predict mortality.

The Charlson comorbidity index includes the following comorbid conditions: acute myocardial infarction, congestive heart failure, peripheral vascular disease, cerebrovascular disease, dementia, chronic obstructive pulmonary disease [COPD], rheumatoid disease, peptic ulcer disease, mild and moderate/severe liver disease, diabetes mellitus with and without complications, hemiplegia/paraplegia, renal disease, cancer (any malignancy) and metastatic solid tumour, AIDS/HIV.

Many variations of the Charlson comorbidity index have been presented, as outlined by Sharabiani et al. in their systematic review. `comorbidity` computes the Quan et al. version of the Charlson score for both ICD-9-CM and ICD-10 coding systems, as outlined in their paper from 2005; in the next subsections, we present the different ICD codes utilised by `comorbidity`. Categorisation of scores and weighted scores are based on work by Menendez et al.

## ICD-9-CM codes

The ICD-9-CM codes used by `comorbidity` to compute the Charlson comorbidity index are:

- Myocardial infarction: 410.x, 412.x

- Congestive heart failure: 398.91, 402.01, 402.11, 402.91, 404.01, 404.03, 404.11, 404.13, 404.91, 404.93, 425.4 - 425.9, 428.x

- Peripheral vascular disease: 093.0, 437.3, 440.x, 441.x, 443.1 - 443.9, 47.1, 557.1, 557.9, V43.4

- Cerebrovascular disease: 362.34, 430.x - 438.x

- Dementia: 290.x, 294.1, 331.2

- Chronic pulmonary disease: 416.8, 416.9, 490.x - 505.x, 506.4, 508.1, 508.8

- Rheumatic disease: 446.5, 710.0 - 710.4, 714.0 - 714.2, 714.8, 725.x

- Peptic ulcer disease: 531.x - 534.x

- Mild liver disease: 070.22, 070.23, 070.32, 070.33, 070.44, 070.54, 070.6, 070.9, 570.x, 571.x, 573.3, 573.4, 573.8, 573.9, V42.7

- Diabetes without chronic complication: 250.0 - 250.3, 250.8, 250.9

- Diabetes with chronic complication: 250.4 - 250.7

- Hemiplegia or paraplegia: 334.1, 342.x, 343.x, 344.0 - 344.6, 344.9

- Renal disease: 403.01, 403.11, 403.91, 404.02, 404.03, 404.12, 404.13, 404.92, 404.93, 582.x, 583.0 - 583.7, 585.x, 586.x, 588.0, V42.0, V45.1, V56.x

- Any malignancy, including lymphoma and leukaemia, except malignant neoplasm of skin: 140.x - 172.x, 174.x - 195.8, 200.x - 208.x, 238.6

- Moderate or severe liver disease: 456.0 - 456.2, 572.2- 572.8

- Metastatic solid tumour: 196.x - 199.x

- AIDS/HIV: 042.x - 044.x

## ICD-10 codes

The ICD-10 codes used by `comorbidity` to compute the Charlson comorbidity index are:

- Myocardial infarction: I21.x, I22.x, I25.2

- Congestive heart failure: I09.9, I11.0, I13.0, I13.2, I25.5, I42.0, I42.5 - I42.9, I43.x, I50.x, P29.0

- Peripheral vascular disease: I70.x, I71.x, I73.1, I73.8, I73.9, I77.1, I79.0, I79.2, K55.1, K55.8, K55.9, Z95.8, Z95.9

- Cerebrovascular disease: G45.x, G46.x, H34.0, I60.x - I69.x

- Dementia: F00.x - F03.x, F05.1, G30.x, G31.1

- Chronic pulmonary disease: I27.8, I27.9, J40.x - J47.x, J60.x - J67.x, J68.4, J70.1, J70.3

- Rheumatic disease: M05.x, M06.x, M31.5, M32.x - M34.x, M35.1, M35.3, M36.0

- Peptic ulcer disease: K25.x - K28.x

- Mild liver disease: B18.x, K70.0 - K70.3, K70.9, K71.3 - K71.5, K71.7, K73.x, K74.x, K76.0, K76.2 - K76.4, K76.8, K76.9, Z94.4

- Diabetes without chronic complication: E10.0, E10.1, E10.6, E10.8, E10.9, E11.0, E11.1, E11.6, E11.8, E11.9, E12.0, E12.1, E12.6, E12.8, E12.9, E13.0, E13.1, E13.6, E13.8, E13.9, E14.0, E14.1, E14.6, E14.8, E14.9

- Diabetes with chronic complication: E10.2 - E10.5, E10.7, E11.2 - E11.5, E11.7, E12.2 - E12.5, E12.7, E13.2 - E13.5, E13.7, E14.2 - E14.5, E14.7

- Hemiplegia or paraplegia: G04.1, G11.4, G80.1, G80.2, G81.x, G82.x, G83.0 - G83.4, G83.9

- Renal disease: I12.0, I13.1, N03.2 - N03.7, N05.2 - N05.7, N18.x, N19.x, N25.0, Z49.0 - Z49.2, Z94.0, Z99.2

- Any malignancy, including lymphoma and leukaemia, except malignant neoplasm of skin: C00.x - C26.x, C30.x - C34.x, C37.x - C41.x, C43.x, C45.x - C58.x, C60.x - C76.x, C81.x - C85.x, C88.x, C90.x - C97.x

- Moderate or severe liver disease: I85.0, I85.9, I86.4, I98.2, K70.4, K71.1, K72.1, K72.9, K76.5, K76.6, K76.7

- Metastatic solid tumour: C77.x - C80.x

- AIDS/HIV: B20.x - B22.x, B24.x

## Weights

Each condition from the Charlson score is assigned a score when computing the weighted Charlson index, irrespectively of the coding system utilised. In particular, diabetes with complications, hemiplegia/paraplegia, renal disease, and malignancies are assigned a score of 2; moderate/severe liver disease is assigned a score of 3; metastatic solid tumour and AIDS/HIV are assigned a score of 6; the remaining comorbidities are assigned a score of 1. `comorbidity` allows the option of applying a hierarchy of comorbidities should a more severe version be present: by choosing to do so (and that is the default behaviour of `comorbidity`) a type of comorbidity is never computed more than once for a given patient.

# Elixhauser comorbidity score

The Elixhauser comorbidity index, analogously as the Charlson comorbidity index, is a method for measuring patient comorbidity based on ICD-9-CM and ICD-10 diagnosis codes found in administrative data developed by Elixhauser et al. in 1998. Over time, there have been changes to the Index based on different research. For instance:

- the original index was developed with 30 categories. Now there are variants with 31 categories (Garland et al., 2012);
- the list of specific ICD diagnosis codes that are used to identify different categories of comorbidity have been modified and updated from ICD-9-CM to work with ICD-10 coding (Quan et al., 2005);
- weighting algorithms were developed, based on the association between comorbidity and death, in order to produce an overall score for the Elixhauser index (van Walraven et al., 2009; Moore et al., 2016).

`comorbidity` is using the coding definition of Quan et al. (2005) for both ICD-9-CM and ICD-10 coding systems; the actual codes and weights utilised by `comorbidity` are introduced in the next subsections. However, there is no consensus regarding the weighting algorithm, with several competing definitions. `comorbidity` implements (and returns) both the AHRQ version of the Elixhauser index (Moore et al., 2017) and the van Walraven et al. (2009) version. The AHRQ Elixhauser comorbidity score only includes 29 comorbidities; the missing comorbidities are therefore assigned a weight of zero. Finally, the categorisation of scores and weighted scores is based on work by Menendez et al.

## ICD-9-CM codes

The ICD-9-CM codes used by `comorbidity` to compute the Elixhauser comorbidity index are:

- Congestive heart failure: 398.91, 402.01, 402.11, 402.91, 404.01, 404.03, 404.11, 404.13, 404.91, 404.93, 425.4 - 425.9, 428.x

- Cardiac arrhythmias: 426.0, 426.13, 426.7, 426.9, 426.10, 426.12, 427.0 - 427.4, 427.6 - 427.9, 785.0, 996.01, 996.04, V45.0, V53.3

- Valvular disease: 093.2, 394.x - 397.x, 424.x, 746.3 - 746.6, V42.2, V43.3

- Pulmonary circulation disorders: 415.0, 415.1, 416.x, 417.0, 417.8, 417.9

- Peripheral vascular disorders: 093.0, 437.3, 440.x, 441.x, 443.1 - 443.9, 447.1, 557.1, 557.9, V43.4

- Hypertension, uncomplicated: 401.x

- Hypertension, complicated: 402.x - 405.x

- Paralysis: 334.1, 342.x, 343.x, 344.0 - 344.6, 344.9

- Other neurological disorders: 331.9, 332.0, 332.1, 333.4, 333.5, 333.92, 334.x - 335.x, 336.2, 340.x, 341.x, 345.x, 348.1, 348.3, 780.3, 784.3

- Chronic pulmonary disease: 416.8, 416.9, 490.x - 505.x, 506.4, 508.1, 508.8

- Diabetes, uncomplicated: 250.0 - 250.3

- Diabetes, complicated: 250.4 - 250.9

- Hypothyroidism: 240.9, 243.x, 244.x, 246.1, 246.8

- Renal failure: 403.01, 403.11, 403.91, 404.02, 404.03, 404.12, 404.13, 404.92, 404.93, 585.x, 586.x, 588.0, V42.0, V45.1, V56.x

- Liver disease: 070.22, 070.23, 070.32, 070.33, 070.44, 070.54, 070.6, 070.9, 456.0 - 456.2, 570.x, 571.x, 572.2 - 572.8, 573.3, 573.4, 573.8, 573.9, V42.7

- Peptic ulcer disease, excluding bleeding: 531.7, 531.9, 532.7, 532.9, 533.7, 533.9, 534.7, 534.9

- AIDS/HIV: 042.x - 044.x

- Lymphoma: 200.x - 202.x, 203.0, 238.6

- Metastatic cancer: 196.x - 199.x

- Solid tumour without metastasis: 140.x - 172.x, 174.x - 195.x

- Rheumatoid arthritis/collagen vascular diseases: 446.x, 701.0, 710.0 - 710.4, 710.8, 710.9, 711.2, 714.x, 719.3, 720.x, 725.x, 728.5, 728.89, 729.30

- Coagulopathy: 286.x, 287.1, 287.3 - 287.5

- Obesity: 278.0

- Weight loss: 260.x - 263.x, 783.2, 799.4

- Fluid and electrolyte disorders: 253.6, 276.x

- Blood loss anaemia: 280.0

- Deficiency anaemia: 280.1 - 280.9, 281.x

- Alcohol abuse: 265.2, 291.1 - 291.3, 291.5 - 291.9, 303.0, 303.9, 305.0, 357.5, 425.5, 535.3, 571.0 - 571.3, 980.x, V11.3

- Drug abuse: 292.x, 304.x, 305.2 - 305.9, V65.42

- Psychoses: 293.8, 295.x, 296.04, 296.14, 296.44, 296.54, 297.x, 298.x

- Depression: 296.2, 296.3, 296.5, 300.4, 309.x, 311

## ICD-10 codes

The ICD-10 codes used by `comorbidity` to compute the Elixhauser comorbidity index are:

- Congestive heart failure: I09.9, I11.0, I13.0, I13.2, I25.5, I42.0, I42.5 - I42.9, I43.x, I50.x, P29.0

- Cardiac arrhythmias: I44.1 - I44.3, I45.6, I45.9, I47.x - I49.x, R00.0, R00.1, R00.8, T82.1, Z45.0, Z95.0

- Valvular disease: A52.0, I05.x - I08.x, I09.1, I09.8, I34.x - I39.x, Q23.0 - Q23.3, Z95.2 - Z95.4

- Pulmonary circulation disorders: I26.x, I27.x, I28.0, I28.8, I28.9

- Peripheral vascular disorders: I70.x, I71.x, I73.1, I73.8, I73.9, I77.1, I79.0, I79.2, K55.1, K55.8, K55.9, Z95.8, Z95.9

- Hypertension, uncomplicated: I10.x

- Hypertension, complicated: I11.x - I13.x, I15.x

- Paralysis: G04.1, G11.4, G80.1, G80.2, G81.x, G82.x, G83.0 - G83.4, G83.9

- Other neurological disorders: G10.x - G13.x, G20.x - G22.x, G25.4, G25.5, G31.2, G31.8, G31.9, G32.x, G35.x - G37.x, G40.x, G41.x, G93.1, G93.4, R47.0, R56.x

- Chronic pulmonary disease: I27.8, I27.9, J40.x - J47.x, J60.x - J67.x, J68.4, J70.1, J70.3

- Diabetes, uncomplicated: E10.0, E10.1, E10.9, E11.0, E11.1, E11.9, E12.0, E12.1, E12.9, E13.0, E13.1, E13.9, E14.0, E14.1, E14.9

- Diabetes, complicated: E10.2 - E10.8, E11.2 - E11.8, E12.2 - E12.8, E13.2 - E13.8, E14.2 - E14.8

- Hypothyroidism: E00.x - E03.x, E89.0

- Renal failure: I12.0, I13.1, N18.x, N19.x, N25.0, Z49.0 - Z49.2, Z94.0, Z99.2

- Liver disease: B18.x, I85.x, I86.4, I98.2, K70.x, K71.1, K71.3 - K71.5, K71.7, K72.x - K74.x, K76.0, K76.2 - K76.9, Z94.4

- Peptic ulcer disease, excluding bleeding: K25.7, K25.9, K26.7, K26.9, K27.7, K27.9, K28.7, K28.9

- AIDS/HIV: B20.x - B22.x, B24.x

- Lymphoma: C81.x - C85.x, C88.x, C96.x, C90.0, C90.2

- Metastatic cancer: C77.x - C80.x

- Solid tumour without metastasis: C00.x - C26.x, C30.x - C34.x, C37.x - C41.x, C43.x, C45.x - C58.x, C60.x - C76.x, C97.x

- Rheumatoid arthritis/collagen vascular diseases: L94.0, L94.1, L94.3, M05.x, M06.x, M08.x, M12.0, M12.3, M30.x, M31.0 - M31.3, M32.x - M35.x, M45.x, M46.1, M46.8, M46.9

- Coagulopathy: D65 - D68.x, D69.1, D69.3 - D69.6

- Obesity: E66.x

- Weight loss: E40.x - E46.x, R63.4, R64

- Fluid and electrolyte disorders: E22.2, E86.x, E87.x

- Blood loss anaemia: D50.0

- Deficiency anaemia: D50.8, D50.9, D51.x - D53.x

- Alcohol abuse: F10, E52, G62.1, I42.6, K29.2, K70.0, K70.3, K70.9, T51.x, Z50.2, Z71.4, Z72.1

- Drug abuse: F11.x - F16.x, F18.x, F19.x, Z71.5, Z72.2

- Psychoses: F20.x, F22.x - F25.x, F28.x, F29.x, F30.2, F31.2, F31.5

- Depression: F20.4, F31.3 - F31.5, F32.x, F33.x, F34.1, F41.2, F43.2

## Weights

The weights for the Elixhauser comorbidity index are included in the following table, depending on the algorithm used for the weighting process:

Comorbidity Domain | AHRQ Algorithm | van Walraven Algorithm
--- | --- | ---
Congestive heart failure | 9 | 7
Cardiac arrhythmias | (0) | 5
Valvular disease | 0 | -1
Pulmonary circulation disorders | 6 | 4
Peripheral vascular disorders | 3 | 2
Hypertension (combined uncomplicated and complicated) | -1 | 0
Paralysis | 5 | 7
Other neurological disorders | 5 | 6
Chronic pulmonary disease | 3 | 3
Diabetes, uncomplicated | 0 | 0
Diabetes, complicated | -3 | 0
Hypothyroidism | 0 | 0
Renal failure | 6 | 5
Liver disease | 4 | 11
Peptic ulcer disease, excluding bleeding | 0 | 0
AIDS/HIV | 0 | 0
Lymphoma | 6 | 9
Metastatic cancer | 14 | 12
Solid tumour without metastasis | 7 | 4
Rheumatoid arthritis/collagen vascular diseases | 0 | 0
Coagulopathy | 11 | 3
Obesity | -5 | -4
Weight loss | 9 | 6
Fluid and electrolyte disorders | 11 | 5
Blood loss anaemia | -3 | -2
Deficiency anaemia | -2 | -2
Alcohol abuse | -1 | 0
Drug abuse | -7 | -7
Psychoses | -5 | 0
Depression | -5 | -3

The AHRQ algorithm does not include cardiac arrhythmias, hence a weight of 0 is assigned.

# Examples

The first step consists in loading the `comorbidity` package:

    library(comorbidity)

We can utilise the built-in `sample_diag()` function to simulate ICD diagnostic codes. Both ICD-9 and ICD-10 codes are supported:

    data9 <- data.frame(
      id = sample(1:10, size = 250, replace = TRUE),
      code = sample_diag(n = 250, version = "ICD9_2015"),
      stringsAsFactors = FALSE
    )
    data9 <- data9[order(data9$id), ]
    data10 <- data.frame(
      id = sample(1:10, size = 250, replace = TRUE),
      code = sample_diag(n = 250, version = "ICD10_2011"),
      stringsAsFactors = FALSE
    )
    data10 <- data10[order(data10$id), ]

Then, we can go ahead and compute various comorbidity scores and indices supported by `comorbidity`. The Charlson score based on ICD-9-CM data is computed as:

    charlson9 <- comorbidity(x = data9, id = "id", code = "code", score = "charlson", icd = "icd9", assign0 = FALSE)
    str(charlson9)
    #> 'data.frame':    10 obs. of  22 variables:
    #>  $ id      : int  1 2 3 4 5 6 7 8 9 10
    #>  $ ami     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ chf     : int  0 0 1 0 0 0 0 0 0 1
    #>  $ pvd     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ cevd    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ dementia: num  0 0 0 0 0 0 0 0 0 0
    #>  $ copd    : int  0 0 0 0 0 1 0 0 1 0
    #>  $ rheumd  : num  0 0 0 0 0 0 0 0 0 0
    #>  $ pud     : int  0 0 0 1 0 0 0 0 0 0
    #>  $ mld     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ diab    : int  1 0 0 0 0 0 0 0 0 0
    #>  $ diabwc  : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hp      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ rend    : int  0 0 0 0 0 0 0 0 1 0
    #>  $ canc    : int  0 1 1 1 1 1 1 1 1 1
    #>  $ msld    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ metacanc: num  0 0 0 0 0 0 0 0 0 0
    #>  $ aids    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ score   : num  1 1 2 2 1 2 1 1 3 2
    #>  $ index   : Factor w/ 4 levels "0","1-2","3-4",..: 2 2 2 2 2 2 2 2 3 2
    #>  $ wscore  : num  1 2 3 3 2 3 2 2 5 3
    #>  $ windex  : Factor w/ 4 levels "0","1-2","3-4",..: 2 2 3 3 2 3 2 2 4 3
    #>  - attr(*, "variable.labels")= chr  "ID" "Myocardial infarction" "Congestive heart failure" "Peripheral vascular disease" ...

The Charlson score based on ICD-10 data:

    charlson10 <- comorbidity(x = data10, id = "id", code = "code", score = "charlson", icd = "icd10", assign0 = FALSE)
    str(charlson10)
    #> 'data.frame':    10 obs. of  22 variables:
    #>  $ id      : int  1 2 3 4 5 6 7 8 9 10
    #>  $ ami     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ chf     : int  0 0 1 1 0 0 0 0 0 0
    #>  $ pvd     : int  0 1 0 0 0 0 0 0 0 0
    #>  $ cevd    : int  0 0 0 0 0 0 0 1 0 0
    #>  $ dementia: num  0 0 0 0 0 0 0 0 0 0
    #>  $ copd    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ rheumd  : num  0 0 0 0 0 0 0 0 0 0
    #>  $ pud     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ mld     : int  0 0 0 0 1 1 0 1 0 0
    #>  $ diab    : int  0 0 0 0 0 0 0 0 1 0
    #>  $ diabwc  : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hp      : int  0 0 0 1 0 0 0 0 0 0
    #>  $ rend    : int  0 0 0 0 1 0 0 0 0 0
    #>  $ canc    : int  1 1 0 0 1 1 0 1 1 0
    #>  $ msld    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ metacanc: int  0 0 0 1 0 0 0 0 0 0
    #>  $ aids    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ score   : num  1 2 1 3 3 2 0 3 2 0
    #>  $ index   : Factor w/ 4 levels "0","1-2","3-4",..: 2 2 2 3 3 2 1 3 2 1
    #>  $ wscore  : num  2 3 1 9 5 3 0 4 3 0
    #>  $ windex  : Factor w/ 4 levels "0","1-2","3-4",..: 2 3 2 4 4 3 1 3 3 1
    #>  - attr(*, "variable.labels")= chr  "ID" "Myocardial infarction" "Congestive heart failure" "Peripheral vascular disease" ...

The Elixhauser score based on ICD-9-CM data:

    elixhauser9 <- comorbidity(x = data9, id = "id", code = "code", score = "elixhauser", icd = "icd9", assign0 = FALSE)
    str(elixhauser9)
    #> 'data.frame':    10 obs. of  38 variables:
    #>  $ id         : int  1 2 3 4 5 6 7 8 9 10
    #>  $ chf        : int  0 0 1 0 0 0 0 0 0 1
    #>  $ carit      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ valv       : int  0 1 0 0 0 0 0 1 0 0
    #>  $ pcd        : int  0 0 0 0 0 1 0 0 0 0
    #>  $ pvd        : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hypunc     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hypc       : int  0 0 1 0 0 0 0 0 1 0
    #>  $ para       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ ond        : int  0 0 0 0 0 1 0 0 0 0
    #>  $ cpd        : int  0 0 0 0 0 1 0 0 1 0
    #>  $ diabunc    : int  1 0 0 0 0 0 0 0 0 0
    #>  $ diabc      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hypothy    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ rf         : int  0 0 0 0 0 0 0 0 1 0
    #>  $ ld         : num  0 0 0 0 0 0 0 0 0 0
    #>  $ pud        : int  0 0 0 1 0 0 0 0 0 0
    #>  $ aids       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ lymph      : int  0 0 1 1 0 1 1 0 1 1
    #>  $ metacanc   : num  0 0 0 0 0 0 0 0 0 0
    #>  $ solidtum   : int  0 1 1 0 1 0 0 1 0 0
    #>  $ rheumd     : int  0 0 0 0 0 0 0 1 0 0
    #>  $ coag       : int  0 0 0 0 0 0 0 0 1 0
    #>  $ obes       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ wloss      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ fed        : num  0 0 0 0 0 0 0 0 0 0
    #>  $ blane      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ dane       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ alcohol    : int  0 0 0 0 0 0 1 0 0 0
    #>  $ drug       : int  0 0 0 0 1 0 0 1 1 1
    #>  $ psycho     : int  0 0 1 0 0 0 0 1 0 0
    #>  $ depre      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ score      : num  1 2 5 2 2 4 2 5 6 3
    #>  $ index      : Factor w/ 4 levels "<0","0","1-4",..: 3 3 4 3 3 3 3 4 4 3
    #>  $ wscore_ahrq: num  0 7 16 6 0 20 5 -5 18 8
    #>  $ wscore_vw  : num  0 3 20 9 -3 22 9 -4 13 9
    #>  $ windex_ahrq: Factor w/ 4 levels "<0","0","1-4",..: 2 4 4 4 2 4 4 1 4 4
    #>  $ windex_vw  : Factor w/ 4 levels "<0","0","1-4",..: 2 3 4 4 1 4 4 1 4 4
    #>  - attr(*, "variable.labels")= chr  "ID" "Congestive heart failure" "Cardiac arrhythmias" "Valvular disease" ...

Finally, the Elixhauser score based on ICD-10 data:

    elixhauser10 <- comorbidity(x = data10, id = "id", code = "code", score = "elixhauser", icd = "icd10", assign0 = FALSE)
    str(elixhauser10)
    #> 'data.frame':    10 obs. of  38 variables:
    #>  $ id         : int  1 2 3 4 5 6 7 8 9 10
    #>  $ chf        : int  0 0 1 1 0 0 0 0 0 0
    #>  $ carit      : int  1 0 0 0 0 0 0 0 0 0
    #>  $ valv       : int  0 0 1 0 0 0 0 0 0 0
    #>  $ pcd        : num  0 0 0 0 0 0 0 0 0 0
    #>  $ pvd        : int  0 1 0 0 0 0 0 0 0 0
    #>  $ hypunc     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hypc       : int  0 0 1 0 0 0 0 0 0 0
    #>  $ para       : int  0 0 0 1 0 0 0 0 0 0
    #>  $ ond        : int  0 0 0 0 0 0 0 0 1 0
    #>  $ cpd        : num  0 0 0 0 0 0 0 0 0 0
    #>  $ diabunc    : int  0 0 0 0 0 0 0 0 1 0
    #>  $ diabc      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ hypothy    : int  0 0 0 0 0 0 1 0 0 0
    #>  $ rf         : num  0 0 0 0 0 0 0 0 0 0
    #>  $ ld         : int  0 0 0 0 1 1 0 1 0 0
    #>  $ pud        : num  0 0 0 0 0 0 0 0 0 0
    #>  $ aids       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ lymph      : int  0 0 0 0 0 0 0 0 1 0
    #>  $ metacanc   : int  0 0 0 1 0 0 0 0 0 0
    #>  $ solidtum   : int  1 1 0 0 1 1 0 0 1 0
    #>  $ rheumd     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ coag       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ obes       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ wloss      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ fed        : num  0 0 0 0 0 0 0 0 0 0
    #>  $ blane      : num  0 0 0 0 0 0 0 0 0 0
    #>  $ dane       : num  0 0 0 0 0 0 0 0 0 0
    #>  $ alcohol    : num  0 0 0 0 0 0 0 0 0 0
    #>  $ drug       : int  0 0 1 0 0 0 0 0 0 0
    #>  $ psycho     : num  0 0 0 0 0 0 0 0 0 0
    #>  $ depre      : int  0 0 0 1 0 0 0 0 0 0
    #>  $ score      : num  2 2 4 4 2 2 1 1 4 0
    #>  $ index      : Factor w/ 4 levels "<0","0","1-4",..: 3 3 3 3 3 3 3 3 3 2
    #>  $ wscore_ahrq: num  7 10 1 23 11 11 0 4 18 0
    #>  $ wscore_vw  : num  9 6 -1 23 15 15 0 11 19 0
    #>  $ windex_ahrq: Factor w/ 4 levels "<0","0","1-4",..: 4 4 3 4 4 4 2 3 4 2
    #>  $ windex_vw  : Factor w/ 4 levels "<0","0","1-4",..: 4 4 1 4 4 4 2 4 4 2
    #>  - attr(*, "variable.labels")= chr  "ID" "Congestive heart failure" "Cardiac arrhythmias" "Valvular disease" ...

# References

- 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. DOI: 10.1016/0021-9681(87)90171-8

- Sharabiani MT, Aylin P, Bottle A. Systematic review of comorbidity indices for administrative data. Medical Care 2012; 50(12):1109-1118. DOI: 10.1097/MLR.0b013e31825f64d0

- 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. DOI: 10.1097/01.mlr.0000182534.19832.83

- 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. DOI: 10.1007/s11999-014-3686-7

- Elixhauser A, Steiner C, Harris DR and Coffey RM. Comorbidity measures for use with administrative data. Medical Care 1998; 36(1):8-27. DOI: 10.1097/00005650-199801000-00004

- Garland A, Fransoo R, Olafson K, Ramsey C, Yogendran M, Chateau D, McGowan K. The epidemiology and outcomes of critical illness in Manitoba. Winnipeg, MB: Manitoba Centre for Health Policy, 2012. URL: http://mchp-appserv.cpe.umanitoba.ca/reference/MCHP_ICU_Report_WEB_(20120403).pdf

- 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. DOI: 10.1097/MLR.0b013e31819432e5

- 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. DOI: 10.1097/MLR.0000000000000735