
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_119_1740601070> [?? x 5]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 9 1933-03-15 1938-02-15
#> 2 2 5 1950-11-03 1969-12-18
#> 3 2 6 1981-04-04 1990-11-04
#> 4 2 7 1980-07-15 1981-04-01
#> 5 3 2 1991-07-01 1997-02-06
#> 6 1 8 1963-01-29 1971-12-21
#> 7 1 10 1973-06-30 1976-03-03
#> 8 3 3 1937-03-05 1941-07-11
#> 9 1 4 1982-01-29 1987-02-08
#> 10 1 1 1981-08-13 1991-12-14
#> # ℹ 1 more variable: in_observation <int>
mockDisconnect(cdm = cdm)
# }