Skip to content

Commit

Permalink
Merge pull request #96 from OHDSI/match_null
Browse files Browse the repository at this point in the history
support null in matchedDiagnostics
  • Loading branch information
edward-burn authored Oct 30, 2024
2 parents a5ffb92 + cebac37 commit e55c0b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/matchedDiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
matchedDiagnostics <- function(cohort,
matchedSample = 1000){

omopgenerics::assertNumeric(matchedSample, min = 1)
omopgenerics::assertNumeric(matchedSample, min = 1, null = TRUE)

cdm <- omopgenerics::cdmReference(cohort)
cohortName <- omopgenerics::tableName(cohort)
Expand All @@ -72,7 +72,8 @@ matchedDiagnostics <- function(cohort,
n = matchedSample,
name = matchedCohortTable)
} else {
cdm[[matchedCohortTable]] <- cdm[[cohortName]]
cdm[[matchedCohortTable]] <- cdm[[cohortName]] |>
dplyr::compute(name = matchedCohortTable, temporary = FALSE)
}

cli::cli_bullets(c("*" = "{.strong Generating a age and sex matched cohorts}"))
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-matchedDiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ test_that("cohort to pop diagnostics", {
schema ="main", overwrite = TRUE)
expect_no_error(result <- cdm$my_cohort |>
matchedDiagnostics())
# can be NULL and would do no sampling
cdm$my_cohort |>
matchedDiagnostics(matchedSample = NULL)

# expected errors
expect_error(matchedDiagnostics(cohort = "not a cohort"))
Expand Down

0 comments on commit e55c0b9

Please sign in to comment.