Skip to contents

[Deprecated]

Usage

generateDeathCohortSet(cdm, name, cohortTable = NULL, cohortId = NULL)

Arguments

cdm

CDM reference

name

name for the created death cohort table

cohortTable

name of the cohort table to create a death cohort for

cohortId

name of the cohort table to create a death cohort for

Value

A cohort table with a death cohort in cdm

Examples

# \donttest{
library(CDMConnector)
library(CohortSurvival)
observation_period <- dplyr::tibble(
  observation_period_id = c(1, 2, 3, 4, 5,6),
  person_id = c(1, 2, 3, 4, 5,6),
  observation_period_start_date = c(
    rep(as.Date("1980-07-20"),6)
  ),
  observation_period_end_date = c(
    rep(as.Date("2023-05-20"),6)
  ),
  period_type_concept_id = c(rep(0,6))
)

deathTable <- dplyr::tibble(
  person_id = c(1,2,3),
  death_date = c(as.Date("2020-01-01"),
                 as.Date("2020-01-02"),
                 as.Date("2020-01-01")))

person <- dplyr::tibble(
  person_id = c(1, 2, 3, 4, 5),
  year_of_birth = c(rep("1990", 5)),
  month_of_birth = c(rep("02", 5)),
  day_of_birth = c(rep("11", 5)),
  gender_concept_id = c(rep(0,5)),
  ethnicity_concept_id = c(rep(0,5)),
  race_concept_id = c(rep(0,5))
)

cdm <- omopgenerics::cdmFromTables(
  tables = list(
    person = person,
    observation_period = observation_period,
    death = deathTable
  ),
  cdmName = "mock_es"
)
#> Warning: ! 7 column in person do not match expected column type:
#>  `person_id` is numeric but expected integer
#>  `year_of_birth` is character but expected integer
#>  `month_of_birth` is character but expected integer
#>  `day_of_birth` is character but expected integer
#>  `gender_concept_id` is numeric but expected integer
#>  `ethnicity_concept_id` is numeric but expected integer
#>  `race_concept_id` is numeric but expected integer
#> Warning: ! 3 column in observation_period do not match expected column type:
#>  `observation_period_id` is numeric but expected integer
#>  `person_id` is numeric but expected integer
#>  `period_type_concept_id` is numeric but expected integer
#> Warning: ! 1 column in death do not match expected column type:
#>  `person_id` is numeric but expected integer
 db <- DBI::dbConnect(duckdb::duckdb(), ":memory:")
cdm2 = CDMConnector::copy_cdm_to(db,
                                 cdm,
                                 schema = "main")
#> Warning: ! 7 column in person do not match expected column type:
#>  `person_id` is numeric but expected integer
#>  `year_of_birth` is character but expected integer
#>  `month_of_birth` is character but expected integer
#>  `day_of_birth` is character but expected integer
#>  `gender_concept_id` is numeric but expected integer
#>  `ethnicity_concept_id` is numeric but expected integer
#>  `race_concept_id` is numeric but expected integer
#> Warning: ! 3 column in observation_period do not match expected column type:
#>  `observation_period_id` is numeric but expected integer
#>  `person_id` is numeric but expected integer
#>  `period_type_concept_id` is numeric but expected integer

attr(cdm2, "cdm_schema") <- "main"
attr(cdm2, "write_schema") <- "main"

cdm2 <- generateDeathCohortSet(cdm=cdm2,
                               name = "death_cohort")
#> Warning: `generateDeathCohortSet()` was deprecated in CohortSurvival 0.6.0.
#> Warning: ! 1 column in death_cohort do not match expected column type:
#>  `subject_id` is numeric but expected integer
# }