Skip to content

Commit

Permalink
codelist class
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn committed Mar 9, 2024
1 parent ba898af commit 11223c9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Description: Generate a candidate code list for the Observational Medical Outcom
License: Apache License (>= 2)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Depends:
R (>= 3.5.0)
Imports:
Expand Down
12 changes: 12 additions & 0 deletions R/drugCodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ getATCCodes <- function(cdm,
dplyr::select("concept_id") %>%
dplyr::distinct() %>%
dplyr::pull()

} else {
atc_descendants[[i]] <- atc_descendants[[i]] %>%
dplyr::select(!"ancestor_concept_id")
Expand All @@ -152,6 +153,11 @@ getATCCodes <- function(cdm,
names(atc_descendants)[i] <- workingName
}
}

if(isFALSE(withConceptDetails)){
atc_descendants <- omopgenerics::newCodelist(atc_descendants)
}

return(atc_descendants)
}

Expand Down Expand Up @@ -278,13 +284,19 @@ getDrugIngredientCodes <- function(cdm,
dplyr::select("concept_id") %>%
dplyr::distinct() %>%
dplyr::pull()

} else {
ingredientCodes[[i]] <- ingredientCodes[[i]] %>%
dplyr::select(!"ancestor_concept_id")
}

names(ingredientCodes)[[i]] <- workingName
}

if(isFALSE(withConceptDetails)){
ingredientCodes <- omopgenerics::newCodelist(ingredientCodes)
}

return(ingredientCodes)
}

Expand Down
5 changes: 5 additions & 0 deletions R/getICD10StandardCodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ getICD10StandardCodes <- function(cdm,
)
}


if(isFALSE(withConceptDetails)){
ICD10StandardCodes <- omopgenerics::newCodelist(ICD10StandardCodes)
}

return(ICD10StandardCodes)
}

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-drugCodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test_that("getATCCodes working", {
for (i in seq_along(backends)) {
cdm <- mockVocabRef(backend = backends[i])
atcCodes <- getATCCodes(cdm, level = "ATC 1st")
expect_true("codelist" %in% class(atcCodes))
expect_true(all(atcCodes[[1]] == c(12,13)))
expect_true(c("alimentary_tract_and_metabolism") %in%
names(atcCodes))
Expand Down

0 comments on commit 11223c9

Please sign in to comment.