
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{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
#> Warning: There are observation period end dates after the current date: 2025-09-13
#> ℹ The latest max observation period end date found is 2031-10-24
cdm$cohort1 |>
addObservationPeriodIdQuery()
#> # 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 3 9 1950-03-14 1954-11-19
#> 2 1 8 1977-03-14 1992-05-11
#> 3 2 10 1962-06-26 1967-01-26
#> 4 1 4 1934-01-15 1937-07-28
#> 5 2 3 1984-09-01 2023-04-10
#> 6 3 5 1934-07-19 1939-02-14
#> 7 2 2 1953-03-03 1972-08-12
#> 8 3 6 1982-07-05 1987-01-09
#> 9 3 1 1955-05-13 1969-01-19
#> 10 3 7 1921-06-30 1938-05-17
#> # ℹ 1 more variable: observation_period_id <int>
# }