
Add the ordinal number of the observation period associated that a given date is in. Result is not computed, only query is added.
Source:R/addObservationPeriodId.R
addObservationPeriodIdQuery.RdAdd the ordinal number of the observation period associated that a given date is in. Result is not computed, only query is added.
Usage
addObservationPeriodIdQuery(
x,
indexDate = "cohort_start_date",
nameObservationPeriodId = "observation_period_id"
)Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addObservationPeriodIdQuery()
#> # 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 1 3 1977-03-15 1988-10-11
#> 2 2 4 1967-10-09 1968-04-23
#> 3 3 7 2010-03-16 2010-05-21
#> 4 3 10 1990-04-14 1990-05-01
#> 5 1 9 2009-06-10 2016-06-19
#> 6 2 5 1971-06-03 2011-02-07
#> 7 3 6 1935-04-21 1952-09-13
#> 8 2 2 1936-06-18 1965-10-10
#> 9 1 1 1953-08-11 1959-10-26
#> 10 3 8 1966-08-08 1981-01-22
#> # ℹ 1 more variable: observation_period_id <int>
# }