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: reviewedEditUnder review
What this benchmark means
README.md

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

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 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 or 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 or 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.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
21 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per milestone: 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

STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.

DSSEQ is 1 for end of treatment and 2 for end of study. 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, either ADVERSE EVENT or OTHER. DSSTDTC is the collected start date for that milestone. The completion flag, reason, code, and date of one milestone are separate collected rows, so the order of the input rows never reaches the output.

Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.

prompts/sdtm-ds-reasons/conventions.md

Edit
14 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per milestone: 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

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 or the collected reason text. DSDECOD holds the controlled term: COMPLETED, 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 per milestone: 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

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

run.R

Edit
4 lines
library(yamaa)ds <- yamaa_domain("spec.yaml")$outputds

run.py

Edit
4 lines
import yamaads = yamaa.yamaa_domain("spec.yaml").outputds

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
74 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.from pathlib import Pathimport polars as plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)wide = (    odm.group_by("StudyOID", "SubjectKey", "StudyEventOID")    .agg(        pl.col("Value").filter(pl.col("ItemOID") == "IT.DS.DTC").first().alias("DTC"),        pl.col("Value").filter(pl.col("ItemOID") == "IT.DS.COMP").first().alias("COMP"),        pl.col("Value").filter(pl.col("ItemOID") == "IT.DS.REASON").first().alias("REASON"),        pl.col("Value")        .filter(pl.col("ItemOID") == "IT.DS.REASONCD")        .first()        .alias("REASONCD"),    )    .filter(pl.col("StudyEventOID").is_in(["EOT", "EOS"])))MILESTONE = {"EOT": ("STUDY TREATMENT", 1), "EOS": ("STUDY", 2)}records: list[dict] = []for row in wide.to_dicts():    study = row["StudyOID"]    subj = row["SubjectKey"]    event = row["StudyEventOID"]    sscat, seq = MILESTONE[event]    comp = row["COMP"] or ""    reason = row["REASON"] or ""    reasoncd = row["REASONCD"] or ""    dtc = row["DTC"] or ""    if comp == "COMPLETED":        term, decod = "COMPLETED", "COMPLETED"    else:        term, decod = (reason or None), (reasoncd or None)    usubjid = subj    records.append(        {            "DOMAIN": "DS",            "STUDYID": study,            "USUBJID": usubjid,            "DSSEQ": seq,            "DSCAT": "DISPOSITION EVENT",            "DSSCAT": sscat,            "DSTERM": term,            "DSDECOD": decod,            "DSSTDTC": dtc or None,        }    )ds = pl.DataFrame(    records,    schema={        "DOMAIN": pl.String,        "STUDYID": pl.String,        "USUBJID": pl.String,        "DSSEQ": pl.Int64,        "DSCAT": pl.String,        "DSSCAT": pl.String,        "DSTERM": pl.String,        "DSDECOD": pl.String,        "DSSTDTC": pl.String,    },).sort(["USUBJID", "DSSEQ"])Path("/app/output").mkdir(exist_ok=True)ds.write_csv("/app/output/ds.csv")

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;