
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.Rd
Add 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{
cdm <- mockPatientProfiles()
cdm$cohort1 |>
addObservationPeriodIdQuery()
#> # Source: SQL [?? x 5]
#> # Database: DuckDB v1.3.1 [unknown@Linux 6.11.0-1015-azure:R 4.5.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 2 9 1959-03-12 1959-05-03
#> 2 3 8 1946-07-31 1947-03-27
#> 3 3 7 1964-05-08 1989-12-19
#> 4 2 3 1996-06-03 2004-07-12
#> 5 1 2 1996-03-22 2006-12-16
#> 6 2 4 1973-12-10 1986-11-03
#> 7 1 6 1999-04-26 2010-12-01
#> 8 1 5 1953-06-05 1963-12-28
#> 9 1 1 2028-05-21 2029-12-02
#> 10 2 10 1940-04-20 1940-06-18
#> # ℹ 1 more variable: observation_period_id <int>
mockDisconnect(cdm = cdm)
# }