
It creates column to indicate the date overlap information between a table and a concept
Source:R/addConceptIntersect.R
addConceptIntersectDate.RdIt creates column to indicate the date overlap information between a table and a concept
Arguments
- x
A table containing individuals in a CDM reference.
- conceptSet
A named list of concept sets.
- indexDate
Name of a date column in
x, or a single date to use for all rows, used as the reference date.- censorDate
Date or name of a date column in
xon which to censor follow-up. IfNULL, no censoring is applied.- window
Window or windows of time relative to
indexDateto consider.- targetDate
Name or names of date columns in the target tables to use for the intersection.
- order
Which record to use when multiple records occur in a window:
"first"or"last".- inObservation
If
TRUE, only records that occur during an observation period are considered.- nameStyle
Naming pattern for the added column or columns. It should include the required formatting variables. If more than one
tableNameis provided, it must include{table_name}.- name
Name of the new table. If
NULL, a temporary table is returned.
Examples
# \donttest{
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
library(dplyr, warn.conflicts = TRUE)
cdm <- mockPatientProfiles(source = "duckdb")
concept <- 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_
) |>
mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- insertTable(cdm, "concept", concept)
cdm$cohort1 |>
addConceptIntersectDate(conceptSet = list("acetaminophen" = 1125315))
#> Warning: ! `codelist` cast to integers.
#> # A query: ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 9 1951-08-30 1952-02-18
#> 2 1 6 1967-11-29 1977-06-16
#> 3 2 1 1958-10-17 1973-07-23
#> 4 2 5 1981-05-13 1983-07-18
#> 5 1 3 1932-01-04 1932-11-28
#> 6 3 8 1904-06-08 1927-08-15
#> 7 2 2 1962-11-17 1964-09-24
#> 8 3 10 1930-04-29 1942-09-13
#> 9 2 7 1961-02-23 1965-04-15
#> 10 1 4 1951-06-14 1951-07-30
#> # ℹ 1 more variable: acetaminophen_0_to_inf <date>
# }