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 output record per collected disposition record, carrying DSDECOD, DSCAT and DSDTC, with DSSEQ numbering each subject's records from the earliest collection date.

Input: one row per collected form, with the subject in the subject field, the recorded outcome in the outcome field, and the collection date text in the date field. The form label does not feed any output column.

Variables:

  • DSSEQ numbers the subject's records from the earliest completed collection date. A partial entry such as 2024-01 takes its position at the imputed 15th, after an earlier full date in that month. A record with no date is numbered after dated records.
  • DSDECOD copies the recorded outcome: COMPLETED, RANDOMIZED, ADVERSE EVENT or SCREEN FAILURE.
  • DSCAT is PROTOCOL MILESTONE when the outcome is RANDOMIZED, and DISPOSITION EVENT for any other outcome.
  • DSDTC is the collection date; a partial entry such as 2024-01 is completed to the 15th of that month, and a year alone is completed to June 15th. It is empty when the date is missing or cannot be read.

Inputs

Under review
1 source file

input/ds_raw.csv

Edit
7 rows
input/ds_raw.csv
STUDYPATNUMINSTANCEDSDECODDSDTCOL
KN189KN189-101COMPLETIONCOMPLETED2024-01-10
KN189KN189-101PROTOCOL MILESTONERANDOMIZED2023-12-20
KN189KN189-102COMPLETIONADVERSE EVENT2024-02-15
KN189KN189-103COMPLETIONCOMPLETED2024-03-01
KN189KN189-104PROTOCOL MILESTONERANDOMIZED2024-01-05
KN189KN189-105SCREENINGSCREEN FAILURE2024-01
KN189KN189-105PROTOCOL MILESTONERANDOMIZED2024-01-05

Expected output

Under review
7 expected rows

expected/ds.csv

Edit
7 rows
expected/ds.csv
DOMAINSTUDYIDUSUBJIDDSSEQDSDECODDSCATDSDTC
DSKN1892COMPLETEDDISPOSITION EVENT2024-01-10
DSKN1891RANDOMIZEDPROTOCOL MILESTONE2023-12-20
DSKN1891ADVERSE EVENTDISPOSITION EVENT2024-02-15
DSKN1891COMPLETEDDISPOSITION EVENT2024-03-01
DSKN1891RANDOMIZEDPROTOCOL MILESTONE2024-01-05
DSKN1892SCREEN FAILUREDISPOSITION EVENT2024-01-15
DSKN1891RANDOMIZEDPROTOCOL MILESTONE2024-01-05
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 DS_RAW.STUDY.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from DS_RAW.PATNUM.SDTM3
DSDTCDate/Time of CollectionCharISO 8601DerivedImpute incomplete date from DS_RAW.DSDTCOL, defaulting month=6, day=15; invalid text → blank.SDTM4
DSSEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by DSDTC.SDTM5
DSDECODStandardized Disposition TermCharCOMPLETED, RANDOMIZED, ADVERSE EVENT, SCREEN FAILURECollectedCopy value from DS_RAW.DSDECOD.SDTM6
DSCATCategory for Disposition EventCharPROTOCOL MILESTONE, DISPOSITION EVENTDerivedIf DSDECOD = 'RANDOMIZED' then "PROTOCOL MILESTONE"; otherwise "DISPOSITION EVENT".SDTM7
TemplateInclude when
disposition
VariablePermitted values
DOMAINDS
DSDECODCOMPLETED, RANDOMIZED, ADVERSE EVENT, SCREEN FAILURE
DSCATPROTOCOL MILESTONE, DISPOSITION EVENT
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-sequence/full.md

Edit
21 lines

Following CDISC SDTM standards, use the provided DS_RAW dataset to create a DS dataset with one record per collected disposition record.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC

DOMAIN is "DS". STUDYID is the study identifier as given, and USUBJID is the subject identifier as given. DSDECOD is the recorded outcome: "COMPLETED", "RANDOMIZED", "ADVERSE EVENT", or "SCREEN FAILURE". DSCAT is "PROTOCOL MILESTONE" when the outcome is "RANDOMIZED", and "DISPOSITION EVENT" for any other outcome. DSDTC is the collection date: a date collected as a year and a month is completed to the 15th of that month, and a year alone is completed to June 15th of that year. DSDTC has no value when the date is missing or cannot be read. DSSEQ numbers a subject's records from 1 in order of the completed collection date, earliest first. A partial entry takes its position at its completed date, after an earlier full date in that month. A record with no date is numbered after the subject's dated records.

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

prompts/sdtm-ds-sequence/conventions.md

Edit
12 lines

Following CDISC SDTM standards, use the provided DS_RAW dataset to create a DS dataset with one record per collected disposition record.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC

DOMAIN is "DS". DSDECOD is the recorded outcome: "COMPLETED", "RANDOMIZED", "ADVERSE EVENT", or "SCREEN FAILURE". DSCAT is "PROTOCOL MILESTONE" or "DISPOSITION EVENT".

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

prompts/sdtm-ds-sequence/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided DS_RAW dataset to create a DS dataset with one record per collected disposition record.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC

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-sequence/result.R

Edit
61 lines
# Reference solution for the yamaa benchmark sdtm-ds-sequence (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(stringr)ds_raw <- read_csv(  "/app/input/ds_raw.csv",  col_types = cols(.default = col_character()))complete_date <- function(x) {  x <- str_trim(x)  if (is.na(x) || x == "") {    return(as.Date(NA))  }  parts <- str_split(x, "-", simplify = TRUE)  n <- ncol(parts)  if (n == 3 && nchar(parts[1]) == 4) {    return(suppressWarnings(as.Date(x)))  }  if (n == 2 && nchar(parts[1]) == 4) {    y <- suppressWarnings(as.integer(parts[1]))    m <- suppressWarnings(as.integer(parts[2]))    if (is.na(y) || is.na(m) || m < 1 || m > 12) {      return(as.Date(NA))    }    return(suppressWarnings(as.Date(sprintf("%04d-%02d-15", y, m))))  }  if (n == 1 && nchar(x) == 4) {    y <- suppressWarnings(as.integer(x))    if (is.na(y)) {      return(as.Date(NA))    }    return(suppressWarnings(as.Date(sprintf("%04d-06-15", y))))  }  as.Date(NA)}ds <- ds_raw |>  rowwise() |>  mutate(    DOMAIN = "DS",    STUDYID = STUDY,    USUBJID = PATNUM,    DSCAT = ifelse(DSDECOD == "RANDOMIZED", "PROTOCOL MILESTONE", "DISPOSITION EVENT"),    DSDTC = complete_date(DSDTCOL)  ) |>  ungroup() |>  arrange(USUBJID, DSDTC, DSDECOD) |>  group_by(USUBJID) |>  mutate(DSSEQ = row_number()) |>  ungroup() |>  select(DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC)dir.create("/app/output", showWarnings = FALSE)write_csv(ds, "/app/output/ds.csv", na = "")

solutions/sdtm-ds-sequence/result.py

Edit
119 lines
# Reference solution for the yamaa benchmark sdtm-ds-sequence (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 collected DS_RAW dataset.One output record per collected disposition record. Partial collectiondates are completed before use: a year and month becomes the 15th ofthat month, and a year alone becomes June 15th of that year. DSSEQnumbers each subject's records from 1 in order of the completedcollection date, earliest first; records with no date come after thesubject's dated records."""import csvimport refrom datetime import dateINPUT_PATH = "/app/input/ds_raw.csv"OUTPUT_PATH = "/app/output/ds.csv"FULL_DATE = re.compile(r"^(\d{4})-(\d{2})-(\d{2})$")YEAR_MONTH = re.compile(r"^(\d{4})-(\d{2})$")YEAR_ONLY = re.compile(r"^(\d{4})$")def complete_date(raw):    """Return the completed ISO date string, or None if unreadable."""    if raw is None:        return None    text = raw.strip()    if not text:        return None    match = FULL_DATE.match(text)    if match:        year, month, day = (int(part) for part in match.groups())    else:        match = YEAR_MONTH.match(text)        if match:            year, month = (int(part) for part in match.groups())            day = 15        else:            match = YEAR_ONLY.match(text)            if match:                year = int(match.group(1))                month, day = 6, 15            else:                return None    try:        completed = date(year, month, day)    except ValueError:        return None    return completed.isoformat()def main():    with open(INPUT_PATH, newline="", encoding="utf-8") as handle:        rows = list(csv.DictReader(handle))    records = []    for position, row in enumerate(rows):        outcome = (row.get("DSDECOD") or "").strip()        dsdtc = complete_date(row.get("DSDTCOL"))        records.append(            {                "DOMAIN": "DS",                "STUDYID": row.get("STUDY") or "",                "USUBJID": row.get("PATNUM") or "",                "DSDECOD": outcome,                "DSCAT": (                    "PROTOCOL MILESTONE"                    if outcome == "RANDOMIZED"                    else "DISPOSITION EVENT"                ),                "DSDTC": dsdtc or "",                "_sort_date": dsdtc,                "_position": position,            }        )    subjects = []    for record in records:        if record["USUBJID"] not in subjects:            subjects.append(record["USUBJID"])    output = []    for subject in subjects:        own = [r for r in records if r["USUBJID"] == subject]        own.sort(            key=lambda r: (                r["_sort_date"] is None,                r["_sort_date"] or "",                r["_position"],            )        )        for index, record in enumerate(own, start=1):            record["DSSEQ"] = index            output.append(record)    fieldnames = [        "DOMAIN",        "STUDYID",        "USUBJID",        "DSSEQ",        "DSDECOD",        "DSCAT",        "DSDTC",    ]    with open(OUTPUT_PATH, "w", newline="", encoding="utf-8") as handle:        writer = csv.DictWriter(handle, fieldnames=fieldnames)        writer.writeheader()        for record in output:            writer.writerow({name: record[name] for name in fieldnames})if __name__ == "__main__":    main()

solutions/sdtm-ds-sequence/result.sas

Edit
24 lines
/* opensas reference solution for the yamaa benchmark sdtm-ds-sequence.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ds_raw;  length STUDY PATNUM INSTANCE DSDECOD DSDTCOL $1024;  infile "/app/input/ds_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDY : $char1024. PATNUM : $char1024. INSTANCE : $char1024. DSDECOD : $char1024. DSDTCOL : $char1024.;run;data prepared; set ds_raw; length DOMAIN $2 STUDYID USUBJID DSCAT DSDTC $1024; DOMAIN='DS'; D=.; DSDTC=''; STUDYID=STUDY; USUBJID=PATNUM;if DSDECOD='RANDOMIZED' then DSCAT='PROTOCOL MILESTONE'; else DSCAT='DISPOSITION EVENT';if lengthn(DSDTCOL)=10 then D=input(DSDTCOL,?? yymmdd10.); else if lengthn(DSDTCOL)=7 then D=input(cats(DSDTCOL,'-15'),?? yymmdd10.); else if lengthn(DSDTCOL)=4 then D=input(cats(DSDTCOL,'-06-15'),?? yymmdd10.);if not missing(D) then DSDTC=put(D,yymmdd10.); NODATE=missing(D); run;proc sort data=prepared; by STUDYID USUBJID NODATE D; run;data result; set prepared; by STUDYID USUBJID; retain DSSEQ;  if first.USUBJID then DSSEQ=0;  DSSEQ+1;run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC from result;quit;proc export data=final outfile="/app/output/ds.csv" dbms=csv replace; run;