
Add Updated Charlson Comorbidity Index (CCI) value based on Quan et al. (2011) (doi:10.1093/aje/kwq433 )
Source:R/addUpdatedCharlsonIndex.R
addUpdatedCharlsonIndex.RdAdd 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_tablecontaining a person identifier column namedperson_idorsubject_id.- indexDate
A character string naming the
Datecolumn inxthat 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 containcongestive_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,aidsas 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
_categoriesis added. Intervals are evaluated in the order supplied, and missing scores are labelledmissing.- name
A character string specifying the name of the output table. If
NULL, a temporary table is created.
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…
# }