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()))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:
Do the tasks in order. The Events session is the reference; try each task before looking back.
21.3 Task
- (Guided) Build the spine. Reproduce the session’s AE build:
USUBJIDfrom DM,AESEQper subject, verbatimAETERM, emptyAEDECOD. Confirm with code thatAESEQis unique within eachUSUBJIDand that everyAETERMvalue is preserved exactly as in the raw file. - (Guided) Study days. Derive
AESTDTC,AEENDTC,AESTDYandAEENDY. Find every row whereAESTDYis null and explain, for each, why. - (Semi-guided) Severity vs seriousness. Produce a table of event counts by
AESEVandAESER. Then answer, with the numbers: how many serious adverse events were there, how many severe, and why are those two counts different? - (Open-ended) The outcome column. The raw
AEOUTvalueRECOVEREDis not controlled terminology. Find the correct codelist value (codelistC66768), map it, and check it withis_term(). Then write one sentence a reviewer would accept explaining why the raw value could not be submitted as-is.
21.4 Acceptance criteria
TipHint
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.