---
title: AEL03
subtitle: Listing of Serious Adverse Events
---
------------------------------------------------------------------------
{{< include ../../_utils/envir_hook.qmd >}}
```{r setup, echo = FALSE, warning = FALSE, message = FALSE}
library(dplyr)
library(rlistings)
adae <- random.cdisc.data::cadae
adae$AESCONG[which(adae$AESER == "Y")[seq(3)]] <- "Y" # To mimic possibility of overlap
out <- adae %>%
filter(AESER == "Y") %>%
mutate(
CPID = paste(SITEID, SUBJID, sep = "/"),
ASR = paste(AGE, SEX, RACE, sep = "/"),
Date_First = toupper(format(as.Date(TRTSDTM), "%d%b%Y")),
Duration = AENDY - ASTDY + 1,
Related = ifelse(AEREL == "Y", "Yes", ifelse(AEREL == "N", "No", "")),
Outcome = case_when(
AEOUT == "FATAL" ~ 1,
AEOUT == "NOT RECOVERED/NOT RESOLVED" ~ 2,
AEOUT == "RECOVERED/RESOLVED" ~ 3,
AEOUT == "RECOVERED/RESOLVED WITH SEQUELAE" ~ 4,
AEOUT == "RECOVERING/RESOLVING" ~ 5,
AEOUT == "UNKNOWN" ~ 6
),
Treated = ifelse(AECONTRT == "Y", "Yes", ifelse(AECONTRT == "N", "No", "")),
Action = case_when(
AEACN == "DOSE INCREASED" ~ 1,
AEACN == "DOSE NOT CHANGED" ~ 2,
AEACN == "DOSE REDUCED" | AEACN == "DOSE RATE REDUCED" ~ 3,
AEACN == "DRUG INTERRUPTED" ~ 4,
AEACN == "DRUG WITHDRAWN" ~ 5,
AEACN == "NOT APPLICABLE" | AEACN == "NOT EVALUABLE" ~ 6,
AEACN == "UNKNOWN" ~ 7
)
) %>%
rowwise() %>%
mutate(
SERREAS = paste(
which(
c(AESDTH, AESLIFE, AESHOSP, AESDISAB, AESCONG, AESMIE) == "Y"
),
collapse = ", "
)
) %>%
ungroup()
out <- out %>%
select(CPID, ASR, TRT01A, AEDECOD, Date_First, ASTDY, Duration, AESEV, Related, Outcome, Treated, Action, SERREAS)
var_labels(out) <- c(
CPID = "Center/Patient ID",
ASR = "Age/Sex/Race",
TRT01A = "Treatment",
AEDECOD = "Adverse\nEvent MedDRA\nPreferred Term",
Date_First = "Date of\nFirst Study\nDrug\nAdministration",
ASTDY = "Study\nDay of\nOnset",
Duration = "AE\nDuration\nin Days",
AESEV = "Most\nExtreme\nIntensity",
Related = "Caused by\nStudy\nDrug",
Outcome = "Outcome\n(1)",
Treated = "Treatment\nfor AE",
Action = "Action\nTaken\n(2)",
SERREAS = "Reason\nClassified\nas Serious\n(3)"
)
```
```{r include = FALSE}
webr_code_labels <- c("setup")
```
{{< include ../../_utils/webr_no_include.qmd >}}
## Output
:::: panel-tabset
## Standard Listing
::: {.panel-tabset .nav-justified group="webr"}
## {{< fa regular file-lines sm fw >}} Preview
```{r lsting, test = list(lsting = "lsting")}
lsting <- as_listing(
out,
key_cols = c("TRT01A", "CPID", "ASR"),
disp_cols = names(out),
main_title = "Listing of Serious Adverse Events",
main_footer = "
(1) Outcome: 1 = fatal; 2 = not recovered/not resolved; 3 = recovered/resolved;
4 = recovered/resolved with sequelae; 5 = recovering/resolving; 6 = unknown.
(2) Action taken with study drug: 1 = dose increased; 2 = dose not changed;
3 = dose reduced; 4 = drug interrupted; 5 = drug withdrawn; 6 = not applicable;
7 = unknown.
(3) Reason classified as serious: 1 = resulted in death; 2 = life threatening;
3 = required prolonged in patient hospitalization; 4 = disabling;
5 = a congenital anomaly/birth defect in offspring of study subject;
6 = does not meet any of the above serious criteria, but may jeopardize the subject,
and may require medical or surgical intervention to prevent one of the outcomes listed above.
* Study day derived from imputed onset date.
** Duration derived from imputed onset date and/or end date."
)
head(lsting, 20)
```
```{r include = FALSE}
webr_code_labels <- c("lsting")
```
{{< include ../../_utils/webr.qmd >}}
:::
## Data Setup
```{r setup}
#| code-fold: show
```
::::
{{< include ../../_utils/save_results.qmd >}}
{{< include ../../repro.qmd >}}