Skip to contents

Add cohort name for each cohort_definition_id

Usage

addCohortName(cohort)

Arguments

cohort

cohort to which add the cohort name

Value

cohort with an extra column with the cohort names

Examples

# \donttest{
library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")
#> Warning: There are observation period end dates after the current date: 2026-04-06
#>  The latest max observation period end date found is 2028-03-15
cdm$cohort1 |>
  addCohortName()
#> # Source:   SQL [?? x 5]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date cohort_name
#>                   <int>      <int> <date>            <date>          <chr>      
#>  1                    2          1 1931-06-29        1938-06-17      cohort_2   
#>  2                    1          9 1995-11-01        2007-12-21      cohort_1   
#>  3                    3          6 1921-09-06        1937-04-30      cohort_3   
#>  4                    3          4 1976-11-22        1983-02-22      cohort_3   
#>  5                    1          8 1915-04-07        1938-12-01      cohort_1   
#>  6                    2         10 1994-10-25        2002-12-30      cohort_2   
#>  7                    3          5 1979-11-30        1982-01-23      cohort_3   
#>  8                    3          2 1984-02-03        1994-01-26      cohort_3   
#>  9                    1          3 1980-04-06        1986-05-31      cohort_1   
#> 10                    3          7 1970-11-16        1972-06-09      cohort_3   
# }