Skip to content

Commit

Permalink
Merge pull request #106 from ramses-antibiotics/develop
Browse files Browse the repository at this point in the history
Ramses 0.6.0
  • Loading branch information
peterdutey authored Oct 23, 2022
2 parents 0aa1c48 + 5f7c2b9 commit e15bf24
Show file tree
Hide file tree
Showing 22 changed files with 581 additions and 316 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- 'feature/**'
- 'bug_fix/**'
- 'bugfix/**'
schedule:
# run release on the 8th of every month to detect problems with new packages/R releases
- cron: '19 3 8 * *'

name: R-CMD-check

Expand Down
3 changes: 2 additions & 1 deletion 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.5.2
Version: 0.6.0
Authors@R: c(
person(given = "Peter",
family = "Dutey-Magni",
Expand Down Expand Up @@ -32,6 +32,7 @@ Imports:
rlang,
dplyr (>= 1.0.1),
dbplyr (>= 2.2.0),
tidyselect,
magrittr,
duckdb (>= 0.4.0),
Rdpack (>= 0.7),
Expand Down
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@

# Ramses 0.6.0

*23 October 2022*

## Improvements

- Changed `validate_inpatient_diagnoses()` to accept two optional fields `diagnosis_start`
and `diagnosis_end` and take advantage of clinical systems such as problem lists
- Changed `therapy_timeline()` to take advantage of `diagnosis_start` and `diagnosis_end`
variables if present
- Changed the `inpatient_diagnoses` mock dataset to removed episode start and end fields [#103](https://github.com/ramses-antibiotics/ramses-package/issues/103) which
duplicated information in `inpatient_episodes`
- Changed `bridge_*()` functions to add a field `antiinfective_type` to bridge tables [#76](https://github.com/ramses-antibiotics/ramses-package/issues/76) and prevent
unrelated generation issues [#104](https://github.com/ramses-antibiotics/ramses-package/issues/104)
- General code maintenance and adaptation to ongoing changes to the `dplyr` data masking
approach [#105](https://github.com/ramses-antibiotics/ramses-package/issues/105).


# Ramses 0.5.2

*13 September 2022*
Expand Down
38 changes: 19 additions & 19 deletions R/clinical_features.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
if ( !is.null(observation_code_system) ) {
db_observation_codes <- dplyr::filter(
dplyr::tbl(conn, "inpatient_investigations"),
observation_code %in% !!observation_code &
observation_code_system == !!observation_code_system
.data$observation_code %in% !!observation_code &
.data$observation_code_system == !!observation_code_system
)
} else {
db_observation_codes <- dplyr::filter(
dplyr::tbl(conn, "inpatient_investigations"),
observation_code %in% !!observation_code
.data$observation_code %in% !!observation_code
)
}

db_observation_codes <- dplyr::distinct(db_observation_codes,
observation_code_system,
observation_code) %>%
dplyr::group_by(observation_code) %>%
.data$observation_code_system,
.data$observation_code) %>%
dplyr::group_by(.data$observation_code) %>%
dplyr::summarise(n = dplyr::n()) %>%
dplyr::collect()

Expand Down Expand Up @@ -99,14 +99,14 @@
operation <- tolower(operation)
if ( is.null(observation_code_system) ) {
parameter_name <- tbl(conn, "inpatient_investigations") %>%
dplyr::filter(observation_code == !!observation_code) %>%
dplyr::distinct(observation_display) %>%
dplyr::filter(.data$observation_code == !!observation_code) %>%
dplyr::distinct(.data$observation_display) %>%
dplyr::collect()
} else {
parameter_name <- tbl(conn, "inpatient_investigations") %>%
dplyr::filter(observation_code == !!observation_code &
observation_code_system == !!observation_code_system) %>%
dplyr::distinct(observation_display) %>%
dplyr::filter(.data$observation_code == !!observation_code &
.data$observation_code_system == !!observation_code_system) %>%
dplyr::distinct(.data$observation_display) %>%
dplyr::collect()
}
if ( nrow(parameter_name) == 0 ) {
Expand Down Expand Up @@ -162,21 +162,21 @@
observations_linked <- dplyr::inner_join(
LT,
dplyr::select(tbl(x@conn, "inpatient_investigations"),
patient_id, observation_datetime,
observation_code, observation_value_numeric,
status, observation_code_system),
"patient_id", "observation_datetime",
"observation_code", "observation_value_numeric",
"status", "observation_code_system"),
by = "patient_id"
) %>%
dplyr::filter(
dplyr::sql(sql_condition_1) &
status %in% c("final", "preliminary", "corrected", "amended") &
observation_code %in% !!observation_code &
!is.na(observation_value_numeric)
.data$status %in% c("final", "preliminary", "corrected", "amended") &
.data$observation_code %in% !!observation_code &
!is.na(.data$observation_value_numeric)
)

if ( !is.null(observation_code_system) ) {
observations_linked <- observations_linked %>%
dplyr::filter(observation_code_system == !!observation_code_system)
dplyr::filter(.data$observation_code_system == !!observation_code_system)
}

observations_linked
Expand Down Expand Up @@ -207,7 +207,7 @@
observation_code_system = observation_code_system
) %>%
dplyr::group_by(.data$patient_id, .data[[x_entity_id_field_name]], .data$t) %>%
dplyr::mutate(keep = dplyr::row_number(dplyr::desc(observation_datetime))) %>%
dplyr::mutate(keep = dplyr::row_number(dplyr::desc(.data$observation_datetime))) %>%
dplyr::ungroup() %>%
dplyr::filter(.data$keep == 1) %>%
dplyr::transmute(.data$t,
Expand Down
Loading

0 comments on commit e15bf24

Please sign in to comment.