Skip to contents

It creates column to indicate the date overlap information between a table and a concept

Usage

addConceptIntersectDate(
  x,
  conceptSet,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  window = list(c(0, Inf)),
  targetDate = "event_start_date",
  order = "first",
  inObservation = TRUE,
  nameStyle = "{concept_name}_{window_name}",
  name = NULL
)

Arguments

x

Table with individuals in the cdm.

conceptSet

Concept set list.

indexDate

Variable in x that contains the date to compute the intersection.

censorDate

whether to censor overlap events at a date column of x

window

window to consider events in.

targetDate

Event date to use for the intersection.

order

last or first date to use for date/days calculations.

inObservation

If TRUE only records inside an observation period will be considered.

nameStyle

naming of the added column or columns, should include required parameters.

name

Name of the new table, if NULL a temporary table is returned.

Value

table with added columns with overlap information

Examples

# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles()
concept <- dplyr::tibble(
  concept_id = c(1125315),
  domain_id = "Drug",
  vocabulary_id = NA_character_,
  concept_class_id = "Ingredient",
  standard_concept = "S",
  concept_code = NA_character_,
  valid_start_date = as.Date("1900-01-01"),
  valid_end_date = as.Date("2099-01-01"),
  invalid_reason = NA_character_
) |>
  dplyr::mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- CDMConnector::insertTable(cdm, "concept", concept)

cdm$cohort1 |>
  addConceptIntersectDate(conceptSet = list("acetaminophen" = 1125315))
#> Warning: ! `codelist` contains numeric values, they are casted to integers.
#> # Source:   table<og_060_1734615491> [?? x 5]
#> # Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1017-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    3          5 1965-06-11        1965-12-17     
#>  2                    1          3 1938-06-07        1946-04-26     
#>  3                    2          7 1921-09-24        1942-08-04     
#>  4                    1         10 1991-01-12        2004-08-17     
#>  5                    1          8 1943-02-06        1948-06-10     
#>  6                    1          1 1933-02-21        1953-11-03     
#>  7                    1          2 1907-11-13        1938-02-01     
#>  8                    3          4 1916-09-30        1916-12-14     
#>  9                    3          6 1982-07-30        1993-01-25     
#> 10                    2          9 1955-08-23        1955-10-05     
#> # ℹ 1 more variable: acetaminophen_0_to_inf <date>

mockDisconnect(cdm = cdm)
# }