
Query to add the number of days of prior observation in the current observation period at a certain date
Source:R/addDemographicsQuery.R
addPriorObservationQuery.RdSame as addPriorObservation(), except query is not computed to a table.
Usage
addPriorObservationQuery(
x,
indexDate = "cohort_start_date",
priorObservationName = "prior_observation",
priorObservationType = "days"
)Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
#> Warning: There are observation period end dates after the current date: 2026-04-06
#> ℹ The latest max observation period end date found is 2034-02-27
cdm$cohort1 |>
addPriorObservationQuery()
#> # 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 1 1938-02-24 1939-08-20
#> 2 3 5 1982-10-02 1984-02-19
#> 3 3 9 1921-01-30 1951-04-20
#> 4 2 7 1980-11-14 1980-12-25
#> 5 2 8 1918-02-09 1920-11-05
#> 6 3 6 1980-02-12 1987-03-26
#> 7 2 10 1973-03-10 1989-04-29
#> 8 2 2 1951-09-02 1955-05-17
#> 9 3 4 1988-01-08 1988-06-02
#> 10 3 3 2001-07-13 2020-01-16
#> # ℹ 1 more variable: prior_observation <int>
# }