
It creates column to indicate the count overlap information between a table and a concept
Source:R/addConceptIntersect.R
addConceptIntersectCount.RdIt creates column to indicate the count 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 will be the number of intersections in the desired window, or NA if the individual is not in observation at any time in the window.
Examples
# \donttest{
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
#>
#> Attaching package: ‘omopgenerics’
#> The following object is masked from ‘package:stats’:
#>
#> filter
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 |>
addConceptIntersectCount(conceptSet = list("acetaminophen" = 1125315))
#> Warning: ! `codelist` casted to integers.
#> # Source: table<og_053_1775495254> [?? 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 2 9 1989-01-01 1990-09-04
#> 2 1 3 1916-06-09 1924-05-16
#> 3 2 1 1958-10-15 1962-04-20
#> 4 2 8 1973-10-24 1981-03-07
#> 5 2 7 2001-02-10 2003-01-29
#> 6 1 5 1972-10-23 1973-06-26
#> 7 3 10 1936-07-05 1946-04-18
#> 8 2 6 1930-03-24 1950-07-21
#> 9 3 2 1972-11-22 1985-11-03
#> 10 2 4 1959-07-23 1978-03-09
#> # ℹ 1 more variable: acetaminophen_0_to_inf <dbl>
# }