
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"),
window = NULL,
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.- window
NULLto use the windows defined by the index components, or a numeric vector of length two,c(min, max), to override the component windows in days relative toindexDate. Use-InforInffor an unbounded lower or upper limit.- 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/Rtmp5IUc4q/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: 41 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 41 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 39 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 39 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 88 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 88 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 59 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 59 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 46 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 46 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 46 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 46 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 34 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 34 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 63 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 63 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 716 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 716 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 17 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 17 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 51 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 51 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: 11 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 11 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> 4199, 4199, 4333, 4392, 4401, 4474, 4475, 4527, 4527…
#> $ cohort_start_date <date> 1952-02-21, 1987-08-30, 1974-10-18, 1991-10-07, 198…
#> $ updated_charlson <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0…
# 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: The following codelist concept IDs are not present in `cdm$concept`:
#> • congestive_heart_failure: 319835
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • dementia: 4182210
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • chronic_pulmonary_disease: 255573
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • connective_tissue_disease: 4134537
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • mild_liver_disease: 194984
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • hemiplegia: 374022
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • severe_chronic_kidney_disease: 46271022
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • diabetes_with_complication: 42538715
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • any_malignancy: 4180914
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • moderate_or_severe_liver_disease: 4212540
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • metastatic_solid_tumor: 432851
#> ! 1 concept(s) from domain NA eliminated as it is not supported.
#> ℹ Supported domains are: device, specimen, measurement, drug, condition,
#> observation, procedure, episode, and visit.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • aids: 4267414
#> ! 1 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> 4199, 4199, 4333, 4392, 4401, 4474, 4475, 4527…
#> $ cohort_start_date <date> 1952-02-21, 1987-08-30, 1974-10-18, 1991-10-0…
#> $ updated_charlson_custom <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1…
# }