
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{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addInObservationQuery()
#> # Source: SQL [?? x 5]
#> # Database: DuckDB 1.4.1 [unknown@Linux 6.11.0-1018-azure:R 4.5.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 2 2 1922-01-12 1937-07-05
#> 2 1 10 1914-06-17 1931-05-27
#> 3 1 9 2006-11-09 2009-04-28
#> 4 1 6 1980-12-07 2005-03-11
#> 5 2 8 1941-11-18 1946-04-18
#> 6 2 7 1984-08-24 1986-03-02
#> 7 3 5 1927-11-09 1934-10-28
#> 8 2 1 1939-02-02 1939-06-18
#> 9 2 4 1948-12-10 1949-05-21
#> 10 3 3 1924-06-03 1926-09-15
#> # ℹ 1 more variable: in_observation <int>
# }