Review ask

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.

  1. 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.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. 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

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Goal: 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:

  • CMTRT keeps the medication name exactly as reported.
  • CMSTDTC and CMENDTC come from the same medication occurrence; an ongoing course has a blank end date.
  • CMROUTE and CMINDC keep that occurrence's route and indication.
  • CMSEQ orders 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 review
1 source file

input/odm.csv

Edit
26 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.DM1IT.DM.SEXF
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM1IT.CM.CMTRTAcetaminophen
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM1IT.CM.CMSTDTC2025-01-01
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM1IT.CM.CMENDTC2025-01-03
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM1IT.CM.CMROUTEORAL
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM1IT.CM.CMINDCHeadache
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM2IT.CM.CMTRTCetirizine
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM2IT.CM.CMSTDTC2025-01-05
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM2IT.CM.CMENDTC—
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM2IT.CM.CMROUTEORAL
YAMAA-01MDV.1YAMAA-01-0001SCREENING1IG.CM2IT.CM.CMINDCSeasonal allergies
YAMAA-01MDV.1YAMAA-01-0001BASELINE1IG.CM1IT.CM.CMTRTAcetaminophen
YAMAA-01MDV.1YAMAA-01-0001BASELINE1IG.CM1IT.CM.CMSTDTC2025-01-12
YAMAA-01MDV.1YAMAA-01-0001BASELINE1IG.CM1IT.CM.CMENDTC2025-01-13
YAMAA-01MDV.1YAMAA-01-0001BASELINE1IG.CM1IT.CM.CMROUTEORAL
YAMAA-01MDV.1YAMAA-01-0001BASELINE1IG.CM1IT.CM.CMINDCFever
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM1IT.CM.CMTRTHydrocortisone cream
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM1IT.CM.CMSTDTC2025-02-03
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM1IT.CM.CMENDTC2025-02-07
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM1IT.CM.CMROUTETOPICAL
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM1IT.CM.CMINDCRash
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM2IT.CM.CMTRT—
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM2IT.CM.CMSTDTC2025-02-04
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM2IT.CM.CMENDTC—
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM2IT.CM.CMROUTEORAL
YAMAA-01MDV.1YAMAA-01-0002SCREENING1IG.CM2IT.CM.CMINDC—

Expected output

Under review
4 expected rows

expected/cm.csv

Edit
4 rows
expected/cm.csv
DOMAINSTUDYIDUSUBJIDCMSEQCMTRTCMSTDTCCMENDTCCMROUTECMINDC
CMYAMAA-011Acetaminophen2025-01-012025-01-03ORALHeadache
CMYAMAA-012Cetirizine2025-01-05—ORALSeasonal allergies
CMYAMAA-013Acetaminophen2025-01-122025-01-13ORALFever
CMYAMAA-011Hydrocortisone cream2025-02-032025-02-07TOPICALRash
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository Discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "CM".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
CMTRTReported Name of Drug, Med, or TherapyCharDerivedSet per constructed row; see the Row construction sheet.SDTM4
CMSTDTCStart Date/Time of MedicationCharDerivedSet per constructed row; see the Row construction sheet.SDTM5
CMENDTCEnd Date/Time of MedicationCharDerivedSet per constructed row; see the Row construction sheet.SDTM6
CMROUTERoute of AdministrationCharDerivedSet per constructed row; see the Row construction sheet.SDTM7
CMINDCIndicationCharDerivedSet per constructed row; see the Row construction sheet.SDTM8
CMSEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by EVENTORD then EVENTREPEAT then REPEATKEY.SDTM9
TemplateInclude whenFORMCMTRTCMSTDTCCMENDTCCMROUTECMINDC
collected-occurrenceFORM = 'IG.CM' AND CMTRT IS NOT NULLCopy ODM.ItemGroupOIDAggregate 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'
VersionDateAuthorDescriptionReviewerSign-off
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/sdtm-cm-odm-repeated/full.md

Edit
20 lines

Following 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

Edit
8 lines

Following 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

Edit
8 lines

Following 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.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)cm <- yamaa_domain("spec.yaml")$outputcm

run.py

Edit
4 lines
import yamaacm = yamaa.yamaa_domain("spec.yaml").outputcm

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/sdtm-cm-odm-repeated/result.R

Edit
60 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

Edit
66 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

Edit
41 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;