| Type: | Package |
| Title: | Patient-Level Indices from the OMOP Common Data Model |
| Version: | 0.1.0 |
| Maintainer: | Martí Català <marti.catalasabate@ndorms.ox.ac.uk> |
| Description: | Provides tools to derive standardised, reproducible patient-level indices and covariates from Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM) databases. Functions calculate comorbidity and frailty scores, including the Charlson Comorbidity Index, Electronic Frailty Index, and Hospital Frailty Risk Score, as well as body mass index, polypharmacy, ethnicity, location, and socioeconomic status measures. |
| License: | Apache License (≥ 2) |
| Encoding: | UTF-8 |
| Suggests: | CDMConnector, CodelistGenerator, CohortConstructor, DBI, duckdb, gt, here, htmltools, knitr, odbc, omock, PhenotypeR, rmarkdown, RPostgres, testthat, visOmopResults |
| URL: | https://OHDSI.github.io/OmopIndices/ |
| BugReports: | https://github.com/OHDSI/OmopIndices/issues |
| Imports: | cli, clock, dplyr, omopgenerics (≥ 1.4.0), PatientProfiles, purrr, rlang |
| Depends: | R (≥ 4.1.0) |
| Config/roxygen2/version: | 8.0.0 |
| Config/Needs/website: | rmarkdown |
| NeedsCompilation: | no |
| Packaged: | 2026-09-09 17:30:20 UTC; martics |
| Author: | Martí Català |
| Repository: | CRAN |
| Date/Publication: | 2026-09-17 13:20:27 UTC |
OmopIndices: Patient-Level Indices from the OMOP Common Data Model
Description
Provides tools to derive standardised, reproducible patient-level indices and covariates from Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM) databases. Functions calculate comorbidity and frailty scores, including the Charlson Comorbidity Index, Electronic Frailty Index, and Hospital Frailty Risk Score, as well as body mass index, polypharmacy, ethnicity, location, and socioeconomic status measures.
Author(s)
Maintainer: Martí Català marti.catalasabate@ndorms.ox.ac.uk (ORCID)
Authors:
Martí Català marti.catalasabate@ndorms.ox.ac.uk (ORCID)
Marta Alcalde marta.alcaldeherraiz@ndorms.ox.ac.uk (ORCID)
Maria T Sanchez-Santos maria.sanchez@ndorms.ox.ac.uk (ORCID)
See Also
Useful links:
Add Body Mass Index measurement
Description
Add Body Mass Index measurement
Usage
addBMI(
x,
conceptSet = NULL,
indexDate = "cohort_start_date",
window = c(-Inf, 0),
order = "last",
nameStyle = "bmi",
categories = NULL,
inObservation = TRUE,
name = tableName(x)
)
Arguments
x |
A |
conceptSet |
A named concept set supplied as a |
indexDate |
A character string naming the |
window |
A numeric vector of length two, |
order |
A character string specifying how to select among multiple BMI
measurements within the window: |
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 BMI interval. An additional categorical column is
added, and missing BMI values are labelled |
inObservation |
Logical; whether to restrict records to the person's observation period. |
name |
A character string specifying the name of the output table. If
|
Value
The table x with a new column containing the selected BMI value.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addBMI(window = c(-365, 0), order = "last") |>
select(subject_id, cohort_start_date, bmi) |>
glimpse()
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.
Description
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.
Usage
addCharlsonIndex(
x,
indexDate = "cohort_start_date",
ageAdjusted = TRUE,
conceptSet = getIndexCodelist("charlson"),
nameStyle = "charlson",
categories = NULL,
name = tableName(x)
)
Arguments
x |
A |
indexDate |
A character string naming the |
ageAdjusted |
Logical; whether to include age adjustment in the Charlson Comorbidity Index. |
conceptSet |
A named concept set supplied as a |
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
|
name |
A character string specifying the name of the output table. If
|
Value
The table x with a new column containing the Charlson Comorbidity
Index value.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
# Using the internal concept sets:
cdm$cohort |>
addCharlsonIndex(ageAdjusted = TRUE) |>
select(subject_id, cohort_start_date, charlson) |>
glimpse()
# 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()
Add Electronic Frailty Index (eFI) value based on Clegg et al. (2016) (doi:10.1093/ageing/afw039)
Description
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 |
indexDate |
A character string naming the |
conceptSet |
A named concept set supplied as a |
categories |
A named list of numeric vectors, each containing the lower
and upper bounds of a score interval. An additional column with the suffix
|
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
Value
The table x with a new column containing the Electronic Frailty
Index value.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
# Using the internal concept sets:
cdm$cohort |>
addElectronicFrailtyIndex() |>
select(subject_id, cohort_start_date, efi, efi_categories) |>
glimpse()
# 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()
Add the ethnicity of a person to a table
Description
Add the ethnicity of a person to a table
Usage
addEthnicity(
x,
from = c("ethnicity_concept_id", "ethnicity_source_concept_id", "race_concept_id",
"race_source_concept_id"),
nameStyle = "ethnicity",
name = tableName(x),
missingEthnicityValue = "Missing"
)
Arguments
x |
A |
from |
A character vector specifying the ethnicity sources to try, in priority order. The first source that provides a value is used. Available options are:
|
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
missingEthnicityValue |
A character string used to replace missing ethnicity values. |
Value
The table x with a new column containing the patient's ethnicity.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addEthnicity() |>
select(subject_id, cohort_start_date, ethnicity) |>
glimpse()
Add the hospital frailty risk score as defined in Gilbert et al. (2018) (doi:10.1016/S0140-6736(18)30668-8)
Description
Add the hospital frailty risk score as defined in Gilbert et al. (2018) (doi:10.1016/S0140-6736(18)30668-8)
Usage
addHospitalFrailtyRiskScore(
x,
indexDate = "cohort_start_date",
conceptSet = getIndexCodelist("hospital_frailty_risk_score"),
categories = list(low = c(0, 5), intermediate = c(5, 15), high = c(15, Inf)),
nameStyle = "hfrs",
name = tableName(x)
)
Arguments
x |
A |
indexDate |
A character string naming the |
conceptSet |
A named concept set supplied as a |
categories |
A named list of numeric vectors, each containing the lower
and upper bounds of a score interval. An additional column with the suffix
|
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
Value
The table x with a new column containing the Hospital Frailty Risk
Score value.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addHospitalFrailtyRiskScore() |>
select(subject_id, cohort_start_date, hfrs, hfrs_categories) |>
glimpse()
Add socioeconomic status as a column to a table using the Index of Multiple Deprivation
Description
Add socioeconomic status as a column to a table using the Index of Multiple Deprivation
Usage
addIndexOfMultipleDeprivation(
x,
indexDate = "cohort_start_date",
window = c(-Inf, Inf),
order = "last",
nameStyle = "socio_economic_status",
name = tableName(x),
missingSocioEconomicStatusValue = "Missing"
)
Arguments
x |
A |
indexDate |
A character string naming the |
window |
A numeric vector of length two, |
order |
A character string specifying which record to select when
multiple records are found: |
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
missingSocioEconomicStatusValue |
A character string used to replace missing socioeconomic status values. |
Value
The table x with a new column containing the Index of Multiple
Deprivation value.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addIndexOfMultipleDeprivation() |>
select(subject_id, cohort_start_date, socio_economic_status) |>
glimpse()
Add the location to a table
Description
Add the location to a table
Usage
addLocation(
x,
from = c("location_id", "care_site_id"),
nameStyle = "location",
name = tableName(x),
locationSource = "location_source_value",
missingLocationValue = "Missing"
)
Arguments
x |
A |
from |
A character vector specifying the location sources to try, in
priority order. The first source that provides a location is used. Supported
values are |
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
locationSource |
A character string specifying the column to retrieve
from the |
missingLocationValue |
A character string used to replace missing location values. |
Value
The table x with a new column containing the patient's location.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addLocation() |>
select(subject_id, cohort_start_date, location) |>
glimpse()
Add the maximum number of ingredients to which an individual is simultaneously exposed within a specified window
Description
Add the maximum number of ingredients to which an individual is simultaneously exposed within a specified window
Usage
addPolypharmacyCount(
x,
indexDate = "cohort_start_date",
window = c(0, 0),
overlap = TRUE,
nameStyle = "polypharmacy_count",
name = tableName(x)
)
Arguments
x |
A |
indexDate |
A character string naming the |
window |
A numeric vector of length two, |
overlap |
Logical; if |
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
Value
The table x with a new column containing the maximum number of
simultaneous ingredients in the window of interest.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addPolypharmacyCount(window = c(-30, 0)) |>
select(subject_id, cohort_start_date, polypharmacy_count) |>
glimpse()
Add socioeconomic status as a column to a table
Description
Add socioeconomic status as a column to a table
Usage
addSocioEconomicStatus(
x,
indexDate = "cohort_start_date",
window = c(-Inf, Inf),
order = "last",
from = c("imd", "townsend"),
nameStyle = "socio_economic_status",
name = tableName(x),
missingSocioEconomicStatusValue = "Missing"
)
Arguments
x |
A |
indexDate |
A character string naming the |
window |
A numeric vector of length two, |
order |
A character string specifying which record to select when
multiple records are found: |
from |
A character vector specifying the socioeconomic status sources
to try, in priority order. Supported values are |
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
missingSocioEconomicStatusValue |
A character string used to replace missing socioeconomic status values. |
Value
The table x with a new column containing the patient's
socioeconomic status.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addSocioEconomicStatus() |>
select(subject_id, cohort_start_date, socio_economic_status) |>
glimpse()
Add socioeconomic status as a column to a table using the Townsend deprivation index
Description
Add socioeconomic status as a column to a table using the Townsend deprivation index
Usage
addTownsend(
x,
indexDate = "cohort_start_date",
window = c(-Inf, Inf),
order = "last",
nameStyle = "socio_economic_status",
name = tableName(x),
missingSocioEconomicStatusValue = "Missing"
)
Arguments
x |
A |
indexDate |
A character string naming the |
window |
A numeric vector of length two, |
order |
A character string specifying which record to select when
multiple records are found: |
nameStyle |
A character string specifying the name of the new column. |
name |
A character string specifying the name of the output table. If
|
missingSocioEconomicStatusValue |
A character string used to replace missing socioeconomic status values. |
Value
The table x with a new column containing the Townsend deprivation
index.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
cdm$cohort |>
addTownsend() |>
select(subject_id, cohort_start_date, socio_economic_status) |>
glimpse()
Add Updated Charlson Comorbidity Index (CCI) value based on Quan et al. (2011) (doi:10.1093/aje/kwq433)
Description
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 |
indexDate |
A character string naming the |
ageAdjusted |
Logical; whether to include age adjustment in the updated Charlson Comorbidity Index. |
conceptSet |
A named concept set supplied as a |
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
|
name |
A character string specifying the name of the output table. If
|
Value
The table x with a new column containing the updated Charlson
Comorbidity Index value.
Examples
library(omock)
library(duckdb)
library(OmopIndices)
library(dplyr)
library(CohortConstructor)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$cohort <- conceptCohort(
cdm = cdm,
conceptSet = list(sinusitis = c(257012L, 4283893L, 4294548L, 40481087L)),
name = "cohort"
)
# Using the internal concept sets:
cdm$cohort |>
addUpdatedCharlsonIndex(ageAdjusted = TRUE) |>
select(subject_id, cohort_start_date, updated_charlson) |>
glimpse()
# 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()
Helper for consistent documentation of categories argument
Description
Helper for consistent documentation of categories argument
Arguments
categories |
A named list of numeric vectors, each containing the lower
and upper bounds of a score interval. An additional column with the suffix
|
Get the codelists used for a specified index calculation
Description
Get the codelists used for a specified index calculation
Usage
getIndexCodelist(index)
Arguments
index |
A character string identifying the index for which to retrieve
internal codelists. Supported values are |
Value
A codelist containing the concepts used for the selected index.
Examples
library(OmopIndices)
getIndexCodelist("charlson")
Helper for consistent documentation of inObservation argument
Description
Helper for consistent documentation of inObservation argument
Arguments
inObservation |
Logical; whether to restrict records to the person's observation period. |
Helper for consistent documentation of indexDate argument
Description
Helper for consistent documentation of indexDate argument
Arguments
indexDate |
A character string naming the |
Helper for consistent documentation of index argument
Description
Helper for consistent documentation of index argument
Arguments
index |
A character string identifying the index for which to retrieve
internal codelists. Supported values are |
Helper for consistent documentation of name argument
Description
Helper for consistent documentation of name argument
Arguments
name |
A character string specifying the name of the output table. If
|
Helper for consistent documentation of nameStyle argument
Description
Helper for consistent documentation of nameStyle argument
Arguments
nameStyle |
A character string specifying the name of the new column. |
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- omopgenerics
Helper for consistent documentation of x argument
Description
Helper for consistent documentation of x argument
Arguments
x |
A |