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_130_1730219857> [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 2 9 1975-09-27 1987-04-04
#> 2 2 10 1966-07-24 1975-12-24
#> 3 2 7 1939-09-05 1946-06-23
#> 4 3 4 1979-10-18 1982-12-15
#> 5 2 6 1939-03-18 1941-07-16
#> 6 2 3 1987-05-07 1988-02-24
#> 7 3 2 1997-04-14 1999-01-24
#> 8 3 5 1975-11-14 1979-07-31
#> 9 2 1 1969-07-29 1969-10-18
#> 10 3 8 1961-03-12 1966-02-02
#> # ℹ 1 more variable: in_observation <int>
mockDisconnect(cdm = cdm)
# }