Skip to contents

Add a column with the individual birth date

Usage

addDateOfBirth(
  x,
  name = "date_of_birth",
  missingDay = 1,
  missingMonth = 1,
  imposeDay = FALSE,
  imposeMonth = FALSE
)

Arguments

x

Table in the cdm that contains 'person_id' or 'subject_id'.

name

Name of the column to be added with the date of birth.

missingDay

Day of the individuals with no or imposed day of birth.

missingMonth

Month of the individuals with no or imposed month of birth.

imposeDay

Whether to impose day of birth.

imposeMonth

Whether to impose month of birth.

Value

The function returns the table x with an extra column that contains the date of birth.

Examples

# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
  addDateOfBirth()
#> # Source:   SQL [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                    3          8 2009-10-03        2016-12-27     
#>  2                    1          5 2104-03-24        2114-07-31     
#>  3                    2          6 1991-08-20        1996-10-14     
#>  4                    2          1 1974-02-20        1991-05-20     
#>  5                    1         10 2021-08-25        2052-11-13     
#>  6                    1          7 2157-08-12        2177-09-29     
#>  7                    3          3 1930-03-04        2045-07-16     
#>  8                    2          2 1916-01-01        1916-01-16     
#>  9                    1          4 2032-11-29        2066-07-08     
#> 10                    2          9 2130-06-03        2133-06-13     
#> # ℹ 1 more variable: date_of_birth <date>
mockDisconnect(cdm = cdm)
# }