
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.3.3-dev231 [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 3 1968-08-08 1969-09-24
#> 2 1 9 1963-03-20 1974-08-18
#> 3 2 8 1955-12-22 1982-06-16
#> 4 3 5 1918-06-19 1930-05-09
#> 5 3 4 1967-12-18 1968-07-16
#> 6 3 10 1932-03-09 1932-04-05
#> 7 1 2 1924-02-08 1932-07-03
#> 8 2 6 1985-08-29 1995-12-22
#> 9 2 1 1944-10-19 1952-04-01
#> 10 3 7 1952-09-30 1962-09-22
#> # ℹ 1 more variable: in_observation <int>
# }