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 [?? x 5]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    1          1 1965-07-04        1965-07-04     
#>  2                    3          2 1990-11-02        1994-10-15     
#>  3                    2          3 1949-10-26        1962-07-29     
#>  4                    2          4 1973-06-19        1978-08-22     
#>  5                    1          5 1946-06-29        1949-02-02     
#>  6                    3          6 1949-03-27        1970-07-12     
#>  7                    3          7 1948-10-24        1948-12-15     
#>  8                    1          8 1928-02-18        1929-12-05     
#>  9                    2          9 1937-03-19        1945-09-24     
#> 10                    2         10 1919-08-31        1934-09-15     
#> # ℹ 1 more variable: future_observation <int>

mockDisconnect(cdm = cdm)
# }