
Add Charlson Comorbidity Index (CCI) value based on Charlson et al. (1987) (doi:10.1016/0021-9681(87)90171-8 ) and Charlson et al. (1994) (doi:10.1016/0895-4356(94)90129-5 ) (age-adjusted) version.
Source:R/addCharlsonIndex.R
addCharlsonIndex.RdAdd Charlson Comorbidity Index (CCI) value based on Charlson et al. (1987) (doi:10.1016/0021-9681(87)90171-8 ) and Charlson et al. (1994) (doi:10.1016/0895-4356(94)90129-5 ) (age-adjusted) version.
Usage
addCharlsonIndex(
x,
indexDate = "cohort_start_date",
ageAdjusted = TRUE,
conceptSet = getIndexCodelist("charlson"),
window = NULL,
nameStyle = "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 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 containmyocardial_infarction,congestive_heart_failure,peripheral_vascular_disease,cerebrovascular_disease,dementia,chronic_pulmonary_disease,connective_tissue_disease,peptic_ulcer_disease,mild_liver_disease,diabetes_without_complication,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 |>
addCharlsonIndex(ageAdjusted = TRUE) |>
select(subject_id, cohort_start_date, charlson) |>
glimpse()
#> Warning: 1559 unique codelist concept IDs are not present in `cdm$concept`.
#> Warning: 23 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 23 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: 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: 58 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 58 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: 128 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 128 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: 111 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 111 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: 31 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 31 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> 7, 57, 57, 86, 187, 187, 222, 248, 297, 297, 297, 39…
#> $ cohort_start_date <date> 1993-03-06, 2004-04-12, 2018-08-15, 2016-12-28, 196…
#> $ charlson <dbl> 0, 0, 1, 2, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0…
# This example uses custom concept sets.
customConceptSet <- list(
myocardial_infarction = 329847L,
congestive_heart_failure = 319835L,
peripheral_vascular_disease = 321052L,
cerebrovascular_disease = 381591L,
dementia = 4182210L,
chronic_pulmonary_disease = 255573L,
connective_tissue_disease = 4134537L,
peptic_ulcer_disease = 4027663L,
mild_liver_disease = 194984L,
moderate_or_severe_liver_disease = 4212540L,
diabetes_without_complication = 201820L,
diabetes_with_complication = 42538715L,
hemiplegia = 374022L,
severe_chronic_kidney_disease = 46271022L,
any_malignancy = 4180914L,
metastatic_solid_tumor = 432851L,
aids = 4267414L
)
cdm$cohort |>
addCharlsonIndex(
conceptSet = customConceptSet,
nameStyle = "charlson_custom"
) |>
select(subject_id, cohort_start_date, charlson_custom) |>
glimpse()
#> Warning: 16 unique codelist concept IDs are not present in `cdm$concept`.
#> Warning: The following codelist concept IDs are not present in `cdm$concept`:
#> • myocardial_infarction: 329847
#> ! 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`:
#> • 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`:
#> • peripheral_vascular_disease: 321052
#> ! 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`:
#> • cerebrovascular_disease: 381591
#> ! 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`:
#> • diabetes_without_complication: 201820
#> ! 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> 7, 57, 57, 86, 187, 187, 222, 248, 297, 297, 297, 39…
#> $ cohort_start_date <date> 1993-03-06, 2004-04-12, 2018-08-15, 2016-12-28, 196…
#> $ charlson_custom <dbl> 0, 0, 1, 2, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0…
# }