Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add asr_skeleton add-in #12

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
66 changes: 66 additions & 0 deletions R/asr_skeleton.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
asr_skeleton <- function(){

args <- formals(asr)

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){
arg <- names(args)[x]
helptext <- args_helpers[[arg]]
paste(arg, "=", deparse(args[[x]]), helptext)
}) |>
paste(collapse = ", \n ")

context <- rstudioapi::getSourceEditorContext()
id <- context$id
rstudioapi::insertText(text = paste0("asr(\n ", args, "\n)"), id = id)

}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# `SwissASR` <img src='man/figures/logo.png' align="right" width="200">

[![](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
Expand Down
4 changes: 4 additions & 0 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Name: Add asr call template
Description: Adds a template function call for the asr function to the current file.
Binding: asr_skeleton
Interactive: false
Loading