Skip to contents

Compute the intersect with an omop table, you can compute the number of occurrences, a flag of presence, a certain date, the time difference and/or obtain a certain column.

Usage

addTableIntersect(
  x,
  tableName,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  window = list(c(0, Inf)),
  order = "first",
  targetStartDate = startDateColumn(tableName),
  targetEndDate = endDateColumn(tableName),
  flag = TRUE,
  count = TRUE,
  date = TRUE,
  days = TRUE,
  field = character(),
  nameStyle = "{table_name}_{value}_{window_name}"
)

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.

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.

order

which record is considered in case of multiple records (only required for date and days options).

targetStartDate

Column name with start date for comparison.

targetEndDate

Column name with end date for comparison.

flag

TRUE or FALSE. If TRUE, flag will calculated for this intersection.

count

TRUE or FALSE. If TRUE, the number of counts will be calculated for this intersection.

date

TRUE or FALSE. If TRUE, date will be calculated for this intersection.

days

TRUE or FALSE. If TRUE, time difference in days will be calculated for this intersection.

field

Other columns from the table to intersect.

nameStyle

naming of the added column or columns, should include required parameters.

Value

table with added columns with intersect information.

Examples

# \donttest{
cdm <- mockPatientProfiles()

cdm$cohort1 %>%
  addTableIntersect(tableName = "visit_occurrence")
#> Warning: `addTableIntersect()` was deprecated in PatientProfiles 0.6.0.
#> please use the specific functions instead:
#>  addTableIntersectFlag()
#>  addTableIntersectCount()
#>  addTableIntersectDate()
#>  addTableIntersectDays()
#> # Source:   table<og_173_1715428984> [2 x 8]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1018-azure:R 4.4.0/:memory:]
#>   cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                  <dbl>      <dbl> <date>            <date>         
#> 1                    1          1 2020-01-01        2020-04-01     
#> 2                    1          1 2020-06-01        2020-08-01     
#> # ℹ 4 more variables: visit_occurrence_flag_0_to_inf <dbl>,
#> #   visit_occurrence_count_0_to_inf <dbl>,
#> #   visit_occurrence_date_0_to_inf <date>, visit_occurrence_days_0_to_inf <dbl>
CDMConnector::cdmDisconnect(cdm = cdm)
# }