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_105_1734613819> [?? x 5]
#> # Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1017-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    1          5 1934-08-22        1950-08-29     
#>  2                    2          2 1936-01-16        1936-04-04     
#>  3                    2          3 1955-01-04        1956-03-20     
#>  4                    2          8 1942-11-03        1943-06-16     
#>  5                    3          1 1947-02-03        1977-02-19     
#>  6                    1          6 1962-10-17        1965-05-01     
#>  7                    2          9 1999-08-05        2000-10-01     
#>  8                    3          4 1971-12-20        1987-07-27     
#>  9                    2         10 1981-08-06        1983-02-11     
#> 10                    3          7 1936-10-05        1949-08-05     
#> # ℹ 1 more variable: days_to_death <dbl>

mockDisconnect(cdm = cdm)
# }