Skip to contents

`r lifecycle::badge("experimental")` Same as `addFutureObservation()`, except query is not computed to a table.

Usage

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

Arguments

x

Table with individuals in the cdm.

indexDate

Variable in x that contains the date to compute the future observation.

futureObservationName

name of the new column to be added.

futureObservationType

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

Value

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

Examples

# \donttest{
library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addFutureObservationQuery()
#> # Source:   SQL [?? x 5]
#> # Database: DuckDB 1.4.1 [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                    1          7 1916-04-09        1923-07-20     
#>  2                    3          5 1961-01-04        1963-04-10     
#>  3                    1          2 1963-06-05        1971-01-08     
#>  4                    3          4 1961-10-05        1961-10-08     
#>  5                    1          6 1978-01-03        1992-11-26     
#>  6                    1          8 2006-03-12        2007-01-31     
#>  7                    3          3 1982-10-12        1991-03-11     
#>  8                    3          1 1962-10-20        1975-05-02     
#>  9                    3          9 1973-01-27        1978-08-22     
#> 10                    3         10 1927-11-18        1931-10-01     
#> # ℹ 1 more variable: future_observation <int>

# }