
Indicate if a certain record is within the observation period
Source:R/addDemographics.R
addInObservation.Rd
Indicate if a certain record is within the observation period
Usage
addInObservation(
x,
indexDate = "cohort_start_date",
window = c(0, 0),
completeInterval = FALSE,
nameStyle = "in_observation",
name = NULL
)
Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the observation flag.
- window
window to consider events of.
- completeInterval
If the individuals are in observation for the full window.
- nameStyle
Name of the new columns to create, it must contain "window_name" if multiple windows are provided.
- name
Name of the new table, if NULL a temporary table is returned.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 |>
addInObservation()
#> # Source: table<og_114_1748639776> [?? 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 2 6 1935-04-02 1935-05-25
#> 2 1 2 2000-01-26 2002-12-01
#> 3 1 10 1935-10-16 1942-01-23
#> 4 3 7 1980-01-07 1998-06-16
#> 5 3 9 1937-09-06 1951-10-20
#> 6 1 4 1972-01-14 1978-11-04
#> 7 1 5 1957-04-15 1968-06-08
#> 8 1 3 1926-10-03 1933-12-29
#> 9 2 8 1917-08-05 1920-10-21
#> 10 2 1 1937-08-10 1937-10-21
#> # ℹ 1 more variable: in_observation <int>
mockDisconnect(cdm = cdm)
# }