Open edward-burn opened 5 months ago
This was one subject born on the 29th of February ahhaha When calculating the 18th birthday by adding 18 years to date of birth we got 28th of February, solved by adding 1 day to these edge cases in PR 127
library(CDMConnector)
library(CodelistGenerator)
library(PatientProfiles)
library(CohortConstructor)
#>
#> Attaching package: 'CohortConstructor'
#> The following objects are masked from 'package:CDMConnector':
#>
#> intersectCohorts, unionCohorts
library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.2.3
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
con <- DBI::dbConnect(duckdb::duckdb(),
dbdir = eunomia_dir())
cdm <- cdm_from_con(con, cdm_schema = "main",
write_schema = c(prefix = "my_study_", schema = "main"))
cdm$working_age_cohort <- demographicsCohort(cdm = cdm,
ageRange = c(18, 65),
name = "working_age_cohort")
#> ℹ Building new trimmed cohort
#> Adding birth date
#> Creating initial cohort
#> Trim age
#> ✔ Cohort trimmed
cdm$working_age_cohort |>
addAge(indexDate = "cohort_start_date") |>
summarise(min_start_age = min(age),
median_start_age = median(age),
max_start_age = max(age))
#> Warning: Missing values are always removed in SQL aggregation functions.
#> Use `na.rm = TRUE` to silence this warning
#> This warning is displayed once every 8 hours.
#> # Source: SQL [1 x 3]
#> # Database: DuckDB v0.10.1 [nmercade@Windows 10 x64:R 4.2.2/C:\Users\nmercade\AppData\Local\Temp\Rtmp8KaPeO\file242c567f7787.duckdb]
#> min_start_age median_start_age max_start_age
#> <dbl> <dbl> <dbl>
#> 1 18 18 18
Created on 2024-05-22 with reprex v2.1.0
Hmm I'm not sure if the issue is not actually that patient profiles should consider 28 Feb the person's birthday if born on a leap year....
@nmercadeb @catalamarti shouldn't min age be 18 in the case below?
Created on 2024-05-22 with reprex v2.1.0