
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.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 1 1 1963-05-31 1963-12-11
#> 2 2 2 1941-04-01 1957-09-11
#> 3 1 3 1955-06-11 1959-05-18
#> 4 1 4 1995-03-06 2000-11-02
#> 5 3 5 1954-06-24 1956-10-06
#> 6 3 6 1941-05-08 1943-03-31
#> 7 2 7 1987-08-23 1996-06-26
#> 8 2 8 1982-07-25 1988-03-16
#> 9 2 9 1925-06-17 1941-11-17
#> 10 2 10 1945-04-18 1958-06-18
#> # ℹ 1 more variable: in_observation <int>
mockDisconnect(cdm = cdm)
# }