Skip to content

Commit

Permalink
Merge pull request #151 from darwin-eu/v3.0
Browse files Browse the repository at this point in the history
V3.0
  • Loading branch information
edward-burn authored May 31, 2024
2 parents f7406d1 + 65c109e commit 647ea79
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ devtools::test()
Code to add new functionality should be accompanied by tests. Code coverage can be checked using:
``` r
# note, you may first have to detach the package
# detach("package:IncidencePrevalence", unload=TRUE)
# detach("package:CodelistGenerator", unload=TRUE)
devtools::test_coverage()
```

Expand Down
8 changes: 2 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CodelistGenerator
Title: Identify Relevant Clinical Codes and Evaluate Their Use
Version: 2.2.3.900
Version: 3.0
Authors@R: c(
person("Edward", "Burn", email = "[email protected]",
role = c("aut", "cre"),
Expand Down Expand Up @@ -32,7 +32,7 @@ Imports:
cli (>= 3.1.0),
purrr,
lubridate,
PatientProfiles (>= 0.6.0),
PatientProfiles (>= 1.0.0),
RJSONIO,
vctrs,
visOmopResults (>= 0.3.0),
Expand All @@ -50,10 +50,6 @@ Suggests:
tibble,
gt,
flextable
Remotes:
darwin-eu-dev/omopgenerics,
darwin-eu/CDMConnector,
darwin-eu/visOmopResults
Config/testthat/edition: 3
Config/testthat/parallel: true
VignetteBuilder: knitr
Expand Down
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# CodelistGenerator 2.2.3.900 (development version)
# CodelistGenerator 3.0
* Add function getRelationshipId
* Add functions summariseAchillesCodeUse (replaces achillesCodeUse), summariseOrphanCodes (replaces findOrphanCodes), tableAchillesCodeUse, tableCodeUse, tableCohortCodeUse, tableOrphanCodes.


# CodelistGenerator 2.2.3
* Fix for forthcoming breaking change in dependency omopgenerics

Expand Down
2 changes: 1 addition & 1 deletion R/checks.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of CodelistGenerator
#
Expand Down
9 changes: 7 additions & 2 deletions R/codesFromConceptSet.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of CodelistGenerator
#
Expand Down Expand Up @@ -364,12 +364,17 @@ formatConceptList <- function(cdm, conceptListTable) {
"descendant_concept_id"
) %>%
dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>%
dplyr::inner_join(
dplyr::right_join(
cdm[[conceptListTable]] %>%
dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>%
dplyr::filter(.data$include_descendants == TRUE),
by = "concept_id"
) %>%
dplyr::mutate(descendant_concept_id = dplyr::if_else(
# in case concept is not in ancestor table
# (even though it should be)
is.na(.data$descendant_concept_id),
.data$concept_id, .data$descendant_concept_id)) %>%
dplyr::select(-"concept_id") %>%
dplyr::rename("concept_id" = "descendant_concept_id")
) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/codesInUse.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of CodelistGenerator
#
Expand Down
2 changes: 1 addition & 1 deletion R/compareCodelists.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion R/drugCodes.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions R/getCandidateCodes.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions R/getICD10StandardCodes.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion R/getMappings.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions R/inputValidation.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions R/mockVocabRef.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion R/runSearch.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions R/summariseCodeUse.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
9 changes: 5 additions & 4 deletions R/vocabUtilities.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2024 DARWIN EU (C)
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -403,7 +403,6 @@ getDescendantsAndAncestor <- function(cdm, conceptId, ingredientRange, doseForm)
dplyr::left_join(cdm$concept,
by = "concept_id") %>%
dplyr::compute()
CDMConnector::dropTable(cdm, conceptIdDbTable)

descendants <- addIngredientCount(cdm = cdm, concepts = descendants) %>%
dplyr::filter(.data$ingredient_count >= !!ingredientRange[1],
Expand Down Expand Up @@ -456,6 +455,8 @@ descendants$ancestor_concept_id <- stringr::str_replace_all(
doseForm = doseForm)
}

CDMConnector::dropTable(cdm, conceptIdDbTable)

# nb conceptId will also be a descendant of itself
return(descendants)

Expand Down Expand Up @@ -520,7 +521,7 @@ addIngredientCount <- function(cdm, concepts) {
dplyr::select("concept_id"),
by = c("ancestor_concept_id" = "concept_id"))

ingredient_count <- concepts%>%
ingredient_count <- concepts %>%
dplyr::select("concept_id") %>%
dplyr::distinct() %>%
dplyr::left_join(ingredient_ancestor,
Expand Down
12 changes: 12 additions & 0 deletions inst/concepts_dbms/oa_desc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"items": [
{
"concept": {
"CONCEPT_ID": 4079750
},
"isExcluded": false,
"includeDescendants": true,
"includeMapped": false
}
]
}
12 changes: 12 additions & 0 deletions inst/concepts_dbms/oa_no_desc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"items": [
{
"concept": {
"CONCEPT_ID": 4079750
},
"isExcluded": false,
"includeDescendants": false,
"includeMapped": false
}
]
}
13 changes: 13 additions & 0 deletions tests/testthat/test-dbms.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ test_that("redshift", {
cdm_schema = Sys.getenv("CDM5_REDSHIFT_CDM_SCHEMA"),
write_schema = Sys.getenv("CDM5_REDSHIFT_SCRATCH_SCHEMA"))

cdm$concept <- cdm$concept |>
dplyr::mutate(concept_id = as.integer64(concept_id)) |>
dplyr::compute()

# candidate code search
expect_no_error(asthma<-getCandidateCodes(cdm,
Expand Down Expand Up @@ -122,6 +125,16 @@ test_that("redshift", {
cdm = cdm,
countBy = "not an option"))

# working concept set example with mock
x <- codesFromConceptSet(
cdm = cdm, path = system.file(package = "CodelistGenerator",
"concepts_dbms")
)
expect_true(x$oa_no_desc == 4079750)
expect_true(!761485 %in% x$oa_no_desc)
expect_true(761485 %in% x$oa_desc)


CDMConnector::cdm_disconnect(cdm)
})

Expand Down

0 comments on commit 647ea79

Please sign in to comment.