Review ask

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

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

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

  • DSSEQ numbers the subject's milestones in the order a subject reaches them: 1 for end of treatment and 2 for end of study. With STUDYID and USUBJID it identifies the record.
  • DSCAT is always DISPOSITION EVENT.
  • DSSCAT names the milestone: STUDY TREATMENT for the end-of-treatment form and STUDY for the end-of-study form.
  • DSTERM holds the reported term: COMPLETED when the completion flag says so, else the collected reason text.
  • DSDECOD holds the controlled term: COMPLETED when completed, else the collected code, which must be ADVERSE EVENT or OTHER.
  • DSSTDTC is 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 review
1 source file

input/odm.csv

Edit
24 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
STUDY01MDV.1003EOS1IG.DS1IT.DS.REASONMoving abroad
STUDY01MDV.1001EOS1IG.DS1IT.DS.COMPCOMPLETED
STUDY01MDV.1002EOT1IG.DS1IT.DS.REASONSevere nausea
STUDY01MDV.1003EOT1IG.DS1IT.DS.DTC2024-02-28
STUDY01MDV.1001EOT1IG.DS1IT.DS.COMPCOMPLETED
STUDY01MDV.1002EOS1IG.DS1IT.DS.DTC2024-06-18
STUDY01MDV.1003EOS1IG.DS1IT.DS.DTC2024-05-10
STUDY01MDV.1002EOT1IG.DS1IT.DS.DTC2024-04-02
STUDY01MDV.1001EOS1IG.DS1IT.DS.DTC2024-06-20
STUDY01MDV.1003EOS1IG.DS1IT.DS.COMPDISCONTINUED
STUDY01MDV.1002EOT1IG.DS1IT.DS.COMPDISCONTINUED
STUDY01MDV.1001EOT1IG.DS1IT.DS.DTC2024-03-15
STUDY01MDV.1003EOT1IG.DS1IT.DS.COMPCOMPLETED
STUDY01MDV.1001EOS1IG.DS1IT.DS.REASON—
STUDY01MDV.1002EOS1IG.DS1IT.DS.COMPCOMPLETED
STUDY01MDV.1003EOS1IG.DS1IT.DS.REASONCDOTHER
STUDY01MDV.1002EOT1IG.DS1IT.DS.REASONCDADVERSE EVENT
STUDY01MDV.1001EOT1IG.DS1IT.DS.REASON—
STUDY01MDV.1003EOT1IG.DS1IT.DS.REASON—
STUDY01MDV.1002EOS1IG.DS1IT.DS.REASON—
STUDY01MDV.1001EOT1IG.DS1IT.DS.REASONCD—
STUDY01MDV.1002EOS1IG.DS1IT.DS.REASONCD—
STUDY01MDV.1003EOT1IG.DS1IT.DS.REASONCD—
STUDY01MDV.1001EOS1IG.DS1IT.DS.REASONCD—

Expected output

Under review
6 expected rows

expected/ds.csv

Edit
6 rows
expected/ds.csv
DOMAINSTUDYIDUSUBJIDDSSEQDSCATDSSCATDSTERMDSDECODDSSTDTC
DSSTUDY011DISPOSITION EVENTSTUDY TREATMENTCOMPLETEDCOMPLETED2024-03-15
DSSTUDY012DISPOSITION EVENTSTUDYCOMPLETEDCOMPLETED2024-06-20
DSSTUDY011DISPOSITION EVENTSTUDY TREATMENTSevere nauseaADVERSE EVENT2024-04-02
DSSTUDY012DISPOSITION EVENTSTUDYCOMPLETEDCOMPLETED2024-06-18
DSSTUDY011DISPOSITION EVENTSTUDY TREATMENTCOMPLETEDCOMPLETED2024-02-28
DSSTUDY012DISPOSITION EVENTSTUDYMoving abroadOTHER2024-05-10
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark 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 AbbreviationCharDSAssignedSet constant value "DS".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
DSSEQSequence NumberNum1, 2CollectedRecode ODM.StudyEventOID: "EOT" → "1", "EOS" → "2"; missing values stay missing; unlisted values are errors.SDTM4
DSCATCategory for Disposition EventCharDISPOSITION EVENTAssignedSet constant value "DISPOSITION EVENT".SDTM5
DSSCATSubcategory for Disposition EventCharSTUDY TREATMENT, STUDYCollectedRecode ODM.StudyEventOID: "EOT" → "STUDY TREATMENT", "EOS" → "STUDY"; missing values stay missing; unlisted values are errors.SDTM6
DSTERMReported Term for the Disposition EventCharDerivedIf COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise copy value from ODM.Value where ODM.ItemOID = 'IT.DS.REASON'.SDTM7
DSDECODStandardized Disposition TermCharCOMPLETED, ADVERSE EVENT, OTHERDerivedIf COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise copy value from ODM.Value where ODM.ItemOID = 'IT.DS.REASONCD'.SDTM8
DSSTDTCStart Date/Time of Disposition EventCharISO 8601CollectedCopy value from ODM.Value where ODM.ItemOID = 'IT.DS.DTC'.SDTM9
VariablePermitted values
DOMAINDS
DSSEQ1, 2
DSCATDISPOSITION EVENT
DSSCATSTUDY TREATMENT, STUDY
DSDECODCOMPLETED, ADVERSE EVENT, OTHER
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
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-ds-reasons/full.md

Edit
29 lines

Following 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

Edit
16 lines

Following 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

Edit
9 lines

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

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

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

solutions/sdtm-ds-reasons/result.R

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

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

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