diff --git a/preprocessing/R/concepts.R b/preprocessing/R/concepts.R index 4d5e8d5..6081e74 100644 --- a/preprocessing/R/concepts.R +++ b/preprocessing/R/concepts.R @@ -9,6 +9,7 @@ generate_concepts <- function(cdm, concept_ids) { # Extract columns from concept table cdm$concept |> dplyr::filter(.data$concept_id %in% concept_ids) |> + dplyr::filter(.data$concept_id != 0) |> # remove "no matching concept" instances dplyr::select( "concept_id", "concept_name", diff --git a/preprocessing/tests/testthat/test-concepts.R b/preprocessing/tests/testthat/test-concepts.R index 740d30e..f90ebde 100644 --- a/preprocessing/tests/testthat/test-concepts.R +++ b/preprocessing/tests/testthat/test-concepts.R @@ -8,3 +8,10 @@ test_that("generate_concepts works on a CDM object", { expect_type(concepts$concept_id, "integer") expect_type(concepts$concept_name, "character") }) + +test_that("'No matching concept' concepts are removed", { + # Explicitly request concept_id 0 "No matching concept" + concepts <- generate_concepts(mock_cdm, concept_ids = c(0, 1569708, 3020630)) + expect_false(0 %in% concepts$concept_id) + expect_equal(nrow(concepts), 2) +})