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

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.

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{
cdm <- mockPatientProfiles()

cdm$cohort1 |>
  addDeathDate()
#> # Source:   table<og_093_1740755700> [?? x 5]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    3          4 1935-05-23        1939-08-17     
#>  2                    3          2 1932-09-08        1932-11-23     
#>  3                    3          9 1948-10-27        1953-06-08     
#>  4                    2          7 1961-02-09        1961-12-06     
#>  5                    1          1 1925-06-04        1942-01-22     
#>  6                    1         10 1982-12-07        1983-03-13     
#>  7                    1          6 1910-12-08        1944-11-26     
#>  8                    1          3 2000-02-19        2008-09-26     
#>  9                    1          8 1954-05-01        1954-06-08     
#> 10                    3          5 1915-04-06        1915-12-30     
#> # ℹ 1 more variable: date_of_death <date>

mockDisconnect(cdm = cdm)
# }