As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.
We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.
Summary
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
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:
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 |
Human review and assessment
| 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.7 | 2026-10-20 | yamaa docs build | Read a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default | ||
| 1.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part | ||
| 1.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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
Edit23 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
DOMAIN is "CM". STUDYID is the study OID and USUBJID is the subject key of the ODM data, each as given. Each ODM row holds one collected item, and the items that share a subject, a visit, a visit repeat number, and a form repeat number make up one medication course. Only items from the IG.CM form contribute: items from other forms contribute no CM record. A course with no reported treatment name contributes no CM record. CMTRT is the medication name exactly as reported for the course. CMSTDTC is the start date and CMENDTC the end date reported for that same course, and an ongoing course has no value for CMENDTC. CMROUTE and CMINDC are the route and indication reported for that same course. A form repeat number reused at a later visit starts a separate course, and a medication reported in two courses gives two records. CMSEQ numbers a subject's courses from 1, in visit order with screening before baseline, then by visit repeat number, then by form repeat number.
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-odm-repeated/conventions.md
Edit10 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
DOMAIN is "CM".
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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/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
Edit104 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.import csvfrom collections import OrderedDictINPUT = "/app/input/odm.csv"OUTPUT = "/app/output/cm.csv"# Visit ordering: screening before baseline; any other visit follows in# order of first appearance in the data.VISIT_ORDER = {"SCREENING": 0, "BASELINE": 1}with open(INPUT, newline="", encoding="utf-8") as f: rows = list(csv.DictReader(f))visit_seen = {}for row in rows: v = row["StudyEventOID"] if v not in visit_seen: visit_seen[v] = len(visit_seen)def visit_key(visit): if visit in VISIT_ORDER: return (0, VISIT_ORDER[visit]) return (1, visit_seen[visit])# Group IG.CM items into courses keyed by subject, visit, visit repeat,# and form repeat.courses = OrderedDict()for row in rows: if row["ItemGroupOID"] != "IG.CM": continue key = ( row["StudyOID"], row["SubjectKey"], row["StudyEventOID"], int(row["StudyEventRepeatKey"]), int(row["ItemGroupRepeatKey"]), ) item = row["ItemOID"].rsplit(".", 1)[-1] courses.setdefault(key, {})[item] = row["Value"]records = []for (studyid, usubjid, visit, visit_rep, form_rep), items in courses.items(): cmtrt = items.get("CMTRT", "") if not cmtrt: # A course with no reported treatment name contributes no record. continue records.append( { "STUDYID": studyid, "USUBJID": usubjid, "CMTRT": cmtrt, "CMSTDTC": items.get("CMSTDTC", ""), "CMENDTC": items.get("CMENDTC", ""), "CMROUTE": items.get("CMROUTE", ""), "CMINDC": items.get("CMINDC", ""), "_sort": (usubjid, visit_key(visit), visit_rep, form_rep), } )records.sort(key=lambda r: r["_sort"])out = []seq_by_subject = {}for rec in records: seq_by_subject[rec["USUBJID"]] = seq_by_subject.get(rec["USUBJID"], 0) + 1 out.append( { "DOMAIN": "CM", "STUDYID": rec["STUDYID"], "USUBJID": rec["USUBJID"], "CMSEQ": seq_by_subject[rec["USUBJID"]], "CMTRT": rec["CMTRT"], "CMSTDTC": rec["CMSTDTC"], "CMENDTC": rec["CMENDTC"], "CMROUTE": rec["CMROUTE"], "CMINDC": rec["CMINDC"], } )with open(OUTPUT, "w", newline="", encoding="utf-8") as f: writer = csv.DictWriter( f, fieldnames=[ "DOMAIN", "STUDYID", "USUBJID", "CMSEQ", "CMTRT", "CMSTDTC", "CMENDTC", "CMROUTE", "CMINDC", ], ) writer.writeheader() writer.writerows(out)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