
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.Rd
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.
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, it can have a different and unpredictable behavior depending on the cdm_source.
- 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 |>
addConceptIntersectField(
conceptSet = list("acetaminophen" = 1125315),
field = "drug_type_concept_id"
)
#> Warning: ! `codelist` casted to integers.
#> # Source: table<og_070_1748639745> [?? x 5]
#> # Database: DuckDB v1.2.2 [unknown@Linux 6.11.0-1015-azure:R 4.5.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 4 1946-02-22 1949-12-10
#> 2 2 9 1974-11-19 1976-08-25
#> 3 1 5 1906-05-26 1914-12-18
#> 4 2 10 1939-09-04 1940-04-14
#> 5 1 8 1938-11-13 1949-05-22
#> 6 2 1 1966-02-07 1966-06-04
#> 7 1 3 1977-11-22 1982-06-12
#> 8 2 2 1931-01-03 1933-12-02
#> 9 2 6 1940-06-29 1947-07-27
#> 10 1 7 1957-12-13 1959-01-18
#> # ℹ 1 more variable: drug_type_concept_id_acetaminophen_0_to_inf <int>
mockDisconnect(cdm = cdm)
# }