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.2 [unknown@Linux 6.11.0-1015-azure:R 4.5.0/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    2          1 1959-04-07        1969-04-19     
#>  2                    2          2 1962-05-23        1978-06-23     
#>  3                    3          3 1904-03-12        1913-10-12     
#>  4                    3          4 2015-10-09        2017-12-21     
#>  5                    2          5 1989-05-28        2013-05-05     
#>  6                    3          6 1929-12-01        1935-08-28     
#>  7                    1          7 1937-04-15        1938-05-07     
#>  8                    3          8 1976-11-09        1978-08-16     
#>  9                    3          9 1922-07-15        1932-08-14     
#> 10                    1         10 1935-05-26        1941-07-28     
#> # ℹ 1 more variable: future_observation <int>

mockDisconnect(cdm = cdm)
# }