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

better error if you apply the same inclusion criteria twice #234

Closed
catalamarti opened this issue Jun 19, 2024 · 4 comments
Closed

better error if you apply the same inclusion criteria twice #234

catalamarti opened this issue Jun 19, 2024 · 4 comments
Assignees
Milestone

Comments

@catalamarti
Copy link
Collaborator

No description provided.

@edward-burn
Copy link
Collaborator

@catalamarti @nmercadeb is this still an issue? If so, with a reprex I could take a look

@edward-burn edward-burn added this to the cran v0.3 milestone Sep 23, 2024
@nmercadeb
Copy link
Collaborator

I think that what marti suggested is to throw and error if you do something like:

cdm$cohort |> requireSex(sex = "Female") |> requireSex(sex = "Female")

@catalamarti correct me if i'm wrong as i dont remember much what it was about

@edward-burn
Copy link
Collaborator

For me I think it is fine that this doesn't produce an error (but will not lead to another row of attrition with nobody dropped)

@edward-burn
Copy link
Collaborator

This is the current behaviour

library(omock)
#> Warning: package 'omock' was built under R version 4.4.1
library(CohortConstructor)
cdm <- mockCdmReference() |>
  mockPerson(nPerson = 100) |>
  mockObservationPeriod() |>
  mockCohort(
    name = "cohort",
    numberCohorts = 1
  )
cdm$cohort <- cdm$cohort |> 
  requireSex(sex = "Female") |> 
  requireSex(sex = "Female")
attrition(cdm$cohort)
#> # A tibble: 3 × 7
#>   cohort_definition_id number_records number_subjects reason_id reason          
#>                  <int>          <int>           <int>     <int> <chr>           
#> 1                    1            100              59         1 Initial qualify…
#> 2                    1             49              28         2 Sex requirement…
#> 3                    1             49              28         3 Sex requirement…
#> # ℹ 2 more variables: excluded_records <int>, excluded_subjects <int>

Created on 2024-09-24 with reprex v2.1.0

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

3 participants