Skip to contents

Add Electronic Frailty Index (eFI) value based on Clegg et al. (2016) (doi:10.1093/ageing/afw039 )

Usage

addElectronicFrailtyIndex(
  x,
  indexDate = "cohort_start_date",
  conceptSet = getIndexCodelist("electronic_frailty_index"),
  categories = list(fit = c(0, 0.12), mild = c(0.12, 0.24), moderate = c(0.24, 0.36),
    severe = c(0.36, 1)),
  nameStyle = "efi",
  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.

conceptSet

A named concept set supplied as a codelist, codelist_with_details, concept_set_expression, or named list of concept IDs. It must contain activity_limitation, anemia, arthritis, atrial_fibrillation, cerebrovascular_disease, chronic_kidney_disease, diabetes, dizziness, dyspnea, falls, foot_problem, fragility_fracture, hearing_impairment, heart_failure, heart_valve_disorder, housebound, hypertension, hypotension_syncope, ischemic_heart_disease, memory_cognitive_disorder, mobility_problems, osteoporosis, parkinsonism_tremor, peptic_ulcer, peripheral_vascular_disease, care_requirement, respiratory_disease, skin_ulcer, sleep_disturbance, social_vulnerability, thyroid_disease, urinary_incontinence, urinary_system_disease, visual_impairment, weight_loss_anorexia as concepts. By default, internal codelists are used.

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.

nameStyle

A character string specifying the name of the new column.

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 Electronic Frailty 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 |>
  addElectronicFrailtyIndex() |>
  select(subject_id, cohort_start_date, efi, efi_categories) |>
  glimpse()
#> Warning: 18203 unique codelist concept IDs are not present in `cdm$concept`.
#> Warning: 18203 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 18885 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: 4
#> $ subject_id        <int> 1309, 4562, 186, 1352, 2498, 1303, 3457, 5277, 2030,
#> $ cohort_start_date <date> 1980-09-24, 1979-03-21, 1989-12-14, 1999-08-10, 201…
#> $ efi               <dbl> 0.02777778, 0.02777778, 0.02777778, 0.05555556, 0.05…
#> $ efi_categories    <chr> "fit", "fit", "fit", "fit", "fit", "fit", "fit", "fi…

# This example uses custom concept sets.
customConceptSet <- list(
  activity_limitation = 763723L,
  anemia = 439777L,
  arthritis = 4291025L,
  atrial_fibrillation = 313217L,
  chronic_kidney_disease = 46271022L,
  cerebrovascular_disease = 381591L,
  dizziness = 4223938L,
  dyspnea = 312437L,
  falls = 4059015L,
  foot_problem = 4101512L,
  fragility_fracture = 3170964L,
  hearing_impairment = 4234647L,
  heart_failure = 316139L,
  heart_valve_disorder = 4281749L,
  housebound = 4052962L,
  hypertension = 319826L,
  hypotension_syncope = 316447L,
  ischemic_heart_disease = 4185932L,
  memory_cognitive_disorder = 4304008L,
  mobility_problems = 4053076L,
  osteoporosis = 80502L,
  parkinsonism_tremor = 4140090L,
  peptic_ulcer = 4027663L,
  peripheral_vascular_disease = 321052L,
  care_requirement = 3661927L,
  respiratory_disease = 317009L,
  skin_ulcer = 4262920L,
  sleep_disturbance = 435524L,
  social_vulnerability = 4026161L,
  diabetes = 201820L,
  thyroid_disease = 4017052L,
  urinary_incontinence = 197672L,
  urinary_system_disease = 75865L,
  visual_impairment = 4265433L,
  weight_loss_anorexia = 436675L
)

cdm$cohort |>
  addElectronicFrailtyIndex(
    conceptSet = customConceptSet,
    nameStyle = "efi_custom"
  ) |>
  select(subject_id, cohort_start_date, efi_custom, efi_custom_categories) |>
  glimpse()
#> Warning: 30 unique codelist concept IDs are not present in `cdm$concept`.
#> Warning: 30 unique codelist concept IDs are not present in `cdm$concept`.
#> ! 30 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: 4
#> $ subject_id            <int> 1309, 4562, 186, 1352, 2498, 1303, 3457, 5277, 2…
#> $ cohort_start_date     <date> 1980-09-24, 1979-03-21, 1989-12-14, 1999-08-10,
#> $ efi_custom            <dbl> 0.00000000, 0.00000000, 0.00000000, 0.00000000, 
#> $ efi_custom_categories <chr> "fit", "fit", "fit", "fit", "fit", "fit", "fit",
# }