Intersecting the cohort with columns of an OMOP table of user's choice. It will add an extra column to the cohort, indicating the intersected entries with the target columns in a window of the user's choice.
Source:R/addTableIntersect.R
addTableIntersectField.Rd
Intersecting the cohort with columns of an OMOP table of user's choice. It will add an extra column to the cohort, indicating the intersected entries with the target columns in a window of the user's choice.
Usage
addTableIntersectField(
x,
tableName,
field,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = startDateColumn(tableName),
order = "first",
nameStyle = "{table_name}_{extra_value}_{window_name}",
name = NULL
)
Arguments
- x
Table with individuals in the cdm.
- tableName
Name of the table to intersect with. Options: visit_occurrence, condition_occurrence, drug_exposure, procedure_occurrence, device_exposure, measurement, observation, drug_era, condition_era, specimen, episode.
- field
The columns from the table in tableName to intersect over. For example, if the user uses visit_occurrence in tableName then for field the possible options include visit_occurrence_id, visit_concept_id, visit_type_concept_id.
- indexDate
Variable in x that contains the date to compute the intersection.
- censorDate
whether to censor overlap events at a specific date or a column date of x.
- window
window to consider events in when intersecting with the chosen column.
- targetDate
The dates in the target columns in tableName that the user may want to restrict to.
- order
which record is considered in case of multiple records (only required for date and days options).
- 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{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addTableIntersectField(
tableName = "visit_occurrence",
field = "visit_concept_id",
order = "last",
window = c(-Inf, -1)
)
#> # Source: table<og_159_1730219878> [10 x 5]
#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 5 1993-04-14 1994-06-18
#> 2 1 2 2010-11-18 2011-08-04
#> 3 2 10 1956-05-20 1958-04-22
#> 4 2 9 1960-08-12 1964-11-18
#> 5 3 7 1957-05-26 1958-09-29
#> 6 1 1 1932-07-13 1934-01-27
#> 7 3 6 1958-10-10 1964-03-03
#> 8 2 4 1937-11-10 1946-04-03
#> 9 3 3 1926-09-19 1931-01-16
#> 10 3 8 1966-09-15 1987-03-22
#> # ℹ 1 more variable: visit_occurrence_visit_concept_id_minf_to_m1 <chr>
mockDisconnect(cdm = cdm)
# }