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{
library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addFutureObservation()
#> # Source:   table<og_114_1757798542> [?? 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                    1         10 1913-07-09        1915-10-24     
#>  2                    1          1 1956-01-14        1967-01-28     
#>  3                    2          8 1978-06-18        1997-05-23     
#>  4                    3          5 1935-01-12        1938-02-18     
#>  5                    1          2 1978-08-02        1979-01-14     
#>  6                    1          4 1973-06-24        1974-12-06     
#>  7                    1          3 1978-10-24        1980-02-02     
#>  8                    1          6 1929-07-30        1936-07-16     
#>  9                    1          7 1964-01-17        1974-10-17     
#> 10                    2          9 1912-01-24        1915-04-26     
#> # ℹ 1 more variable: future_observation <int>

# }