Skip to content

Commit

Permalink
Merge pull request #110 from ramses-antibiotics/develop
Browse files Browse the repository at this point in the history
Ramses 0.7.0
  • Loading branch information
peterdutey authored Apr 11, 2023
2 parents e15bf24 + e4e2888 commit ebd423f
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 35 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'feature/**'
- 'bug_fix/**'
- 'bugfix/**'
- 'maint/**'
schedule:
# run release on the 8th of every month to detect problems with new packages/R releases
- cron: '19 3 8 * *'
Expand Down Expand Up @@ -37,7 +38,7 @@ jobs:
# container action is not supported on windows or macOS
# - {os: windows-latest, r: 'release'}
# - {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: '4.0.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

Expand Down Expand Up @@ -82,14 +83,16 @@ jobs:
- name: Install dependencies
run: |
remotes::install_github("msberends/AMR", build = TRUE)
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
run: |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Code coverage
Expand Down
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Ramses
Type: Package
Title: R Package for Antimicrobial Stewardship & Surveillance
Version: 0.6.0
Version: 0.7.0
Authors@R: c(
person(given = "Peter",
family = "Dutey-Magni",
Expand All @@ -25,14 +25,14 @@ BugReports: https://github.com/ramses-antibiotics/ramses-package/issues
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.6.0),
R (>= 4.0.0),
AMR (>= 1.8.0)
Imports:
DBI,
rlang,
dplyr (>= 1.0.1),
dbplyr (>= 2.2.0),
tidyselect,
dplyr (>= 1.1.0),
dbplyr (>= 2.3.2),
tidyselect (>= 1.2.0),
magrittr,
duckdb (>= 0.4.0),
Rdpack (>= 0.7),
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@

# Ramses 0.7.0

*11 April 2023*

## Changed

- Now requires minimum R v4.0.0, `dplyr` v1.1.0, `dbplyr` v2.3.2 and `tidyselect` v1.2.0.
- Internal code maintenance in line with new tidy programming practice.
- Tolerance built into the timeline for handling of no growth results. Ramses does not
currently prescribe whether no growth should be loaded into `microbiology_isolates` or not ([#108](https://github.com/ramses-antibiotics/ramses-package/issues/108)).
The timeline will now show specimens without an isolate record at the time of collection.


# Ramses 0.6.0

*23 October 2022*
Expand Down
16 changes: 9 additions & 7 deletions R/metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ download_icd10cm <- function(silent = FALSE) {
icd_source$level <- nchar(icd_source$icd_code)

icd3 <- dplyr::filter(icd_source, .data$level == 3) %>%
dplyr::transmute(category_code = .data$icd_code,
category_description = .data$icd_description)
dplyr::mutate(category_code = .data$icd_code,
category_description = .data$icd_description,
.keep = "none")

icd5 <- dplyr::filter(icd_source, .data$header_indicator == 1) %>%
dplyr::mutate(category_code = substring(.data$icd_code, 0, 3))
Expand Down Expand Up @@ -113,8 +114,9 @@ import_icd <- function(archive, version) {
icd_source$level <- nchar(icd_source[["alt_code"]])

icd3 <- dplyr::filter(icd_source, .data$level == 3) %>%
dplyr::transmute(category_code = .data$alt_code,
category_description = .data$description)
dplyr::mutate(category_code = .data$alt_code,
category_description = .data$description,
.keep = "none")

icd5 <- dplyr::filter(icd_source, .data$level > 3) %>%
dplyr::mutate(category_code = substring(.data$alt_code, 0, 3))
Expand All @@ -127,9 +129,9 @@ import_icd <- function(archive, version) {
icd$edition <- version

icd <- dplyr::rename(icd,
icd_display = .data$code,
icd_code = .data$alt_code,
icd_description = .data$description)
icd_display = "code",
icd_code = "alt_code",
icd_description = "description")
icd <- arrange_variables(icd,
first_column_names = c(
"icd_code",
Expand Down
4 changes: 2 additions & 2 deletions R/objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Encounter <- function(conn, id, extend_table_start = NULL) {
if(is(conn, "PqConnection") | is(conn, "duckdb_connection")) {
tbl(conn, "ramses_tally") %>%
dplyr::mutate(t = .data$t - as.integer(extend_table_start)) %>%
dplyr::full_join(longitudinal_table, by = character()) %>%
dplyr::cross_join(longitudinal_table) %>%
dplyr::mutate(t_start = dplyr::sql("admission_date + interval '1h' * t ")) %>%
dplyr::filter(.data$t_start < .data$discharge_date) %>%
dplyr::mutate(t_end = dplyr::sql("admission_date + interval '1h' * (t + 1)")) %>%
Expand Down Expand Up @@ -369,7 +369,7 @@ setGeneric(name = "TherapyEpisode", def = TherapyEpisode)
if(is(conn, "PqConnection") | is(conn, "duckdb_connection")) {
tbl(conn, "ramses_tally") %>%
dplyr::mutate(t = .data$t - as.integer(extend_table_start)) %>%
dplyr::full_join(longitudinal_table, by = character()) %>%
dplyr::cross_join(longitudinal_table) %>%
dplyr::mutate(t_start = dplyr::sql("therapy_start + interval '1h' * t "))%>%
dplyr::filter(.data$t_start < .data$therapy_end) %>%
dplyr::mutate(t_end = dplyr::sql("therapy_start + interval '1h' * (t + 1)")) %>%
Expand Down
1 change: 0 additions & 1 deletion R/reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@
#' \item{\code{pt_term}}{SNOMED CT Preferred Term}
#' \item{\code{snomed_release_version}}{SNOMED CT RF2 release date}
#' }
#' @seealso \url{https://snomedizer.web.app}
#' @format A data frame.
#' @docType data
#' @name reference_specimen_type
Expand Down
5 changes: 5 additions & 0 deletions R/timeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ setMethod(
dplyr::mutate(className = dplyr::if_else(is.na(.data$organism_code),
"micro-report-no-growth",
"micro-report")) %>%
dplyr::mutate(isolation_datetime = dplyr::if_else(
is.na(.data$isolation_datetime),
.data$specimen_datetime,
.data$isolation_datetime
)) %>%
dplyr::group_by(.data$specimen_id, .data$className) %>%
dplyr::summarise(
id = paste0("Specimen ID:",
Expand Down
3 changes: 0 additions & 3 deletions man/reference_specimen_type.Rd

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

12 changes: 9 additions & 3 deletions tests/testthat/test-objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,9 @@ test_that("Encounter..constructor", {
fake_db_conn,
dplyr::tibble(
patient_id = "9",
encounter_id = "999999"
encounter_id = "999999",
admission_date = Sys.Date(),
discharge_date = Sys.Date()
),
"inpatient_episodes",
temporary = FALSE
Expand All @@ -812,7 +814,9 @@ test_that("Encounter..constructor", {
fake_db_conn,
dplyr::tibble(
patient_id = 9,
encounter_id = 999999
encounter_id = 999999,
admission_date = Sys.Date(),
discharge_date = Sys.Date()
),
"inpatient_episodes",
temporary = FALSE
Expand All @@ -828,7 +832,9 @@ test_that("Encounter..constructor", {
fake_db_conn,
dplyr::tibble(
patient_id = 9L,
encounter_id = 999999L
encounter_id = 999999L,
admission_date = Sys.Date(),
discharge_date = Sys.Date()
),
"inpatient_episodes",
temporary = FALSE
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-warehousing-duckdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_that(".create_sql_index on DuckDB", {
expect_equal(
DBI::dbGetQuery(db_conn, "SELECT * FROM pg_catalog.pg_indexes") %>%
dplyr::filter(.data$tablename == "test_table") %>%
dplyr::select(.data$tablename, .data$indexname) %>%
dplyr::select("tablename", "indexname") %>%
dplyr::collect(),
data.frame(
tablename = "test_table",
Expand Down Expand Up @@ -103,8 +103,8 @@ test_that("drug_prescriptions_edges on DuckDB", {
load_medications(db_conn, records_rx, overwrite = T)

output <- dplyr::distinct(tbl(db_conn, "drug_prescriptions_edges"),
patient_id, edge_type, relation_type) %>%
dplyr::arrange(patient_id) %>%
.data$patient_id, .data$edge_type, .data$relation_type) %>%
dplyr::arrange(.data$patient_id) %>%
dplyr::collect()

records_edges <- read.csv(system.file("test_cases", "prescription_linkage_edges_classes.csv",
Expand All @@ -131,8 +131,8 @@ test_that("create_mock_database on DuckDB", {
dplyr::filter(prescription_id %in% c("592a738e4c2afcae6f625c01856151e0",
"89ac870bc1c1e4b2a37cec79d188cb08",
"0bf9ea7732dd6e904ab670a407382d95")) %>%
dplyr::select(prescription_id, combination_id, therapy_id) %>%
dplyr::arrange(therapy_id, prescription_id) %>%
dplyr::select("prescription_id", "combination_id", "therapy_id") %>%
dplyr::arrange(.data$therapy_id, .data$prescription_id) %>%
dplyr::collect()
expect_equal(
test_output,
Expand Down Expand Up @@ -226,8 +226,8 @@ test_that("Ramses on DuckDB (system test)", {
dplyr::filter(prescription_id %in% c("592a738e4c2afcae6f625c01856151e0",
"89ac870bc1c1e4b2a37cec79d188cb08",
"0bf9ea7732dd6e904ab670a407382d95")) %>%
dplyr::select(prescription_id, combination_id, therapy_id) %>%
dplyr::arrange(therapy_id, prescription_id) %>%
dplyr::select("prescription_id", "combination_id", "therapy_id") %>%
dplyr::arrange(.data$therapy_id, .data$prescription_id) %>%
dplyr::collect()
expect_equal(
test_output,
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-warehousing-postgres.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test_that(".create_sql_index on Postgres", {
expect_equal(
DBI::dbGetQuery(pq_conn, "SELECT * FROM pg_catalog.pg_indexes") %>%
dplyr::filter(.data$tablename == "test_table") %>%
dplyr::select(.data$tablename, .data$indexname) %>%
dplyr::select("tablename", "indexname") %>%
dplyr::collect(),
data.frame(
tablename = "test_table",
Expand Down Expand Up @@ -152,8 +152,8 @@ test_that("drug_prescriptions_edges on Postgres", {
load_medications(pq_conn, records_rx, overwrite = T)

output <- dplyr::distinct(tbl(pq_conn, "drug_prescriptions_edges"),
patient_id, edge_type, relation_type) %>%
dplyr::arrange(patient_id) %>%
.data$patient_id, .data$edge_type, .data$relation_type) %>%
dplyr::arrange(.data$patient_id) %>%
dplyr::collect()

records_edges <- read.csv(system.file("test_cases", "prescription_linkage_edges_classes.csv",
Expand Down Expand Up @@ -253,8 +253,8 @@ test_that("Ramses on PosgreSQL (system test)", {
dplyr::filter(prescription_id %in% c("592a738e4c2afcae6f625c01856151e0",
"89ac870bc1c1e4b2a37cec79d188cb08",
"0bf9ea7732dd6e904ab670a407382d95")) %>%
dplyr::select(prescription_id, combination_id, therapy_id) %>%
dplyr::arrange(therapy_id, prescription_id) %>%
dplyr::select("prescription_id", "combination_id", "therapy_id") %>%
dplyr::arrange(.data$therapy_id, .data$prescription_id) %>%
dplyr::collect()
expect_equal(
test_output,
Expand Down

0 comments on commit ebd423f

Please sign in to comment.