From 1c358e3afcedd3f5c73523db2769ff140a53a59c Mon Sep 17 00:00:00 2001 From: Alan Haynes Date: Wed, 15 May 2024 12:58:25 +0200 Subject: [PATCH 1/3] add skeleton addin --- DESCRIPTION | 2 +- R/asr_skeleton.R | 16 ++++++++++++++++ inst/rstudio/addins.dcf | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 R/asr_skeleton.R create mode 100644 inst/rstudio/addins.dcf diff --git a/DESCRIPTION b/DESCRIPTION index 0cfdf75..964c633 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: SwissASR Title: Automated Completion of the SwissEthics Annual Safety Report -Version: 0.4.0 +Version: 0.4.1 Authors@R: c(person(given = "Alan G.", family = "Haynes", diff --git a/R/asr_skeleton.R b/R/asr_skeleton.R new file mode 100644 index 0000000..6e4512c --- /dev/null +++ b/R/asr_skeleton.R @@ -0,0 +1,16 @@ +asr_skeleton <- function(){ + + args <- formals(asr) + + args$data <- "sae_data" + + args <- lapply(1:length(args), function(x){ + paste(names(args)[x], "=", deparse(args[[x]])) + }) |> + paste(collapse = ", \n ") + + context <- rstudioapi::getSourceEditorContext() + id <- context$id + rstudioapi::insertText(text = paste0("asr(\n ", args, "\n)"), id = id) + +} diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf new file mode 100644 index 0000000..78e834b --- /dev/null +++ b/inst/rstudio/addins.dcf @@ -0,0 +1,4 @@ +Name: Add asr template +Description: Adds a template function call for the asr function to the current file. +Binding: asr_skeleton +Interactive: false From 09328829fa810cc701e68391c0fe6635751fd783 Mon Sep 17 00:00:00 2001 From: Alan Haynes Date: Wed, 15 May 2024 15:17:26 +0200 Subject: [PATCH 2/3] add extra help --- R/asr_skeleton.R | 52 ++++++++++++++++++++++++++++++++++++++++- inst/rstudio/addins.dcf | 2 +- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/R/asr_skeleton.R b/R/asr_skeleton.R index 6e4512c..2b14492 100644 --- a/R/asr_skeleton.R +++ b/R/asr_skeleton.R @@ -4,8 +4,58 @@ asr_skeleton <- function(){ args$data <- "sae_data" + args_helpers <- list( + data = "# dataframe containing SAEs", + target = "# word file as output\n\n # TRIAL INFORMATION", + trial_title = "", + protocol_number = "", + basec_number = "", + snctp_number = "", + swissmedic_number = "", + ec_name = "# ethics committee", + product_name = "# product/intervention name\n\n # SPONSOR INFORMATION", + sponsor_contact = "", + inst_name_address = "\n\n # TRIAL PROGRESS", + n_centers_t = "# total number of participating centres", + n_centers_p = "# planned number of participating centres", + n_centers_c = "# number of closed centres", + n_centers_o = "# number of open centres", + n_pat_t = "# total target number of participants ", + n_pat_e = "# actual number of participants enrolled", + n_pat_c = "# number of participants completed", + n_pat_p = "# number of participants prematurely terminated\n\n # REPORT INFORMATION", + report_date = "# normally Sys.Date()", + period_from = "# date of previous report", + period_to = "# probably Sys.Date()-1", + template = "# Word file to use as the template", + international = "# TRUE if the trial is international", + trial_type = "# type of trial\n\n # VARIABLES IN data", + var_class = "# variable containing SAE class. Options allowed are 'SAE', 'SADR', 'SUSAR'", + var_sae_n = "# variable containing SAE ID", + var_part_id = "# variable containing participant ID", + var_age = "# variable containing participant age", + var_sex = "# variable containing participant sex", + var_country = "# variable containing participants country", + var_site = "# variable containing participants site", + var_sae = "# variable containing SAE type (description)", + var_date_onset = "# variable containing the date the SAE occurred", + var_trt = "# variable containing the treatment used to alleviate the SAE", + var_date_trt_start = "# variable containing the date that the treatment started", + var_date_trt_stop = "# variable containing the date that the treatment stopped", + var_outcome = "# variable containing the outcome of the SAE", + var_comment = "# variable containing any comment", + var_relation = "# variable containing the relationship to randomized intervention", + var_expected = "# variable saying whether the SAE was expected", + var_devdef = "# variable containing whether the SAE is a device deficiency (MD trials only)", + var_devattr = "# variable containing whether the SAE is attributable to the device (MD trials only)", + var_devint = "# variable containing whether the SAE is attributable to an intervention in the trial", + var_safetymeasure = "# variable containing whether the SAE required safety related measures", + var_tx = "# variable indicating the intervention group. If provided, this variable will be included in the line listing") + args <- lapply(1:length(args), function(x){ - paste(names(args)[x], "=", deparse(args[[x]])) + arg <- names(args)[x] + helptext <- args_helpers[[arg]] + paste(arg, "=", deparse(args[[x]]), helptext) }) |> paste(collapse = ", \n ") diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index 78e834b..05cfacb 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -1,4 +1,4 @@ -Name: Add asr template +Name: Add asr call template Description: Adds a template function call for the asr function to the current file. Binding: asr_skeleton Interactive: false From d8d0446de32b75ac488afc23050a3a16e622003f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 May 2024 13:19:06 +0000 Subject: [PATCH 3/3] Re-build README.Rmd --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e32c350..7a69eca 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # `SwissASR` -[![](https://img.shields.io/badge/dev%20version-0.4.0-blue.svg)](https://github.com/CTU-Bern/redcaptools) +[![](https://img.shields.io/badge/dev%20version-0.4.1-blue.svg)](https://github.com/CTU-Bern/redcaptools) [![R-CMD-check](https://github.com/CTU-Bern/SwissASR/workflows/R-CMD-check/badge.svg)](https://github.com/CTU-Bern/SwissASR/actions) Participant safety is a big issue in clinical trials and reporting