Skip to contents

Add date of death for individuals. Only death within the same observation period than indexDate will be observed.

Usage

addDeathDate(
  x,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  window = c(0, Inf),
  deathDateName = "date_of_death",
  name = NULL
)

Arguments

x

A table containing individuals in a CDM reference.

indexDate

Name of a date column in x, or a single date to use for all rows, used as the reference date.

censorDate

Date or name of a date column in x on which to censor follow-up. If NULL, no censoring is applied.

window

Window or windows of time relative to indexDate to consider.

deathDateName

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

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addDeathDate()
#> # A query:  ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    1          7 1978-09-18        1983-11-13     
#>  2                    2          8 1975-03-10        1998-05-27     
#>  3                    1          3 1961-12-27        1972-12-16     
#>  4                    2          1 1919-08-26        1922-02-11     
#>  5                    1          4 1994-06-01        2003-09-25     
#>  6                    2          5 1952-12-02        1952-12-30     
#>  7                    3          6 1944-12-26        1945-03-09     
#>  8                    3         10 1911-06-03        1915-06-23     
#>  9                    3          9 1998-03-26        2008-08-15     
#> 10                    1          2 2009-06-16        2009-07-13     
#> # ℹ 1 more variable: date_of_death <date>

# }