Skip to contents

Validate a cohort table input.

Usage

validateCohortArgument(
  cohort,
  checkEndAfterStart = FALSE,
  checkOverlappingEntries = FALSE,
  checkMissingValues = FALSE,
  checkInObservation = FALSE,
  checkAttributes = FALSE,
  dropExtraColumns = FALSE,
  validation = "error",
  call = parent.frame()
)

Arguments

cohort

Object to be validated as a valid cohort input.

checkEndAfterStart

If TRUE a check that all cohort end dates come on or after cohort start date will be performed.

checkOverlappingEntries

If TRUE a check that no individuals have overlapping cohort entries will be performed.

checkMissingValues

If TRUE a check that there are no missing values in required fields will be performed.

checkInObservation

If TRUE a check that cohort entries are within the individuals observation periods will be performed.

checkAttributes

Whether to check if attributes are present and populated correctly.

dropExtraColumns

Whether to drop extra columns that are not the required ones.

validation

How to perform validation: "error", "warning".

call

A call argument to pass to cli functions.

Examples

cdm <- cdmFromTables(
  tables = list(
    "person" = dplyr::tibble(
      person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990,
      race_concept_id = 0, ethnicity_concept_id = 0
    ),
    "observation_period" = dplyr::tibble(
      observation_period_id = 1:3, person_id = 1:3,
      observation_period_start_date = as.Date("2000-01-01"),
      observation_period_end_date = as.Date("2023-12-31"),
      period_type_concept_id = 0
    )
   ),
   cohortTables = list(
    cohort = dplyr::tibble(
      cohort_definition_id = 1L,
      subject_id = 1L,
      cohort_start_date = as.Date("2020-01-01"),
      cohort_end_date = as.Date("2021-02-10")
    )
  ),
  cdmName = "mock"
)

validateCohortArgument(cdm$cohort)
#> # A tibble: 1 × 4
#>   cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                  <int>      <int> <date>            <date>         
#> 1                    1          1 2020-01-01        2021-02-10