This function allows the use of the asr_safety_summary
function outside
of the normal asr
function, which might be desirable to get an overview
of the information in a different format to MS Word.
Usage
asr_dataprep(
data,
trial_type = "imp",
international = FALSE,
period_from = NA,
period_to = NA,
var_class = "class",
var_sae_n = "sae_n",
var_part_id = "record_id",
var_age = "age",
var_sex = "sex",
var_country = "country",
var_site = "site",
var_sae = "sae",
var_date_onset = "sae_date",
var_trt = "trt",
var_date_trt_start = "sae_trtstart",
var_date_trt_stop = "sae_trtstop",
var_outcome = "outcome",
var_comment = "comment",
var_relation = "related",
var_expected = "expected",
var_devdef = "devdef",
var_devattr = "devattr",
var_devint = "devint",
var_safetymeasure = "safetymeasure",
var_tx = NULL
)
Arguments
- data
dataframe containing safety data
- trial_type
one of
imp
,medical device
,other
. Abbreviations OK.- international
internation or national trial (logical)
- period_from
start of reporting period
- period_to
end of reporting period
- 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 occured
- 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 ended
- 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
- var_devattr
variable containing whether the SAE is attributable to the device
- 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
Value
a list of 2 dataframes (data
containing all data submitted to
the function and period_data
which contains only the data for the relevant
period) with variables renamed to those expected by asr_safety_summary
Examples
data(asr_sae)
# IMP
asr_dataprep(asr_sae, period_from = as.Date("2020-10-10"), period_to = as.Date("2021-10-10"))
#> $data
#> sae_date record_id age sex country site sae
#> 9 15/10/2020 131 48 M CH b poor sleep
#> 18 15/10/2020 182 61 M CH c headache
#> 19 15/10/2020 184 51 M CH j spontaneous unconsciousness
#> 6 16/10/2020 66 72 M CH e headache
#> 14 17/10/2020 299 65 F CH e poor sleep
#> 5 20/10/2020 122 49 M CH e spontaneous unconsciousness
#> 16 25/10/2020 117 59 M CH l spontaneous unconsciousness
#> 17 25/10/2020 79 49 M CH d spontaneous unconsciousness
#> 15 26/10/2020 258 73 F CH k death
#> 2 27/10/2020 212 60 F CH f diarhea
#> 8 27/10/2020 108 68 F CH a headache
#> 20 01/11/2020 221 72 F CH d death
#> 3 02/11/2020 195 47 F CH j headache
#> 12 02/11/2020 228 47 M CH j spontaneous unconsciousness
#> 13 06/11/2020 298 55 F CH b spontaneous unconsciousness
#> 1 08/11/2020 40 54 M CH f poor sleep
#> 10 14/11/2020 41 61 F CH n headache
#> 4 17/11/2020 93 62 M CH f spontaneous unconsciousness
#> 7 18/11/2020 175 45 M CH m poor sleep
#> 11 19/11/2020 115 57 F CH f diarhea
#> intervention outcome comment trt class expected devdef devattr devint
#> 9 grp2 Fatal foobar trt3 SAE FALSE TRUE TRUE TRUE
#> 18 grp2 Sequel trt3 SUSAR FALSE FALSE FALSE FALSE
#> 19 grp1 Unknown fribble trt3 SAE TRUE TRUE FALSE FALSE
#> 6 grp2 Resolved foo trt4 SADR FALSE TRUE FALSE TRUE
#> 14 grp1 Improved foo trt2 SUSAR TRUE FALSE TRUE FALSE
#> 5 grp2 Fatal fribble SAE FALSE FALSE FALSE FALSE
#> 16 grp2 Resolved fribble SADR TRUE TRUE TRUE FALSE
#> 17 grp1 Sequel foo SUSAR FALSE FALSE TRUE TRUE
#> 15 grp1 Resolved fribble trt4 SADR FALSE TRUE TRUE FALSE
#> 2 grp1 Sequel foobar trt3 SUSAR FALSE TRUE TRUE TRUE
#> 8 grp1 Improved foo trt2 SAE FALSE TRUE FALSE FALSE
#> 20 grp1 Resolved foobar trt4 SAE FALSE TRUE TRUE FALSE
#> 3 grp2 Sequel fribble trt1 SAE TRUE TRUE FALSE FALSE
#> 12 grp2 Resolved fribble trt2 SAE FALSE FALSE FALSE FALSE
#> 13 grp1 Resolved foo SADR TRUE TRUE TRUE FALSE
#> 1 grp2 Resolved foo trt3 SADR FALSE FALSE TRUE TRUE
#> 10 grp2 Unknown trt3 SUSAR TRUE FALSE FALSE FALSE
#> 4 grp1 Improved foo trt3 SAE TRUE FALSE TRUE TRUE
#> 7 grp2 Resolved bar trt2 SAE FALSE TRUE TRUE FALSE
#> 11 grp1 Fatal foo trt2 SUSAR FALSE FALSE FALSE TRUE
#> safetymeasure sae_n sae_trtstop sae_trtstart related agesex country_site
#> 9 TRUE 1 16/10/2020 16/10/2020 TRUE 48/M b
#> 18 TRUE 2 <NA> 16/10/2020 FALSE 61/M c
#> 19 FALSE 3 <NA> 16/10/2020 FALSE 51/M j
#> 6 TRUE 4 17/10/2020 17/10/2020 FALSE 72/M e
#> 14 FALSE 5 <NA> 18/10/2020 TRUE 65/F e
#> 5 TRUE 6 <NA> <NA> FALSE 49/M e
#> 16 TRUE 7 <NA> <NA> FALSE 59/M l
#> 17 FALSE 8 <NA> <NA> TRUE 49/M d
#> 15 TRUE 9 27/10/2020 27/10/2020 FALSE 73/F k
#> 2 TRUE 10 <NA> 28/10/2020 FALSE 60/F f
#> 8 TRUE 11 <NA> 28/10/2020 FALSE 68/F a
#> 20 FALSE 12 02/11/2020 02/11/2020 FALSE 72/F d
#> 3 TRUE 13 <NA> 03/11/2020 FALSE 47/F j
#> 12 TRUE 14 03/11/2020 03/11/2020 FALSE 47/M j
#> 13 FALSE 15 <NA> <NA> TRUE 55/F b
#> 1 FALSE 16 09/11/2020 09/11/2020 FALSE 54/M f
#> 10 FALSE 17 <NA> 15/11/2020 TRUE 61/F n
#> 4 FALSE 18 <NA> 18/11/2020 FALSE 62/M f
#> 7 TRUE 19 19/11/2020 19/11/2020 FALSE 45/M m
#> 11 TRUE 20 20/11/2020 20/11/2020 FALSE 57/F f
#> trt_dates
#> 9 16/10/2020 - 16/10/2020
#> 18 16/10/2020
#> 19 16/10/2020
#> 6 17/10/2020 - 17/10/2020
#> 14 18/10/2020
#> 5
#> 16
#> 17
#> 15 27/10/2020 - 27/10/2020
#> 2 28/10/2020
#> 8 28/10/2020
#> 20 02/11/2020 - 02/11/2020
#> 3 03/11/2020
#> 12 03/11/2020 - 03/11/2020
#> 13
#> 1 09/11/2020 - 09/11/2020
#> 10 15/11/2020
#> 4 18/11/2020
#> 7 19/11/2020 - 19/11/2020
#> 11 20/11/2020 - 20/11/2020
#>
#> $period_data
#> sae_date record_id age sex country site sae
#> 9 2020-10-15 131 48 M CH b poor sleep
#> 18 2020-10-15 182 61 M CH c headache
#> 19 2020-10-15 184 51 M CH j spontaneous unconsciousness
#> 6 2020-10-16 66 72 M CH e headache
#> 14 2020-10-17 299 65 F CH e poor sleep
#> 5 2020-10-20 122 49 M CH e spontaneous unconsciousness
#> 16 2020-10-25 117 59 M CH l spontaneous unconsciousness
#> 17 2020-10-25 79 49 M CH d spontaneous unconsciousness
#> 15 2020-10-26 258 73 F CH k death
#> 2 2020-10-27 212 60 F CH f diarhea
#> 8 2020-10-27 108 68 F CH a headache
#> 20 2020-11-01 221 72 F CH d death
#> 3 2020-11-02 195 47 F CH j headache
#> 12 2020-11-02 228 47 M CH j spontaneous unconsciousness
#> 13 2020-11-06 298 55 F CH b spontaneous unconsciousness
#> 1 2020-11-08 40 54 M CH f poor sleep
#> 10 2020-11-14 41 61 F CH n headache
#> 4 2020-11-17 93 62 M CH f spontaneous unconsciousness
#> 7 2020-11-18 175 45 M CH m poor sleep
#> 11 2020-11-19 115 57 F CH f diarhea
#> intervention outcome comment trt class expected devdef devattr devint
#> 9 grp2 fatal foobar trt3 SAE FALSE TRUE TRUE TRUE
#> 18 grp2 sequel trt3 SUSAR FALSE FALSE FALSE FALSE
#> 19 grp1 unknown fribble trt3 SAE TRUE TRUE FALSE FALSE
#> 6 grp2 resolved foo trt4 SADR FALSE TRUE FALSE TRUE
#> 14 grp1 improved foo trt2 SUSAR TRUE FALSE TRUE FALSE
#> 5 grp2 fatal fribble SAE FALSE FALSE FALSE FALSE
#> 16 grp2 resolved fribble SADR TRUE TRUE TRUE FALSE
#> 17 grp1 sequel foo SUSAR FALSE FALSE TRUE TRUE
#> 15 grp1 resolved fribble trt4 SADR FALSE TRUE TRUE FALSE
#> 2 grp1 sequel foobar trt3 SUSAR FALSE TRUE TRUE TRUE
#> 8 grp1 improved foo trt2 SAE FALSE TRUE FALSE FALSE
#> 20 grp1 resolved foobar trt4 SAE FALSE TRUE TRUE FALSE
#> 3 grp2 sequel fribble trt1 SAE TRUE TRUE FALSE FALSE
#> 12 grp2 resolved fribble trt2 SAE FALSE FALSE FALSE FALSE
#> 13 grp1 resolved foo SADR TRUE TRUE TRUE FALSE
#> 1 grp2 resolved foo trt3 SADR FALSE FALSE TRUE TRUE
#> 10 grp2 unknown trt3 SUSAR TRUE FALSE FALSE FALSE
#> 4 grp1 improved foo trt3 SAE TRUE FALSE TRUE TRUE
#> 7 grp2 resolved bar trt2 SAE FALSE TRUE TRUE FALSE
#> 11 grp1 fatal foo trt2 SUSAR FALSE FALSE FALSE TRUE
#> safetymeasure sae_n sae_trtstop sae_trtstart related agesex country_site
#> 9 TRUE 1 2020-10-16 2020-10-16 TRUE 48/M b
#> 18 TRUE 2 <NA> 2020-10-16 FALSE 61/M c
#> 19 FALSE 3 <NA> 2020-10-16 FALSE 51/M j
#> 6 TRUE 4 2020-10-17 2020-10-17 FALSE 72/M e
#> 14 FALSE 5 <NA> 2020-10-18 TRUE 65/F e
#> 5 TRUE 6 <NA> <NA> FALSE 49/M e
#> 16 TRUE 7 <NA> <NA> FALSE 59/M l
#> 17 FALSE 8 <NA> <NA> TRUE 49/M d
#> 15 TRUE 9 2020-10-27 2020-10-27 FALSE 73/F k
#> 2 TRUE 10 <NA> 2020-10-28 FALSE 60/F f
#> 8 TRUE 11 <NA> 2020-10-28 FALSE 68/F a
#> 20 FALSE 12 2020-11-02 2020-11-02 FALSE 72/F d
#> 3 TRUE 13 <NA> 2020-11-03 FALSE 47/F j
#> 12 TRUE 14 2020-11-03 2020-11-03 FALSE 47/M j
#> 13 FALSE 15 <NA> <NA> TRUE 55/F b
#> 1 FALSE 16 2020-11-09 2020-11-09 FALSE 54/M f
#> 10 FALSE 17 <NA> 2020-11-15 TRUE 61/F n
#> 4 FALSE 18 <NA> 2020-11-18 FALSE 62/M f
#> 7 TRUE 19 2020-11-19 2020-11-19 FALSE 45/M m
#> 11 TRUE 20 2020-11-20 2020-11-20 FALSE 57/F f
#>
asr_dataprep(asr_sae, period_from = min(asr_sae$sae_date), period_to = Sys.Date())
#> $data
#> sae_date record_id age sex country site sae
#> 9 15/10/2020 131 48 M CH b poor sleep
#> 18 15/10/2020 182 61 M CH c headache
#> 19 15/10/2020 184 51 M CH j spontaneous unconsciousness
#> 6 16/10/2020 66 72 M CH e headache
#> 14 17/10/2020 299 65 F CH e poor sleep
#> 5 20/10/2020 122 49 M CH e spontaneous unconsciousness
#> 16 25/10/2020 117 59 M CH l spontaneous unconsciousness
#> 17 25/10/2020 79 49 M CH d spontaneous unconsciousness
#> 15 26/10/2020 258 73 F CH k death
#> 2 27/10/2020 212 60 F CH f diarhea
#> 8 27/10/2020 108 68 F CH a headache
#> 20 01/11/2020 221 72 F CH d death
#> 3 02/11/2020 195 47 F CH j headache
#> 12 02/11/2020 228 47 M CH j spontaneous unconsciousness
#> 13 06/11/2020 298 55 F CH b spontaneous unconsciousness
#> 1 08/11/2020 40 54 M CH f poor sleep
#> 10 14/11/2020 41 61 F CH n headache
#> 4 17/11/2020 93 62 M CH f spontaneous unconsciousness
#> 7 18/11/2020 175 45 M CH m poor sleep
#> 11 19/11/2020 115 57 F CH f diarhea
#> intervention outcome comment trt class expected devdef devattr devint
#> 9 grp2 Fatal foobar trt3 SAE FALSE TRUE TRUE TRUE
#> 18 grp2 Sequel trt3 SUSAR FALSE FALSE FALSE FALSE
#> 19 grp1 Unknown fribble trt3 SAE TRUE TRUE FALSE FALSE
#> 6 grp2 Resolved foo trt4 SADR FALSE TRUE FALSE TRUE
#> 14 grp1 Improved foo trt2 SUSAR TRUE FALSE TRUE FALSE
#> 5 grp2 Fatal fribble SAE FALSE FALSE FALSE FALSE
#> 16 grp2 Resolved fribble SADR TRUE TRUE TRUE FALSE
#> 17 grp1 Sequel foo SUSAR FALSE FALSE TRUE TRUE
#> 15 grp1 Resolved fribble trt4 SADR FALSE TRUE TRUE FALSE
#> 2 grp1 Sequel foobar trt3 SUSAR FALSE TRUE TRUE TRUE
#> 8 grp1 Improved foo trt2 SAE FALSE TRUE FALSE FALSE
#> 20 grp1 Resolved foobar trt4 SAE FALSE TRUE TRUE FALSE
#> 3 grp2 Sequel fribble trt1 SAE TRUE TRUE FALSE FALSE
#> 12 grp2 Resolved fribble trt2 SAE FALSE FALSE FALSE FALSE
#> 13 grp1 Resolved foo SADR TRUE TRUE TRUE FALSE
#> 1 grp2 Resolved foo trt3 SADR FALSE FALSE TRUE TRUE
#> 10 grp2 Unknown trt3 SUSAR TRUE FALSE FALSE FALSE
#> 4 grp1 Improved foo trt3 SAE TRUE FALSE TRUE TRUE
#> 7 grp2 Resolved bar trt2 SAE FALSE TRUE TRUE FALSE
#> 11 grp1 Fatal foo trt2 SUSAR FALSE FALSE FALSE TRUE
#> safetymeasure sae_n sae_trtstop sae_trtstart related agesex country_site
#> 9 TRUE 1 16/10/2020 16/10/2020 TRUE 48/M b
#> 18 TRUE 2 <NA> 16/10/2020 FALSE 61/M c
#> 19 FALSE 3 <NA> 16/10/2020 FALSE 51/M j
#> 6 TRUE 4 17/10/2020 17/10/2020 FALSE 72/M e
#> 14 FALSE 5 <NA> 18/10/2020 TRUE 65/F e
#> 5 TRUE 6 <NA> <NA> FALSE 49/M e
#> 16 TRUE 7 <NA> <NA> FALSE 59/M l
#> 17 FALSE 8 <NA> <NA> TRUE 49/M d
#> 15 TRUE 9 27/10/2020 27/10/2020 FALSE 73/F k
#> 2 TRUE 10 <NA> 28/10/2020 FALSE 60/F f
#> 8 TRUE 11 <NA> 28/10/2020 FALSE 68/F a
#> 20 FALSE 12 02/11/2020 02/11/2020 FALSE 72/F d
#> 3 TRUE 13 <NA> 03/11/2020 FALSE 47/F j
#> 12 TRUE 14 03/11/2020 03/11/2020 FALSE 47/M j
#> 13 FALSE 15 <NA> <NA> TRUE 55/F b
#> 1 FALSE 16 09/11/2020 09/11/2020 FALSE 54/M f
#> 10 FALSE 17 <NA> 15/11/2020 TRUE 61/F n
#> 4 FALSE 18 <NA> 18/11/2020 FALSE 62/M f
#> 7 TRUE 19 19/11/2020 19/11/2020 FALSE 45/M m
#> 11 TRUE 20 20/11/2020 20/11/2020 FALSE 57/F f
#> trt_dates
#> 9 16/10/2020 - 16/10/2020
#> 18 16/10/2020
#> 19 16/10/2020
#> 6 17/10/2020 - 17/10/2020
#> 14 18/10/2020
#> 5
#> 16
#> 17
#> 15 27/10/2020 - 27/10/2020
#> 2 28/10/2020
#> 8 28/10/2020
#> 20 02/11/2020 - 02/11/2020
#> 3 03/11/2020
#> 12 03/11/2020 - 03/11/2020
#> 13
#> 1 09/11/2020 - 09/11/2020
#> 10 15/11/2020
#> 4 18/11/2020
#> 7 19/11/2020 - 19/11/2020
#> 11 20/11/2020 - 20/11/2020
#>
#> $period_data
#> sae_date record_id age sex country site sae
#> 9 2020-10-15 131 48 M CH b poor sleep
#> 18 2020-10-15 182 61 M CH c headache
#> 19 2020-10-15 184 51 M CH j spontaneous unconsciousness
#> 6 2020-10-16 66 72 M CH e headache
#> 14 2020-10-17 299 65 F CH e poor sleep
#> 5 2020-10-20 122 49 M CH e spontaneous unconsciousness
#> 16 2020-10-25 117 59 M CH l spontaneous unconsciousness
#> 17 2020-10-25 79 49 M CH d spontaneous unconsciousness
#> 15 2020-10-26 258 73 F CH k death
#> 2 2020-10-27 212 60 F CH f diarhea
#> 8 2020-10-27 108 68 F CH a headache
#> 20 2020-11-01 221 72 F CH d death
#> 3 2020-11-02 195 47 F CH j headache
#> 12 2020-11-02 228 47 M CH j spontaneous unconsciousness
#> 13 2020-11-06 298 55 F CH b spontaneous unconsciousness
#> 1 2020-11-08 40 54 M CH f poor sleep
#> 10 2020-11-14 41 61 F CH n headache
#> 4 2020-11-17 93 62 M CH f spontaneous unconsciousness
#> 7 2020-11-18 175 45 M CH m poor sleep
#> 11 2020-11-19 115 57 F CH f diarhea
#> intervention outcome comment trt class expected devdef devattr devint
#> 9 grp2 fatal foobar trt3 SAE FALSE TRUE TRUE TRUE
#> 18 grp2 sequel trt3 SUSAR FALSE FALSE FALSE FALSE
#> 19 grp1 unknown fribble trt3 SAE TRUE TRUE FALSE FALSE
#> 6 grp2 resolved foo trt4 SADR FALSE TRUE FALSE TRUE
#> 14 grp1 improved foo trt2 SUSAR TRUE FALSE TRUE FALSE
#> 5 grp2 fatal fribble SAE FALSE FALSE FALSE FALSE
#> 16 grp2 resolved fribble SADR TRUE TRUE TRUE FALSE
#> 17 grp1 sequel foo SUSAR FALSE FALSE TRUE TRUE
#> 15 grp1 resolved fribble trt4 SADR FALSE TRUE TRUE FALSE
#> 2 grp1 sequel foobar trt3 SUSAR FALSE TRUE TRUE TRUE
#> 8 grp1 improved foo trt2 SAE FALSE TRUE FALSE FALSE
#> 20 grp1 resolved foobar trt4 SAE FALSE TRUE TRUE FALSE
#> 3 grp2 sequel fribble trt1 SAE TRUE TRUE FALSE FALSE
#> 12 grp2 resolved fribble trt2 SAE FALSE FALSE FALSE FALSE
#> 13 grp1 resolved foo SADR TRUE TRUE TRUE FALSE
#> 1 grp2 resolved foo trt3 SADR FALSE FALSE TRUE TRUE
#> 10 grp2 unknown trt3 SUSAR TRUE FALSE FALSE FALSE
#> 4 grp1 improved foo trt3 SAE TRUE FALSE TRUE TRUE
#> 7 grp2 resolved bar trt2 SAE FALSE TRUE TRUE FALSE
#> 11 grp1 fatal foo trt2 SUSAR FALSE FALSE FALSE TRUE
#> safetymeasure sae_n sae_trtstop sae_trtstart related agesex country_site
#> 9 TRUE 1 2020-10-16 2020-10-16 TRUE 48/M b
#> 18 TRUE 2 <NA> 2020-10-16 FALSE 61/M c
#> 19 FALSE 3 <NA> 2020-10-16 FALSE 51/M j
#> 6 TRUE 4 2020-10-17 2020-10-17 FALSE 72/M e
#> 14 FALSE 5 <NA> 2020-10-18 TRUE 65/F e
#> 5 TRUE 6 <NA> <NA> FALSE 49/M e
#> 16 TRUE 7 <NA> <NA> FALSE 59/M l
#> 17 FALSE 8 <NA> <NA> TRUE 49/M d
#> 15 TRUE 9 2020-10-27 2020-10-27 FALSE 73/F k
#> 2 TRUE 10 <NA> 2020-10-28 FALSE 60/F f
#> 8 TRUE 11 <NA> 2020-10-28 FALSE 68/F a
#> 20 FALSE 12 2020-11-02 2020-11-02 FALSE 72/F d
#> 3 TRUE 13 <NA> 2020-11-03 FALSE 47/F j
#> 12 TRUE 14 2020-11-03 2020-11-03 FALSE 47/M j
#> 13 FALSE 15 <NA> <NA> TRUE 55/F b
#> 1 FALSE 16 2020-11-09 2020-11-09 FALSE 54/M f
#> 10 FALSE 17 <NA> 2020-11-15 TRUE 61/F n
#> 4 FALSE 18 <NA> 2020-11-18 FALSE 62/M f
#> 7 TRUE 19 2020-11-19 2020-11-19 FALSE 45/M m
#> 11 TRUE 20 2020-11-20 2020-11-20 FALSE 57/F f
#>