Skip to content

Commit

Permalink
omopgenerics validate
Browse files Browse the repository at this point in the history
  • Loading branch information
nmercadeb committed Sep 23, 2024
1 parent 10e5ddd commit 58f42b0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/stratifyCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#'
#' cdm$my_cohort <- cdm$cohort1 |>
#' addAge(ageGroup = list("child" = c(0, 17), "adult" = c(18, Inf))) |>
#' addSex() |>
#' addSex(name = "my_cohort") |>
#' stratifyCohorts(
#' strata = list("sex", c("sex", "age_group")), name = "my_cohort"
#' )
Expand All @@ -33,7 +33,7 @@
#' settings(cdm$my_cohort)
#'
#' attrition(cdm$my_cohort)
#' }
#'}
stratifyCohorts <- function(cohort,
strata,
cohortId = NULL,
Expand Down
3 changes: 2 additions & 1 deletion R/unionCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ unionCohorts <- function(cohort,
cdm <- omopgenerics::validateCdmArgument(omopgenerics::cdmReference(cohort))
cohortId <- validateCohortId(cohortId, settings(cohort))
omopgenerics::assertNumeric(gap, integerish = TRUE, min = 0, length = 1)
cohortName <- omopgenerics::validateNameArgument(cohortName, validation = "warning")
omopgenerics::assertCharacter(cohortName, length = 1, null = TRUE)
omopgenerics::assertLogical(keepOriginalCohorts, length = 1)

if (length(cohortId) < 2) {
cli::cli_abort("Settings of cohort table must contain at least two cohorts.")
Expand Down
2 changes: 1 addition & 1 deletion man/stratifyCohorts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-unionCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("unionCohorts works", {
omock::mockObservationPeriod() |>
omock::mockCohort(name = c("cohort1"), numberCohorts = 4)
cdm <- cdm_local |> copyCdm()
# simple example
# simple example
cdm$cohort2 <- unionCohorts(cdm$cohort1, name = "cohort2")
expect_true(all(
cdm$cohort2 %>% dplyr::pull("cohort_start_date") %>% sort() ==
Expand Down

0 comments on commit 58f42b0

Please sign in to comment.