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

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: give each vital-signs record of a two-period crossover study its analysis date and datetime (ADT, ADTM), the analysis period it falls in (APERIOD), and that period's actual treatment (TRTA).

Input: Study Data Tabulation Model (SDTM) vital signs with the collection date and time (VSDTC), and the subject-level analysis dataset (ADSL) with each period's start date and datetime (AP01SDT, AP01SDTM, AP02SDT, AP02SDTM) and actual treatment (TRT01A, TRT02A). A subject who never started period 2 has no period-2 start or treatment.

Variables:

  • PARAMCD and AVAL carry the test code and the numeric result.
  • ADT is the collection date; empty when no date was collected.
  • ADTM is the collection date and time; empty when only a date was collected, since no time is supplied.
  • APERIOD is the latest period whose start is at or before the record, so a period runs from its start up to, but not including, the next period's start: a record exactly at the period 2 start is in period 2, one second earlier in period 1. The last period a subject started has no end. A record with a date but no time is placed by its date against the period start dates, so a date-only record on the day period 2 starts is in period 2. Empty before the first period starts and when no date was collected.
  • TRTA is the actual treatment of that period: TRT01A in period 1 and TRT02A in period 2; empty when the record has no period.

Inputs

Under review
2 source files

input/adsl.csv

Edit
3 rows
input/adsl.csv
STUDYIDUSUBJIDTRT01ATRT02AAP01SDTAP01SDTMAP02SDTAP02SDTM
YAMAA-01DRUG APLACEBO2026-04-062026-04-06T08:00:002026-04-202026-04-20T08:30:00
YAMAA-01PLACEBODRUG A2026-04-072026-04-07T09:10:002026-04-212026-04-21T09:00:00
YAMAA-01DRUG A—2026-04-082026-04-08T08:15:00——

input/vs.csv

Edit
8 rows
input/vs.csv
STUDYIDUSUBJIDVSSEQVSTESTCDVSSTRESNVSDTC
YAMAA-011SYSBP1242026-03-30T10:00
YAMAA-012SYSBP1212026-04-20T08:29:59
YAMAA-013SYSBP1262026-04-20T08:30:00
YAMAA-011SYSBP1312026-04-08T09:10
YAMAA-012SYSBP1282026-04-21
YAMAA-013SYSBP1252026-04-22T09:00
YAMAA-014SYSBP129—
YAMAA-011SYSBP1222026-05-06T10:00

Expected output

Under review
8 expected rows

expected/advs.csv

Edit
8 rows
expected/advs.csv
STUDYIDUSUBJIDVSSEQPARAMCDAVALADTADTMAPERIODTRTA
YAMAA-011SYSBP1242026-03-302026-03-30T10:00:00——
YAMAA-012SYSBP1212026-04-202026-04-20T08:29:591DRUG A
YAMAA-013SYSBP1262026-04-202026-04-20T08:30:002PLACEBO
YAMAA-011SYSBP1312026-04-082026-04-08T09:10:001PLACEBO
YAMAA-012SYSBP1282026-04-21—2DRUG A
YAMAA-013SYSBP1252026-04-222026-04-22T09:00:002DRUG A
YAMAA-014SYSBP129————
YAMAA-011SYSBP1222026-05-062026-05-06T10:00:001DRUG A
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

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADVSSTUDYIDStudy IdentifiercharacterCopy value from VS.STUDYID.Predecessor
ADVSUSUBJIDUnique Subject IdentifiercharacterCopy value from VS.USUBJID.Predecessor
ADVSVSSEQSequence NumbernumericCopy value from VS.VSSEQ.Predecessor
ADVSPARAMCDParameter CodecharacterCopy value from VS.VSTESTCD.Predecessor
ADVSAVALAnalysis ValuenumericCopy value from VS.VSSTRESN.Predecessor
ADVSADTAnalysis DatenumericISO 8601Take the date part of VS.VSDTC, blank for a year or a year and month alone.Derived
ADVSADTMAnalysis DatetimenumericISO 8601If str_contains(VS.VSDTC, 'T') then "VS.VSDTC"; otherwise blank.Derived
ADVSAPERIODPeriodnumeric1, 2If ADTM >= ADSL.AP02SDTM OR (ADTM IS NULL AND ADT >= ADSL.AP02SDT) then "2"; If ADTM >= ADSL.AP01SDTM OR (ADTM IS NULL AND ADT >= ADSL.AP01SDT) then "1"; otherwise blank.Derived
ADVSTRTAActual TreatmentcharacterDRUG A, PLACEBOIf APERIOD = 1 then "ADSL.TRT01A"; If APERIOD = 2 then "ADSL.TRT02A"; otherwise blank.Derived
VariablePermitted values
APERIOD1, 2
TRTADRUG A, PLACEBO
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/adam-advs-crossover-period-records/full.md

Edit
22 lines

Following CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per vital-signs record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, VSSEQ, PARAMCD, AVAL, ADT, ADTM, APERIOD, TRTA

PARAMCD is the test code and AVAL is the numeric result. ADT is the collection date and has no value when no date was collected. ADTM is the collection date and time and has no value when only a date was collected, since no time is supplied. APERIOD is the latest period whose start is at or before the record. A period runs from its start up to, but not including, the next period's start, so a record exactly at the start of period 2 is in period 2, and a record one second earlier is in period 1. A record with a date but no time is placed by its date against the period start dates, so a date-only record on the day period 2 starts is in period 2. The last period a subject started has no end. APERIOD has no value before the first period starts or when no date was collected. TRTA is the actual treatment of the record's period: TRT01A in period 1 and TRT02A in period 2. TRTA has no value when the record has no period.

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

prompts/adam-advs-crossover-period-records/conventions.md

Edit
11 lines

Following CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per vital-signs record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, VSSEQ, PARAMCD, AVAL, ADT, ADTM, APERIOD, TRTA

TRTA is the actual treatment of the record's period: TRT01A in period 1 and TRT02A in period 2, or has no value.

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

prompts/adam-advs-crossover-period-records/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per vital-signs record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, VSSEQ, PARAMCD, AVAL, ADT, ADTM, APERIOD, TRTA

Read the source datasets from /app/input and save the completed dataset as /app/output/advs.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/adam-advs-crossover-period-records/result.R

Edit
72 lines
# Reference solution for the yamaa benchmark# adam-advs-crossover-period-records (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(lubridate)library(readr)library(stringr)vs <- read_csv(  "/app/input/vs.csv",  col_types = cols(    VSSEQ = col_integer(), VSSTRESN = col_double(),    .default = col_character()  ))adsl <- read_csv(  "/app/input/adsl.csv",  col_types = cols(    AP01SDT = col_date(), AP02SDT = col_date(),    AP01SDTM = col_datetime(), AP02SDTM = col_datetime(),    .default = col_character()  ))# The collection date is the date part of the collection datetime;# the datetime itself exists only when a time was collected. A time# may be written with or without seconds, so both forms are tried.collected <- vs |>  mutate(    ADT = as.Date(str_sub(VSDTC, 1, 10)),    parsed_hms = suppressWarnings(ymd_hms(VSDTC, quiet = TRUE, tz = "UTC")),    parsed_hm = suppressWarnings(ymd_hm(VSDTC, quiet = TRUE, tz = "UTC")),    moment = case_when(      !is.na(VSDTC) & str_detect(VSDTC, "T") ~        coalesce(parsed_hms, parsed_hm),      .default = as.POSIXct(NA, tz = "UTC")    ),    ADTM = format(moment, "%Y-%m-%dT%H:%M:%S", tz = "UTC")  )# The latest period whose start is at or before the record. A record# with a time is compared with the period start datetimes, a date-only# record with the period start dates; a missing start never matches,# so a subject who never started period 2 stays in period 1.advs <- collected |>  left_join(adsl, by = c("STUDYID", "USUBJID")) |>  mutate(    APERIOD = case_when(      !is.na(moment) & !is.na(AP02SDTM) & moment >= AP02SDTM ~ 2L,      is.na(moment) & !is.na(ADT) & !is.na(AP02SDT) & ADT >= AP02SDT ~ 2L,      !is.na(moment) & !is.na(AP01SDTM) & moment >= AP01SDTM ~ 1L,      is.na(moment) & !is.na(ADT) & !is.na(AP01SDT) & ADT >= AP01SDT ~ 1L,      .default = NA_integer_    ),    PARAMCD = VSTESTCD,    AVAL = VSSTRESN,    TRTA = case_when(      APERIOD %in% 1L ~ TRT01A,      APERIOD %in% 2L ~ TRT02A,      .default = NA_character_    )  ) |>  select(    STUDYID, USUBJID, VSSEQ, PARAMCD, AVAL, ADT, ADTM, APERIOD, TRTA  )dir.create("/app/output", showWarnings = FALSE)write_csv(advs, "/app/output/advs.csv", na = "")

solutions/adam-advs-crossover-period-records/result.py

Edit
117 lines
# Reference solution for the yamaa benchmark adam-advs-crossover-period-records (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 datetime import datetimeINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def parse_date(text):    text = (text or "").strip()    if not text:        return None    return datetime.strptime(text, "%Y-%m-%d").date()def parse_dtc(text):    """Return (date, datetime or None) for an ISO 8601 collection value.    A date-only value yields a date with no datetime; a value carrying a    time yields both its date and its datetime.    """    text = (text or "").strip()    if not text:        return None, None    if "T" not in text:        return parse_date(text), None    for fmt in ("%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M"):        try:            moment = datetime.strptime(text, fmt)            return moment.date(), moment        except ValueError:            continue    raise ValueError("unrecognised datetime: %r" % text)def fmt_date(d):    return d.isoformat() if d is not None else ""def fmt_dtm(m):    return m.strftime("%Y-%m-%dT%H:%M:%S") if m is not None else ""def main():    with open(INPUT_DIR + "/adsl.csv", newline="") as f:        adsl = {row["USUBJID"]: row for row in csv.DictReader(f)}    with open(INPUT_DIR + "/vs.csv", newline="") as f:        vs_rows = list(csv.DictReader(f))    out_rows = []    for row in vs_rows:        subj = adsl[row["USUBJID"]]        # Periods the subject started, in order: (number, start date,        # start datetime, actual treatment).        periods = []        for num, sdt_key, sdtm_key, trt_key in (            (1, "AP01SDT", "AP01SDTM", "TRT01A"),            (2, "AP02SDT", "AP02SDTM", "TRT02A"),        ):            start_date = parse_date(subj.get(sdt_key))            if start_date is None:                continue            _, start_dtm = parse_dtc(subj.get(sdtm_key))            if start_dtm is None:                start_dtm = datetime.combine(start_date, datetime.min.time())            periods.append((num, start_date, start_dtm, subj.get(trt_key) or ""))        coll_date, coll_dtm = parse_dtc(row.get("VSDTC"))        aperiod = ""        trta = ""        if coll_date is not None:            for num, start_date, start_dtm, trt in periods:                if coll_dtm is not None:                    placed = start_dtm <= coll_dtm                else:                    placed = start_date <= coll_date                if placed:                    aperiod = num                    trta = trt        out_rows.append(            {                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "VSSEQ": row["VSSEQ"],                "PARAMCD": row["VSTESTCD"],                "AVAL": row["VSSTRESN"],                "ADT": fmt_date(coll_date),                "ADTM": fmt_dtm(coll_dtm),                "APERIOD": aperiod,                "TRTA": trta,            }        )    fieldnames = [        "STUDYID",        "USUBJID",        "VSSEQ",        "PARAMCD",        "AVAL",        "ADT",        "ADTM",        "APERIOD",        "TRTA",    ]    with open(OUTPUT_DIR + "/advs.csv", "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=fieldnames)        writer.writeheader()        writer.writerows(out_rows)if __name__ == "__main__":    main()

solutions/adam-advs-crossover-period-records/result.sas

Edit
54 lines
/* opensas reference solution for the yamaa benchmark adam-advs-crossover-period-records.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl;  length STUDYID USUBJID TRT01A TRT02A AP01SDT AP01SDTM AP02SDT AP02SDTM $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRT01A : $char1024. TRT02A : $char1024. AP01SDT : $char1024. AP01SDTM : $char1024. AP02SDT : $char1024. AP02SDTM : $char1024.;run;data vs;  length STUDYID USUBJID VSTESTCD VSDTC $1024;  infile "/app/input/vs.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. VSSEQ VSTESTCD : $char1024. VSSTRESN VSDTC : $char1024.;run;/* The collection date is the date part of VSDTC. ADTM holds the full   datetime, with seconds added when the collected time has none, and   is empty when only a date was collected. ISO text compares in   calendar and clock order. */data collected;  length PARAMCD $16 ADT ADTM $19;  set vs;  PARAMCD=VSTESTCD; AVAL=VSSTRESN;  if not missing(VSDTC) then ADT=substr(VSDTC,1,10);  if index(VSDTC,'T') then do;    if length(trim(VSDTC))=16 then ADTM=trim(VSDTC)||":00";    else ADTM=VSDTC;  end;run;proc sql;  create table joined as select a.*,b.TRT01A,b.TRT02A,b.AP01SDT,b.AP01SDTM,b.AP02SDT,b.AP02SDTM from collected as a    left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;/* The latest period whose start is at or before the record: a record   with a time is compared with the start datetimes, a date-only   record with the start dates, and a missing start never matches. */data result;  length TRTA $1024;  set joined;  if not missing(ADTM) and not missing(AP02SDTM) and ADTM>=AP02SDTM then APERIOD=2;  else if missing(ADTM) and not missing(ADT) and not missing(AP02SDT) and ADT>=AP02SDT then APERIOD=2;  else if not missing(ADTM) and not missing(AP01SDTM) and ADTM>=AP01SDTM then APERIOD=1;  else if missing(ADTM) and not missing(ADT) and not missing(AP01SDT) and ADT>=AP01SDT then APERIOD=1;  if APERIOD=1 then TRTA=TRT01A;  else if APERIOD=2 then TRTA=TRT02A;run;proc sql;  create table final as select STUDYID, USUBJID, VSSEQ, PARAMCD, AVAL, ADT, ADTM, APERIOD, TRTA from result;quit;proc export data=final outfile="/app/output/advs.csv" dbms=csv replace; run;