Same as
addBirthday(), except query is not computed to a table.
The function accounts for leap years and corrects the invalid dates to the next valid date.
Usage
addBirthdayQuery(
x,
birthdayName = "birthday",
birthday = 0,
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE
)Arguments
- x
Table with individuals in the cdm.
- birthdayName
Birth day variable name.
- birthday
Number of birth day.
- ageMissingMonth
Month of the year assigned to individuals with missing month of birth.
- ageMissingDay
day of the month assigned to individuals with missing day of birth.
- ageImposeMonth
TRUE or FALSE. Whether the month of the date of birth will be considered as missing for all the individuals.
- ageImposeDay
TRUE or FALSE. Whether the day of the date of birth will be considered as missing for all the individuals.
Examples
# \donttest{
library(PatientProfiles)
library(dplyr)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addBirthdayQuery() |>
glimpse()
#> Rows: ??
#> Columns: 5
#> Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> $ cohort_definition_id <int> 2, 3, 2, 2, 2, 3, 3, 3, 1, 3
#> $ subject_id <int> 9, 6, 7, 10, 3, 5, 1, 8, 2, 4
#> $ cohort_start_date <date> 1923-09-26, 1945-02-07, 1970-09-16, 1945-12-04, 1…
#> $ cohort_end_date <date> 1923-10-22, 1947-02-25, 1980-01-03, 1960-10-26, 1…
#> $ birthday <date> 1912-01-01, 1934-01-01, 1941-01-01, 1945-01-01, …
cdm$cohort1 |>
addBirthdayQuery(birthday = 5) |>
glimpse()
#> Rows: ??
#> Columns: 5
#> Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> $ cohort_definition_id <int> 2, 3, 2, 2, 2, 3, 3, 3, 1, 3
#> $ subject_id <int> 9, 6, 7, 10, 3, 5, 1, 8, 2, 4
#> $ cohort_start_date <date> 1923-09-26, 1945-02-07, 1970-09-16, 1945-12-04, 1…
#> $ cohort_end_date <date> 1923-10-22, 1947-02-25, 1980-01-03, 1960-10-26, 1…
#> $ birthday <date> 1917-01-01, 1939-01-01, 1946-01-01, 1950-01-01, …
# }
