diff --git a/.Rbuildignore b/.Rbuildignore index 531ef051..8b3a68f1 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,4 @@ ^LICENSE ^extras$ ^cran-comments\.md$ +^data-raw$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 00000000..0f2fe080 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,52 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/r-cmd-check-ubuntu.yaml b/.github/workflows/r-cmd-check-ubuntu.yaml deleted file mode 100644 index f30453c1..00000000 --- a/.github/workflows/r-cmd-check-ubuntu.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [main, develop] - pull_request: - branches: [main, develop] - -name: R-CMD-check - -jobs: - R-CMD-check: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - steps: - - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - - uses: r-lib/actions/check-r-package@v2 diff --git a/R/codesFromConceptSet.R b/R/codesFromConceptSet.R index 092794c5..b4f24239 100644 --- a/R/codesFromConceptSet.R +++ b/R/codesFromConceptSet.R @@ -76,7 +76,19 @@ codesFromConceptSet <- function(path, cdm, withConceptDetails = FALSE) { } # second part: produce output list - conceptFinalList <- formatConceptList(conceptList, cdm) + if(nrow(conceptList) == 0){ + cli::cli_abort("No concepts found in concept set") + } + + conceptListTable <- omopgenerics::uniqueTableName() + cdm <- omopgenerics::insertTable(cdm = cdm, + name = conceptListTable, + table = conceptList, + overwrite = TRUE, + temporary = FALSE) + + conceptFinalList <- formatConceptList(cdm = cdm, + conceptListTable = conceptListTable) if(isTRUE(withConceptDetails)){ conceptFinalList <- addDetails(conceptList = conceptFinalList, @@ -113,8 +125,21 @@ codesFromCohort <- function(path, cdm, withConceptDetails = FALSE) { dplyr::union_all(extractCodes(files[k], unknown)) } + codelistTable <- omopgenerics::uniqueTableName() + cdm <- omopgenerics::insertTable(cdm = cdm, + name = codelistTable, + table = codelistTibble, + overwrite = TRUE, + temporary = FALSE) + # obtain descendants - codelistTibble <- appendDescendants(codelistTibble, cdm) + codelistTibble <- appendDescendants(cdm, codelistTable) |> + dplyr::collect(name = codelistTable, + overwrite = TRUE, + temporary = FALSE) + + CDMConnector::dropTable(cdm = cdm, name = codelistTable) + cdm[[codelistTable]] <- NULL # exclude codelistTibble <- excludeCodes(codelistTibble) @@ -188,26 +213,26 @@ extractCodes <- function(file, unknown) { return(codelistTibble) } -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)) %>% +appendDescendants <- function(cdm, codelistTable) { + + cdm[[codelistTable]] %>% + dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>% + dplyr::filter(.data$include_descendants == TRUE) %>% + dplyr::rename("ancestor_concept_id" = "concept_id") %>% dplyr::inner_join( - 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", - copy = TRUE + cdm[["concept_ancestor"]] %>% + dplyr::select("ancestor_concept_id", "descendant_concept_id") %>% + dplyr::mutate(ancestor_concept_id = as.integer(.data$ancestor_concept_id)), + by = "ancestor_concept_id" ) %>% - dplyr::collect() %>% dplyr::select(-"ancestor_concept_id") %>% dplyr::rename("concept_id" = "descendant_concept_id") %>% dplyr::union_all( - codelistTibble %>% - dplyr::filter(.data$include_descendants == FALSE) + cdm[[codelistTable]] %>% + dplyr::filter(.data$include_descendants == "FALSE") ) %>% dplyr::select(-"include_descendants") + } excludeCodes <- function(codelistTibble) { @@ -270,15 +295,21 @@ addDetails <- function(conceptList, cdm){ concept_set = names(conceptList)[i]) } conceptList <- dplyr::bind_rows(unclass(conceptList)) - } + } - conceptList <- conceptList %>% + tableConceptList <- omopgenerics::uniqueTableName() + cdm <- omopgenerics::insertTable(cdm = cdm, + table = conceptList, + name = tableConceptList, + overwrite = TRUE, + temporary = FALSE) + + conceptList <- cdm[[tableConceptList]] %>% dplyr::left_join(cdm[["concept"]] %>% dplyr::select("concept_id", "concept_name", "domain_id", "vocabulary_id", "standard_concept"), - by = "concept_id", - copy = TRUE) %>% + by = "concept_id") %>% dplyr::mutate( standard_concept = ifelse(is.na(.data$standard_concept), "non-standard", .data$standard_concept @@ -293,7 +324,11 @@ addDetails <- function(conceptList, cdm){ standard_concept = ifelse(.data$standard_concept == "S", "standard", .data$standard_concept ) - ) + ) %>% + dplyr::collect() + + CDMConnector::dropTable(cdm = cdm, name = tableConceptList) + cdm[[tableConceptList]] <- NULL if(isFALSE(inputIsTbl)){ conceptList <- split( @@ -319,8 +354,8 @@ addDetails <- function(conceptList, cdm){ #' #' @return list of concept_ids and respective cohort_definition_ids of interest #' @noRd -formatConceptList <- function(conceptList, cdm) { - conceptList <- conceptList %>% +formatConceptList <- function(cdm, conceptListTable) { + conceptList <- cdm[[conceptListTable]] %>% dplyr::filter(.data$include_descendants == FALSE) %>% dplyr::union_all( cdm[["concept_ancestor"]] %>% @@ -330,32 +365,31 @@ formatConceptList <- function(conceptList, cdm) { ) %>% dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>% dplyr::inner_join( - conceptList %>% + cdm[[conceptListTable]] %>% dplyr::mutate(concept_id = as.integer(.data$concept_id)) %>% dplyr::filter(.data$include_descendants == TRUE), - copy = TRUE, by = "concept_id" ) %>% dplyr::select(-"concept_id") %>% - dplyr::rename("concept_id" = "descendant_concept_id") %>% - dplyr::collect() + dplyr::rename("concept_id" = "descendant_concept_id") ) %>% dplyr::select(-"include_descendants") %>% - dplyr::rename("drug_concept_id" = "concept_id") + dplyr::collect() # eliminate the ones that is_excluded = TRUE conceptList <- conceptList %>% dplyr::filter(.data$is_excluded == FALSE) %>% - dplyr::select("cohort_name", "drug_concept_id") %>% + dplyr::select("cohort_name", "concept_id") %>% dplyr::anti_join( conceptList %>% dplyr::filter(.data$is_excluded == TRUE), - by = c("cohort_name","drug_concept_id") + by = c("cohort_name","concept_id") ) + conceptFinalList <- list() for(n in conceptList[["cohort_name"]] %>% unique()) { conceptFinalList[[n]] <- conceptList %>% dplyr::filter(.data$cohort_name == n) %>% - dplyr::select("drug_concept_id") %>% + dplyr::select("concept_id") %>% dplyr::pull() } return(conceptFinalList) diff --git a/R/runSearch.R b/R/runSearch.R index 28abf7e5..67ad01b6 100644 --- a/R/runSearch.R +++ b/R/runSearch.R @@ -167,7 +167,7 @@ runSearch <- function(keywords, dplyr::select("concept_id") %>% dplyr::distinct() %>% dplyr::left_join(workingConcept, - by = "concept_id", copy = TRUE + by = "concept_id" ) candidateCodes <- dplyr::union_all( @@ -230,7 +230,7 @@ runSearch <- function(keywords, candidateCodes <- candidateCodes %>% dplyr::anti_join(excludeCodes %>% dplyr::select("concept_id"), - by = "concept_id", copy = TRUE + by = "concept_id" )|> dplyr::compute() } @@ -476,13 +476,13 @@ addAncestor <- function(workingCandidateCodes, dplyr::select("concept_id") %>% dplyr::rename("descendant_concept_id" = "concept_id") %>% dplyr::left_join(conceptAncestorDf, - by = "descendant_concept_id", copy = TRUE + by = "descendant_concept_id" ) %>% dplyr::filter(.data$min_levels_of_separation == "1") %>% dplyr::select("ancestor_concept_id") %>% dplyr::rename("concept_id" = "ancestor_concept_id") %>% dplyr::left_join(conceptDf, - by = "concept_id", copy = TRUE + by = "concept_id" ) # keep if not already in candidateCodes diff --git a/R/summariseCodeUse.R b/R/summariseCodeUse.R index c95fdad0..a8440f31 100644 --- a/R/summariseCodeUse.R +++ b/R/summariseCodeUse.R @@ -254,18 +254,39 @@ getCodeUse <- function(x, call = call) } - intermediateTable <- omopgenerics::uniqueTableName() - - codes <- dplyr::tibble(concept_id = x[[1]]) %>% + tableCodelist <- omopgenerics::uniqueTableName() + cdm <- omopgenerics::insertTable(cdm = cdm, + name = tableCodelist, + table = dplyr::tibble(concept_id = x[[1]]), + overwrite = TRUE, + temporary = FALSE) + cdm[[tableCodelist]] <- cdm[[tableCodelist]] %>% dplyr::left_join( cdm[["concept"]] %>% dplyr::select("concept_id", "domain_id"), - by = "concept_id", - copy = TRUE) + by = "concept_id") + - codes <- codes %>% addDomainInfo(cdm = cdm) + tableDomainsData <- omopgenerics::uniqueTableName() + cdm <- omopgenerics::insertTable(cdm = cdm, + name = tableDomainsData, + table = conceptDomainsData, + overwrite = TRUE, + temporary = FALSE) - records <- getRelevantRecords(codes = codes, - cdm = cdm, + cdm[[tableCodelist]] <- cdm[[tableCodelist]] %>% + dplyr::mutate(domain_id = tolower(.data$domain_id)) |> + dplyr::left_join(cdm[[tableDomainsData]], + by = "domain_id") |> + dplyr::compute(name = tableCodelist, + temporary = FALSE, + overwrite = TRUE) + + CDMConnector::dropTable(cdm = cdm, name = tableDomainsData) + cdm[[tableDomainsData]] <- NULL + + intermediateTable <- omopgenerics::uniqueTableName() + records <- getRelevantRecords(cdm = cdm, + tableCodelist = tableCodelist, cohortTable = cohortTable, cohortId = cohortId, timing = timing, @@ -332,82 +353,84 @@ getCodeUse <- function(x, return(codeCounts) } - -addDomainInfo <- function(codes, - cdm) { - - codes <- codes %>% - dplyr::mutate(domain_id = tolower(.data$domain_id)) %>% - dplyr::mutate(table_name = - dplyr::case_when( - stringr::str_detect(domain_id,"condition") ~ "condition_occurrence", - stringr::str_detect(domain_id,"drug") ~ "drug_exposure", - stringr::str_detect(domain_id,"observation") ~ "observation", - stringr::str_detect(domain_id,"measurement") ~ "measurement", - stringr::str_detect(domain_id,"visit") ~ "visit_occurrence", - stringr::str_detect(domain_id,"procedure") ~ "procedure_occurrence", - stringr::str_detect(domain_id,"device") ~ "device_exposure" - ) - ) %>% - dplyr::mutate(standard_concept_id_name = - dplyr::case_when( - stringr::str_detect(domain_id,"condition") ~ "condition_concept_id", - stringr::str_detect(domain_id,"drug") ~ "drug_concept_id", - stringr::str_detect(domain_id,"observation") ~ "observation_concept_id", - stringr::str_detect(domain_id,"measurement") ~ "measurement_concept_id", - stringr::str_detect(domain_id,"visit") ~ "visit_concept_id", - stringr::str_detect(domain_id,"procedure") ~ "procedure_concept_id", - stringr::str_detect(domain_id,"device") ~ "device_concept_id" - ) - ) %>% - dplyr::mutate(source_concept_id_name = - dplyr::case_when( - stringr::str_detect(domain_id,"condition") ~ "condition_source_concept_id", - stringr::str_detect(domain_id,"drug") ~ "drug_source_concept_id", - stringr::str_detect(domain_id,"observation") ~ "observation_source_concept_id", - stringr::str_detect(domain_id,"measurement") ~ "measurement_source_concept_id", - stringr::str_detect(domain_id,"visit") ~ "visit_source_concept_id", - stringr::str_detect(domain_id,"procedure") ~ "procedure_source_concept_id", - stringr::str_detect(domain_id,"device") ~ "device_source_concept_id" - ) - ) %>% - dplyr::mutate(date_name = - dplyr::case_when( - stringr::str_detect(domain_id,"condition") ~ "condition_start_date", - stringr::str_detect(domain_id,"drug") ~ "drug_exposure_start_date", - stringr::str_detect(domain_id,"observation") ~ "observation_date", - stringr::str_detect(domain_id,"measurement") ~ "measurement_date", - stringr::str_detect(domain_id,"visit") ~ "visit_start_date", - stringr::str_detect(domain_id,"procedure") ~ "procedure_date", - stringr::str_detect(domain_id,"device") ~ "device_exposure_start_date" - ) - ) - - unsupported_domains <- codes %>% - dplyr::filter(!is.na(.data$domain_id)) %>% - dplyr::filter(is.na(.data$table_name)) %>% - dplyr::pull("domain_id") - - if(length(unsupported_domains)>0){ - cli::cli_warn("Concepts included from non-supported domains - ({unsupported_domains})") - } - - return(codes) - -} +# +# addDomainInfo <- function(codes, +# cdm) { +# +# codes <- codes %>% +# dplyr::mutate(domain_id = tolower(.data$domain_id)) %>% +# dplyr::mutate(table_name = +# dplyr::case_when( +# stringr::str_detect(domain_id,"condition") ~ "condition_occurrence", +# stringr::str_detect(domain_id,"drug") ~ "drug_exposure", +# stringr::str_detect(domain_id,"observation") ~ "observation", +# stringr::str_detect(domain_id,"measurement") ~ "measurement", +# stringr::str_detect(domain_id,"visit") ~ "visit_occurrence", +# stringr::str_detect(domain_id,"procedure") ~ "procedure_occurrence", +# stringr::str_detect(domain_id,"device") ~ "device_exposure" +# ) +# ) %>% +# dplyr::mutate(standard_concept_id_name = +# dplyr::case_when( +# stringr::str_detect(domain_id,"condition") ~ "condition_concept_id", +# stringr::str_detect(domain_id,"drug") ~ "drug_concept_id", +# stringr::str_detect(domain_id,"observation") ~ "observation_concept_id", +# stringr::str_detect(domain_id,"measurement") ~ "measurement_concept_id", +# stringr::str_detect(domain_id,"visit") ~ "visit_concept_id", +# stringr::str_detect(domain_id,"procedure") ~ "procedure_concept_id", +# stringr::str_detect(domain_id,"device") ~ "device_concept_id" +# ) +# ) %>% +# dplyr::mutate(source_concept_id_name = +# dplyr::case_when( +# stringr::str_detect(domain_id,"condition") ~ "condition_source_concept_id", +# stringr::str_detect(domain_id,"drug") ~ "drug_source_concept_id", +# stringr::str_detect(domain_id,"observation") ~ "observation_source_concept_id", +# stringr::str_detect(domain_id,"measurement") ~ "measurement_source_concept_id", +# stringr::str_detect(domain_id,"visit") ~ "visit_source_concept_id", +# stringr::str_detect(domain_id,"procedure") ~ "procedure_source_concept_id", +# stringr::str_detect(domain_id,"device") ~ "device_source_concept_id" +# ) +# ) %>% +# dplyr::mutate(date_name = +# dplyr::case_when( +# stringr::str_detect(domain_id,"condition") ~ "condition_start_date", +# stringr::str_detect(domain_id,"drug") ~ "drug_exposure_start_date", +# stringr::str_detect(domain_id,"observation") ~ "observation_date", +# stringr::str_detect(domain_id,"measurement") ~ "measurement_date", +# stringr::str_detect(domain_id,"visit") ~ "visit_start_date", +# stringr::str_detect(domain_id,"procedure") ~ "procedure_date", +# stringr::str_detect(domain_id,"device") ~ "device_exposure_start_date" +# ) +# ) +# +# unsupported_domains <- codes %>% +# dplyr::filter(!is.na(.data$domain_id)) %>% +# dplyr::filter(is.na(.data$table_name)) %>% +# dplyr::pull("domain_id") +# +# if(length(unsupported_domains)>0){ +# cli::cli_warn("Concepts included from non-supported domains +# ({unsupported_domains})") +# } +# +# return(codes) +# +# } -getRelevantRecords <- function(codes, - cdm, +getRelevantRecords <- function(cdm, + tableCodelist, cohortTable, cohortId, timing, intermediateTable){ - tableName <- purrr::discard(unique(codes$table_name), is.na) - standardConceptIdName <- purrr::discard(unique(codes$standard_concept_id_name), is.na) - sourceConceptIdName <- purrr::discard(unique(codes$source_concept_id_name), is.na) + codes <- cdm[[tableCodelist]] |> dplyr::collect() + + tableName <- purrr::discard(unique(codes$table), is.na) + standardConceptIdName <- purrr::discard(unique(codes$standard_concept), is.na) + sourceConceptIdName <- purrr::discard(unique(codes$source_concept), is.na) dateName <- purrr::discard(unique(codes$date_name), is.na) if(!is.null(cohortTable)){ @@ -452,7 +475,7 @@ getRelevantRecords <- function(codes, dplyr::rename("standard_concept_id" = .env$standardConceptIdName[[1]], "source_concept_id" = .env$sourceConceptIdName[[1]]) %>% dplyr::inner_join(codes %>% - dplyr::filter(.data$table_name == tableName[[1]]) %>% + dplyr::filter(.data$table == !!tableName[[1]]) %>% dplyr::select("concept_id", "domain_id"), by = c("standard_concept_id"="concept_id"), copy = TRUE) %>% @@ -491,7 +514,7 @@ getRelevantRecords <- function(codes, dplyr::rename("standard_concept_id" = .env$standardConceptIdName[[i+1]], "source_concept_id" = .env$sourceConceptIdName[[i+1]]) %>% dplyr::inner_join(codes %>% - dplyr::filter(.data$table_name == tableName[[i+1]]) %>% + dplyr::filter(.data$table == tableName[[i+1]]) %>% dplyr::select("concept_id", "domain_id"), by = c("standard_concept_id"="concept_id"), copy = TRUE) diff --git a/R/sysdata.rda b/R/sysdata.rda new file mode 100644 index 00000000..6a45e415 Binary files /dev/null and b/R/sysdata.rda differ diff --git a/README.Rmd b/README.Rmd index 4e78c14a..5c1a6f59 100644 --- a/README.Rmd +++ b/README.Rmd @@ -22,6 +22,7 @@ knitr::opts_chunk$set( [![codecov.io](https://codecov.io/github/darwin-eu/CodelistGenerator/coverage.svg?branch=main)](https://app.codecov.io/github/darwin-eu/CodelistGenerator?branch=main) [![R-CMD-check](https://github.com/darwin-eu/CodelistGenerator/workflows/R-CMD-check/badge.svg)](https://github.com/darwin-eu/CodelistGenerator/actions) [![Lifecycle:Stable](https://img.shields.io/badge/Lifecycle-Stable-97ca00)](https://lifecycle.r-lib.org/articles/stages.html) +[![R-CMD-check](https://github.com/darwin-eu/CodelistGenerator/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/darwin-eu/CodelistGenerator/actions/workflows/R-CMD-check.yaml) ## Installation diff --git a/data-raw/conceptDomainsData.R b/data-raw/conceptDomainsData.R new file mode 100644 index 00000000..e1fdf1a6 --- /dev/null +++ b/data-raw/conceptDomainsData.R @@ -0,0 +1,52 @@ + +conceptDomainsData <- dplyr::tibble(domain_id = c("drug","condition", + "procedure", "observation", + "measurement", "visit", + "device")) %>% + dplyr::mutate(table = + dplyr::case_when( + stringr::str_detect(domain_id,"condition") ~ "condition_occurrence", + stringr::str_detect(domain_id,"drug") ~ "drug_exposure", + stringr::str_detect(domain_id,"observation") ~ "observation", + stringr::str_detect(domain_id,"measurement") ~ "measurement", + stringr::str_detect(domain_id,"visit") ~ "visit_occurrence", + stringr::str_detect(domain_id,"procedure") ~ "procedure_occurrence", + stringr::str_detect(domain_id,"device") ~ "device_exposure" + ) + ) %>% + dplyr::mutate(standard_concept = + dplyr::case_when( + stringr::str_detect(domain_id,"condition") ~ "condition_concept_id", + stringr::str_detect(domain_id,"drug") ~ "drug_concept_id", + stringr::str_detect(domain_id,"observation") ~ "observation_concept_id", + stringr::str_detect(domain_id,"measurement") ~ "measurement_concept_id", + stringr::str_detect(domain_id,"visit") ~ "visit_concept_id", + stringr::str_detect(domain_id,"procedure") ~ "procedure_concept_id", + stringr::str_detect(domain_id,"device") ~ "device_concept_id" + ) + ) %>% + dplyr::mutate(source_concept = + dplyr::case_when( + stringr::str_detect(domain_id,"condition") ~ "condition_source_concept_id", + stringr::str_detect(domain_id,"drug") ~ "drug_source_concept_id", + stringr::str_detect(domain_id,"observation") ~ "observation_source_concept_id", + stringr::str_detect(domain_id,"measurement") ~ "measurement_source_concept_id", + stringr::str_detect(domain_id,"visit") ~ "visit_source_concept_id", + stringr::str_detect(domain_id,"procedure") ~ "procedure_source_concept_id", + stringr::str_detect(domain_id,"device") ~ "device_source_concept_id" + ) + ) %>% + dplyr::mutate(date_name = + dplyr::case_when( + stringr::str_detect(domain_id,"condition") ~ "condition_start_date", + stringr::str_detect(domain_id,"drug") ~ "drug_exposure_start_date", + stringr::str_detect(domain_id,"observation") ~ "observation_date", + stringr::str_detect(domain_id,"measurement") ~ "measurement_date", + stringr::str_detect(domain_id,"visit") ~ "visit_start_date", + stringr::str_detect(domain_id,"procedure") ~ "procedure_date", + stringr::str_detect(domain_id,"device") ~ "device_exposure_start_date" + ) + ) + +usethis::use_data(conceptDomainsData, overwrite = TRUE, internal = TRUE) + diff --git a/man/CodelistGenerator-package.Rd b/man/CodelistGenerator-package.Rd index 23678775..861600be 100644 --- a/man/CodelistGenerator-package.Rd +++ b/man/CodelistGenerator-package.Rd @@ -21,7 +21,7 @@ Useful links: Other contributors: \itemize{ \item Marti Catala \email{marti.catalasabate@ndorms.ox.ac.uk} (\href{https://orcid.org/0000-0003-3308-9905}{ORCID}) [contributor] - \item Xihang Chen \email{xihang.chen@ndorms.ox.ac.uk} (\href{https://orcid.org/0009-0001-8112-8959}{ORCID}) [contributor] + \item Xihang Chen \email{xihang.chen@ndorms.ox.ac.uk} (\href{https://orcid.org/0009-0001-8112-8959}{ORCID}) [contributor] } } diff --git a/tests/testthat/test-codesFrom.R b/tests/testthat/test-codesFrom.R index d6eacc6b..53d253db 100644 --- a/tests/testthat/test-codesFrom.R +++ b/tests/testthat/test-codesFrom.R @@ -23,7 +23,7 @@ test_that("test inputs - mock", { "concepts_for_mock") )) # codesFromConceptSet won´t work with cohorts - expect_error( codesFromConceptSet( + expect_error(codesFromConceptSet( cdm = cdm, path = system.file(package = "CodelistGenerator", "cohorts_for_mock") )) diff --git a/tests/testthat/test-dbms.R b/tests/testthat/test-dbms.R index 9aba8b1e..33da1f8f 100644 --- a/tests/testthat/test-dbms.R +++ b/tests/testthat/test-dbms.R @@ -210,7 +210,7 @@ test_that("snowflake", { dplyr::mutate(stratum_2 = NA, stratum_3 = NA, analysis_id = 400) %>% - CDMConnector::computeQuery() + dplyr::compute() asthma <- list(asthma = c(317009, 257581)) result_achilles <- summariseAchillesCodeUse(asthma,