Flag if patient has a record with null values of AEACNOT1 and AEACNOT2 but AEACNOTH = 'MULTIPLE', so a likely mapping issue

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

Arguments

AE

Adverse Events SDTM dataset with variables USUBJID, AETERM, AESTDTC, AEACNOTH, AEACNOT1/2, AESPID (optional)

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

Ross Farrugia

Examples


AE <- data.frame(
 USUBJID = 1:7,
 AETERM = 1:7,
 AESTDTC = 1:7,
 AEACNOTH = 1:7,
 AEACNOT1 = 1:7,
 AEACNOT2 = 1:7,
 AESPID = "FORMNAME-R:13/L:13XXXX"
)

# pass
check_ae_aeacnoth(AE)
#> [1] TRUE

AE$AEACNOTH[1] = ""
AE$AEACNOT1[1] = ""
AE$AEACNOT2[1] = ""
AE$AEACNOTH[2] = "MULTIPLE"
AE$AEACNOT1[2] = "DOSE REDUCED"
AE$AEACNOT2[2] = "DRUG WITHDRAWN"
AE$AEACNOTH[3] = "MULTIPLE"
AE$AEACNOT1[3] = "DOSE REDUCED"
AE$AEACNOT2[3] = ""
AE$AEACNOTH[4] = "MULTIPLE"
AE$AEACNOT1[4] = ""
AE$AEACNOT2[4] = "DRUG WITHDRAWN"
AE$AEACNOTH[5] = "MULTIPLE"
AE$AEACNOT1[5] = ""
AE$AEACNOT2[5] = ""

# fail
check_ae_aeacnoth(AE)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 3 record(s) with null AEACNOT[1/2] when AEACNOTH = 'MULTIPLE'. "
#> attr(,"data")
#>   USUBJID AETERM AESTDTC AEACNOTH     AEACNOT1       AEACNOT2
#> 1       3      3       3 MULTIPLE DOSE REDUCED               
#> 2       4      4       4 MULTIPLE              DRUG WITHDRAWN
#> 3       5      5       5 MULTIPLE                            
check_ae_aeacnoth(AE,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 3 record(s) with null AEACNOT[1/2] when AEACNOTH = 'MULTIPLE'. "
#> attr(,"data")
#>   USUBJID AETERM AESTDTC AEACNOTH     AEACNOT1       AEACNOT2          RAVE
#> 1       3      3       3 MULTIPLE DOSE REDUCED                FORMNAME-R:13
#> 2       4      4       4 MULTIPLE              DRUG WITHDRAWN FORMNAME-R:13
#> 3       5      5       5 MULTIPLE                             FORMNAME-R:13

AE$AEACNOTH[1] = NA
AE$AEACNOT1[1] = NA
AE$AEACNOT2[1] = NA
AE$AEACNOT2[3] = NA 
AE$AEACNOT1[4] = NA 
AE$AEACNOT1[5] = NA
AE$AEACNOT2[5] = NA

# fail
check_ae_aeacnoth(AE)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 3 record(s) with null AEACNOT[1/2] when AEACNOTH = 'MULTIPLE'. "
#> attr(,"data")
#>   USUBJID AETERM AESTDTC AEACNOTH     AEACNOT1       AEACNOT2
#> 1       3      3       3 MULTIPLE DOSE REDUCED           <NA>
#> 2       4      4       4 MULTIPLE         <NA> DRUG WITHDRAWN
#> 3       5      5       5 MULTIPLE         <NA>           <NA>
check_ae_aeacnoth(AE,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 3 record(s) with null AEACNOT[1/2] when AEACNOTH = 'MULTIPLE'. "
#> attr(,"data")
#>   USUBJID AETERM AESTDTC AEACNOTH     AEACNOT1       AEACNOT2          RAVE
#> 1       3      3       3 MULTIPLE DOSE REDUCED           <NA> FORMNAME-R:13
#> 2       4      4       4 MULTIPLE         <NA> DRUG WITHDRAWN FORMNAME-R:13
#> 3       5      5       5 MULTIPLE         <NA>           <NA> FORMNAME-R:13


AE$AEACNOTH <- NULL
AE$AEACNOT1 <- NULL
AE$AEACNOT2 <- NULL
AE$AESPID <- NULL
check_ae_aeacnoth(AE)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variables: AEACNOTH, AEACNOT1, AEACNOT2"