Flag if patient has a record with null value of AEREL but AEREL1 - AERELN contain 'Y'/'N'/'NA', so a likely mapping issue or if AEREL is missing and there is no any AERELn variable or if AEREL has unexpected value

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

Arguments

AE

Adverse Events SDTM dataset with variables USUBJID, AESEQ, AETERM, AESTDTC, AEREL, AERELn, AESPID (if present)

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

Vira Vrakina

Examples


AE <- data.frame(
    STUDYID = 1001,
    USUBJID = c(1,2,3,1,2,3),
    AESTDTC = rep('2020-05-05',6),
    AETERM  = c("abc Covid-19", "covid TEST POSITIVE","CHILLS"),
    AESEQ   = c(1,1,1,2,2,2),
    AEREL   = c("Y", "N", "NA", "N", "N", "Y"),
    AEREL1  = c("Y", "N", "NA", "N", "NA", "Y"),
    AEREL2  = c("Y", "N", "NA", "N", "N", "N"),
    AESPID = "FORMNAME-R:13/L:13XXXX",
    stringsAsFactors = FALSE
)

check_ae_aerel(AE)
#> [1] TRUE

AE1 <- data.frame(
    STUDYID = 1001,
    USUBJID = c(1,2,3,1,2,3),
    AESTDTC = rep('2020-05-05',6),
    AETERM  = c("abc Covid-19", "covid TEST POSITIVE","CHILLS"),
    AESEQ   = c(1,1,1,2,2,2),
    AEREL   = c("Y", "N", "N", "N", "N", "N"),
    AEREL1  = c("Y", "N", "NA", "N", "N", ""),
    AEREL2  = c("Y", "N", " ", "N", "N", " "),
    AESPID = "FORMNAME-R:13/L:13XXXX",
    stringsAsFactors = FALSE
)

check_ae_aerel(AE1)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC AETERM AEREL AEREL1 AEREL2
#> 1       3 2020-05-05 CHILLS     N     NA       
#> 2       3 2020-05-05 CHILLS     N              
check_ae_aerel(AE1,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC AETERM          RAVE AEREL AEREL1 AEREL2
#> 1       3 2020-05-05 CHILLS FORMNAME-R:13     N     NA       
#> 2       3 2020-05-05 CHILLS FORMNAME-R:13     N              

AE2 <- data.frame(
    STUDYID = 1001,
    USUBJID = c(1,2,3,1,2,3),
    AESTDTC = rep('2020-05-05',6),
    AETERM  = c("abc Covid-19", "covid TEST POSITIVE","CHILLS"),
    AESEQ   = c(1,1,1,2,2,2),
    AEREL   = c("Y", "N", " ", "N", "N", " "),
    AEREL1  = c("NA", "N", "NA", "Y", "N", " "),
    AEREL2  = c("Y", "N", " ", "N", "N", " "),
    AESPID = "FORMNAME-R:13/L:13XXXX",
    stringsAsFactors = FALSE
)

check_ae_aerel(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC       AETERM AEREL AEREL1 AEREL2
#> 1       1 2020-05-05 abc Covid-19     N      Y      N
#> 2       3 2020-05-05       CHILLS           NA       
check_ae_aerel(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC       AETERM          RAVE AEREL AEREL1 AEREL2
#> 1       1 2020-05-05 abc Covid-19 FORMNAME-R:13     N      Y      N
#> 2       3 2020-05-05       CHILLS FORMNAME-R:13           NA       

AE3 <- data.frame(
    STUDYID = 1001,
    USUBJID = c(1,2,3,1,2,3),
    AESTDTC = rep('2020-05-05',6),
    AETERM  = c("abc Covid-19", "covid TEST POSITIVE","CHILLS"),
    AESEQ   = c(1,1,1,2,2,2),
    AEREL   = c("Y", " ", " ", "N", " ", "NA"),
    AESPID = "FORMNAME-R:13/L:13XXXX",
    stringsAsFactors = FALSE
)

check_ae_aerel(AE3)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 3 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC              AETERM AEREL
#> 1       2 2020-05-05 covid TEST POSITIVE      
#> 2       3 2020-05-05              CHILLS      
#> 3       2 2020-05-05 covid TEST POSITIVE      
check_ae_aerel(AE3,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 3 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC              AETERM          RAVE AEREL
#> 1       2 2020-05-05 covid TEST POSITIVE FORMNAME-R:13      
#> 2       3 2020-05-05              CHILLS FORMNAME-R:13      
#> 3       2 2020-05-05 covid TEST POSITIVE FORMNAME-R:13      


AE4 <- data.frame(
    STUDYID = 1001,
    USUBJID = c(1,2,3,4,5,6),
    AESTDTC = rep('2020-05-05',6),
    AETERM  = c("abc Covid-19", "covid TEST POSITIVE","CHILLS"),
    AESEQ   = c(1,2,3,4,5,6),
    AEREL   = c("Y", "Y", "N", "", "Y", "NA"),
    AEREL1  = "",
    AEREL2  = "",
    AESPID = "FORMNAME-R:13/L:13XXXX",
    stringsAsFactors = FALSE
)

check_ae_aerel(AE4)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 5 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC              AETERM AEREL AEREL1 AEREL2
#> 1       1 2020-05-05        abc Covid-19     Y              
#> 2       2 2020-05-05 covid TEST POSITIVE     Y              
#> 3       5 2020-05-05 covid TEST POSITIVE     Y              
#> 4       3 2020-05-05              CHILLS     N              
#> 5       4 2020-05-05        abc Covid-19                    
check_ae_aerel(AE4,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 5 observations where AEREL is missing but one of AEREL1 - AEREL[n] is equal to Y/N/NA, or AEREL has an unexpected value, or AEREL[n] missing. "
#> attr(,"data")
#>   USUBJID    AESTDTC              AETERM          RAVE AEREL AEREL1 AEREL2
#> 1       1 2020-05-05        abc Covid-19 FORMNAME-R:13     Y              
#> 2       2 2020-05-05 covid TEST POSITIVE FORMNAME-R:13     Y              
#> 3       5 2020-05-05 covid TEST POSITIVE FORMNAME-R:13     Y              
#> 4       3 2020-05-05              CHILLS FORMNAME-R:13     N              
#> 5       4 2020-05-05        abc Covid-19 FORMNAME-R:13