data-analysis
From EDC Chaos to SDTM: sdtm-oak Skill for R Agents
A practical look at the sdtm-oak agent skill for generating submission-ready SDTM domain R code from raw clinical data.
Where this fits
A clinical programmer gets raw ae_raw.csv and vs_raw.csv from the EDC system the morning a SDTM deliverable is due. Instead of writing mapping scripts from scratch, an agent using sdtm-oak can inspect the raw columns, ask about visit windows and controlled terminology, and generate domain R code using the {sdtm.oak} framework. This skill fits exactly where raw EDC data must become CDISC-compliant AE, CM, MH, VS, LB, EG, or EX domains with defensible derivations.
Why agents benefit
- It turns a vague mapping request into a concrete executable path: choose sdtm.oak functions, set key variables, and produce a runnable script.
- It keeps derivations consistent: ISO 8601
--DTC, study day--DY, sequence--SEQ, and controlled terminology recoding are encoded in the generated code. - It reduces back-and-forth: the agent pre-checks required inputs such as raw datasets and a CT CSV, then asks only for what is missing.
- It generates human-auditable comments and function calls, so a clinical programmer can review the logic before submission.
- It is scoped to R and sdtm.oak, so the agent is not inventing mapping logic; it follows a known framework.
Practical scenarios
AE mapping with CT recode
Raw AE data has sponsor codes and free-text severity. The agent generates AE domain code that applies MedDRA or sponsor CT mappings, derives AESTDTC and AEENDTC in ISO 8601, and numbers records with AESEQ and study day.
VS findings with visit windows
Unscheduled visits and missing numeric results complicate a vital signs dataset. The agent asks how to handle visit windows, then emits sdtm.oak-based VS code with VSTPT, VSDTC, and VSDY, preserving raw values while flagging missing rows.
EX from dense dosing records
A dosing schedule must become one record per dose or per period. The agent generates EX mapping with sdtm.oak, calculates EXSTDTC and EXENDTC, and checks controlled terminology for route and dose form.
Add it to your agent workflow
Install the skill with:
npx skills add RConsortium/pharma-skills --skill sdtm-oak
Then prompt your agent: 'Use the sdtm-oak skill to generate R code for mapping ex_raw.csv to SDTM EX. Raw data has SUBJID, EXDOSE, EXDOSU, EXROUTE, and start/end datetime columns. CT mappings are in ct.csv.' The agent reads the skill reference, checks inputs, and returns an executable R script for an environment with sdtm.oak, dplyr, and tibble.
Compare before adopting
Compare the following before making this a fixture:
- Quality signals: Is sdtm.oak actively maintained? Are there validation examples in the repository?
- Maintenance freshness: Does the skill track the latest sdtm.oak release and CDISC terminology?
- Alternatives: Would a custom R script, another pharma skill, or a non-R tool be simpler for your domain?
- Workflow fit: Does your environment support R packages and GxP audit needs? The skill expects
sdtm.oak (>= 0.2.0)and a CT CSV.
Why it is worth tracking
The sdtm-oak skill is part of the RConsortium pharma-skills repo with 103 stars and a narrow, well-scoped job: turn raw EDC data into CDISC SDTM using an established R package. Community visibility plus strict scope gives a reliable signal: if sdtm.oak stays maintained, the skill is a useful building block for R-based clinical reporting workflows. Track it on OpenAgentSkill at https://www.openagentskill.com/skills/rconsortium-sdtm-oak, and re-evaluate when the sdtm.oak API changes or the skill adds support for more domain-specific edge cases.
Featured Skill
sdtm-oak
Skill by RConsortium