
Query to add a new column to indicate if a certain record is within the observation period
Source:R/addDemographicsQuery.R
addInObservationQuery.RdSame 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.
Value
cohort table with the added numeric column assessing observation (1 in observation, 0 not in observation).
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addInObservationQuery()
#> # Source: SQL [?? x 5]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 8 1969-06-23 1971-03-25
#> 2 3 5 1974-07-27 1980-11-02
#> 3 2 9 1941-05-26 1941-06-09
#> 4 1 2 1915-10-29 1919-11-18
#> 5 1 1 1922-06-15 1926-11-26
#> 6 3 10 1970-11-28 1971-01-20
#> 7 1 7 1923-12-19 1936-06-17
#> 8 2 3 1936-05-04 1957-10-11
#> 9 2 6 1977-12-17 1978-05-23
#> 10 3 4 1912-11-09 1915-09-24
#> # ℹ 1 more variable: in_observation <int>
# }