Skip to contents

Same as addFutureObservation(), except query is not computed to a table.

Usage

addFutureObservationQuery(
  x,
  indexDate = "cohort_start_date",
  futureObservationName = "future_observation",
  futureObservationType = "days",
  type = "numeric"
)

Arguments

x

A table containing individuals in a CDM reference.

indexDate

Name of a date column in x, or a single date to use for all rows, used as the reference date.

futureObservationName

Name of the future-observation column to add.

futureObservationType

Whether to return a "date" or a number of "days".

type

Type of the created column(s). Counts, days, age, and observation durations can be "numeric" or "integer". Flag columns can also be "logical". Field columns can use "auto" to preserve the source type, or can be converted to "numeric", "integer", "logical", or "character".

Value

cohort table with added column containing future observation of the individuals.

Examples

# \donttest{
library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addFutureObservationQuery()
#> # 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          1 1935-07-30        1937-12-28     
#>  2                    3          5 1964-07-18        1972-08-03     
#>  3                    3          2 1925-05-17        1934-12-12     
#>  4                    3          4 1949-09-08        1957-04-25     
#>  5                    2          8 1941-08-21        1945-02-17     
#>  6                    3          6 1915-09-16        1919-10-29     
#>  7                    3         10 1947-01-30        1949-07-10     
#>  8                    3          7 1937-12-22        1962-09-29     
#>  9                    2          3 1989-01-02        2002-12-24     
#> 10                    2          9 1965-06-18        1967-08-24     
#> # ℹ 1 more variable: future_observation <dbl>

# }