This check identifies that an infusion drug has same EXSTDTC and EXENDTC dateparts. If time is available for both dates, also check that end time is after start time. Missing start/end dates are also included.

check_ex_infusion_exstdtc_exendtc(EX)

Arguments

EX

Exposure SDTM dataset with variables USUBJID,EXTRT,EXSTDTC,EXENDTC,EXROUTE

Value

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

Author

Anastasiia Khmelnytska, Stella Banjo(HackR 2021)

Examples


EX <- data.frame(
 STUDYID = 1,
 USUBJID = 1:12,
 EXTRT = "SOME DRUG",
 EXROUTE = "INTRAVENOUS",
 EXSTDTC = c("2017-01-01","2017-01-02","2017-01-01T14:36","2015","2017-02","2017"      ,""    ,
             "2017"   ,"2017-01-01T14:26","2017-01-01T14:26","2017-01-01T14","2017-01-01T14:26:01")
             ,
 EXENDTC = c("2017-01-01","2017-01-03","2017-01-01T14:35","2017","2017-01","2016-01-01","2000",
             "2017-02","2017-01-01"      ,"2017-01","2017-01-01T13","2017-01-02T14:26:02")
             ,
 EXOCCUR = "Y",
 VISIT = "CYCLE 1 DAY 1",
 stringsAsFactors=FALSE
)

 check_ex_infusion_exstdtc_exendtc(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "EX has 6 record(s) with issues on date checks and 3 record(s) with issues on date/time checks. "
#> attr(,"data")
#>   USUBJID     EXTRT             EXSTDTC             EXENDTC         VISIT
#> 1       2 SOME DRUG          2017-01-02          2017-01-03 CYCLE 1 DAY 1
#> 2       4 SOME DRUG                2015                2017 CYCLE 1 DAY 1
#> 3       5 SOME DRUG             2017-02             2017-01 CYCLE 1 DAY 1
#> 4       6 SOME DRUG                2017          2016-01-01 CYCLE 1 DAY 1
#> 5       7 SOME DRUG                                    2000 CYCLE 1 DAY 1
#> 6       8 SOME DRUG                2017             2017-02 CYCLE 1 DAY 1
#> 7       3 SOME DRUG    2017-01-01T14:36    2017-01-01T14:35 CYCLE 1 DAY 1
#> 8      11 SOME DRUG       2017-01-01T14       2017-01-01T13 CYCLE 1 DAY 1
#> 9      12 SOME DRUG 2017-01-01T14:26:01 2017-01-02T14:26:02 CYCLE 1 DAY 1
#>                                          check_stat check_flag
#> 1             Different Start/End date for Infusion          A
#> 2             Different Start/End date for Infusion          A
#> 3             Different Start/End date for Infusion          A
#> 4             Different Start/End date for Infusion          A
#> 5                                Missing Start date          C
#> 6             Different Start/End date for Infusion          A
#> 7 Same Start/End date but Start time after End time          D
#> 8 Same Start/End date but Start time after End time          D
#> 9             Different Start/End date for Infusion          A

 EX2 <- data.frame(
 STUDYID = 1,
 USUBJID = 1:4,
 EXTRT = "SOME DRUG",
 EXROUTE = "INTRAVENOUS",
 EXSTDTC = c("2017-01-03", "", "2017-02-01T14:26", ""),
 EXENDTC = c("", "2017-02-03", "", "2017-02-02T14:26:02"),
 EXOCCUR = "Y",
 VISIT = "CYCLE 1 DAY 1",
 stringsAsFactors = FALSE
 )

 check_ex_infusion_exstdtc_exendtc(EX2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "EX has 2 record(s) with issues on date checks and 2 record(s) with issues on date/time checks. "
#> attr(,"data")
#>   USUBJID     EXTRT          EXSTDTC             EXENDTC         VISIT
#> 1       1 SOME DRUG       2017-01-03                     CYCLE 1 DAY 1
#> 2       2 SOME DRUG                           2017-02-03 CYCLE 1 DAY 1
#> 3       3 SOME DRUG 2017-02-01T14:26                     CYCLE 1 DAY 1
#> 4       4 SOME DRUG                  2017-02-02T14:26:02 CYCLE 1 DAY 1
#>                check_stat check_flag
#> 1        Missing End date          B
#> 2      Missing Start date          C
#> 3   Missing End date/time          F
#> 4 Missing Start date/time          G

 EX3 <- data.frame(
     STUDYID = 1,
     USUBJID = 1:3,
     EXTRT = "SOME DRUG",
     EXROUTE = "INTRAVENOUS",
     EXSTDTC = c("2017-01-01", "2017-01-01T14:26", "2017-01-01T14:26"),
     EXENDTC = c("2017-01-01", "2017-01-01", "2017-01"),
     EXOCCUR = "Y",
     VISIT = "CYCLE 1 DAY 1",
     stringsAsFactors=FALSE
 )

 check_ex_infusion_exstdtc_exendtc(EX3)
#> [1] TRUE