Skip to content

Commit

Permalink
Merge pull request #10 from mbranca/main
Browse files Browse the repository at this point in the history
Update bookmarks and fields
  • Loading branch information
aghaynes authored Feb 2, 2024
2 parents 02897e4 + 39f73ed commit b3ef579
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 49 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- {os: windows-latest, r: 'oldrel-1'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}
#- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
#- {os: ubuntu-latest, r: 'release'}
#- {os: ubuntu-latest, r: 'oldrel'}


env:
Expand All @@ -57,6 +57,21 @@ jobs:
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: install freetype2 and imagemagick deps and libreoffice
if: matrix.config.os == 'macOS-latest'
run: |
brew install --cask libreoffice
- name: install libreoffice for ubuntu
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt install libreoffice
- name: install libreoffice for windows
if: matrix.config.os == 'windows-latest'
run: |
choco install libreoffice-fresh -y
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v2
- name: install freetype2 and imagemagick deps and libreoffice
run: brew install --cask libreoffice
- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
Expand Down
16 changes: 11 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
Package: SwissASR
Title: Automated Completion of the SwissEthics Annual Safety Report
Version: 0.3.0
Version: 0.4.0
Authors@R:
person(given = "Alan G.",
c(person(given = "Alan G.",
family = "Haynes",
role = c("aut", "cre"),
email = "alan.haynes@ctu.unibe.ch",
comment = c(ORCID = "0000-0003-1374-081X"))
email = "alan.haynes@unibe.ch",
comment = c(ORCID = "0000-0003-1374-081X")),
person(given = "Mattia",
family = "Branca",
role = "ctb",
email = "mattia.branca@unibe.ch",
comment = c(ORCID = "0000-0002-8063-7882")) )
Description: Completing the SwissEthics Annual Safety Report can be tiresome. This package eases the pain by providing an automated method to fill it out.
License: MIT + file LICENSE
Encoding: UTF-8
Expand All @@ -21,4 +26,5 @@ Imports:
magrittr,
officer,
stringr,
tibble
tibble,
doconv
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(asr_dataprep)
export(asr_safety_summary)
import(flextable)
import(officer)
importFrom(doconv,docx_update)
importFrom(glue,glue)
importFrom(magrittr,"%>%")
importFrom(stringr,str_to_lower)
Expand Down
11 changes: 8 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# swissethics 0.3.0
# SwissASR 0.4.0

* Modified some bookmarks into word fields such that the replacement can still happen in tables and not after them, as per recent update of officer package. This resolves issue #9.
* The above change requires use of the `doconv` package, which may require **setting some permissions on MAC OS** (for details see [the doconv documentation](https://github.com/ardata-fr/doconv)), and **may not work on Ubuntu** systems.

# SwissASR 0.3.0

* Additional option to include an intervention (random allocation) variable into the line listing (option `var_tx`), which is sometimes requested by ethics bodies.
* Addition of a logo

# swissethics 0.2.0
# SwissASR 0.2.0

* Addition of `asr_dataprep` and `asr_safety_summary` functions allowing for production of tables without generation of the MS Word report.
* Reworking of the internals of `asr` to utilise the above mentioned functions.
* Addition of demonstration dataset.
* Line listing pages in the word template set to landscape.

# swissethics 0.1.0
# SwissASR 0.1.0

* Added a `NEWS.md` file to track changes to the package.
101 changes: 65 additions & 36 deletions R/asr.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
#' @importFrom tibble tribble
#' @importFrom glue glue
#' @importFrom stringr str_to_lower str_to_sentence
#' @importFrom doconv docx_update
#' @examples
#'
#' data(asr_sae)
Expand Down Expand Up @@ -202,7 +203,7 @@ asr <- function(data,
, report_date = format(Sys.Date(), format = "%d/%m/%Y")
, period_from = as.Date("2020-11-02")
, period_to = as.Date("2020-11-17")
, template = system.file("extdata/clino_annual_safety_report_bm.docx", package = "SwissASR")
, template = system.file("extdata/clino_annual_safety_report_fm.docx", package = "SwissASR")
, international = FALSE
, trial_type = "imp"
# dataframe variables
Expand Down Expand Up @@ -394,49 +395,72 @@ asr <- function(data,


# ..general info, details of trial ----
period <- glue("{period_from} to {period_to}")

for(i in c("trial_title",
"protocol_number",
"basec_number",
"snctp_number",
"swissmedic_number",
"ec_name",
"product_name",
"sponsor_contact",
"inst_name_address",
"report_date",
"period",
"n_centers_t",
"n_centers_p",
"n_centers_c",
"n_centers_o",
"n_pat_t",
"n_pat_e",
"n_pat_c",
"n_pat_p")){
x <- get(i)
doc <- doc %>%
cursor_bookmark(i) %>%
body_add_par(x, pos = "after")
}



#
# for(i in c("trial_title",
# "protocol_number",
# "basec_number",
# "snctp_number",
# "swissmedic_number",
# "ec_name",
# "product_name",
# "sponsor_contact",
# "inst_name_address",
# "report_date",
# "period",
# "n_centers_t",
# "n_centers_p",
# "n_centers_c",
# "n_centers_o",
# "n_pat_t",
# "n_pat_e",
# "n_pat_c",
# "n_pat_p")){
# x <- get(i)
# doc <- doc %>%
# cursor_bookmark(i) %>%
# body_add_par(x, pos = "after")
# }


## participant safety ----
period <- glue("{period_from} to {period_to}")
## New code to insert the fields instead of bookmarks
doc <- doc %>%
set_doc_properties(trial_title = get("trial_title"),
protocol_number = get("protocol_number"),
basec_number = get("basec_number"),
snctp_number = get("snctp_number"),
swissmedic_number = get("swissmedic_number"),
ec_name = get("ec_name"),
product_name = get("product_name"),
sponsor_contact = get("sponsor_contact"),
inst_name_address = get("inst_name_address"),
report_date = get("report_date"),
period = get("period"),
n_centers_t = get("n_centers_t"),
n_centers_p = get("n_centers_p"),
n_centers_c = get("n_centers_c"),
n_centers_o = get("n_centers_o"),
n_pat_t = as.character(n_pat_t),
n_pat_e = as.character(n_pat_e),
n_pat_c = as.character(n_pat_c),
n_pat_p = as.character(n_pat_p) )


#} ## participant safety ----
summ <- asr_safety_summary(data = data,
period_data = period_data,
trial_type = trial_type,
n_pat_e = n_pat_e)

# doc <- doc %>%
# cursor_bookmark("partsafety_text")
# for(i in 1:length(summ$txt)){
# txt <- summ$txt[i]
# doc <- doc %>% body_add_par(txt, style = "Text")
# }

doc <- doc %>%
cursor_bookmark("partsafety_text")
for(i in 1:length(summ$txt)){
txt <- summ$txt[i]
doc <- doc %>% body_add_par(txt, style = "Text")
}
officer::set_doc_properties(partsafety_text = paste0(summ$txt, collapse = " ") )

# map <- data.frame(
# col_key = c("x1", "x2", "x3", "x4", "x5"),
Expand Down Expand Up @@ -613,6 +637,11 @@ asr <- function(data,
print(doc, target = target)


doc <- doc %>%
doc_properties()

docx_update(input = target)

}


Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ knitr::opts_chunk$set(echo = TRUE)

Participant safety is a big issue in clinical trials and reporting safety related events to the authorities is mandatory for certain trial types. One aspect of this is the annual safety report (ASR) which contains both summary information and listings of safety events. The `SwissASR` R package helps in compiling this report.

Provide a dataframe with the given variables and the function will return a filled out (as far as possible - some things require PI input) ASR in MS Word format. This could then be forwarded to the PI for supplimental details, signing and submission to the relevant governing bodies.
Provide a dataframe with the given variables and the function will return a filled out (as far as possible - some things require PI input) ASR in MS Word format. This could then be forwarded to the PI for supplemental details, signing and submission to the relevant governing bodies.

## Example usage

Expand Down
Binary file modified inst/extdata/clino_annual_safety_report_bm.docx
Binary file not shown.
Binary file added inst/extdata/clino_annual_safety_report_fm.docx
Binary file not shown.
2 changes: 1 addition & 1 deletion man/asr.Rd

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

0 comments on commit b3ef579

Please sign in to comment.