Skip to contents

Compute the number of days till the end of the observation period at a certain date

Usage

addFutureObservation(
  x,
  indexDate = "cohort_start_date",
  futureObservationName = "future_observation",
  futureObservationType = "days",
  name = NULL
)

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".

name

Name of the new table, if NULL a temporary table is returned.

Value

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

Examples

# \donttest{
cdm <- mockPatientProfiles()

cdm$cohort1 %>%
  addFutureObservation()
#> # Source:   table<og_128_1730219853> [10 x 5]
#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    1          1 1991-07-07        2000-10-09     
#>  2                    1          2 1951-05-23        1952-08-27     
#>  3                    3          3 1914-06-22        1941-06-28     
#>  4                    3          4 1965-10-17        1985-05-25     
#>  5                    2          5 1983-04-22        1986-04-23     
#>  6                    2          6 1955-05-27        1958-12-17     
#>  7                    2          7 1980-06-12        1991-07-27     
#>  8                    2          8 1973-03-12        1979-05-29     
#>  9                    1          9 2001-03-28        2002-12-07     
#> 10                    2         10 1964-03-14        1974-10-16     
#> # ℹ 1 more variable: future_observation <int>
mockDisconnect(cdm = cdm)
# }