diff --git a/R/eudract/DESCRIPTION b/R/eudract/DESCRIPTION index d72d423..940aabb 100644 --- a/R/eudract/DESCRIPTION +++ b/R/eudract/DESCRIPTION @@ -1,8 +1,8 @@ Package: eudract Type: Package Title: Creates Safety Results Summary in XML to Upload to EudraCT -Date: 2020-04-03 -Version: 0.9.2.9000 +Date: 2021-02-24 +Version: 0.9.3 Authors@R: c( person("Simon", "Bond", email="simon.bond@addenbrookes.nhs.uk", role="cre"), person("Beatrice","Pantaleo", email="bp403@medschl.cam.ac.uk", role="aut")) @@ -15,7 +15,7 @@ Encoding: UTF-8 LazyData: true Imports: tidyr, xslt, dplyr, xml2, utils, magrittr Depends: R (>= 3.5.0) -RoxygenNote: 7.0.1 +RoxygenNote: 7.1.0 Suggests: testthat, knitr, diff --git a/R/eudract/NAMESPACE b/R/eudract/NAMESPACE index fe6b572..533c647 100644 --- a/R/eudract/NAMESPACE +++ b/R/eudract/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2: do not edit by hand +# Generated by roxygen2: do not edit by hand S3method(print,safety_summary) export(create.safety_summary) diff --git a/R/eudract/NEWS.md b/R/eudract/NEWS.md index 9aa29c7..c651c4a 100644 --- a/R/eudract/NEWS.md +++ b/R/eudract/NEWS.md @@ -1,6 +1,6 @@ # eudract v0.9.3 -Placeholder for the next version +Error is caused if any of the group names are less than 4 characters in length, as EudraCT will reject this. # eudract v 0.9.2 diff --git a/R/eudract/R/safety_summary.R b/R/eudract/R/safety_summary.R index b656d86..6c63cc2 100644 --- a/R/eudract/R/safety_summary.R +++ b/R/eudract/R/safety_summary.R @@ -57,6 +57,8 @@ safety_summary <- function(data, exposed, excess_deaths=0, freq_threshold=0, soc data$group <- factor(as.character(data$group), levels=group_names) + #Check length of group name text + if( min(nchar(group_names))<4){stop("Group names must be at least 4 characters in length.")} # check length, value and names of excess_deaths if( length(excess_deaths)==1 && length(group_names)>1 && excess_deaths==0){ diff --git a/R/eudract/build_dashboard.R b/R/eudract/build_dashboard.R index f60d062..3dc7e2f 100644 --- a/R/eudract/build_dashboard.R +++ b/R/eudract/build_dashboard.R @@ -13,11 +13,11 @@ devtools::document(roclets = c('rd', 'collate', 'namespace')) devtools::build() #Check you've got the right version number -install.packages("../eudract_0.9.2.tar.gz", +install.packages("../eudract_0.9.3.tar.gz", repos = NULL, type = "source") -devtools::build("../eudract_0.9.2.tar.gz", binary=TRUE) +devtools::build("../eudract_0.9.3.tar.gz", binary=TRUE) -install.packages("V:/STATISTICS/NON STUDY FOLDER/Software/R/R Code Library/cctu_0.9.2.zip", +install.packages("V:/STATISTICS/NON STUDY FOLDER/Software/R/R Code Library/eudract_0.9.3.zip", repos = NULL, type="win.binary") #devtools::build( binary=TRUE) diff --git a/R/eudract/cran-comments.md b/R/eudract/cran-comments.md index 11158d4..b4643df 100644 --- a/R/eudract/cran-comments.md +++ b/R/eudract/cran-comments.md @@ -4,6 +4,11 @@ * Windows Server 2012 R2 x64 (build 9600) on (appveyor), R3.6.1 * check_win_release +## Change 24FEB2021 + +an error is created if input fails the check of group names being at least 4 characters in length. + + ## Change 03APR2020 Minor corrections to test code, setting a resetting options(StringsAsFactors). diff --git a/R/eudract/man/append_xml.Rd b/R/eudract/man/append_xml.Rd index d56d19d..d53b039 100644 --- a/R/eudract/man/append_xml.Rd +++ b/R/eudract/man/append_xml.Rd @@ -1,12 +1,12 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/simple_safety_xml.R -\name{append_xml} -\alias{append_xml} -\title{internal function to append rows to the output xml file} -\usage{ -append_xml(data, file_connection) -} -\description{ -internal function to append rows to the output xml file -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/simple_safety_xml.R +\name{append_xml} +\alias{append_xml} +\title{internal function to append rows to the output xml file} +\usage{ +append_xml(data, file_connection) +} +\description{ +internal function to append rows to the output xml file +} \keyword{internal} diff --git a/R/eudract/man/create.safety_summary.Rd b/R/eudract/man/create.safety_summary.Rd index 18bc59e..2fcaf70 100644 --- a/R/eudract/man/create.safety_summary.Rd +++ b/R/eudract/man/create.safety_summary.Rd @@ -18,4 +18,4 @@ a safety_summary object } \description{ function that creates a safety_summary object from individual data.frames -} +} diff --git a/R/eudract/man/df_to_char.Rd b/R/eudract/man/df_to_char.Rd index b2f1437..2fb8132 100644 --- a/R/eudract/man/df_to_char.Rd +++ b/R/eudract/man/df_to_char.Rd @@ -1,15 +1,15 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/safety_summary.R -\name{df_to_char} -\alias{df_to_char} -\title{function to make a data frame be entirely character vectors} -\usage{ -df_to_char(df) -} -\arguments{ -\item{df}{a data frame} -} -\description{ -function to make a data frame be entirely character vectors -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/safety_summary.R +\name{df_to_char} +\alias{df_to_char} +\title{function to make a data frame be entirely character vectors} +\usage{ +df_to_char(df) +} +\arguments{ +\item{df}{a data frame} +} +\description{ +function to make a data frame be entirely character vectors +} \keyword{internal} diff --git a/R/eudract/man/eudract_convert.Rd b/R/eudract/man/eudract_convert.Rd index f57c26a..6dc9e41 100644 --- a/R/eudract/man/eudract_convert.Rd +++ b/R/eudract/man/eudract_convert.Rd @@ -40,4 +40,4 @@ eudract_convert(input=simple, } \seealso{ \code{\link{safety_summary}} \code{\link{simple_safety_xml}} -} +} diff --git a/R/eudract/man/print.safety_summary.Rd b/R/eudract/man/print.safety_summary.Rd index d7baa50..a3e77d9 100644 --- a/R/eudract/man/print.safety_summary.Rd +++ b/R/eudract/man/print.safety_summary.Rd @@ -1,17 +1,17 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/safety_summary.R -\name{print.safety_summary} -\alias{print.safety_summary} -\title{print method for safety summary object} -\usage{ -\method{print}{safety_summary}(x, ...) -} -\arguments{ -\item{x}{a safety_summary object} - -\item{...}{extra arguments for the generic print method} -} -\description{ -print method for safety summary object -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/safety_summary.R +\name{print.safety_summary} +\alias{print.safety_summary} +\title{print method for safety summary object} +\usage{ +\method{print}{safety_summary}(x, ...) +} +\arguments{ +\item{x}{a safety_summary object} + +\item{...}{extra arguments for the generic print method} +} +\description{ +print method for safety summary object +} \keyword{internal} diff --git a/R/eudract/man/safety.Rd b/R/eudract/man/safety.Rd index c7d2acc..4ccfc0d 100644 --- a/R/eudract/man/safety.Rd +++ b/R/eudract/man/safety.Rd @@ -4,7 +4,8 @@ \name{safety} \alias{safety} \title{Example of safety data} -\format{a data frame with 8 columns and 16 rows +\format{ +a data frame with 8 columns and 16 rows \describe{ \item{pt}{meddra preferred term code} \item{subjid}{a unique subject identifier} @@ -14,7 +15,8 @@ \item{serious}{a numerical 0/1 to indicate if the event was serious} \item{group}{the treatment group for the subject} \item{term}{a text description of the event. Needs to be matching 1-1 with the pt code} -}} +} +} \usage{ safety } @@ -28,4 +30,4 @@ as patients with no events will not be included in these data. The variable names and formats are those required by \code{\link{safety_summary}}. The variable \code{pt} is not strictly required. An alternative to \code{soc} would be the equivalent character string from \code{\link{soc_code}} } -\keyword{datasets} +\keyword{datasets} diff --git a/R/eudract/man/safety_summary.Rd b/R/eudract/man/safety_summary.Rd index b63a239..f8757c7 100644 --- a/R/eudract/man/safety_summary.Rd +++ b/R/eudract/man/safety_summary.Rd @@ -46,4 +46,4 @@ eudract_convert(input=simple, } \seealso{ \code{\link{eudract_convert}} \code{\link{simple_safety_xml}} -} +} diff --git a/R/eudract/man/simple_safety_xml.Rd b/R/eudract/man/simple_safety_xml.Rd index 02401fd..8274f8c 100644 --- a/R/eudract/man/simple_safety_xml.Rd +++ b/R/eudract/man/simple_safety_xml.Rd @@ -34,4 +34,4 @@ eudract_convert(input=simple, } \seealso{ \code{\link{eudract_convert}} \code{\link{safety_summary}} -} +} diff --git a/R/eudract/man/soc_code.Rd b/R/eudract/man/soc_code.Rd index ef57db6..5febe69 100644 --- a/R/eudract/man/soc_code.Rd +++ b/R/eudract/man/soc_code.Rd @@ -4,12 +4,14 @@ \name{soc_code} \alias{soc_code} \title{System Organ Class coding} -\format{a data frame with 3 columns and 27 rows +\format{ +a data frame with 3 columns and 27 rows \describe{ \item{soc_term}{a text description} \item{eutctId}{the eudraCT coding} \item{meddra}{the meddra code} -}} +} +} \source{ \url{https://www.meddra.org/}, \url{https://spor.ema.europa.eu/rmswi/#/} } @@ -19,4 +21,4 @@ soc_code \description{ A dataset containing text descriptions and medDRA and EudraCT codes for each system organ class } -\keyword{datasets} +\keyword{datasets} diff --git a/R/eudract/tests/testthat/test_errors.R b/R/eudract/tests/testthat/test_errors.R index 98ebc5a..d6ca6dd 100644 --- a/R/eudract/tests/testthat/test_errors.R +++ b/R/eudract/tests/testthat/test_errors.R @@ -62,6 +62,17 @@ test_that("missing variable",{ expect_error(safety_summary(aes[,-2], exposed=c(700,750,730), soc_index = "soc_term"),"your input data are missing the following variables:") }) + +test_that("Too short group names",{ + + aes <- read.csv(file.path(path,"data/events.csv"), stringsAsFactors = FALSE) + aes$group <- ifelse(aes$group=="Group A", "A", aes$group) + expect_error(safety_summary(aes, exposed=c(700,750,730), soc_index = "soc_term"), + "Group names must be at least 4 characters in length.") + +}) + + test_that("exposed has too few elements",{ aes <- read.csv(file.path(path,"data/events.csv"), stringsAsFactors = FALSE) expect_is(safety_summary(aes, exposed=c(700,750,730), soc_index = "soc_term"),"safety_summary") diff --git a/R/eudract/vignettes/eudract.Rmd b/R/eudract/vignettes/eudract.Rmd index 1db93ba..938f6b4 100644 --- a/R/eudract/vignettes/eudract.Rmd +++ b/R/eudract/vignettes/eudract.Rmd @@ -4,7 +4,7 @@ author: "Simon Bond" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{eudract} + %\VignetteIndexEntry{Eudract Safety XML} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- diff --git a/R/eudract_0.9.3.tar.gz b/R/eudract_0.9.3.tar.gz new file mode 100644 index 0000000..d7bd024 Binary files /dev/null and b/R/eudract_0.9.3.tar.gz differ diff --git a/R/eudract_0.9.3.zip b/R/eudract_0.9.3.zip new file mode 100644 index 0000000..1d38f3b Binary files /dev/null and b/R/eudract_0.9.3.zip differ diff --git a/Stata/Stata Eudract Tools.zip b/Stata/Stata Eudract Tools.zip index 84ea3fc..de63de6 100644 Binary files a/Stata/Stata Eudract Tools.zip and b/Stata/Stata Eudract Tools.zip differ diff --git a/Stata/safety_scriptv0.2.do b/Stata/safety_scriptv0.2.do index 474c564..2ac1e81 100644 --- a/Stata/safety_scriptv0.2.do +++ b/Stata/safety_scriptv0.2.do @@ -20,7 +20,7 @@ save soc_code, replace import delimited using ${datafile} , varnames(1) clear save raw, replace - +* The length of the group names must be 4 characters or longer gen nonserious=1-serious diff --git a/docs/_posts/2021-02-24-stata-bug-fix.md b/docs/_posts/2021-02-24-stata-bug-fix.md new file mode 100644 index 0000000..864b6d6 --- /dev/null +++ b/docs/_posts/2021-02-24-stata-bug-fix.md @@ -0,0 +1,18 @@ +--- +layout: post +title: Stata bug fix and minor improvements. +date: 2021-02-24 +--- + +A bug was identified in the stata code where the serious events were being used to +create the output for the non-serious events. + +SAS code was in error if the SOC code linked to the soc_code data set using soc_term +rather than meddra code. + +Comments added to SAS and Stata to warn that the group names need to be 4 characters +in length. An error is created in the R package for this scenario; new version +released on CRAN. + +Advice provide in the FAQ on how to default to systematic, rather than non-systematic, +as the method of data collection. diff --git a/docs/faq.md b/docs/faq.md index 784cd39..35692e8 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -63,6 +63,24 @@ to clean the data. Yes, please do review and ammend by hand using the Eudract portal manually. You may want to confirm if study-wide default values (AE dictionary, version number, incidence threshold,...) are accurate. +## Systematic vs Non-Systematic reporting + +The majority of studies use non-systematic reporting, whereby a patient is asked what AEs happened to them. +The alternative is where a specific list of AEs is provided and the incidence of each AE is explicitly determined. + +The default in the tool is to assume that non-systematic reporting was used. +To change this manually inside the EudraCT portal would require it to be done for each AE in the list, +which may be too many changes to be practical. + +An automated alternative, _at the user's risk_, is to edit the final xslt file +[simpleToEudraCT.xlst]( {{ site.ghpath }}/xml%20tools/simpleToEudraCT.xslt) +in lines 15 and 71. + +In the R package, this new xslt file would need to be saved locally and the filepath +used as an argument to the `xslt=` argument within `eudract_convert()` . +In SAS, line 297 in the script would need to be edited to use the revised xslt file. +In Stata, line 226 would need to be edited to use the revised xslt file. + ## I want to use my own code to calculate the summary statistics As described in the [Specification]( {{ site.ghpath }}/Specification/Eudract%20Tool%20Specification%20V0.3.docx?raw=true ) this is