# Introduction

The European Clinical Trials Database Eudract is run by the European Medicines Agency. All studies that are officially registered clinical trials have to enter the results of the final analysis into the website to be made public. There is a large amount of documentation online that will not be repeated here.

The detailed entering of safety information is an onerous task if it is to be done by hand. However we do have the facility to upload an XML file to automate this step. This R package seeks to enable the production of an XML file from a standard structure of Safety data that is recorded on a patient-level.

The key functions are:

• safety_summary
• simple_safety_xml
• eudract_convert

We provide a dummy safety data set that is one line per patient-event: ?safety. The format of the data, specifically the variable names is described in the help file printed below. This needs to be turned into several frequency tables: one given information at a group level; one given at the event level, broken down into serious and non-serious events. The term “group” here corresponds to treatment arms in a randomised control trial. You need to define a group within Eudract even if it is a one-armed study, in which case it can be a “dummy” label.

Some information is defined in a hard-coded fashion below, but it is understood that this will be generated by code if applied in real life. Each entry in the vectors below correspond to counts in each of the two groups.

subjectsExposed <- c("Control"=99,"Experimental"=101)
#count of deaths not in the Safety data. Could be c(0,0)
deathsExternal <- c("Control"=3,"Experimental"=5)

Coded adverse events are required to be helpful and avoid the task of reconciling minor spelling or text inconsistencies. This package and vignette assumes this is the case, and will not work in the absence of coding. We cannot provide the full MedDRA dictionary, due to copy right reasons. But normally this is available to sponsors. However, for upload into Eudract, as a minimal requirement, only the System Organ Class (SOC) needs to be fully coded into the Eudract internal version coding system. We have provided an internal data set, derived from the eutct site in the package to use this; see ?soc_code.

## Safety data set

 safety R Documentation

## Example of safety data

### Description

A dataset containing some example data of safety event in raw source format

### Usage

safety


### Format

a data frame with 8 columns and 16 rows

pt

meddra preferred term code

subjid

a unique subject identifier

related

a logical indicating if the event is related to the treatment

soc

the meddra code for the System Organ Class

fatal

a numerical 0/1 to indicate if the event was fatal

serious

a numerical 0/1 to indicate if the event was serious

group

the treatment group for the subject

term

a text description of the event. Needs to be matching 1-1 with the pt code

### Details

The data contains one row per patient-event. So the numbers exposed in each arm cannot be inferred from these data, as patients with no events will not be included in these data.

The variable names and formats are those required by safety_summary. The variable pt is not strictly required. An alternative to soc would be the equivalent character string from soc_code

## Calculate Summary Statistics

We provide a function that derives the patient and event counts as required in a format internal to R.

safety_statistics <- safety_summary(safety,
exposed=subjectsExposed,
excess_deaths = deathsExternal,
freq_threshold = 1
)
safety_statistics
## Group-Level Statistics
##
## 1      Control                                     15
## 2 Experimental                                     33
## 1                                        15                                9
## 2                                        24                               22
##   subjectsExposed deathsAllCauses
## 1              99              12
## 2             101              27
##
## Non-serious event-level statistics (intial rows)
##
##     groupTitle subjectsAffected occurrences                    term
## 1      Control                1           1 Acute coronary syndrome
## 2 Experimental                0           0 Acute coronary syndrome
## 3      Control                1           1  Intestinal perforation
## 4 Experimental                0           0  Intestinal perforation
## 5      Control                1           1      Laryngeal stenosis
## 6 Experimental                1           1      Laryngeal stenosis
##        eutctId
## 1 100000004849
## 2 100000004849
## 3 100000004856
## 4 100000004856
## 5 100000004855
## 6 100000004855
##
## Serious event-level statistics (intial rows)
##
##     groupTitle subjectsAffected occurrences                     term
## 1      Control                1           1           Abdominal pain
## 2 Experimental                0           0           Abdominal pain
## 3      Control                1           1 Aortic valve replacement
## 4 Experimental                0           0 Aortic valve replacement
## 5      Control                1           1          B-cell lymphoma
## 6 Experimental                0           0          B-cell lymphoma
##        eutctId occurrencesCausallyRelatedToTreatment deaths
## 1 100000004856                                     0      0
## 2 100000004856                                     0      0
## 3 100000004865                                     0      0
## 4 100000004865                                     0      0
## 5 100000004851                                     0      0
## 6 100000004851                                     0      0
##   deathsCausallyRelatedToTreatment
## 1                                0
## 2                                0
## 3                                0
## 4                                0
## 5                                0
## 6                                0

## Convert to XML

If you have produced these statistics through separate coding, then you can use the eudract:::create.summary_statistics() function to put them into the correct internal format and start the conversion to XML directly.

First we export the safety_statistics to a XML document that is human readable “simple.xml”. Then we convert to the EudraCT format.

simple <- tempfile(fileext = ".xml")
simple_safety_xml(safety_statistics, simple)
## 'C:\Users\sjb277\AppData\Local\Temp\RtmpSceTDd\file3c07f8b1bba.xml' is created or modified
eudract_convert(input=simple,
output=eudract_upload_file)
## 'C:\Users\sjb277\AppData\Local\Temp\RtmpSceTDd\file3c07211178e.xml' is created or modified
## Please email cctu@addenbrookes.nhs.uk to tell us if you have successfully uploaded a study to EudraCT.
## This is to allow us to measure the impact of this tool.

# Output

We can validate the output against the XML schema provided by Eudract, although the call to eudract_convert() does also do this behind the scenes, returning the value TRUE if there are no errors against the schema validation. The schema, was downloaded to this package on 15NOV2016 - note this is a semi-readible file of code/data rather than a standard web page.
myschema <- xml2::read_xml(system.file("extdata","adverseEvents.xsd", package="eudract"))
if(check){print("Validation against the schema has passed!")}
## [1] "Validation against the schema has passed!"