Skip to contents

Add a column with the individual birth date

Usage

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

Arguments

x

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

dateOfBirthName

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.

name

Name of the new table, if NULL a temporary table is returned.

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:   table<og_095_1730219838> [10 x 5]
#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    3          1 1995-12-06        2000-02-18     
#>  2                    1         10 1970-02-09        1971-05-02     
#>  3                    2          5 1932-05-07        1979-02-05     
#>  4                    1          6 1997-10-21        2000-05-11     
#>  5                    2          9 1901-02-25        1905-02-05     
#>  6                    1          8 1953-07-29        1957-02-01     
#>  7                    2          2 1990-06-10        2005-07-27     
#>  8                    2          3 1943-10-16        1951-02-27     
#>  9                    2          7 1967-10-24        1969-10-11     
#> 10                    1          4 1907-06-21        1908-02-22     
#> # ℹ 1 more variable: date_of_birth <date>
mockDisconnect(cdm = cdm)
# }