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.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          4 1974-06-05        1982-01-08     
#>  2                    1          7 1967-10-05        1967-10-08     
#>  3                    1          5 1967-10-29        1968-09-14     
#>  4                    3          2 1955-12-21        1956-09-05     
#>  5                    3         10 1964-03-11        1964-05-19     
#>  6                    3          9 1984-10-12        1993-03-11     
#>  7                    3          3 1967-10-20        1982-01-04     
#>  8                    3          1 1978-01-28        1981-12-11     
#>  9                    1          8 1972-11-17        1984-11-12     
#> 10                    3          6 1971-04-07        1974-07-08     
#> # ℹ 1 more variable: future_observation <int>

# }