library(tidyverse)
library(sdtm.terminology)
dm_raw <- read_csv("data/raw/dm_raw.csv", show_col_types = FALSE,
col_types = cols(.default = col_character()))
ex_raw <- read_csv("data/raw/ex_raw.csv", show_col_types = FALSE,
col_types = cols(.default = col_character()))20 Exercise 1: SDTM Demographics
20.1 Goal
Rebuild the core of the GLPX-1 DM dataset yourself, including the three decisions that make it more than a rename, and defend the result.
20.2 Setup
Work from the project root, with the session’s packages loaded:
Do the tasks in order: each builds on the last. The DM Domain session is the reference; try each task before looking back at how the session did the equivalent step.
20.3 Task
- (Guided) The identifier block. Reduce
dm_rawto one row per subject, then buildSTUDYID,DOMAIN,USUBJIDandSUBJID. Confirm (with code, not by inspection) thatUSUBJIDis unique and that no identifier would change if a subject moved sites. - (Guided) The clock. Derive
RFSTDTC,RFENDTC,RFXSTDTCandRFXENDTCfrom the dosing file. Then compute the study day of2024-03-05and2024-03-06for subject101-012(first dose 2024-03-06) and check you get −1 and 1. - (Semi-guided) Defend the nulls. Identify every subject whose
AGEmust be null, and write one sentence per subject saying why- naming the precision of the birth date you refused to extend. Then name two columns that must be present-but-null and two that must be absent, and say which core designation produces each fate.
- (Open-ended) The decision log. Write the two decision-log entries a reviewer would want for this dataset: the one-row resolution for
101-012and the SEX resolution for111-003. Each entry: what conflicted, what rule was applied, why that rule, and what was queried. Aim for the register of study documentation, not a chat message.
20.4 Acceptance criteria
Task 2’s check is the two-branch rule from the session: before the reference date, the study day is the plain date difference; on or after it, the difference plus one. If you got 0 for 2024-03-05, you used one branch for both dates.
Task 4’s entries need three ingredients each: the conflict, the rule (one row per person; site-entered source outranks a downstream copy), and the action taken (SUPPDM note; query to the lab).
Solutions are in the paid tier.