Skip to contents

Add days to death for individuals. Only death within the same observation period than `indexDate` will be observed.

Usage

addDeathDays(
  x,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  window = c(0, Inf),
  deathDaysName = "days_to_death",
  name = NULL
)

Arguments

x

Table with individuals in the cdm.

indexDate

Variable in x that contains the window origin.

censorDate

Name of a column to stop followup.

window

window to consider events over.

deathDaysName

name of the new column to be added.

name

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

Value

table x with the added column with death information added.

Examples

# \donttest{
cdm <- mockPatientProfiles()

cdm$cohort1 |>
  addDeathDays()
#> # Source:   table<og_099_1741347131> [?? x 5]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.3/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    1          2 1983-10-13        1987-11-10     
#>  2                    2          4 1969-12-26        1974-04-19     
#>  3                    2          7 1933-05-04        1935-09-17     
#>  4                    2          9 1933-07-01        1952-10-23     
#>  5                    2          8 1946-05-02        1968-04-11     
#>  6                    1          1 1974-11-12        1992-01-19     
#>  7                    1          5 1916-12-27        1917-11-26     
#>  8                    1          3 1945-07-13        1982-01-04     
#>  9                    1          6 1961-10-28        1964-05-20     
#> 10                    1         10 1985-03-09        1988-12-11     
#> # ℹ 1 more variable: days_to_death <int>

mockDisconnect(cdm = cdm)
# }