
It creates column to indicate the flag overlap information between a table and a concept
Source:R/addConceptIntersect.R
addConceptIntersectFlag.RdIt creates column to indicate the flag overlap information between a table and 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.
- targetStartDate
Event start date to use for the intersection.
- targetEndDate
Event end date to use for the intersection.
- 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
The original table (x) with one added column per intersection with the desired conceptSet in a specific window. One column will be created for each combination of window and conceptSet. The value of the column can either be: 1 to indicate presence of the intersection, 0 to indicate no intersection or NA if the individual is not in observation at any time of the window.
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 |>
addConceptIntersectFlag(conceptSet = list("acetaminophen" = 1125315))
#> Warning: ! `codelist` casted to integers.
#> # Source: table<og_097_1775495271> [?? x 5]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 4 1958-09-09 1981-10-18
#> 2 2 6 2014-02-11 2016-02-11
#> 3 2 10 1966-03-04 1970-12-07
#> 4 1 5 1965-09-27 1973-09-01
#> 5 3 8 1958-12-18 1962-10-05
#> 6 1 7 1947-10-01 1950-09-11
#> 7 1 1 1999-09-13 2000-01-27
#> 8 2 3 1952-02-08 1957-10-15
#> 9 1 2 1975-10-19 1976-04-27
#> 10 3 9 1975-01-12 1987-06-18
#> # ℹ 1 more variable: acetaminophen_0_to_inf <dbl>
# }