
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()
#> # A query: ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 9 1936-06-05 1938-09-03
#> 2 1 7 1973-01-22 1974-12-25
#> 3 2 10 1926-10-10 1946-05-31
#> 4 1 3 1916-09-25 1922-11-30
#> 5 1 5 1976-08-14 1976-08-26
#> 6 1 4 1941-07-26 1948-07-04
#> 7 1 1 1928-03-20 1929-03-28
#> 8 2 2 1964-12-18 1969-01-18
#> 9 1 8 1990-09-24 1991-11-18
#> 10 3 6 1958-01-17 1959-06-10
#> # ℹ 1 more variable: observation_period_id <int>
# }