Skip to content

Commit

Permalink
feat(preprocessing): remove no matching concept instances (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft authored Nov 18, 2024
1 parent 239c646 commit 500fbbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions preprocessing/R/concepts.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions preprocessing/tests/testthat/test-concepts.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

0 comments on commit 500fbbc

Please sign in to comment.