OHDSI / omock

https://ohdsi.github.io/omock/
Apache License 2.0
2 stars 1 forks source link

cohort dates out of observation for large n #21

Closed edward-burn closed 6 months ago

edward-burn commented 6 months ago
library(omock)
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
emptyCdmReference(cdmName = "synthetic cdm") %>% 
    mockPerson(nPerson = 10) %>% 
    mockObservationPeriod() %>% 
    mockCohort(tableName = "my_cohort")
#> 
#> ── # OMOP CDM reference (local) of synthetic cdm ───────────────────────────────
#> • omop tables: person, observation_period
#> • cohort tables: my_cohort
#> • achilles tables: -
#> • other tables: -
emptyCdmReference(cdmName = "synthetic cdm") %>% 
  mockPerson(nPerson = 1000) %>% 
  mockObservationPeriod() %>% 
  mockCohort(tableName = "my_cohort")
#> Error in `validateGeneratedCohortSet()` at OMOPGenerics/R/classCohortTable.R:53:3:
#> ! cohort_start_date must be <= tham cohort_end_date. There are 6 entries
#>   where cohort_end_date < cohort_start_date first 5:
#> $ cohort_definition_id <int> 1, 1, 1, 1, 1
#> $ subject_id <int> 49, 247, 250, 501, 576
#> $ cohort_start_date <date> 2019-12-13, 2016-12-15, 2018-04-17, 2004-08-03, 2…
#> $ cohort_end_date <date> 2019-12-12, 2016-12-14, 2018-04-16, 2004-08-02, 2…
#> # A tibble: 5 × 4
#> Backtrace:
#>     ▆
#>  1. ├─... %>% mockCohort(tableName = "my_cohort")
#>  2. └─omock::mockCohort(., tableName = "my_cohort")
#>  3.   └─omopgenerics::newCohortTable(...) at omock/R/mockCohort.R:118:3
#>  4.     └─omopgenerics:::validateGeneratedCohortSet(cohort, soft = .softValidation) at OMOPGenerics/R/classCohortTable.R:53:3
#>  5.       └─omopgenerics:::checkStartEnd(cohort) at OMOPGenerics/R/classCohortTable.R:198:5
#>  6.         └─cli::cli_abort(...) at OMOPGenerics/R/classCohortTable.R:285:5
#>  7.           └─rlang::abort(...)

Created on 2024-02-26 with reprex v2.0.2