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 and end dates and datetimes (AP01SDT, AP01SDTM, AP01EDT, AP01EDTM, AP02SDT, AP02SDTM, AP02EDT, AP02EDTM) and actual treatment (TRT01A, TRT02A). A period's datetime is empty when no time was recorded for it, and a subject who never started period 2 has no period-2 dates 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 period whose start and end the record lies within, both included. Each limit is compared by time when both the record and the limit have a time, and by date otherwise: a record at 10:00 on the day period 1 ends at 08:00 is after period 1, while a date-only record on that day is in period 1, as is a timed record against a period with no recorded times. Empty for a record between the periods, before the first or after the last, 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.

Note: a period with no start or end date holds no record. When a date-only record falls on a day that ends one period and starts the next, it is placed in the later period.

Inputs

Under review
2 source files

input/adsl.csv

Edit
3 rows
input/adsl.csv
STUDYIDUSUBJIDTRT01ATRT02AAP01SDTAP01SDTMAP01EDTAP01EDTMAP02SDTAP02SDTMAP02EDTAP02EDTM
YAMAA-01DRUG APLACEBO2026-04-062026-04-06T08:00:002026-04-132026-04-13T08:00:002026-04-202026-04-20T08:30:002026-04-272026-04-27T08:30:00
YAMAA-01PLACEBODRUG A2026-04-072026-04-07T09:10:002026-04-142026-04-14T09:10:002026-04-212026-04-21T09:00:002026-04-282026-04-28T09:00:00
YAMAA-01DRUG A—2026-04-08—2026-04-15—————

input/vs.csv

Edit
12 rows
input/vs.csv
STUDYIDUSUBJIDVSSEQVSTESTCDVSSTRESNVSDTC
YAMAA-011SYSBP1242026-03-30T10:00
YAMAA-012SYSBP1212026-04-13T08:00:00
YAMAA-013SYSBP1192026-04-13T10:00
YAMAA-014SYSBP1232026-04-20T08:29:59
YAMAA-015SYSBP1262026-04-20T08:30:00
YAMAA-016SYSBP1222026-04-28T09:00
YAMAA-011SYSBP1312026-04-08T09:10
YAMAA-012SYSBP1272026-04-14
YAMAA-013SYSBP1282026-04-21
YAMAA-014SYSBP129—
YAMAA-011SYSBP1202026-04-15T10:00
YAMAA-012SYSBP1222026-05-06T10:00

Expected output

Under review
12 expected rows

expected/advs.csv

Edit
12 rows
expected/advs.csv
STUDYIDUSUBJIDVSSEQPARAMCDAVALADTADTMAPERIODTRTA
YAMAA-011SYSBP1242026-03-302026-03-30T10:00:00——
YAMAA-012SYSBP1212026-04-132026-04-13T08:00:001DRUG A
YAMAA-013SYSBP1192026-04-132026-04-13T10:00:00——
YAMAA-014SYSBP1232026-04-202026-04-20T08:29:59——
YAMAA-015SYSBP1262026-04-202026-04-20T08:30:002PLACEBO
YAMAA-016SYSBP1222026-04-282026-04-28T09:00:00——
YAMAA-011SYSBP1312026-04-082026-04-08T09:10:001PLACEBO
YAMAA-012SYSBP1272026-04-14—1PLACEBO
YAMAA-013SYSBP1282026-04-21—2DRUG A
YAMAA-014SYSBP129————
YAMAA-011SYSBP1202026-04-152026-04-15T10:00:001DRUG A
YAMAA-012SYSBP1222026-05-062026-05-06T10:00:00——
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 IS NOT NULL AND ADSL.AP02SDTM IS NOT NULL AND ADTM >= ADSL.AP02SDTM) OR ((ADTM IS NULL OR ADSL.AP02SDTM IS NULL) AND ADT >= ADSL.AP02SDT)) AND ((ADTM IS NOT NULL AND ADSL.AP02EDTM IS NOT NULL AND ADTM <= ADSL.AP02EDTM) OR ((ADTM IS NULL OR ADSL.AP02EDTM IS NULL) AND ADT <= ADSL.AP02EDT)) then "2"; If ((ADTM IS NOT NULL AND ADSL.AP01SDTM IS NOT NULL AND ADTM >= ADSL.AP01SDTM) OR ((ADTM IS NULL OR ADSL.AP01SDTM IS NULL) AND ADT >= ADSL.AP01SDT)) AND ((ADTM IS NOT NULL AND ADSL.AP01EDTM IS NOT NULL AND ADTM <= ADSL.AP01EDTM) OR ((ADTM IS NULL OR ADSL.AP01EDTM IS NULL) AND ADT <= ADSL.AP01EDT)) 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.82026-11-19yamaa docs buildState open and closed range endpoints, including bounds of zero
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
27 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. Period xx starts at APxxSDT, or APxxSDTM when a time was recorded for it, and ends at APxxEDT, or APxxEDTM when a time was recorded for it. APERIOD is the period whose start and end the record lies within, both included. Each limit is compared by time when both the record and the limit have a time, and by date otherwise. So a record exactly at a period's start or end time is in that period, a record at 10:00 on the day a period ends at 08:00 is not in it, a date-only record on a period's first or last day is in it, and a record with a time is placed by its date against a period with no recorded times. APERIOD has no value for a record between the periods, before the first or after the last, when no date was collected, and for a period with no start or end date. When a date-only record falls on a day that ends one period and starts the next, it is in the later period. 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
13 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

APERIOD is 1, 2, or has no value. A period includes its start and end. A record is compared by time with a period limit when both have a time, and by date otherwise. 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
82 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(), AP01EDT = col_date(),    AP02SDT = col_date(), AP02EDT = col_date(),    AP01SDTM = col_datetime(), AP01EDTM = col_datetime(),    AP02SDTM = col_datetime(), AP02EDTM = 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")  )# Whether a record lies within a period's start and end, both included.# Each limit is compared by time when both the record and the limit have# one, and by date otherwise; a missing date or limit never matches.within <- function(adt, moment, sdt, sdtm, edt, edtm) {  after_start <- if_else(    !is.na(moment) & !is.na(sdtm), moment >= sdtm, adt >= sdt  )  before_end <- if_else(    !is.na(moment) & !is.na(edtm), moment <= edtm, adt <= edt  )  coalesce(after_start & before_end, FALSE)}# The later period wins when a record lies within both.advs <- collected |>  left_join(adsl, by = c("STUDYID", "USUBJID")) |>  mutate(    APERIOD = case_when(      within(ADT, moment, AP02SDT, AP02SDTM, AP02EDT, AP02EDTM) ~ 2L,      within(ADT, moment, AP01SDT, AP01SDTM, AP01EDT, AP01EDTM) ~ 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
124 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"]]        # The subject's periods with a start and an end date, in order:        # (number, start date, start datetime or None, end date, end        # datetime or None, actual treatment).        periods = []        for num in (1, 2):            prefix = "AP%02d" % num            start_date = parse_date(subj.get(prefix + "SDT"))            end_date = parse_date(subj.get(prefix + "EDT"))            if start_date is None or end_date is None:                continue            _, start_dtm = parse_dtc(subj.get(prefix + "SDTM"))            _, end_dtm = parse_dtc(subj.get(prefix + "EDTM"))            trt = subj.get("TRT%02dA" % num) or ""            periods.append((num, start_date, start_dtm, end_date, end_dtm, trt))        coll_date, coll_dtm = parse_dtc(row.get("VSDTC"))        aperiod = ""        trta = ""        if coll_date is not None:            # Each limit is compared by time when both the record and the            # limit have one, and by date otherwise. A later period that            # also holds the record wins.            for num, start_date, start_dtm, end_date, end_dtm, trt in periods:                if coll_dtm is not None and start_dtm is not None:                    after_start = start_dtm <= coll_dtm                else:                    after_start = start_date <= coll_date                if coll_dtm is not None and end_dtm is not None:                    before_end = coll_dtm <= end_dtm                else:                    before_end = coll_date <= end_date                if after_start and before_end:                    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
65 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 AP01EDT AP01EDTM AP02SDT AP02SDTM AP02EDT AP02EDTM $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. AP01EDT : $char1024. AP01EDTM : $char1024. AP02SDT : $char1024. AP02SDTM : $char1024. AP02EDT : $char1024. AP02EDTM : $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.AP01EDT,b.AP01EDTM,b.AP02SDT,b.AP02SDTM,b.AP02EDT,b.AP02EDTM from collected as a    left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;/* The period whose start and end the record lies within, both included.   Each limit is compared by time when both the record and the limit have   one, and by date otherwise; a missing date or limit never matches. The   later period wins when a record lies within both. A period datetime is   written with seconds, as ADTM is. */data result;  length TRTA $1024;  set joined;  array sdt{2} $1024 AP01SDT AP02SDT;  array sdtm{2} $1024 AP01SDTM AP02SDTM;  array edt{2} $1024 AP01EDT AP02EDT;  array edtm{2} $1024 AP01EDTM AP02EDTM;  do p=1 to 2;    if not missing(ADT) and not missing(sdt{p}) and not missing(edt{p}) then do;      if not missing(ADTM) and not missing(sdtm{p}) then after_start=(ADTM>=sdtm{p});      else after_start=(ADT>=sdt{p});      if not missing(ADTM) and not missing(edtm{p}) then before_end=(ADTM<=edtm{p});      else before_end=(ADT<=edt{p});      if after_start and before_end then APERIOD=p;    end;  end;  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;