
Query to add a new column to indicate if a certain record is within the observation period
Source:R/addDemographicsQuery.R
addInObservationQuery.Rd
`r lifecycle::badge("experimental")` Same as `addInObservation()`, except query is not computed to a table.
Usage
addInObservationQuery(
x,
indexDate = "cohort_start_date",
window = c(0, 0),
completeInterval = FALSE,
nameStyle = "in_observation"
)
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.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 |>
addInObservationQuery()
#> # Source: SQL [?? 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 2 4 2004-03-12 2007-12-25
#> 2 2 2 1934-01-13 1938-05-24
#> 3 2 3 1930-05-03 1953-01-01
#> 4 3 1 1928-06-05 1928-10-26
#> 5 2 5 1967-07-13 1967-08-09
#> 6 3 9 1984-09-10 1988-06-25
#> 7 2 6 1940-01-18 1941-10-17
#> 8 2 7 1959-12-31 1961-03-19
#> 9 3 10 1990-01-02 1995-06-14
#> 10 2 8 1946-04-24 1954-01-26
#> # ℹ 1 more variable: in_observation <int>
mockDisconnect(cdm = cdm)
# }