As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.
- Task: Would a real study need this derivation, specified this way? Does it follow CDISC SDTM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- Expected output: Would independent QC programming reproduce every value from these inputs and rules?
The other tabs beside Comments are background for assessment, not under review.
Summary
README.mdGoal: create one CM record per reported medication course from long-form Operational Data Model (ODM) item data.
Input: each collected item has its own ODM row. Items belonging to one medication course share the subject, visit, visit repeat, and form repeat identifiers. Items from other forms contribute no CM record.
Variables:
CMTRTkeeps the medication name exactly as reported.CMSTDTCandCMENDTCcome from the same medication occurrence; an ongoing course has a blank end date.CMROUTEandCMINDCkeep that occurrence's route and indication.CMSEQorders courses within a subject by visit (screening before baseline), visit repeat, and form repeat.
Note: A form repeat number reused at a later visit starts a separate course, and a medication reported in two courses gives two records. A course without a reported treatment name contributes no CM record.
Inputs
Under review1 source fileinput/odm.csv
Edit26 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | F |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMTRT | Acetaminophen |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2025-01-01 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMENDTC | 2025-01-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMROUTE | ORAL |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMINDC | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMTRT | Cetirizine |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMSTDTC | 2025-01-05 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMENDTC | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMROUTE | ORAL |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMINDC | Seasonal allergies |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | IG.CM | 1 | IT.CM.CMTRT | Acetaminophen |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2025-01-12 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | IG.CM | 1 | IT.CM.CMENDTC | 2025-01-13 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | IG.CM | 1 | IT.CM.CMROUTE | ORAL |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | IG.CM | 1 | IT.CM.CMINDC | Fever |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMTRT | Hydrocortisone cream |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2025-02-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMENDTC | 2025-02-07 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMROUTE | TOPICAL |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 1 | IT.CM.CMINDC | Rash |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMTRT | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMSTDTC | 2025-02-04 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMENDTC | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMROUTE | ORAL |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | IG.CM | 2 | IT.CM.CMINDC | — |
Expected output
Under review4 expected rowsexpected/cm.csv
Edit4 rows| DOMAIN | STUDYID | USUBJID | CMSEQ | CMTRT | CMSTDTC | CMENDTC | CMROUTE | CMINDC |
|---|---|---|---|---|---|---|---|---|
| CM | YAMAA-01 | 1 | Acetaminophen | 2025-01-01 | 2025-01-03 | ORAL | Headache | |
| CM | YAMAA-01 | 2 | Cetirizine | 2025-01-05 | — | ORAL | Seasonal allergies | |
| CM | YAMAA-01 | 3 | Acetaminophen | 2025-01-12 | 2025-01-13 | ORAL | Fever | |
| CM | YAMAA-01 | 1 | Hydrocortisone cream | 2025-02-03 | 2025-02-07 | TOPICAL | Rash |
Comments and assessment materials
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "CM". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| CMTRT | Reported Name of Drug, Med, or Therapy | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| CMSTDTC | Start Date/Time of Medication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| CMENDTC | End Date/Time of Medication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | ||||
| CMROUTE | Route of Administration | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 7 | ||||
| CMINDC | Indication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 8 | ||||
| CMSEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by EVENTORD then EVENTREPEAT then REPEATKEY. | SDTM | 9 |
| Template | Include when | FORM | CMTRT | CMSTDTC | CMENDTC | CMROUTE | CMINDC |
|---|---|---|---|---|---|---|---|
| collected-occurrence | FORM = 'IG.CM' AND CMTRT IS NOT NULL | Copy ODM.ItemGroupOID | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMTRT' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMSTDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMENDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMROUTE' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMINDC' |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/sdtm-cm-odm-repeated/full.md
Edit20 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per reported medication course.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDTC, CMENDTC, CMROUTE, CMINDC
STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.
Each form repeat within a visit repeat is a separate course, so a form repeat number reused at a later visit starts a separate course, and a medication reported in two courses gives two records. Only CM forms are read, and a course without a reported treatment name gives no record. CMTRT keeps the medication name exactly as reported. CMSTDTC and CMENDTC come from the same course; an ongoing course has no value for the end date. CMROUTE and CMINDC keep that course's route and indication. CMSEQ numbers the subject's courses from 1 by visit (screening before baseline), visit repeat, and form repeat.
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-odm-repeated/conventions.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per reported medication course.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDTC, CMENDTC, CMROUTE, CMINDC
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-odm-repeated/brief.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per reported medication course.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDTC, CMENDTC, CMROUTE, CMINDC
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
run.R
Edit4 lineslibrary(yamaa)cm <- yamaa_domain("spec.yaml")$outputcmrun.py
Edit4 linesimport yamaacm = yamaa.yamaa_domain("spec.yaml").outputcmsolutions/sdtm-cm-odm-repeated/result.R
Edit60 lines# Reference solution for the yamaa benchmark sdtm-cm-odm-repeated (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(readr)library(tidyr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))# One course per form repeat within a visit repeat: subject, visit, visit# repeat, and form repeat. A course without a reported treatment name gives# no record; a repeat number reused at a later visit starts a new course.courses <- odm |> filter(ItemGroupOID == "IG.CM") |> pivot_wider( id_cols = c( StudyOID, SubjectKey, StudyEventOID, StudyEventRepeatKey, ItemGroupRepeatKey ), names_from = ItemOID, values_from = Value, values_fn = first ) |> mutate( CMTRT = `IT.CM.CMTRT`, CMSTDTC = `IT.CM.CMSTDTC`, CMENDTC = `IT.CM.CMENDTC`, CMROUTE = `IT.CM.CMROUTE`, CMINDC = `IT.CM.CMINDC` ) |> filter(!is.na(CMTRT) & CMTRT != "") |> # Courses run by visit (screening before baseline), visit repeat, and # form repeat; the same medication in two courses stays two records. mutate( VISITORD = case_when( StudyEventOID == "SCREENING" ~ 0L, StudyEventOID == "BASELINE" ~ 1L, .default = 2L ), VISITREP = as.integer(StudyEventRepeatKey), IGREP = as.integer(ItemGroupRepeatKey) ) |> arrange(SubjectKey, VISITORD, VISITREP, IGREP) |> group_by(SubjectKey) |> mutate(CMSEQ = row_number()) |> ungroup() |> mutate(DOMAIN = "CM", STUDYID = StudyOID, USUBJID = SubjectKey) |> select( DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDTC, CMENDTC, CMROUTE, CMINDC )dir.create("/app/output", showWarnings = FALSE)write_csv(courses, "/app/output/cm.csv", na = "")solutions/sdtm-cm-odm-repeated/result.py
Edit66 lines# Reference solution for the yamaa benchmark sdtm-cm-odm-repeated (Python track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.from pathlib import Pathimport polars as plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)# One course per form repeat within a visit repeat: subject, visit, visit# repeat, and form repeat. A course without a reported treatment name gives# no record; a repeat number reused at a later visit starts a new course.courses = ( odm.filter(pl.col("ItemGroupOID") == "IG.CM") .pivot( index=[ "StudyOID", "SubjectKey", "StudyEventOID", "StudyEventRepeatKey", "ItemGroupRepeatKey", ], on="ItemOID", values="Value", aggregate_function="first", ) .with_columns( CMTRT=pl.col("IT.CM.CMTRT"), CMSTDTC=pl.col("IT.CM.CMSTDTC"), CMENDTC=pl.col("IT.CM.CMENDTC"), CMROUTE=pl.col("IT.CM.CMROUTE"), CMINDC=pl.col("IT.CM.CMINDC"), ) .filter(pl.col("CMTRT").fill_null("") != "") # Courses run by visit (screening before baseline), visit repeat, and # form repeat; the same medication in two courses stays two records. .with_columns( VISITORD=pl.when(pl.col("StudyEventOID") == "SCREENING") .then(0) .when(pl.col("StudyEventOID") == "BASELINE") .then(1) .otherwise(2), VISITREP=pl.col("StudyEventRepeatKey").cast(pl.Int64), IGREP=pl.col("ItemGroupRepeatKey").cast(pl.Int64), ) .sort(["SubjectKey", "VISITORD", "VISITREP", "IGREP"]) .with_columns(CMSEQ=pl.col("SubjectKey").cum_count().over("SubjectKey")) .with_columns(DOMAIN=pl.lit("CM"), STUDYID=pl.col("StudyOID"), USUBJID=pl.col("SubjectKey")) .select( "DOMAIN", "STUDYID", "USUBJID", "CMSEQ", "CMTRT", "CMSTDTC", "CMENDTC", "CMROUTE", "CMINDC", ))Path("/app/output").mkdir(exist_ok=True)courses.write_csv("/app/output/cm.csv")solutions/sdtm-cm-odm-repeated/result.sas
Edit41 lines/* opensas reference solution for the yamaa benchmark sdtm-cm-odm-repeated. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; run;data wide; length CMTRT CMSTDTC CMENDTC CMROUTE CMINDC CMONGO $1024; retain CMTRT CMSTDTC CMENDTC CMROUTE CMINDC CMONGO; set ordered; where ItemGroupOID='IG.CM'; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; CMTRT=''; CMSTDTC=''; CMENDTC=''; CMROUTE=''; CMINDC=''; CMONGO=''; end; if ItemOID='IT.CM.CMTRT' then CMTRT=Value; if ItemOID='IT.CM.CMSTDTC' then CMSTDTC=Value; if ItemOID='IT.CM.CMENDTC' then CMENDTC=Value; if ItemOID='IT.CM.CMROUTE' then CMROUTE=Value; if ItemOID='IT.CM.CMINDC' then CMINDC=Value; if ItemOID='IT.CM.CMONGO' then CMONGO=Value; if last.ItemGroupRepeatKey then output;run;data prepared; set wide; if not missing(CMTRT); length DOMAIN $2 STUDYID USUBJID $1024; DOMAIN='CM'; STUDYID=StudyOID; USUBJID=SubjectKey;if CMONGO='Y' then CMENDTC=''; VISITORD=2; if StudyEventOID='SCREENING' then VISITORD=0; if StudyEventOID='BASELINE' then VISITORD=1;VISITREP=input(StudyEventRepeatKey,best32.); IGREP=input(ItemGroupRepeatKey,best32.); run;proc sort data=prepared; by STUDYID USUBJID VISITORD VISITREP IGREP; run;data result; set prepared; by STUDYID USUBJID; retain CMSEQ; if first.USUBJID then CMSEQ=0; CMSEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDTC, CMENDTC, CMROUTE, CMINDC from result;quit;proc export data=final outfile="/app/output/cm.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions