Skip to contents

Add Updated Charlson Comorbidity Index (CCI) value based on Quan et al. (2011) (doi:10.1093/aje/kwq433 )

Usage

addUpdatedCharlsonIndex(
  x,
  indexDate = "cohort_start_date",
  ageAdjusted = TRUE,
  conceptSet = getIndexCodelist("updated_charlson"),
  nameStyle = "updated_charlson",
  categories = NULL,
  name = tableName(x)
)

Arguments

x

A cdm_table containing a person identifier column named person_id or subject_id.

indexDate

A character string naming the Date column in x that defines the index date.

ageAdjusted

Logical; whether to include age adjustment in the updated Charlson Comorbidity Index.

conceptSet

A named concept set supplied as a codelist, codelist_with_details, concept_set_expression, or named list of concept IDs. It must contain congestive_heart_failure, dementia, chronic_pulmonary_disease, connective_tissue_disease, mild_liver_disease, hemiplegia, severe_chronic_kidney_disease, diabetes_with_complication, any_malignancy, moderate_or_severe_liver_disease, metastatic_solid_tumor, aids as concepts. By default, internal codelists are used.

nameStyle

A character string specifying the name of the new column.

categories

A named list of numeric vectors, each containing the lower and upper bounds of a score interval. An additional column with the suffix _categories is added. Intervals are evaluated in the order supplied, and missing scores are labelled missing.

name

A character string specifying the name of the output table. If NULL, a temporary table is created.

Value

The table x with a new column containing the updated Charlson Comorbidity Index value.

Examples

# \donttest{
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)

cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
#>  Loading bundled GiBleed tables from package data.
#>  Adding drug_strength table.
#>  Creating local <cdm_reference> object.
#>  Inserting <cdm_reference> into duckdb.
#> duckdb keeps downloaded extensions and secrets in a temporary directory:
#>  /tmp/Rtmplwnqmn/duckdb
#> This is removed when the R session ends.
#>  Extensions are re-downloaded each session.
#>  Secrets are lost.
#>  Run duckdb(shared_home = TRUE) (or create ~/.duckdb) to keep them (suitable for most users).
#>  Run duckdb(shared_home = FALSE) to accept the temporary directory (and silence this message).
#>  See ?duckdb_storage for details and alternatives.
cdm$cohort <- conceptCohort(
  cdm = cdm,
  conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
  name = "cohort"
)
#>  Subsetting table condition_occurrence using 4 concepts with domain:
#>   condition.
#>  Combining tables.
#>  Creating cohort attributes.
#>  Applying cohort requirements.
#>  Merging overlapping records.
#>  Cohort cohort created.

# Using the internal concept sets:
cdm$cohort |>
  addUpdatedCharlsonIndex(ageAdjusted = TRUE) |>
  select(subject_id, cohort_start_date, updated_charlson) |>
  glimpse()
#> Warning: 1208 unique codelist concept IDs are not present in `cdm$concept`.
#> Warning: 1208 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 1211 concept(s) from domain NA eliminated as it is not supported.
#>  Supported domains are: device, specimen, measurement, drug, condition,
#>   observation, procedure, episode, and visit.
#> Rows: ??
#> Columns: 3
#> $ subject_id        <int> 153, 340, 439, 539, 580, 752, 762, 1128, 1321, 1321,
#> $ cohort_start_date <date> 2013-08-16, 1967-01-02, 1990-01-03, 1954-11-20, 194…
#> $ updated_charlson  <dbl> 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 1, 1…

# This example uses custom concept sets.
customConceptSet <- list(
  congestive_heart_failure = 319835L,
  dementia = 4182210L,
  chronic_pulmonary_disease = 255573L,
  connective_tissue_disease = 4134537L,
  mild_liver_disease = 194984L,
  moderate_or_severe_liver_disease = 4212540L,
  diabetes_with_complication = 42538715L,
  hemiplegia = 374022L,
  severe_chronic_kidney_disease = 46271022L,
  any_malignancy = 4180914L,
  metastatic_solid_tumor = 432851L,
  aids = 4267414L
)

cdm$cohort |>
  addUpdatedCharlsonIndex(
    conceptSet = customConceptSet,
    nameStyle = "updated_charlson_custom"
  ) |>
  select(subject_id, cohort_start_date, updated_charlson_custom) |>
  glimpse()
#> Warning: 12 unique codelist concept IDs are not present in `cdm$concept`.
#> Warning: 12 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 12 concept(s) from domain NA eliminated as it is not supported.
#>  Supported domains are: device, specimen, measurement, drug, condition,
#>   observation, procedure, episode, and visit.
#> Rows: ??
#> Columns: 3
#> $ subject_id              <int> 153, 340, 439, 539, 580, 752, 762, 1128, 1321,
#> $ cohort_start_date       <date> 2013-08-16, 1967-01-02, 1990-01-03, 1954-11-2…
#> $ updated_charlson_custom <dbl> 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0…
# }