Skip to contents

conceptCohort() creates a cohort table from patient records from the clinical tables in the OMOP CDM.

The following tables are currently supported for creating concept cohorts:

  • condition_occurrence

  • device_exposure

  • drug_exposure

  • measurement

  • observation

  • procedure_occurrence

  • visit_occurrence

Cohort duration is based on record start and end (e.g. condition_start_date and condition_end_date for records coming from the condition_occurrence tables). So that the resulting table satisfies the requirements of an OMOP CDM cohort table:

  • Overlapping records are collapsed into a single cohort entry.

  • If a record starts outside of an observation period it will be silently ignored.

  • If a record ends outside of an observation period it will be trimmed so as to end at the preceding observation period end date.

Usage

conceptCohort(
  cdm,
  conceptSet,
  name,
  exit = "event_end_date",
  useSourceFields = FALSE
)

Arguments

cdm

A cdm reference.

conceptSet

A conceptSet, which can either be a codelist or a conceptSetExpression.

name

Name of the new cohort table created in the cdm object.

exit

How the cohort end date is defined. Can be either "event_end_date" or "event_start_date".

useSourceFields

If TRUE, the source concept_id fields will also be used when identifying relevant clinical records. If FALSE, only the standard concept_id fields will be used.

Value

A cohort table

Examples

# \donttest{
library(CohortConstructor)

cdm <- mockCohortConstructor(conditionOccurrence = TRUE)
#> Note: method with signature ‘DBIConnection#Id’ chosen for function ‘dbExistsTable’,
#>  target signature ‘duckdb_connection#Id’.
#>  "duckdb_connection#ANY" would also be valid

cohort <- conceptCohort(cdm = cdm, conceptSet = list(a = 1), name = "cohort")
#> Warning: ! `codelist` contains numeric values, they are casted to integers.
#>  Subsetting table condition_occurrence using 1 concept with domain: condition.
#>  Combining tables.
#>  Creating cohort attributes.
#>  Applying cohort requirements.
#>  Collapsing records.
#>  Cohort cohort created.

cohort |> attrition()
#> # A tibble: 3 × 7
#>   cohort_definition_id number_records number_subjects reason_id reason          
#>                  <int>          <int>           <int>     <int> <chr>           
#> 1                    1             10               7         1 Initial qualify…
#> 2                    1             10               7         2 cohort requirem…
#> 3                    1              7               7         3 Overlapping rec…
#> # ℹ 2 more variables: excluded_records <int>, excluded_subjects <int>
# }