Skip to contents

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

Usage

addDeathFlag(
  x,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  window = c(0, Inf),
  deathFlagName = "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.

deathFlagName

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 |>
  addDeathFlag()
#> # Source:   table<og_102_1750280278> [?? x 5]
#> # Database: DuckDB v1.3.0 [unknown@Linux 6.11.0-1015-azure:R 4.5.1/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date death
#>                   <int>      <int> <date>            <date>          <dbl>
#>  1                    3          5 1985-05-23        1990-06-24          0
#>  2                    2          6 1946-05-04        1951-04-29          0
#>  3                    3          1 1941-01-03        1947-06-10          0
#>  4                    3          8 1923-12-17        1936-01-21          0
#>  5                    2          7 1929-11-22        1933-09-29          0
#>  6                    2          4 2001-05-03        2004-10-15          0
#>  7                    3         10 2025-06-24        2026-08-15          0
#>  8                    2          3 1959-12-05        1960-10-08          0
#>  9                    2          9 2000-06-27        2004-09-06          0
#> 10                    2          2 1921-12-04        1944-09-08          0

mockDisconnect(cdm = cdm)
# }