
It adds a custom column (field) from the intersection with a certain table subsetted by concept id. In general it is used to add the first value of a certain measurement.
Source:R/addConceptIntersect.R
addConceptIntersectField.RdIt adds a custom column (field) from the intersection with a certain table subsetted by concept id. In general it is used to add the first value of a certain measurement.
Arguments
- x
Table with individuals in the cdm.
- conceptSet
Concept set list.
- field
Column in the standard omop table that you want to add.
- 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' to refer to which event consider if multiple events are present in the same window.
- inObservation
If TRUE only records inside an observation period will be considered.
- allowDuplicates
Whether to allow multiple records with same conceptSet, person_id and targetDate. If switched to TRUE, the created new columns (field) will be collapsed to a character vector separated by
;to account for multiple values per person.- 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)
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 |>
addConceptIntersectField(
conceptSet = list("acetaminophen" = 1125315),
field = "drug_type_concept_id"
)
#> Warning: ! `codelist` casted to integers.
#> # Source: table<og_087_1775495267> [?? 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 4 1913-12-27 1919-05-14
#> 2 1 9 1951-01-30 1963-05-06
#> 3 1 6 1982-01-25 1986-03-01
#> 4 2 2 1927-05-27 1938-06-19
#> 5 1 1 1981-10-10 1995-12-06
#> 6 1 10 1926-11-20 1929-08-06
#> 7 3 7 1935-01-19 1935-03-12
#> 8 3 8 1925-10-01 1925-10-31
#> 9 3 3 1917-07-20 1930-08-31
#> 10 3 5 1931-02-06 1936-10-01
#> # ℹ 1 more variable: drug_type_concept_id_acetaminophen_0_to_inf <chr>
# }