R/check_ae_aedthdtc_ds_death.R
check_ae_aedthdtc_ds_death.Rd
This check looks for missing AEDTHDTC values if a patient has a DS record where DSDECOD=DEATH and DSTERM contains ADVERSE EVENT
check_ae_aedthdtc_ds_death(AE, DS)
Adverse Events SDTM dataset with variables USUBJID, AEDTHDTC
Disposition SDTM dataset with variables USUBJID, DSDECOD, DSTERM, DSSTDTC
boolean value if check failed or passed with 'msg' attribute if the test failed
AE <- data.frame(
USUBJID = 1:3,
AEDTHDTC = c(NA,NA,1)
)
# older mapping
DS <- data.frame(
USUBJID = 1:4,
DSTERM = c("DEATH DUE TO ADVERSE EVENT","DEATH DUE TO PROGRESSIVE DISEASE",
"DEATH DUE TO ADVERSE EVENT","DEATH DUE TO ADVERSE EVENT")
,
DSDECOD = rep("DEATH",4),
DSSTDTC = "2020-01-01"
)
check_ae_aedthdtc_ds_death(AE,DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "2 patient(s) where DS.DSDECOD contains 'DEATH' and DS.DSTERM contains 'ADVERSE EVENT' but with no death date in AE.AEDTHDTC (DSTERM mapping only applicable to older studies). "
#> attr(,"data")
#> USUBJID DSTERM DSSTDTC
#> 1 1 DEATH DUE TO ADVERSE EVENT 2020-01-01
#> 2 4 DEATH DUE TO ADVERSE EVENT 2020-01-01
DS$DSSTDTC = NULL
check_ae_aedthdtc_ds_death(AE,DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DS is missing the variable: DSSTDTC"
# newer mapping that
DS <- data.frame(
USUBJID = 1:4,
DSTERM = c("DEATH DUE TO MYOCARDIAL INFARCTION","DEATH DUE TO PROGRESSIVE DISEASE",
"DEATH DUE TO COVID-19","DEATH")
,
DSDECOD = rep("DEATH",4),
DSSTDTC = "2020-01-01"
)
# pass for study with newer mapping, as another function (check_dd_death_date.R) covers this
check_ae_aedthdtc_ds_death(AE,DS)
#> [1] TRUE