Skip to content

Commit

Permalink
Merge pull request #104 from darwin-eu/device
Browse files Browse the repository at this point in the history
support device concepts in summarise code use
  • Loading branch information
edward-burn authored Nov 17, 2023
2 parents d3cfcd0 + ba489b2 commit 5014437
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 136 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CodelistGenerator
Title: Generate Code Lists for the OMOP Common Data Model
Version: 2.0.0
Version: 2.1.0
Authors@R: c(
person("Edward", "Burn", email = "[email protected]",
role = c("aut", "cre"),
Expand Down
8 changes: 6 additions & 2 deletions R/codesFromConceptSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ extractCodes <- function(file, unknown) {
appendDescendants <- function(codelistTibble, cdm) {
cdm[["concept_ancestor"]] %>%
dplyr::select("ancestor_concept_id", "descendant_concept_id") %>%
dplyr::mutate(ancestor_concept_id = as.integer(.data$ancestor_concept_id)) %>%
dplyr::inner_join(
codelistTibble %>%
codelistTibble%>%
dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>%
dplyr::filter(.data$include_descendants == TRUE) %>%
dplyr::rename("ancestor_concept_id" = "concept_id"),
by = "ancestor_concept_id",
Expand Down Expand Up @@ -283,14 +285,16 @@ addDetails <- function(conceptList, cdm){
formatConceptList <- function(conceptList, cdm) {
conceptList <- conceptList %>%
dplyr::filter(.data$include_descendants == FALSE) %>%
dplyr::union(
dplyr::union_all(
cdm[["concept_ancestor"]] %>%
dplyr::select(
"concept_id" = "ancestor_concept_id",
"descendant_concept_id"
) %>%
dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>%
dplyr::inner_join(
conceptList %>%
dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>%
dplyr::filter(.data$include_descendants == TRUE),
copy = TRUE,
by = "concept_id"
Expand Down
22 changes: 14 additions & 8 deletions R/drugCodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
#' @param doseForm Only descendants codes with the specified dose form
#' will be returned. If NULL, descendant codes will be returned regardless
#' of dose form.
#' @param withConceptDetails If FALSE a vector of concept IDs will be returned
#' for each ATC group If TRUE a tibble will be returned with additional
#' @param withConceptDetails If FALSE, each item in the list of results (one per
#' ATC group) will contain a vector of concept IDs for each ingredient. If
#' TRUE each item in the list of results will contain a tibble with additional
#' information on the identified concepts.
#'
#' @return A named list, with each element containing the descendant
#' concepts for a particular ATC group
#' @return A named list, with each item containing a vector of descendant
#' concepts of an ATC group (if withConceptDetails was set as FALSE) or a
#' tibble with the descendant concepts along with additional details about them
#' (if withConceptDetails was set as TRUE).
#' @export
#'
#' @examples
Expand Down Expand Up @@ -159,12 +162,15 @@ getATCCodes <- function(cdm,
#' @param doseForm Only descendants codes with the specified dose form
#' will be returned. If NULL, descendant codes will be returned regardless
#' of dose form.
#' @param withConceptDetails If FALSE a vector of concept IDs will be returned
#' for each ingredient. If TRUE a tibble will be returned with additional
#' @param withConceptDetails If FALSE, each item in the list of results (one per
#' ingredient) will contain a vector of concept IDs for each ingredient. If
#' TRUE each item in the list of results will contain a tibble with additional
#' information on the identified concepts.
#'
#' @return A named list, with each item containing descendant concepts of
#' an ingredient
#' @return A named list, with each item containing a vector of descendant
#' concepts of an ingredient (if withConceptDetails was set as FALSE) or a
#' tibble with the descendant concepts along with additional details about them
#' (if withConceptDetails was set as TRUE).
#' @export
#'
#' @examples
Expand Down
Loading

0 comments on commit 5014437

Please sign in to comment.