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"
)

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.

Value

table x with the added column with death information added.

Examples

# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
  addDeathDate()
#> # Source:   table<og_090_1715898445> [10 x 5]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    2          9 2110-10-25        2145-09-13     
#>  2                    2          3 1958-01-14        2015-05-05     
#>  3                    1          7 2102-06-28        2142-08-25     
#>  4                    2          8 1974-11-01        2055-08-07     
#>  5                    2          1 1995-02-05        2024-04-09     
#>  6                    2          2 2085-07-05        2136-11-13     
#>  7                    2          4 2071-08-17        2074-02-25     
#>  8                    2         10 2018-08-29        2048-03-14     
#>  9                    2          5 2028-11-30        2032-11-15     
#> 10                    1          6 2044-12-20        2046-05-21     
#> # ℹ 1 more variable: date_of_death <date>
mockDisconnect(cdm = cdm)
# }