This check identifies AESTDTC values that are after AEENDTC values

check_ae_aestdtc_after_aeendtc(AE, preproc = identity, ...)

Arguments

AE

Adverse Event SDTM dataset with variables USUBJID,AETERM,AEDECOD,AESTDTC,AEENDTC

preproc

An optional company specific preprocessing script

...

Other arguments passed to methods

Value

boolean value if check failed or passed with 'msg' attribute if the test failed

Author

Sara Bodach

Examples


AE <- data.frame(
 USUBJID = 1:12,
 AETERM = "SOME AE TERM",
 AEDECOD = "SOME AE PT",
 AESTDTC = c("2017-01-01","2017-01-03","2017-01-01T14:26","2017","2017-02","2017"      ,""    ,
             "2017"   ,"2017-01-01T14:26","2017-01-01T14:26","2017-01-01T14","2017-01-01T14:26:02")
             ,
 AEENDTC = c("2017-01-01","2017-01-02","2017-01-01T14:25","2015","2017-01","2016-01-01",
             "2000","2017-02","2017-01-01"      ,"2017-01","2017-01-01T13","2017-01-01T14:26:01")
             ,
 AESPID = "FORMNAME-R:19/L:19XXXX",
 stringsAsFactors=FALSE
)

check_ae_aestdtc_after_aeendtc(AE)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 6 records with AESTDTC after AEENDTC. "
#> attr(,"data")
#>   USUBJID       AETERM    AEDECOD          AESTDTC          AEENDTC
#> 1       2 SOME AE TERM SOME AE PT       2017-01-03       2017-01-02
#> 2       3 SOME AE TERM SOME AE PT 2017-01-01T14:26 2017-01-01T14:25
#> 3       4 SOME AE TERM SOME AE PT             2017             2015
#> 4       5 SOME AE TERM SOME AE PT          2017-02          2017-01
#> 5       6 SOME AE TERM SOME AE PT             2017       2016-01-01
#> 6      11 SOME AE TERM SOME AE PT    2017-01-01T14    2017-01-01T13
check_ae_aestdtc_after_aeendtc(AE,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 6 records with AESTDTC after AEENDTC. "
#> attr(,"data")
#>   USUBJID       AETERM    AEDECOD          AESTDTC          AEENDTC
#> 1       2 SOME AE TERM SOME AE PT       2017-01-03       2017-01-02
#> 2       3 SOME AE TERM SOME AE PT 2017-01-01T14:26 2017-01-01T14:25
#> 3       4 SOME AE TERM SOME AE PT             2017             2015
#> 4       5 SOME AE TERM SOME AE PT          2017-02          2017-01
#> 5       6 SOME AE TERM SOME AE PT             2017       2016-01-01
#> 6      11 SOME AE TERM SOME AE PT    2017-01-01T14    2017-01-01T13
#>            RAVE
#> 1 FORMNAME-R:19
#> 2 FORMNAME-R:19
#> 3 FORMNAME-R:19
#> 4 FORMNAME-R:19
#> 5 FORMNAME-R:19
#> 6 FORMNAME-R:19

AE$AETERM <- NULL
check_ae_aestdtc_after_aeendtc(AE)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variable: AETERM"