Skip to content

Commit

Permalink
Merge branch 'main' into 454-bug-null-report@main
Browse files Browse the repository at this point in the history
  • Loading branch information
BFalquet authored Oct 9, 2024
2 parents 840a182 + ea1b62f commit ea6c504
Show file tree
Hide file tree
Showing 56 changed files with 203 additions and 724 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# All available hooks: https://pre-commit.com/hooks.html
# R specific hooks: https://github.com/lorenzwalthert/precommit
default_stages: [commit]
default_stages: [pre-commit]
default_language_version:
python: python3
repos:
Expand Down
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: chevron
Title: Standard TLGs for Clinical Trials Reporting
Version: 0.2.6.9021
Date: 2024-09-16
Version: 0.2.7.9000
Date: 2024-10-09
Authors@R: c(
person("Liming", "Li", , "liming.li@roche.com", role = c("aut", "cre")),
person("Benoit", "Falquet", , "benoit.falquet@roche.com", role = "aut"),
Expand Down Expand Up @@ -31,7 +31,7 @@ Imports:
dplyr (>= 1.1.0),
dunlin (>= 0.1.7),
forcats (>= 1.0.0),
formatters (>= 0.5.8),
formatters (>= 0.5.9),
ggplot2 (>= 3.4.0),
glue (>= 1.0.0),
grid,
Expand All @@ -43,9 +43,9 @@ Imports:
purrr (>= 0.3.0),
rlang (>= 1.0.0),
rlistings (>= 0.2.9),
rtables (>= 0.6.8),
rtables (>= 0.6.10),
stringr (>= 1.4.1),
tern (>= 0.9.5),
tern (>= 0.9.6),
tibble (>= 2.0.0),
utils
Suggests:
Expand Down
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# chevron 0.2.6.9021
# chevron 0.2.7.9000

* Add `AEL02`, `AEL03`, `CML02A_gl` templates.
# chevron 0.2.7

* Add the `AEL02`, `AEL03` and `CML02A_gl` templates.
* Modify the post processing of `MHT01` to allow multiple `row_split_var`.
* Improve the `report_null` method to facilitate the creation of null reports
* Improve the `report_null` method to facilitate the creation of null reports.
* Export the `std_postprocessing` function to simplify post processing logic.
* `AET01` can now additionally display the number of death and withdrawal using the `show_wd` argument.
* `MNG01` line type can now be controlled with the `line_type` argument.
Expand Down
8 changes: 6 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,12 @@ listing_format_chevron <- function() {
#' @export
#' @examples
#' format_date("%d%b%Y")(as.Date("2021-01-01"))
#' format_date("%d%b%Y")(as.POSIXct("2021-01-01 00:00:01", tz = "NZ"))
#' format_date("%d%b%Y")(as.POSIXct("2021-01-01 00:00:01", tz = "US/Pacific"))
#' if ("NZ" %in% OlsonNames()) {
#' format_date("%d%b%Y")(as.POSIXct("2021-01-01 00:00:01", tz = "NZ"))
#' }
#' if ("US/Pacific" %in% OlsonNames()) {
#' format_date("%d%b%Y")(as.POSIXct("2021-01-01 00:00:01", tz = "US/Pacific"))
#' }
format_date <- function(date_format = "%d%b%Y") {
function(x, ...) {
toupper(
Expand Down
8 changes: 6 additions & 2 deletions man/format_date.Rd

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

704 changes: 0 additions & 704 deletions tests/testthat/_snaps/vst01.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions tests/testthat/test-ael01_nollt.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_that("ael01_nollt works with admh dataset", {


test_that("ael01_nollt works with non-default label", {
skip_on_os("windows")
proc_data <- syn_data
attr(proc_data$adae$AETERM, "label") <- "Investigator-Specified\n Adverse Event Term"
res <- expect_silent(
Expand All @@ -21,6 +22,7 @@ test_that("ael01_nollt works with non-default label", {
})

test_that("ael01_nollt can handle all missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -34,6 +36,7 @@ test_that("ael01_nollt can handle all missing values", {
})

test_that("ael01_nollt can handle some missing values", {
skip_on_os("windows")
new_aebodsys <- c(NA, "", as.character(syn_data$adae$AEBODSYS[-c(1, 2)]))
new_aedecod <- c(NA, "", as.character(syn_data$adae$AEDECOD[-c(1, 2)]))

Expand All @@ -49,6 +52,7 @@ test_that("ael01_nollt can handle some missing values", {
})

test_that("ael01_nollt listing can be split by an additional variable", {
skip_on_os("windows")
res <- expect_silent(
run(
ael01_nollt,
Expand All @@ -64,6 +68,7 @@ test_that("ael01_nollt listing can be split by an additional variable", {
})

test_that("split ael01_nollt listing do not display missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$admh <- proc_data$admh[proc_data$admh$SEX == "F", ]

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ael02.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("ael02 works with adae dataset", {
})

test_that("ael02 can handle all missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -27,6 +28,7 @@ test_that("ael02 can handle all missing values", {


test_that("ael02 functions work as expected", {
skip_on_os("windows")
res <- expect_silent(
ael02_pre(syn_data) %>%
ael02_main()
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ael03.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("ael03 works with adae dataset", {
})

test_that("ael03 can handle all missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -27,6 +28,7 @@ test_that("ael03 can handle all missing values", {
# ael03 functions ----

test_that("ael03 functions work as expected", {
skip_on_os("windows")
res <- expect_silent(
ael03_pre(syn_data) %>%
ael03_main()
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-aet01.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test_that("aet01 can handle all NA values", {
})

test_that("aet01 can handle some NA values", {
skip_on_os("windows")
new_aesdth <- c(NA, "", as.character(syn_data$adae$AESDTH[-c(1, 2)]))
new_aeser <- c(NA, "", as.character(syn_data$adae$AESER[-c(1, 2)]))

Expand All @@ -30,12 +31,14 @@ test_that("aet01 can handle some NA values", {
})

test_that("aet01 can use custom anl_vars", {
skip_on_os("windows")
proc_data <- syn_data
res <- expect_silent(run(aet01, proc_data, anl_vars = list(safety_var = "FATAL")))
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
})

test_that("aet01 fails on incomplete data input", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(AESER = NULL)
Expand All @@ -48,6 +51,7 @@ test_that("aet01 fails on incomplete data input", {
})

test_that("aet01 can use custom medconcept_var", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae$SMQ01 <- with_label(proc_data$adae$SMQ01NAM != "", "SMQ 01")
res <- expect_silent(
Expand All @@ -66,6 +70,7 @@ test_that("aet01 can use custom medconcept_var", {
})

test_that("aet01 can conditionally show the number of withdrawal", {
skip_on_os("windows")
expect_silent(res <- run(aet01, syn_data, arm_var = "ARM", show_wd = FALSE))
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
})
3 changes: 3 additions & 0 deletions tests/testthat/test-aet01_aesi.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test_that("aet01_aesi can handle all NA values", {
})

test_that("aet01_aesi can handle some NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -31,12 +32,14 @@ test_that("aet01_aesi can handle some NA values", {
})

test_that("aet01_aesi works with `ALL` argument", {
skip_on_os("windows")
proc_data <- syn_data
res <- expect_silent(run(aet01_aesi, proc_data, aesi_vars = c("ALL")))
expect_snapshot(cat(export_as_txt(res, lpp = 100, cpp = 200)))
})

test_that("aet01_aesi_check fails on incomplete data input", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(AEOUT = NULL)
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-aet02.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test_that("aet02 fails on incomplete data input", {
})

test_that("aet02 handle empty data input", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
filter(
Expand All @@ -25,6 +26,7 @@ test_that("aet02 handle empty data input", {
})

test_that("aet02 can have different levels of row_split", {
skip_on_os("windows")
res1 <- run(aet02, syn_data, row_split_var = NULL)
res2 <- run(aet02, syn_data, row_split_var = c("AEBODSYS", "AEDECOD"))
expect_snapshot(cat(export_as_txt(res1, lpp = 100)))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet03.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test_that("aet03 can handle NA values", {
})

test_that("aet03 can handle some NA values", {
skip_on_os("windows")
new_aebodsys <- c(NA, "", as.character(syn_data$adae$AEBODSYS[-c(1, 2)]))
new_aedecod <- c(NA, "", as.character(syn_data$adae$AEDECOD[-c(1, 2)]))
new_asev <- c(NA, "", as.character(syn_data$adae$ASEV[-c(1, 2)]))
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-aet04.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("aet04 can handle NA values", {

res1 <- expect_silent(run(aet04, proc_data))
expect_snapshot(cat(export_as_txt(res1, lpp = 100)))

skip_on_os("windows")
grade_groups <- list(
"Grade 1-2" = c("1", "2"),
"Grade 3-4" = c("3", "4"),
Expand All @@ -26,6 +26,7 @@ test_that("aet04 can handle NA values", {
})

test_that("aet04 can handle some NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae[1:2, c("AEBODSYS", "AEDECOD")] <- NA
res1 <- expect_silent(run(aet04, proc_data))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet05.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("aet05 can handle NA values", {
})

test_that("aet05 can handle some NA values", {
skip_on_os("windows")
new_paramcd <- c(
as.character(syn_data$adsaftte$PARAMCD[1:4]), NA, "",
as.character(syn_data$adsaftte$PARAMCD[-rep(1:6)])
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet05_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("aet05_all can handle NA values", {
})

test_that("aet05_all can handle some NA values", {
skip_on_os("windows")
new_paramcd <- c(NA, "", as.character(syn_data$adsaftte$PARAMCD[-c(1, 2)]))

proc_data <- syn_data
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet10.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test_that("aet10 can handle NA values", {
})

test_that("aet10 can handle some NA values", {
skip_on_os("windows")
new_aedecod <- c(NA, "", as.character(syn_data$adae$AEDECOD[-c(1, 2)]))

proc_data <- syn_data
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-cfbt01.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# cfbt01 functions ----

test_that("cfbt01 functions with default argument value return expected result with test data", {
skip_on_os("windows")
pre_data <- cfbt01_pre(syn_data, dataset = "advs")
raw_res <- cfbt01_main(pre_data, dataset = "advs")
res <- cfbt01_post(raw_res)
Expand All @@ -10,6 +11,7 @@ test_that("cfbt01 functions with default argument value return expected result w
# cfbt01 ----

test_that("cfbt01 can handle n = 0 and outputs NE instead of infs and NAs", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(
syn_data,
PARAMCD %in% c("DIABP", "SYSBP"), "advs"
Expand Down
Loading

0 comments on commit ea6c504

Please sign in to comment.