Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should we validate cohorts at each step? #194

Open
edward-burn opened this issue Jun 3, 2024 · 1 comment
Open

should we validate cohorts at each step? #194

edward-burn opened this issue Jun 3, 2024 · 1 comment
Assignees

Comments

@edward-burn
Copy link
Collaborator

@nmercadeb @catalamarti I think we did discuss this before and decided not to validate the cohort at each step to be more performant, but maybe we should think about this again. Below for example I can pass dates out of observation, but maybe the default should be to validate and error? I suppose in the example below, we have the choice whether this should be no error (like now), cause an error (which would happen if we passed cohort validation internally), or the record should be dropped.

library(CohortConstructor)
cdm <- mockCohortConstructor(tables = list(
"cohort" = dplyr::tibble(
  cohort_definition_id = 1,
  subject_id = c(1, 2, 3, 4),
  cohort_start_date = as.Date(c("2000-06-03", "2000-01-01", "2015-01-15", "2000-12-09")),
  cohort_end_date = as.Date(c("2001-09-01", "2001-01-12", "2015-02-15", "2002-12-09")),
  date_1 = as.Date(c("2001-08-01", "1900-01-01", "2015-01-15", "2002-12-09")),
  date_2 = as.Date(c("2001-08-01", NA, "2015-02-14", "2002-12-09"))
)
))
cdm$cohort <- cdm$cohort |> 
  entryAtFirstDate(dateColumns = c("date_1", "date_2"))

cdm$cohort |> 
  omopgenerics::checkCohortRequirements() 
#> Error:
#> ! 1 observation outside observation period.

Created on 2024-06-03 with reprex v2.1.0

@nmercadeb
Copy link
Collaborator

only use in functions that modify cohort start and end

@nmercadeb nmercadeb self-assigned this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants