From 9cd914a97f8e05390a163811b9856c34ade6cf0c Mon Sep 17 00:00:00 2001 From: Peter Dutey-Magni Date: Sun, 19 Nov 2023 11:31:33 +0000 Subject: [PATCH 1/5] upgrade to dbplyr 2.4.0 and change unit tests of remote tables for Ramses objects --- DESCRIPTION | 9 ++- NEWS.md | 9 +++ tests/testthat/test-objects.R | 144 +++++++++++++--------------------- 3 files changed, 69 insertions(+), 93 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1d6ef1d..7d81fa1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Ramses Type: Package Title: R Package for Antimicrobial Stewardship & Surveillance -Version: 0.7.0 +Version: 0.7.1 Authors@R: c( person(given = "Peter", family = "Dutey-Magni", @@ -31,7 +31,7 @@ Imports: DBI, rlang, dplyr (>= 1.1.0), - dbplyr (>= 2.3.2), + dbplyr (>= 2.4.0), tidyselect (>= 1.2.0), magrittr, duckdb (>= 0.4.0), @@ -59,11 +59,12 @@ Suggests: R.utils, comorbidity, RPostgres, - gh (>= 1.3.0) + gh (>= 1.3.0), + vctrs Remotes: ramses-antibiotics/snomedizer RdMacros: Rdpack -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.3 VignetteBuilder: knitr,rmarkdown Collate: 'Ramses-deprecated.R' diff --git a/NEWS.md b/NEWS.md index 1929f14..c8c6095 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,13 @@ +# Ramses 0.7.1 + +*19 November 2023* + +## Changed + +- Now requires minimum `dbplyr` v2.4.0. +- Unit test maintenance required by `dbplyr` v2.4.0. + # Ramses 0.7.0 *11 April 2023* diff --git a/tests/testthat/test-objects.R b/tests/testthat/test-objects.R index 8467bf7..877ba32 100644 --- a/tests/testthat/test-objects.R +++ b/tests/testthat/test-objects.R @@ -68,16 +68,14 @@ test_that("Patient..interface_methods DuckDB", { expect_equal(capture.output(patient_object)[1], "Patient 99999999999 ") # COMPUTE - expect_equal( - patient_object@record$lazy_query$x$x, - structure("patients", class = c("ident", "character")) - ) + expect_is(patient_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(patient_object@record$lazy_query$x$x, "table"), "patients") + patient_object_computed <- compute(patient_object) + expect_true( grepl("^dbplyr_", - as.character( - patient_object_computed@record$lazy_query$x - )) + vctrs::field(patient_object_computed@record$lazy_query$x, "table")) ) # COLLECT @@ -119,16 +117,14 @@ test_that("Patient..interface_methods Postgres", { expect_equal(capture.output(patient_object)[1], "Patient 99999999999 ") # COMPUTE - expect_equal( - patient_object@record$lazy_query$x$x, - structure("patients", class = c("ident", "character")) - ) + expect_is(patient_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(patient_object@record$lazy_query$x$x, "table"), "patients") + patient_object_computed <- compute(patient_object) + expect_true( grepl("^dbplyr_", - as.character( - patient_object_computed@record$lazy_query$x - )) + vctrs::field(patient_object_computed@record$lazy_query$x, "table")) ) # COLLECT @@ -278,16 +274,16 @@ test_that("MedicationRequest..interface_methods DuckDB", { ) # COMPUTE + expect_is(med_req_object@record$lazy_query$x$x, "dbplyr_table_ident") expect_equal( - med_req_object@record$lazy_query$x$x, - structure("drug_prescriptions", class = c("ident", "character")) + vctrs::field(med_req_object@record$lazy_query$x$x, "table"), + "drug_prescriptions" ) + med_req_object_computed <- compute(med_req_object) expect_true( grepl("^dbplyr_", - as.character( - med_req_object_computed@record$lazy_query$x - )) + vctrs::field(med_req_object_computed@record$lazy_query$x, "table")) ) # COLLECT @@ -381,16 +377,13 @@ test_that("MedicationRequest..interface_methods Postgres", { ) # COMPUTE - expect_equal( - med_req_object@record$lazy_query$x$x, - structure("drug_prescriptions", class = c("ident", "character")) - ) + expect_is(med_req_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(med_req_object@record$lazy_query$x$x, "table"), "drug_prescriptions") + med_req_object_computed <- compute(med_req_object) expect_true( grepl("^dbplyr_", - as.character( - med_req_object_computed@record$lazy_query$x - )) + vctrs::field(med_req_object_computed@record$lazy_query$x, "table")) ) # COLLECT @@ -533,38 +526,31 @@ test_that("TherapyEpisode..interface_methods DuckDB", { ) # COMPUTE - expect_equal( - therapy_object@record$lazy_query$x$x, - structure("drug_therapy_episodes", class = c("ident", "character")) - ) + expect_is(therapy_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(therapy_object@record$lazy_query$x$x, "table"), + "drug_therapy_episodes") therapy_object_computed <- compute(therapy_object) expect_true( grepl("^dbplyr_", - as.character( - therapy_object_computed@record$lazy_query$x - )) - ) - expect_equal( - therapy_object_multi@record$lazy_query$x$x, - structure("drug_therapy_episodes", class = c("ident", "character")) + vctrs::field(therapy_object_computed@record$lazy_query$x, "table")) ) + + expect_is(therapy_object_multi@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(therapy_object_multi@record$lazy_query$x$x, "table"), + "drug_therapy_episodes") therapy_object_multi_computed <- compute(therapy_object_multi) expect_true( grepl("^dbplyr_", - as.character( - therapy_object_multi_computed@record$lazy_query$x - )) - ) - expect_equal( - therapy_object_multi4@record$lazy_query$x$x, - structure("drug_therapy_episodes", class = c("ident", "character")) + vctrs::field(therapy_object_multi_computed@record$lazy_query$x, "table")) ) + + expect_is(therapy_object_multi4@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(therapy_object_multi4@record$lazy_query$x$x, "table"), + "drug_therapy_episodes") therapy_object_multi_computed4 <- compute(therapy_object_multi4) expect_true( grepl("^dbplyr_", - as.character( - therapy_object_multi_computed4@record$lazy_query$x - )) + vctrs::field(therapy_object_multi_computed4@record$lazy_query$x, "table")) ) # COLLECT @@ -699,38 +685,28 @@ test_that("TherapyEpisode..interface_methods Postgres", { ) # COMPUTE - expect_equal( - therapy_object@record$lazy_query$x$x, - structure("drug_therapy_episodes", class = c("ident", "character")) - ) + expect_is(therapy_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(therapy_object@record$lazy_query$x$x, "table"), "drug_therapy_episodes") therapy_object_computed <- compute(therapy_object) expect_true( grepl("^dbplyr_", - as.character( - therapy_object_computed@record$lazy_query$x - )) - ) - expect_equal( - therapy_object_multi@record$lazy_query$x$x, - structure("drug_therapy_episodes", class = c("ident", "character")) + vctrs::field(therapy_object_computed@record$lazy_query$x, "table")) ) + + expect_is(therapy_object_multi@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(therapy_object_multi@record$lazy_query$x$x, "table"), "drug_therapy_episodes") therapy_object_multi_computed <- compute(therapy_object_multi) expect_true( grepl("^dbplyr_", - as.character( - therapy_object_multi_computed@record$lazy_query$x - )) - ) - expect_equal( - therapy_object_multi4@record$lazy_query$x$x, - structure("drug_therapy_episodes", class = c("ident", "character")) + vctrs::field(therapy_object_multi_computed@record$lazy_query$x, "table")) ) + + expect_is(therapy_object_multi4@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(therapy_object_multi4@record$lazy_query$x$x, "table"), "drug_therapy_episodes") therapy_object_multi_computed4 <- compute(therapy_object_multi4) expect_true( grepl("^dbplyr_", - as.character( - therapy_object_multi_computed4@record$lazy_query$x - )) + vctrs::field(therapy_object_multi_computed4@record$lazy_query$x, "table")) ) # COLLECT @@ -898,38 +874,28 @@ test_that("Encounter..interface_methods DuckDB", { ) # COMPUTE - expect_equal( - encounter_object@record$lazy_query$x$x, - structure("inpatient_episodes", class = c("ident", "character")) - ) + expect_is(encounter_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(encounter_object@record$lazy_query$x$x, "table"), "inpatient_episodes") encounter_object_computed <- compute(encounter_object) expect_true( grepl("^dbplyr_", - as.character( - encounter_object_computed@record$lazy_query$x - )) - ) - expect_equal( - encounter_object_multi@record$lazy_query$x$x, - structure("inpatient_episodes", class = c("ident", "character")) + vctrs::field(encounter_object_computed@record$lazy_query$x, "table")) ) + + expect_is(encounter_object_multi@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(encounter_object_multi@record$lazy_query$x$x, "table"), "inpatient_episodes") encounter_object_multi_computed <- compute(encounter_object_multi) expect_true( grepl("^dbplyr_", - as.character( - encounter_object_multi_computed@record$lazy_query$x - )) - ) - expect_equal( - encounter_object_multi5@record$lazy_query$x$x, - structure("inpatient_episodes", class = c("ident", "character")) + vctrs::field(encounter_object_multi_computed@record$lazy_query$x, "table")) ) + + expect_is(encounter_object_multi5@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(encounter_object_multi5@record$lazy_query$x$x, "table"), "inpatient_episodes") encounter_object_multi5_computed <- compute(encounter_object_multi5) expect_true( grepl("^dbplyr_", - as.character( - encounter_object_multi5_computed@record$lazy_query$x - )) + vctrs::field(encounter_object_multi5_computed@record$lazy_query$x, "table")) ) # COLLECT From 6a2b3bfe25aad6819470310228ab79415b0966c5 Mon Sep 17 00:00:00 2001 From: Peter Dutey-Magni Date: Sun, 19 Nov 2023 11:44:33 +0000 Subject: [PATCH 2/5] Update NEWS --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index c8c6095..051678a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ - Now requires minimum `dbplyr` v2.4.0. - Unit test maintenance required by `dbplyr` v2.4.0. + # Ramses 0.7.0 *11 April 2023* From 0d54256042353d7a9fee43b4d4d177277673e37a Mon Sep 17 00:00:00 2001 From: Peter Dutey-Magni Date: Sun, 19 Nov 2023 12:39:14 +0000 Subject: [PATCH 3/5] finish correcting unit test --- tests/testthat/test-objects.R | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/tests/testthat/test-objects.R b/tests/testthat/test-objects.R index 877ba32..aef2cb2 100644 --- a/tests/testthat/test-objects.R +++ b/tests/testthat/test-objects.R @@ -1037,38 +1037,28 @@ test_that("Encounter..interface_methods Postgres", { ) # COMPUTE - expect_equal( - encounter_object@record$lazy_query$x$x, - structure("inpatient_episodes", class = c("ident", "character")) - ) + expect_is(encounter_object@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(encounter_object@record$lazy_query$x$x, "table"), "inpatient_episodes") encounter_object_computed <- compute(encounter_object) expect_true( grepl("^dbplyr_", - as.character( - encounter_object_computed@record$lazy_query$x - )) - ) - expect_equal( - encounter_object_multi@record$lazy_query$x$x, - structure("inpatient_episodes", class = c("ident", "character")) + vctrs::field(encounter_object_computed@record$lazy_query$x, "table")) ) + + expect_is(encounter_object_multi@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(encounter_object_multi@record$lazy_query$x$x, "table"), "inpatient_episodes") encounter_object_multi_computed <- compute(encounter_object_multi) expect_true( grepl("^dbplyr_", - as.character( - encounter_object_multi_computed@record$lazy_query$x - )) - ) - expect_equal( - encounter_object_multi5@record$lazy_query$x$x, - structure("inpatient_episodes", class = c("ident", "character")) + vctrs::field(encounter_object_multi_computed@record$lazy_query$x, "table")) ) + + expect_is(encounter_object_multi5@record$lazy_query$x$x, "dbplyr_table_ident") + expect_equal(vctrs::field(encounter_object_multi5@record$lazy_query$x$x, "table"), "inpatient_episodes") encounter_object_multi5_computed <- compute(encounter_object_multi5) expect_true( grepl("^dbplyr_", - as.character( - encounter_object_multi5_computed@record$lazy_query$x - )) + vctrs::field(encounter_object_multi5_computed@record$lazy_query$x, "table")) ) # COLLECT From 62f965744e2b9b6f9d66e452b3b8a8e85eb09652 Mon Sep 17 00:00:00 2001 From: Peter Dutey Date: Sun, 19 Nov 2023 15:25:19 +0000 Subject: [PATCH 4/5] refactor firebase deploy authentication --- .Rbuildignore | 1 + .firebaserc | 5 +++++ .github/workflows/R-CMD-check.yaml | 12 ++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .firebaserc diff --git a/.Rbuildignore b/.Rbuildignore index 4f4c124..5304a9c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,3 +17,4 @@ ^\.covrignore$ ^firebase\.json$ ^\.github$ +^\.firebaserc$ diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..93ac65d --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "ramses-antibiotics" + } +} diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 27baa78..ef4bcbb 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -107,13 +107,13 @@ jobs: - name: Deploy to Firebase if: github.ref == 'refs/heads/master' && github.event_name == 'push' && matrix.config.os == 'ubuntu-20.04' && matrix.config.r == 'release' - uses: w9jds/firebase-action@master + uses: FirebaseExtended/action-hosting-deploy@v0 with: - args: deploy --only hosting - env: - PROJECT_ID: ramses-antibiotics - FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} - + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_RAMSES_ANTIBIOTICS }}' + projectId: ramses-antibiotics + channelId: live + - uses: r-lib/actions/setup-tinytex@v2 if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') && github.event_name == 'push' && matrix.config.os == 'ubuntu-20.04' && matrix.config.r == 'release' From d13a573e004b0c986dbee653f186146e74370324 Mon Sep 17 00:00:00 2001 From: Peter Dutey-Magni Date: Sun, 11 Feb 2024 13:49:37 +0000 Subject: [PATCH 5/5] fix AMR deprecated as.rsi() --- DESCRIPTION | 6 +++--- NEWS.md | 12 ++++++++++++ R/validate_data.R | 2 +- man/validate_microbiology.Rd | 2 +- vignettes/load-data.Rmd | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7d81fa1..f90fc8f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Ramses Type: Package Title: R Package for Antimicrobial Stewardship & Surveillance -Version: 0.7.1 +Version: 0.7.2 Authors@R: c( person(given = "Peter", family = "Dutey-Magni", @@ -26,7 +26,7 @@ Encoding: UTF-8 LazyData: true Depends: R (>= 4.0.0), - AMR (>= 1.8.0) + AMR (>= 2.0.0) Imports: DBI, rlang, @@ -64,7 +64,7 @@ Suggests: Remotes: ramses-antibiotics/snomedizer RdMacros: Rdpack -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 VignetteBuilder: knitr,rmarkdown Collate: 'Ramses-deprecated.R' diff --git a/NEWS.md b/NEWS.md index 051678a..cf6cfc7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,20 @@ +# Ramses 0.7.2 + +*11 February 2024* + + +## Changed + +- Now requires minimum `AMR` v2.0.0. +- Updated function calls and documentation following deprecation of `AMR::as.rsi()`. + + # Ramses 0.7.1 *19 November 2023* + ## Changed - Now requires minimum `dbplyr` v2.4.0. diff --git a/R/validate_data.R b/R/validate_data.R index e56013f..bfb75dd 100644 --- a/R/validate_data.R +++ b/R/validate_data.R @@ -1201,7 +1201,7 @@ validate_administrations <- function(data) { #' (can be the same as \code{drug_name})} #' \item{\code{rsi_code}}{\code{"R"} (resistant), \code{"S"} (susceptible), #' or \code{"I"} (intermediate exposure), as determined by the laboratory or by -#' \code{\link[AMR]{as.rsi}()} on the basis of minimum inhibitory concentrations +#' \code{\link[AMR]{as.sir}()} on the basis of minimum inhibitory concentrations #' or disk diffusion diameters} #' } #' diff --git a/man/validate_microbiology.Rd b/man/validate_microbiology.Rd index c248967..14f099d 100644 --- a/man/validate_microbiology.Rd +++ b/man/validate_microbiology.Rd @@ -123,7 +123,7 @@ Validate microbial isolates & susceptibility records (can be the same as \code{drug_name})} \item{\code{rsi_code}}{\code{"R"} (resistant), \code{"S"} (susceptible), or \code{"I"} (intermediate exposure), as determined by the laboratory or by - \code{\link[AMR]{as.rsi}()} on the basis of minimum inhibitory concentrations + \code{\link[AMR]{as.sir}()} on the basis of minimum inhibitory concentrations or disk diffusion diameters} } } diff --git a/vignettes/load-data.Rmd b/vignettes/load-data.Rmd index e5203cb..d557f5f 100644 --- a/vignettes/load-data.Rmd +++ b/vignettes/load-data.Rmd @@ -580,7 +580,7 @@ be found in `Ramses::reference_specimen_type`. Susceptibility testing results in the example dataset are already interpreted as Resistant/Increased exposure/Susceptible (RSI). Where needed, minimum inhibitory concentrations and disk diffusion diameters -can be interpreted as RSI using the `as.rsi()` function provided by the +can be interpreted as RSI using the `as.sir()` function provided by the AMR package. If possible, use the most specific concept available (eg