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: build one Disposition (DS) record per subject
for each of two milestones: end of treatment and end of
study, carrying the reported reason (DSTERM), the
controlled reason (DSDECOD), the milestone (DSSCAT),
the category (DSCAT) and the start date (DSSTDTC),
with DSSEQ numbering the subject's two milestones.
Input: EDC output in long form, one row per collected item; each row names the subject, the visit (end of treatment or end of study), the item (completion flag, reason text, controlled code, or date) and the value, in no particular order.
Variables:
DSSEQnumbers the subject's milestones in the order a subject reaches them:1for end of treatment and2for end of study. WithSTUDYIDandUSUBJIDit identifies the record.DSCATis alwaysDISPOSITION EVENT.DSSCATnames the milestone:STUDY TREATMENTfor the end-of-treatment form andSTUDYfor the end-of-study form.DSTERMholds the reported term:COMPLETEDwhen the completion flag says so, else the collected reason text.DSDECODholds the controlled term:COMPLETEDwhen completed, else the collected code, which must beADVERSE EVENTorOTHER.DSSTDTCis the collected start date for that milestone.
Note: the completion flag, the reason, the code and
the date of one milestone are four separate collected
rows. One record covers all four, and each variable reads
its own item, so the order of the input rows never
reaches the output. Records are listed by subject and
then by DSSEQ.
Provenance: DSCAT/DSSCAT/DSTERM/DSDECOD follow
the CDISC SDTMIG DS assumptions, and the controlled terms
follow the FDA Technical Conformance Guide DS guidance.
All subjects, dates and reasons are invented fixtures.
Inputs
Under review1 source fileinput/odm.csv
Edit24 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.REASON | Moving abroad |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.REASON | Severe nausea |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.DTC | 2024-02-28 |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.DTC | 2024-06-18 |
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.DTC | 2024-05-10 |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.DTC | 2024-04-02 |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.DTC | 2024-06-20 |
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.COMP | DISCONTINUED |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.COMP | DISCONTINUED |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.DTC | 2024-03-15 |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.REASONCD | OTHER |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.REASONCD | ADVERSE EVENT |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
Expected output
Under review6 expected rowsexpected/ds.csv
Edit6 rows| DOMAIN | STUDYID | USUBJID | DSSEQ | DSCAT | DSSCAT | DSTERM | DSDECOD | DSSTDTC |
|---|---|---|---|---|---|---|---|---|
| DS | STUDY01 | 1 | DISPOSITION EVENT | STUDY TREATMENT | COMPLETED | COMPLETED | 2024-03-15 | |
| DS | STUDY01 | 2 | DISPOSITION EVENT | STUDY | COMPLETED | COMPLETED | 2024-06-20 | |
| DS | STUDY01 | 1 | DISPOSITION EVENT | STUDY TREATMENT | Severe nausea | ADVERSE EVENT | 2024-04-02 | |
| DS | STUDY01 | 2 | DISPOSITION EVENT | STUDY | COMPLETED | COMPLETED | 2024-06-18 | |
| DS | STUDY01 | 1 | DISPOSITION EVENT | STUDY TREATMENT | COMPLETED | COMPLETED | 2024-02-28 | |
| DS | STUDY01 | 2 | DISPOSITION EVENT | STUDY | Moving abroad | OTHER | 2024-05-10 |
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 | DS | Assigned | Set constant value "DS". | 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 | ||||
| DSSEQ | Sequence Number | Num | 1, 2 | Collected | Recode ODM.StudyEventOID: "EOT" → "1", "EOS" → "2"; missing values stay missing; unlisted values are errors. | SDTM | 4 | |||
| DSCAT | Category for Disposition Event | Char | DISPOSITION EVENT | Assigned | Set constant value "DISPOSITION EVENT". | SDTM | 5 | |||
| DSSCAT | Subcategory for Disposition Event | Char | STUDY TREATMENT, STUDY | Collected | Recode ODM.StudyEventOID: "EOT" → "STUDY TREATMENT", "EOS" → "STUDY"; missing values stay missing; unlisted values are errors. | SDTM | 6 | |||
| DSTERM | Reported Term for the Disposition Event | Char | Derived | If COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise copy value from ODM.Value where ODM.ItemOID = 'IT.DS.REASON'. | SDTM | 7 | ||||
| DSDECOD | Standardized Disposition Term | Char | COMPLETED, ADVERSE EVENT, OTHER | Derived | If COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise copy value from ODM.Value where ODM.ItemOID = 'IT.DS.REASONCD'. | SDTM | 8 | |||
| DSSTDTC | Start Date/Time of Disposition Event | Char | ISO 8601 | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DS.DTC'. | SDTM | 9 |
| Variable | Permitted values |
|---|---|
| DOMAIN | DS |
| DSSEQ | 1, 2 |
| DSCAT | DISPOSITION EVENT |
| DSSCAT | STUDY TREATMENT, STUDY |
| DSDECOD | COMPLETED, ADVERSE EVENT, OTHER |
| 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-ds-reasons/full.md
Edit29 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject for each of the two milestones: end of treatment and end of study.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC
- DOMAIN is "DS".
- STUDYID is the ODM study OID and USUBJID is the ODM subject key, each as given.
- DSSEQ is 1 for the end-of-treatment milestone and 2 for the end-of-study milestone.
- DSCAT is always "DISPOSITION EVENT".
- DSSCAT is "STUDY TREATMENT" for the end-of-treatment milestone and "STUDY" for the end-of-study milestone.
- DSTERM is "COMPLETED" when the completion flag for the milestone is "COMPLETED", and the collected reason text otherwise.
- DSDECOD is "COMPLETED" when the completion flag for the milestone is "COMPLETED", and the collected controlled code otherwise.
- The collected controlled code is "ADVERSE EVENT" or "OTHER".
- DSSTDTC is the start date collected for the milestone.
- The completion flag, reason text, controlled code, and start date of a milestone are collected as separate items, and the record for the milestone carries the values of that milestone's items, in whatever order the input rows hold them.
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
prompts/sdtm-ds-reasons/conventions.md
Edit16 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject for each of the two milestones: end of treatment and end of study.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC
- DOMAIN is "DS".
- DSCAT is always "DISPOSITION EVENT".
- DSSCAT is "STUDY TREATMENT" or "STUDY".
- DSTERM is "COMPLETED" or the collected reason text.
- DSDECOD is "COMPLETED" or the collected controlled code.
- The collected controlled code is "ADVERSE EVENT" or "OTHER".
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
prompts/sdtm-ds-reasons/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject for each of the two milestones: end of treatment and end of study.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-ds-reasons/result.R
Edit43 lines# Reference solution for the yamaa benchmark sdtm-ds-reasons (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()))wide <- odm |> filter(StudyEventOID %in% c("EOT", "EOS")) |> group_by(StudyOID, SubjectKey, StudyEventOID) |> summarise( DTC = Value[ItemOID == "IT.DS.DTC"][1], COMP = Value[ItemOID == "IT.DS.COMP"][1], REASON = Value[ItemOID == "IT.DS.REASON"][1], REASONCD = Value[ItemOID == "IT.DS.REASONCD"][1], .groups = "drop" )ds <- wide |> mutate( DOMAIN = "DS", STUDYID = StudyOID, USUBJID = SubjectKey, DSSEQ = ifelse(StudyEventOID == "EOT", 1L, 2L), DSCAT = "DISPOSITION EVENT", DSSCAT = ifelse(StudyEventOID == "EOT", "STUDY TREATMENT", "STUDY"), DSTERM = ifelse(COMP == "COMPLETED", "COMPLETED", na_if(REASON, "")), DSDECOD = ifelse(COMP == "COMPLETED", "COMPLETED", na_if(REASONCD, "")), DSSTDTC = suppressWarnings(as.Date(na_if(DTC, ""))) ) |> select(DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC) |> arrange(USUBJID, DSSEQ)dir.create("/app/output", showWarnings = FALSE)write_csv(ds, "/app/output/ds.csv", na = "")solutions/sdtm-ds-reasons/result.py
Edit93 lines# Reference solution for the yamaa benchmark sdtm-ds-reasons (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."""Build the SDTM DS dataset from the ODM extract.One record per subject for each of the two milestones: end oftreatment (EOT) and end of study (EOS). Each milestone's completionflag, reason text, controlled code, and start date are collected asseparate items in the ODM rows; the record for a milestone carriesthe values of that milestone's items, in whatever order the inputrows hold them."""import csvfrom pathlib import PathINPUT = Path("/app/input")OUTPUT = Path("/app/output")# (StudyEventOID, DSSEQ, DSSCAT) for each milestone, in DSSEQ order.MILESTONES = [ ("EOT", 1, "STUDY TREATMENT"), ("EOS", 2, "STUDY"),]ITEM_COMPLETION = "IT.DS.COMP"ITEM_REASON = "IT.DS.REASON"ITEM_REASON_CODE = "IT.DS.REASONCD"ITEM_DATE = "IT.DS.DTC"COLUMNS = [ "DOMAIN", "STUDYID", "USUBJID", "DSSEQ", "DSCAT", "DSSCAT", "DSTERM", "DSDECOD", "DSSTDTC",]def main() -> None: with open(INPUT / "odm.csv", newline="") as handle: odm_rows = list(csv.DictReader(handle)) # Collect each milestone's items per subject: # items[(subject, event)][item oid] = value. items: dict[tuple[str, str], dict[str, str]] = {} study_by_subject: dict[str, str] = {} for row in odm_rows: subject = row["SubjectKey"] study_by_subject.setdefault(subject, row["StudyOID"]) key = (subject, row["StudyEventOID"]) items.setdefault(key, {})[row["ItemOID"]] = row["Value"] records = [] for subject in sorted(study_by_subject): for event_oid, dsseq, dsscat in MILESTONES: collected = items.get((subject, event_oid), {}) if collected.get(ITEM_COMPLETION) == "COMPLETED": dsterm = "COMPLETED" dsdecod = "COMPLETED" else: dsterm = collected.get(ITEM_REASON, "") dsdecod = collected.get(ITEM_REASON_CODE, "") records.append( { "DOMAIN": "DS", "STUDYID": study_by_subject[subject], "USUBJID": subject, "DSSEQ": str(dsseq), "DSCAT": "DISPOSITION EVENT", "DSSCAT": dsscat, "DSTERM": dsterm, "DSDECOD": dsdecod, "DSSTDTC": collected.get(ITEM_DATE, ""), } ) OUTPUT.mkdir(parents=True, exist_ok=True) with open(OUTPUT / "ds.csv", "w", newline="") as handle: writer = csv.DictWriter(handle, fieldnames=COLUMNS) writer.writeheader() writer.writerows(records)if __name__ == "__main__": main()solutions/sdtm-ds-reasons/result.sas
Edit34 lines/* opensas reference solution for the yamaa benchmark sdtm-ds-reasons. 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; run;data wide; length COMP DTC REASON REASONCD $1024; retain COMP DTC REASON REASONCD; set ordered; by StudyOID SubjectKey StudyEventOID; if first.StudyEventOID then do; COMP=''; DTC=''; REASON=''; REASONCD=''; end; if ItemOID='IT.DS.COMP' then COMP=Value; if ItemOID='IT.DS.DTC' then DTC=Value; if ItemOID='IT.DS.REASON' then REASON=Value; if ItemOID='IT.DS.REASONCD' then REASONCD=Value; if last.StudyEventOID then output;run;data prepared; set wide; length DOMAIN $2 STUDYID USUBJID DSTERM DSDECOD DSCAT DSSCAT DSSTDTC $1024;DOMAIN='DS'; STUDYID=StudyOID; USUBJID=SubjectKey; DSCAT='DISPOSITION EVENT'; DSSTDTC=DTC; DSTERM=REASON; DSDECOD=REASONCD;if COMP='COMPLETED' then do; DSTERM='COMPLETED'; DSDECOD='COMPLETED'; end;if StudyEventOID='EOT' then do; DSSEQ=1; DSSCAT='STUDY TREATMENT'; end; else do; DSSEQ=2; DSSCAT='STUDY'; end; run; data result; set prepared; run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC from result;quit;proc export data=final outfile="/app/output/ds.csv" dbms=csv replace; run;
yamaa