Skip to content

Commit 95b555e

Browse files
committed
v3.3.2
1 parent 5b8db0b commit 95b555e

41 files changed

Lines changed: 218 additions & 167 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: CodelistGenerator
22
Title: Identify Relevant Clinical Codes and Evaluate Their Use
3-
Version: 3.3.1
3+
Version: 3.3.2
44
Authors@R: c(
55
person("Edward", "Burn", email = "edward.burn@ndorms.ox.ac.uk",
66
role = c("aut", "cre"),
@@ -25,28 +25,29 @@ Encoding: UTF-8
2525
Roxygen: list(markdown = TRUE)
2626
RoxygenNote: 7.3.2
2727
Depends:
28-
R (>= 3.5.0)
28+
R (>= 4.1)
2929
Imports:
3030
checkmate (>= 2.0.0),
3131
DBI (>= 1.1.0),
3232
dplyr (>= 1.1.0),
33-
omopgenerics (>= 0.4.0),
33+
omopgenerics (>= 0.4.1),
3434
rlang (>= 1.0.0),
3535
glue (>= 1.5.0),
3636
stringr (>= 1.4.0),
37+
stringi (>= 1.8.1),
3738
tidyselect (>= 1.2.0),
3839
tidyr (>= 1.2.0),
3940
cli (>= 3.1.0),
4041
purrr,
4142
lubridate,
42-
PatientProfiles (>= 1.1.0),
43+
PatientProfiles (>= 1.2.3),
4344
vctrs,
44-
visOmopResults (>= 0.5.0),
4545
RJSONIO
4646
Suggests:
4747
covr,
4848
duckdb,
49-
CDMConnector (>= 1.3.0),
49+
CDMConnector (>= 1.7.0),
50+
visOmopResults (>= 1.0.0),
5051
knitr,
5152
rmarkdown,
5253
testthat (>= 3.0.0),

R/getMappings.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' Show mappings from non-standard vocabularies to standard
1919
#'
2020
#' @param candidateCodelist Dataframe
21-
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
21+
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
2222
#' @param nonStandardVocabularies Character vector
2323
#'
2424
#' @return tibble

R/runSearch.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ tidyWords <- function(words) {
391391
Encoding(words) <- "latin1"
392392

393393
# some generic formatting
394+
workingWords <- stringi::stri_trans_nfkc(words)
394395
workingWords <- trimws(words)
395396
workingWords <- stringr::str_replace_all(workingWords, "-", " ")
396397
workingWords <- stringr::str_replace_all(workingWords, "[[:punct:]]", "")

R/summariseAchillesCodeUse.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Summarise code use from achilles counts
22
#'
33
#' @param x Codelist
4-
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
4+
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
55
#' @param countBy Either "record" for record-level counts or "person" for
66
#' person-level counts
77
#'
@@ -113,8 +113,8 @@ summariseAchillesCodeUse <- function(x,
113113
estimate_type = "integer",
114114
estimate_value = as.character(.data$n)
115115
) |>
116-
visOmopResults::uniteAdditional(cols = c("standard_concept", "vocabulary_id")) |>
117-
visOmopResults::uniteStrata(cols = c("domain_id")) |>
116+
omopgenerics::uniteAdditional(cols = c("standard_concept", "vocabulary_id")) |>
117+
omopgenerics::uniteStrata(cols = c("domain_id")) |>
118118
dplyr::select(dplyr::any_of(omopgenerics::resultColumns("summarised_result")))
119119

120120
codeUse <- codeUse |>

R/summariseCodeUse.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#' Summarise code use in patient-level data
1818
#'
1919
#' @param x List of concept IDs
20-
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
20+
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
2121
#' @param countBy Either "record" for record-level counts or "person" for
2222
#' person-level counts
2323
#' @param byConcept TRUE or FALSE. If TRUE code use will be summarised by
@@ -32,10 +32,10 @@
3232
#' @examples
3333
#' \dontrun{
3434
#' con <- DBI::dbConnect(duckdb::duckdb(),
35-
#' dbdir = CDMConnector::eunomia_dir())
36-
#' cdm <- CDMConnector::cdm_from_con(con,
37-
#' cdm_schem = "main",
38-
#' write_schema = "main")
35+
#' dbdir = CDMConnector::eunomiaDir())
36+
#' cdm <- CDMConnector::cdmFromCon(con,
37+
#' cdmSchema = "main",
38+
#' writeSchema = "main")
3939
#'acetiminophen <- c(1125315, 1127433, 40229134,
4040
#'40231925, 40162522, 19133768, 1127078)
4141
#'poliovirus_vaccine <- c(40213160)
@@ -101,7 +101,7 @@ summariseCodeUse <- function(x,
101101
#' Summarise code use among a cohort in the cdm reference
102102
#'
103103
#' @param x Vector of concept IDs
104-
#' @param cdm cdm_reference via CDMConnector::cdm_from_con()
104+
#' @param cdm cdm_reference via CDMConnector::cdmFromCon()
105105
#' @param cohortTable A cohort table from the cdm reference.
106106
#' @param cohortId A vector of cohort IDs to include
107107
#' @param timing When to assess the code use relative cohort dates. This can
@@ -121,10 +121,10 @@ summariseCodeUse <- function(x,
121121
#' @examples
122122
#' \dontrun{
123123
#' con <- DBI::dbConnect(duckdb::duckdb(),
124-
#' dbdir = CDMConnector::eunomia_dir())
125-
#' cdm <- CDMConnector::cdm_from_con(con,
126-
#' cdm_schem = "main",
127-
#' write_schema = "main")
124+
#' dbdir = CDMConnector::eunomiaDir())
125+
#' cdm <- CDMConnector::cdmFromCon(con,
126+
#' cdmSchema = "main",
127+
#' writeSchema = "main")
128128
#' cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
129129
#' conceptSet = list(a = 260139,
130130
#' b = 1127433),
@@ -203,7 +203,7 @@ summariseCohortCodeUse <- function(x,
203203
)
204204
)
205205
} else {
206-
codeUse <- omopgenerics::emptySummarisedResult()
206+
cohortCodeUse <- omopgenerics::emptySummarisedResult()
207207
}
208208

209209
return(cohortCodeUse)
@@ -321,8 +321,8 @@ getCodeUse <- function(x,
321321
"variable_name" = dplyr::if_else(is.na(.data$standard_concept_name), "overall", .data$standard_concept_name),
322322
"variable_level" = as.character(.data$standard_concept_id)
323323
) |>
324-
visOmopResults::uniteGroup(cols = c("cohort_name", "codelist_name")) |>
325-
visOmopResults::uniteAdditional(
324+
omopgenerics::uniteGroup(cols = c("cohort_name", "codelist_name")) |>
325+
omopgenerics::uniteAdditional(
326326
cols = c("source_concept_name", "source_concept_id",
327327
"source_concept_value", "domain_id"),
328328
ignore = "overall"
@@ -334,7 +334,7 @@ getCodeUse <- function(x,
334334
)
335335

336336
} else {
337-
codeCounts <- dplyr::tibble()
337+
codeCounts <- omopgenerics::emptySummarisedResult()
338338
cli::cli_inform(c(
339339
"i" = "No records found in the cdm for the concepts provided."
340340
))
@@ -715,7 +715,7 @@ getGroupedRecordCount <- function(records,
715715
dplyr::mutate(estimate_value = as.character(.data$estimate_value)) |>
716716
dplyr::collect()
717717
) |>
718-
visOmopResults::uniteStrata(cols = groupBy) |>
718+
omopgenerics::uniteStrata(cols = groupBy) |>
719719
dplyr::mutate(estimate_name = "record_count")
720720

721721
return(groupedCounts)
@@ -749,7 +749,7 @@ getGroupedPersonCount <- function(records,
749749
dplyr::tally(name = "estimate_value") |>
750750
dplyr::mutate(estimate_value = as.character(.data$estimate_value)) |>
751751
dplyr::collect()) |>
752-
visOmopResults::uniteStrata(cols = groupBy) |>
752+
omopgenerics::uniteStrata(cols = groupBy) |>
753753
dplyr::mutate(estimate_name = "person_count")
754754

755755
return(groupedCounts)

R/tableAchillesCodeUse.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ tableAchillesCodeUse <- function(result,
4343
hide = character(),
4444
.options = list()) {
4545

46+
rlang::check_installed("visOmopResults", version = "1.0.0")
47+
4648
# checks
4749
if(nrow(result) == 0){
4850
cli::cli_warn("`result` object is empty")
@@ -122,6 +124,8 @@ tableOrphanCodes <- function(result,
122124
hide = character(),
123125
.options = list()) {
124126

127+
rlang::check_installed("visOmopResults", version = "1.0.0")
128+
125129
if(nrow(result) == 0){
126130
cli::cli_warn("`result` object is empty")
127131
return(emptyResultTable(type = type))

R/tableCodeUse.R

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
#' @examples
3232
#' \dontrun{
3333
#' con <- DBI::dbConnect(duckdb::duckdb(),
34-
#' dbdir = CDMConnector::eunomia_dir())
35-
#' cdm <- CDMConnector::cdm_from_con(con,
36-
#' cdm_schem = "main",
37-
#' write_schema = "main")
34+
#' dbdir = CDMConnector::eunomiaDir())
35+
#' cdm <- CDMConnector::cdmFromCon(con,
36+
#' cdmSchema = "main",
37+
#' writeSchema = "main")
3838
#'acetiminophen <- c(1125315, 1127433, 40229134,
3939
#'40231925, 40162522, 19133768, 1127078)
4040
#'poliovirus_vaccine <- c(40213160)
@@ -53,6 +53,8 @@ tableCodeUse <- function(result,
5353
hide = character(),
5454
.options = list()) {
5555

56+
rlang::check_installed("visOmopResults", version = "1.0.0")
57+
5658
# checks
5759
if(nrow(result) == 0){
5860
cli::cli_warn("`result` object is empty")
@@ -116,10 +118,10 @@ tableCodeUse <- function(result,
116118
#' @examples
117119
#' \dontrun{
118120
#' con <- DBI::dbConnect(duckdb::duckdb(),
119-
#' dbdir = CDMConnector::eunomia_dir())
120-
#' cdm <- CDMConnector::cdm_from_con(con,
121-
#' cdm_schem = "main",
122-
#' write_schema = "main")
121+
#' dbdir = CDMConnector::eunomiaDir())
122+
#' cdm <- CDMConnector::cdmFromCon(con,
123+
#' cdmSchema = "main",
124+
#' writeSchema = "main")
123125
#' cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
124126
#' conceptSet = list(a = 260139,
125127
#' b = 1127433),
@@ -145,6 +147,8 @@ tableCohortCodeUse <- function(result,
145147
hide = character(),
146148
.options = list()) {
147149

150+
rlang::check_installed("visOmopResults", version = "1.0.0")
151+
148152
# checks
149153
if(nrow(result) == 0){
150154
cli::cli_warn("`result` object is empty")
@@ -191,9 +195,9 @@ internalTableCodeUse <- function(result,
191195
.options <- optionsCodeUse(.options)
192196

193197
if (timing) {
194-
settingsColumns <- "timing"
198+
settingsColumn <- "timing"
195199
} else {
196-
settingsColumns <- character()
200+
settingsColumn <- character()
197201
}
198202

199203
x <- result |>
@@ -211,7 +215,7 @@ internalTableCodeUse <- function(result,
211215
header = header,
212216
groupColumn = groupColumn,
213217
type = type,
214-
settingsColumns = settingsColumns,
218+
settingsColumn = settingsColumn,
215219
rename = c(
216220
"Domain ID" = "domain_id", "Database name" = "cdm_name",
217221
"Standard concept ID" = "standard_concept_id",

R/tableUnmappedCodes.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ tableUnmappedCodes <- function(result,
3434
groupColumn = character(),
3535
hide = character(),
3636
.options = list()) {
37+
38+
rlang::check_installed("visOmopResults", version = "1.0.0")
39+
3740
# checks
3841
if(nrow(result) == 0){
3942
cli::cli_warn("`result` object is empty")

README.Rmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ library(CodelistGenerator)
4444

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

5154
## Exploring the OMOP CDM Vocabulary tables

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ For this example we’ll use the Eunomia dataset (which only contains a
3939
subset of the OMOP CDM vocabularies)
4040

4141
``` r
42-
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
43-
cdm <- cdm_from_con(db, cdm_schema = "main", write_schema = c(prefix = "cg_", schema = "main"))
42+
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
43+
cdm <- cdmFromCon(db,
44+
cdmSchema = "main",
45+
writeSchema = "main",
46+
writePrefix = "cg_")
4447
```
4548

4649
## Exploring the OMOP CDM Vocabulary tables
@@ -186,16 +189,16 @@ summariseCodeUse(list("asthma" = asthma_codes1$concept_id),
186189
#> Rows: 6
187190
#> Columns: 13
188191
#> $ result_id <int> 1, 1, 1, 1, 1, 1
189-
#> $ cdm_name <chr> "Synthea synthetic health database", "Synthea synthet
192+
#> $ cdm_name <chr> "An OMOP CDM database", "An OMOP CDM database", "An O
190193
#> $ group_name <chr> "codelist_name", "codelist_name", "codelist_name", "c…
191194
#> $ group_level <chr> "asthma", "asthma", "asthma", "asthma", "asthma", "as…
192195
#> $ strata_name <chr> "overall", "overall", "overall", "overall", "overall"…
193196
#> $ strata_level <chr> "overall", "overall", "overall", "overall", "overall"…
194-
#> $ variable_name <chr> "overall", "Childhood asthma", "Asthma", "overall", "…
195-
#> $ variable_level <chr> NA, "4051466", "317009", NA, "317009", "4051466"
197+
#> $ variable_name <chr> "overall", "Asthma", "Childhood asthma", "overall", "…
198+
#> $ variable_level <chr> NA, "317009", "4051466", NA, "4051466", "317009"
196199
#> $ estimate_name <chr> "record_count", "record_count", "record_count", "pers…
197200
#> $ estimate_type <chr> "integer", "integer", "integer", "integer", "integer"…
198-
#> $ estimate_value <chr> "101", "96", "5", "101", "5", "96"
199-
#> $ additional_name <chr> "overall", "source_concept_name &&& source_concept_id…
200-
#> $ additional_level <chr> "overall", "Childhood asthma &&& 4051466 &&& conditio
201+
#> $ estimate_value <chr> "101", "5", "96", "101", "96", "5"
202+
#> $ additional_name <chr> "source_concept_name &&& source_concept_id &&& source
203+
#> $ additional_level <chr> "NA &&& NA &&& NA &&& NA", "Asthma &&& 317009 &&& 195
201204
```

0 commit comments

Comments
 (0)