21  Exercise 2: SDTM Events (Adverse Events)

21.1 Goal

Finish the AE domain slice from The Events session and use it to answer the questions a safety reviewer actually asks.

21.2 Setup

Work from the project root. The AE raw file and the DM dataset you built last session are both inputs:

library(tidyverse)
library(sdtm.terminology)

ae_raw <- read_csv("data/raw/ae_raw.csv", show_col_types = FALSE,
                   col_types = cols(.default = col_character()))
dm <- read_csv("data/sdtm/dm.csv", show_col_types = FALSE,
               col_types = cols(.default = col_character()))

Do the tasks in order. The Events session is the reference; try each task before looking back.

21.3 Task

  1. (Guided) Build the spine. Reproduce the session’s AE build: USUBJID from DM, AESEQ per subject, verbatim AETERM, empty AEDECOD. Confirm with code that AESEQ is unique within each USUBJID and that every AETERM value is preserved exactly as in the raw file.
  2. (Guided) Study days. Derive AESTDTC, AEENDTC, AESTDY and AEENDY. Find every row where AESTDY is null and explain, for each, why.
  3. (Semi-guided) Severity vs seriousness. Produce a table of event counts by AESEV and AESER. Then answer, with the numbers: how many serious adverse events were there, how many severe, and why are those two counts different?
  4. (Open-ended) The outcome column. The raw AEOUT value RECOVERED is not controlled terminology. Find the correct codelist value (codelist C66768), map it, and check it with is_term(). Then write one sentence a reviewer would accept explaining why the raw value could not be submitted as-is.

21.4 Acceptance criteria

Task 2: AESTDY is null wherever AESTDTC is null. You cannot count days from a reference date without a date. There is exactly one such event in GLPX-1 (defect D4).

Task 3: the serious count comes only from AESER == "Y"; the severe count from AESEV == "SEVERE". If those two numbers are equal, you have counted the same column twice.

Solutions are in the paid tier.