It creates column to indicate the days of difference from an index date to a concept
Source:R/addConceptIntersect.R
addConceptIntersectDays.Rd
It creates column to indicate the days of difference from an index date to a concept
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.
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 |>
addConceptIntersectDays(conceptSet = list("acetaminophen" = 1125315))
#> Warning: ! `codelist` contains numeric values, they are casted to integers.
#> # Source: table<og_071_1734615494> [?? 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 2 9 1974-06-04 1977-02-23
#> 2 3 3 1964-01-07 1972-01-19
#> 3 3 1 1931-12-16 1940-08-04
#> 4 3 8 1930-08-30 1933-01-12
#> 5 2 10 1925-12-18 1930-02-10
#> 6 2 6 1926-07-15 1930-04-29
#> 7 3 7 1976-07-31 1983-05-19
#> 8 3 4 1976-02-18 1977-06-05
#> 9 1 2 1990-07-18 1994-05-01
#> 10 2 5 1961-07-01 1966-10-11
#> # ℹ 1 more variable: acetaminophen_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }