Skip to content

Commit

Permalink
v3.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn committed Jan 28, 2025
1 parent 5b8db0b commit 95b555e
Show file tree
Hide file tree
Showing 41 changed files with 218 additions and 167 deletions.
13 changes: 7 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: 3.3.1
Version: 3.3.2
Authors@R: c(
person("Edward", "Burn", email = "[email protected]",
role = c("aut", "cre"),
Expand All @@ -25,28 +25,29 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Depends:
R (>= 3.5.0)
R (>= 4.1)
Imports:
checkmate (>= 2.0.0),
DBI (>= 1.1.0),
dplyr (>= 1.1.0),
omopgenerics (>= 0.4.0),
omopgenerics (>= 0.4.1),
rlang (>= 1.0.0),
glue (>= 1.5.0),
stringr (>= 1.4.0),
stringi (>= 1.8.1),
tidyselect (>= 1.2.0),
tidyr (>= 1.2.0),
cli (>= 3.1.0),
purrr,
lubridate,
PatientProfiles (>= 1.1.0),
PatientProfiles (>= 1.2.3),
vctrs,
visOmopResults (>= 0.5.0),
RJSONIO
Suggests:
covr,
duckdb,
CDMConnector (>= 1.3.0),
CDMConnector (>= 1.7.0),
visOmopResults (>= 1.0.0),
knitr,
rmarkdown,
testthat (>= 3.0.0),
Expand Down
2 changes: 1 addition & 1 deletion R/getMappings.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' Show mappings from non-standard vocabularies to standard
#'
#' @param candidateCodelist Dataframe
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
#' @param nonStandardVocabularies Character vector
#'
#' @return tibble
Expand Down
1 change: 1 addition & 0 deletions R/runSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ tidyWords <- function(words) {
Encoding(words) <- "latin1"

# some generic formatting
workingWords <- stringi::stri_trans_nfkc(words)
workingWords <- trimws(words)
workingWords <- stringr::str_replace_all(workingWords, "-", " ")
workingWords <- stringr::str_replace_all(workingWords, "[[:punct:]]", "")
Expand Down
6 changes: 3 additions & 3 deletions R/summariseAchillesCodeUse.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Summarise code use from achilles counts
#'
#' @param x Codelist
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
#' @param countBy Either "record" for record-level counts or "person" for
#' person-level counts
#'
Expand Down Expand Up @@ -113,8 +113,8 @@ summariseAchillesCodeUse <- function(x,
estimate_type = "integer",
estimate_value = as.character(.data$n)
) |>
visOmopResults::uniteAdditional(cols = c("standard_concept", "vocabulary_id")) |>
visOmopResults::uniteStrata(cols = c("domain_id")) |>
omopgenerics::uniteAdditional(cols = c("standard_concept", "vocabulary_id")) |>
omopgenerics::uniteStrata(cols = c("domain_id")) |>
dplyr::select(dplyr::any_of(omopgenerics::resultColumns("summarised_result")))

codeUse <- codeUse |>
Expand Down
32 changes: 16 additions & 16 deletions R/summariseCodeUse.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' Summarise code use in patient-level data
#'
#' @param x List of concept IDs
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
#' @param countBy Either "record" for record-level counts or "person" for
#' person-level counts
#' @param byConcept TRUE or FALSE. If TRUE code use will be summarised by
Expand All @@ -32,10 +32,10 @@
#' @examples
#' \dontrun{
#' con <- DBI::dbConnect(duckdb::duckdb(),
#' dbdir = CDMConnector::eunomia_dir())
#' cdm <- CDMConnector::cdm_from_con(con,
#' cdm_schem = "main",
#' write_schema = "main")
#' dbdir = CDMConnector::eunomiaDir())
#' cdm <- CDMConnector::cdmFromCon(con,
#' cdmSchema = "main",
#' writeSchema = "main")
#'acetiminophen <- c(1125315, 1127433, 40229134,
#'40231925, 40162522, 19133768, 1127078)
#'poliovirus_vaccine <- c(40213160)
Expand Down Expand Up @@ -101,7 +101,7 @@ summariseCodeUse <- function(x,
#' Summarise code use among a cohort in the cdm reference
#'
#' @param x Vector of concept IDs
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
#' @param cohortTable A cohort table from the cdm reference.
#' @param cohortId A vector of cohort IDs to include
#' @param timing When to assess the code use relative cohort dates. This can
Expand All @@ -121,10 +121,10 @@ summariseCodeUse <- function(x,
#' @examples
#' \dontrun{
#' con <- DBI::dbConnect(duckdb::duckdb(),
#' dbdir = CDMConnector::eunomia_dir())
#' cdm <- CDMConnector::cdm_from_con(con,
#' cdm_schem = "main",
#' write_schema = "main")
#' dbdir = CDMConnector::eunomiaDir())
#' cdm <- CDMConnector::cdmFromCon(con,
#' cdmSchema = "main",
#' writeSchema = "main")
#' cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
#' conceptSet = list(a = 260139,
#' b = 1127433),
Expand Down Expand Up @@ -203,7 +203,7 @@ summariseCohortCodeUse <- function(x,
)
)
} else {
codeUse <- omopgenerics::emptySummarisedResult()
cohortCodeUse <- omopgenerics::emptySummarisedResult()
}

return(cohortCodeUse)
Expand Down Expand Up @@ -321,8 +321,8 @@ getCodeUse <- function(x,
"variable_name" = dplyr::if_else(is.na(.data$standard_concept_name), "overall", .data$standard_concept_name),
"variable_level" = as.character(.data$standard_concept_id)
) |>
visOmopResults::uniteGroup(cols = c("cohort_name", "codelist_name")) |>
visOmopResults::uniteAdditional(
omopgenerics::uniteGroup(cols = c("cohort_name", "codelist_name")) |>
omopgenerics::uniteAdditional(
cols = c("source_concept_name", "source_concept_id",
"source_concept_value", "domain_id"),
ignore = "overall"
Expand All @@ -334,7 +334,7 @@ getCodeUse <- function(x,
)

} else {
codeCounts <- dplyr::tibble()
codeCounts <- omopgenerics::emptySummarisedResult()
cli::cli_inform(c(
"i" = "No records found in the cdm for the concepts provided."
))
Expand Down Expand Up @@ -715,7 +715,7 @@ getGroupedRecordCount <- function(records,
dplyr::mutate(estimate_value = as.character(.data$estimate_value)) |>
dplyr::collect()
) |>
visOmopResults::uniteStrata(cols = groupBy) |>
omopgenerics::uniteStrata(cols = groupBy) |>
dplyr::mutate(estimate_name = "record_count")

return(groupedCounts)
Expand Down Expand Up @@ -749,7 +749,7 @@ getGroupedPersonCount <- function(records,
dplyr::tally(name = "estimate_value") |>
dplyr::mutate(estimate_value = as.character(.data$estimate_value)) |>
dplyr::collect()) |>
visOmopResults::uniteStrata(cols = groupBy) |>
omopgenerics::uniteStrata(cols = groupBy) |>
dplyr::mutate(estimate_name = "person_count")

return(groupedCounts)
Expand Down
4 changes: 4 additions & 0 deletions R/tableAchillesCodeUse.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ tableAchillesCodeUse <- function(result,
hide = character(),
.options = list()) {

rlang::check_installed("visOmopResults", version = "1.0.0")

# checks
if(nrow(result) == 0){
cli::cli_warn("`result` object is empty")
Expand Down Expand Up @@ -122,6 +124,8 @@ tableOrphanCodes <- function(result,
hide = character(),
.options = list()) {

rlang::check_installed("visOmopResults", version = "1.0.0")

if(nrow(result) == 0){
cli::cli_warn("`result` object is empty")
return(emptyResultTable(type = type))
Expand Down
26 changes: 15 additions & 11 deletions R/tableCodeUse.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#' @examples
#' \dontrun{
#' con <- DBI::dbConnect(duckdb::duckdb(),
#' dbdir = CDMConnector::eunomia_dir())
#' cdm <- CDMConnector::cdm_from_con(con,
#' cdm_schem = "main",
#' write_schema = "main")
#' dbdir = CDMConnector::eunomiaDir())
#' cdm <- CDMConnector::cdmFromCon(con,
#' cdmSchema = "main",
#' writeSchema = "main")
#'acetiminophen <- c(1125315, 1127433, 40229134,
#'40231925, 40162522, 19133768, 1127078)
#'poliovirus_vaccine <- c(40213160)
Expand All @@ -53,6 +53,8 @@ tableCodeUse <- function(result,
hide = character(),
.options = list()) {

rlang::check_installed("visOmopResults", version = "1.0.0")

# checks
if(nrow(result) == 0){
cli::cli_warn("`result` object is empty")
Expand Down Expand Up @@ -116,10 +118,10 @@ tableCodeUse <- function(result,
#' @examples
#' \dontrun{
#' con <- DBI::dbConnect(duckdb::duckdb(),
#' dbdir = CDMConnector::eunomia_dir())
#' cdm <- CDMConnector::cdm_from_con(con,
#' cdm_schem = "main",
#' write_schema = "main")
#' dbdir = CDMConnector::eunomiaDir())
#' cdm <- CDMConnector::cdmFromCon(con,
#' cdmSchema = "main",
#' writeSchema = "main")
#' cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
#' conceptSet = list(a = 260139,
#' b = 1127433),
Expand All @@ -145,6 +147,8 @@ tableCohortCodeUse <- function(result,
hide = character(),
.options = list()) {

rlang::check_installed("visOmopResults", version = "1.0.0")

# checks
if(nrow(result) == 0){
cli::cli_warn("`result` object is empty")
Expand Down Expand Up @@ -191,9 +195,9 @@ internalTableCodeUse <- function(result,
.options <- optionsCodeUse(.options)

if (timing) {
settingsColumns <- "timing"
settingsColumn <- "timing"
} else {
settingsColumns <- character()
settingsColumn <- character()
}

x <- result |>
Expand All @@ -211,7 +215,7 @@ internalTableCodeUse <- function(result,
header = header,
groupColumn = groupColumn,
type = type,
settingsColumns = settingsColumns,
settingsColumn = settingsColumn,
rename = c(
"Domain ID" = "domain_id", "Database name" = "cdm_name",
"Standard concept ID" = "standard_concept_id",
Expand Down
3 changes: 3 additions & 0 deletions R/tableUnmappedCodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ tableUnmappedCodes <- function(result,
groupColumn = character(),
hide = character(),
.options = list()) {

rlang::check_installed("visOmopResults", version = "1.0.0")

# checks
if(nrow(result) == 0){
cli::cli_warn("`result` object is empty")
Expand Down
7 changes: 5 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ library(CodelistGenerator)

For this example we'll use the Eunomia dataset (which only contains a subset of the OMOP CDM vocabularies)
```{r}
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdm_from_con(db, cdm_schema = "main", write_schema = c(prefix = "cg_", schema = "main"))
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
cdm <- cdmFromCon(db,
cdmSchema = "main",
writeSchema = "main",
writePrefix = "cg_")
```

## Exploring the OMOP CDM Vocabulary tables
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ For this example we’ll use the Eunomia dataset (which only contains a
subset of the OMOP CDM vocabularies)

``` r
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdm_from_con(db, cdm_schema = "main", write_schema = c(prefix = "cg_", schema = "main"))
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
cdm <- cdmFromCon(db,
cdmSchema = "main",
writeSchema = "main",
writePrefix = "cg_")
```

## Exploring the OMOP CDM Vocabulary tables
Expand Down Expand Up @@ -186,16 +189,16 @@ summariseCodeUse(list("asthma" = asthma_codes1$concept_id),
#> Rows: 6
#> Columns: 13
#> $ result_id <int> 1, 1, 1, 1, 1, 1
#> $ cdm_name <chr> "Synthea synthetic health database", "Synthea synthet
#> $ cdm_name <chr> "An OMOP CDM database", "An OMOP CDM database", "An O
#> $ group_name <chr> "codelist_name", "codelist_name", "codelist_name", "c…
#> $ group_level <chr> "asthma", "asthma", "asthma", "asthma", "asthma", "as…
#> $ strata_name <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name <chr> "overall", "Childhood asthma", "Asthma", "overall", "…
#> $ variable_level <chr> NA, "4051466", "317009", NA, "317009", "4051466"
#> $ variable_name <chr> "overall", "Asthma", "Childhood asthma", "overall", "…
#> $ variable_level <chr> NA, "317009", "4051466", NA, "4051466", "317009"
#> $ estimate_name <chr> "record_count", "record_count", "record_count", "pers…
#> $ estimate_type <chr> "integer", "integer", "integer", "integer", "integer"…
#> $ estimate_value <chr> "101", "96", "5", "101", "5", "96"
#> $ additional_name <chr> "overall", "source_concept_name &&& source_concept_id…
#> $ additional_level <chr> "overall", "Childhood asthma &&& 4051466 &&& conditio
#> $ estimate_value <chr> "101", "5", "96", "101", "96", "5"
#> $ additional_name <chr> "source_concept_name &&& source_concept_id &&& source
#> $ additional_level <chr> "NA &&& NA &&& NA &&& NA", "Asthma &&& 317009 &&& 195
```
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## R CMD check results

This is a patch release for a breaking change in a dependency.
This is a new release.
6 changes: 3 additions & 3 deletions extras/precomputeVignetteData.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ db <- dbConnect(RPostgres::Postgres(),
vocabularyDatabaseSchema <- Sys.getenv("DB_VOCAB_SCHEMA")

# create cdm reference
cdm <- CDMConnector::cdm_from_con(con = db,
cdm_schema = vocabularyDatabaseSchema,
write_schema = "results")
cdm <- CDMConnector::cdmFromCon(con = db,
cdmSchema = vocabularyDatabaseSchema,
writeSchema = "results")

# intro vignette ----
vocabVersion <- getVocabVersion(cdm = cdm)
Expand Down
2 changes: 1 addition & 1 deletion man/getMappings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/summariseAchillesCodeUse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/summariseCodeUse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 95b555e

Please sign in to comment.