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{
cdm <- mockPatientProfiles()

cdm$cohort1 %>%
  addFutureObservationQuery()
#> # Source:   SQL [10 x 5]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    3          1 2013-02-02        2013-03-12     
#>  2                    2          2 1936-10-05        1968-09-14     
#>  3                    3          3 1949-03-17        1951-03-09     
#>  4                    1          4 1967-01-14        1972-08-10     
#>  5                    3          5 1988-05-20        1996-03-03     
#>  6                    3          6 1999-03-12        2000-04-26     
#>  7                    3          7 1935-11-12        1938-02-26     
#>  8                    3          8 1918-08-31        1935-04-14     
#>  9                    2          9 1969-12-14        1969-12-15     
#> 10                    1         10 1926-05-17        1930-07-01     
#> # ℹ 1 more variable: future_observation <int>
mockDisconnect(cdm = cdm)
# }