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: carry each collected vital-signs result with its test, result, and collection date-time, and add the trial period from the subject's own elements: VSTESTCD, VSORRES, VSDTC, and EPOCH.

Input: collected vital-signs rows with test, result, and collection date-time; and the subject's elements with the start and end of each element.

Variables:

  • VSDTC is the collection date-time, carried over unchanged; missing when no date was collected.
  • EPOCH is the trial period of the element in progress at the collection date-time: the element whose start is on or before the collection and whose end is on or after it. A reading collected as a date alone is compared by date: the element whose start date is on or before that date and whose end date is on or after it. It is missing when the reading has no date or only a partial one, or falls outside every element, such as before the first element starts.

Note: the first-dose day shows why a date-time matters: a pre-dose reading on that day belongs to screening and a post-dose reading to treatment. A date-only reading on that day has no time to place it, and no time is assumed; it matches both elements by date. When a reading matches two elements, at a shared boundary moment or on a shared boundary date, it belongs to the later element.

Inputs

Under review
2 source files

input/se.csv

Edit
8 rows
input/se.csv
STUDYIDUSUBJIDETCDELEMENTEPOCHSESTDTCSEENDTC
YAMAA-01SCRNScreeningSCREENING2026-01-02T00:002026-01-06T09:30
YAMAA-01TRTATreatment ATREATMENT2026-01-06T09:302026-02-02T00:00
YAMAA-01FUPFollow-upFOLLOW-UP2026-02-02T00:002026-02-17T00:00
YAMAA-01SCRNScreeningSCREENING2026-01-03T00:002026-01-06T09:30
YAMAA-01TRTBTreatment BTREATMENT2026-01-06T09:302026-01-20T00:00
YAMAA-01FUPFollow-upFOLLOW-UP2026-01-20T00:002026-02-17T00:00
YAMAA-01SCRNScreeningSCREENING2026-03-01T00:002026-03-05T10:00
YAMAA-01TRTATreatment ATREATMENT2026-03-05T10:002026-03-19T00:00

input/vs_raw.csv

Edit
10 rows
input/vs_raw.csv
STUDYIDUSUBJIDVSSEQVSTESTCDVSORRESVSDTC
YAMAA-011SYSBP1282026-01-06T08:00
YAMAA-012SYSBP1322026-01-06T10:30
YAMAA-013SYSBP1302026-01-06
YAMAA-014SYSBP126—
YAMAA-015SYSBP1342026-02-02T00:00
YAMAA-016SYSBP1202026-01
YAMAA-011SYSBP1182026-01-06T09:30
YAMAA-012SYSBP1222026-01-02
YAMAA-013SYSBP1252026-01-25
YAMAA-011SYSBP1352026-03-05T14:00

Expected output

Under review
10 expected rows

expected/vs.csv

Edit
10 rows
expected/vs.csv
DOMAINSTUDYIDUSUBJIDVSSEQVSTESTCDVSORRESVSDTCEPOCH
VSYAMAA-011SYSBP1282026-01-06T08:00SCREENING
VSYAMAA-012SYSBP1322026-01-06T10:30TREATMENT
VSYAMAA-013SYSBP1302026-01-06TREATMENT
VSYAMAA-014SYSBP126——
VSYAMAA-015SYSBP1342026-02-02T00:00FOLLOW-UP
VSYAMAA-016SYSBP1202026-01—
VSYAMAA-011SYSBP1182026-01-06T09:30TREATMENT
VSYAMAA-012SYSBP1222026-01-02—
VSYAMAA-013SYSBP1252026-01-25FOLLOW-UP
VSYAMAA-011SYSBP1352026-03-05T14:00TREATMENT
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 AbbreviationChar2AssignedReqSet constant value "VS".SDTM1
STUDYIDStudy IdentifierChar20ProtocolReqCopy value from VS_RAW.STUDYID.SDTM2
USUBJIDUnique Subject IdentifierChar30AssignedReqCopy value from VS_RAW.USUBJID.SDTM3
VSSEQSequence NumberNum8AssignedReqCopy value from VS_RAW.VSSEQ.SDTM4
VSTESTCDVital Signs Test Short NameChar8AssignedReqCopy value from VS_RAW.VSTESTCD.SDTM5
VSORRESResult or Finding in Original UnitsChar20CollectedExpCopy value from VS_RAW.VSORRES.SDTM6
VSDTCDate/Time of MeasurementsCharISO 8601CollectedExpCopy value from VS_RAW.VSDTC.SDTM7
EPOCHEpochChar10EpochDerivedPermTake EPOCH from the last SE record matching on STUDYID and USUBJID, where VSDTM falls within SESTDTC to SEENDTC, ordered by SE.SESTDTC. A reading collected as a date without a time is matched by date instead, where the date falls within the start and end dates of SESTDTC and SEENDTC. No match yields blank.SDTM8
Codelist IDNameValueDecodeCodelist NCI aliasValue NCI aliasExtensibleExtended valueSAS formatDictionaryVersion
EPOCHEpochSCREENINGYes
EPOCHEpochTREATMENTYes
EPOCHEpochFOLLOW-UPYes
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-vs-epoch-from-subject-elements/full.md

Edit
20 lines

Following CDISC SDTM standards, use the provided SE and VS_RAW datasets to create a VS dataset with one record per vital signs measurement.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, VSSEQ, VSTESTCD, VSORRES, VSDTC, EPOCH

DOMAIN is "VS". VSDTC is the collection date-time as collected, and has no value when no date was collected. EPOCH is the trial period of the subject's element in progress at the collection date-time: the element whose start is on or before the collection and whose end is on or after it. A collection that gives a date but no time is compared by date, with no time assumed: it falls in the element whose start date is on or before that date and whose end date is on or after it. When a reading falls in two elements, exactly at a shared element boundary or on a date that ends one element and starts the next, it belongs to the later element. EPOCH has no value when the reading has no date or only a partial one, or when the collection date-time falls outside every element of the subject, such as before the first element starts.

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

prompts/sdtm-vs-epoch-from-subject-elements/conventions.md

Edit
10 lines

Following CDISC SDTM standards, use the provided SE and VS_RAW datasets to create a VS dataset with one record per vital signs measurement.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, VSSEQ, VSTESTCD, VSORRES, VSDTC, EPOCH

DOMAIN is "VS". EPOCH has no value.

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

prompts/sdtm-vs-epoch-from-subject-elements/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided SE and VS_RAW datasets to create a VS dataset with one record per vital signs measurement.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, VSSEQ, VSTESTCD, VSORRES, VSDTC, EPOCH

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

yamaa code

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

R

Edit
3 lines
library(yamaa)yamaa_project("project.yaml")$spec("VS")$run()$output

Python

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

Solution without yamaa

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

solutions/sdtm-vs-epoch-from-subject-elements/result.R

Edit
97 lines
# Reference solution for the yamaa benchmark sdtm-vs-epoch-from-subject-elements (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(purrr)library(readr)parse_moment <- function(x) {  if (is.na(x) || x == "") {    return(as.POSIXct(NA, tz = "UTC"))  }  # A partial date such as YYYY-MM has no day, so it cannot be placed.  if (nchar(x) == 7 && substr(x, 5, 5) == "-") {    return(as.POSIXct(NA, tz = "UTC"))  }  if (nchar(x) == 4 && grepl("^[0-9]{4}$", x)) {    return(as.POSIXct(NA, tz = "UTC"))  }  # A date alone has no time and is compared by date instead.  if (!grepl("T", x, fixed = TRUE)) {    as.POSIXct(NA, tz = "UTC")  } else {    # Element bounds and collections use ISO datetimes without seconds.    out <- suppressWarnings(ymd_hm(x, tz = "UTC"))    if (is.na(out)) {      out <- suppressWarnings(ymd_hms(x, tz = "UTC"))    }    out  }}se <- read_csv(  "/app/input/se.csv",  col_types = cols(.default = col_character()))vs_raw <- read_csv(  "/app/input/vs_raw.csv",  col_types = cols(VSSEQ = col_integer(), .default = col_character()))se <- se |>  mutate(    start = vapply(SESTDTC, function(x) as.numeric(parse_moment(x)), numeric(1)),    end = vapply(SEENDTC, function(x) as.numeric(parse_moment(x)), numeric(1))  )vs_raw <- vs_raw |>  mutate(    moment = vapply(VSDTC, function(x) as.numeric(parse_moment(x)), numeric(1)),    day = if_else(      grepl("^[0-9]{4}-[0-9]{2}-[0-9]{2}$", coalesce(VSDTC, "")),      suppressWarnings(as.numeric(ymd(VSDTC))),      NA_real_    )  )# The calendar dates of each element's start and end, in days.se <- se |>  mutate(    start_day = as.numeric(as.Date(as.POSIXct(start, origin = "1970-01-01", tz = "UTC"))),    end_day = as.numeric(as.Date(as.POSIXct(end, origin = "1970-01-01", tz = "UTC")))  )vs <- vs_raw |>  mutate(    DOMAIN = "VS",    EPOCH = pmap_chr(      list(USUBJID, moment, day),      function(usubjid, coll, coll_day) {        # A date-time is placed by moment, a date alone by calendar date;        # when two elements match, the later one wins.        if (!is.na(coll)) {          hits <- se |> filter(USUBJID == usubjid, start <= coll, coll <= end)        } else if (!is.na(coll_day)) {          hits <- se |>            filter(USUBJID == usubjid, start_day <= coll_day, coll_day <= end_day)        } else {          return(NA_character_)        }        hits <- hits |> arrange(start)        if (nrow(hits) == 0) {          return(NA_character_)        }        hits$EPOCH[nrow(hits)]      },      .progress = FALSE    )  ) |>  arrange(USUBJID, VSSEQ) |>  select(DOMAIN, STUDYID, USUBJID, VSSEQ, VSTESTCD, VSORRES, VSDTC, EPOCH)dir.create("/app/output", showWarnings = FALSE)write_csv(vs, "/app/output/vs.csv", na = "")

solutions/sdtm-vs-epoch-from-subject-elements/result.py

Edit
131 lines
# Reference solution for the yamaa benchmark sdtm-vs-epoch-from-subject-elements (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 VS dataset, deriving EPOCH from the subject's SE elements.Reads SE and VS_RAW from /app/input and writes /app/output/vs.csv with onerecord per vital signs measurement.EPOCH is the trial period of the subject's element in progress at thecollection date-time: the element whose start is on or before the collectionand whose end is on or after it. A date-only collection is compared by date,with no time assumed: the element whose start date is on or before it andwhose end date is on or after it. A reading that falls in two elementsbelongs to the later one. EPOCH is blank when the reading has no date oronly a partial one, or when it falls outside every element."""import csvimport refrom datetime import date, datetimeINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"FULL_DATETIME = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$")FULL_DATE = re.compile(r"^\d{4}-\d{2}-\d{2}$")def parse_element_bound(text):    """Parse an SE start/end date-time (always fully specified)."""    return datetime.fromisoformat(text)def parse_collection(text):    """Return the collection date-time or date, or None if missing or partial.    A full date-time parses to a datetime; a full date alone parses to a    date, with no time assumed. Anything else (empty, year-month, year    only) yields None.    """    if not text:        return None    text = text.strip()    if FULL_DATETIME.match(text):        return datetime.fromisoformat(text)    if FULL_DATE.match(text):        return date.fromisoformat(text)    return Nonedef covers(element, collection):    """Whether the element is in progress at the collection: by moment for a    date-time, by calendar date for a date alone."""    if isinstance(collection, datetime):        return element["start"] <= collection <= element["end"]    return element["start"].date() <= collection <= element["end"].date()def derive_epoch(collection, elements):    """Return the EPOCH of the element in progress at the collection.    When two elements cover the collection, at a shared boundary instant    or on a shared boundary date, the later element (the one starting at    the boundary) wins.    """    if collection is None:        return ""    matches = [element for element in elements if covers(element, collection)]    if not matches:        return ""    later = max(matches, key=lambda element: element["start"])    return later["epoch"]def main():    with open(f"{INPUT_DIR}/se.csv", newline="") as handle:        se_rows = list(csv.DictReader(handle))    elements_by_subject = {}    for row in se_rows:        key = (row["STUDYID"], row["USUBJID"])        elements_by_subject.setdefault(key, []).append(            {                "epoch": row["EPOCH"],                "start": parse_element_bound(row["SESTDTC"]),                "end": parse_element_bound(row["SEENDTC"]),            }        )    with open(f"{INPUT_DIR}/vs_raw.csv", newline="") as handle:        vs_rows = list(csv.DictReader(handle))    out_rows = []    for row in vs_rows:        key = (row["STUDYID"], row["USUBJID"])        elements = elements_by_subject.get(key, [])        collection = parse_collection(row["VSDTC"])        out_rows.append(            {                "DOMAIN": "VS",                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "VSSEQ": row["VSSEQ"],                "VSTESTCD": row["VSTESTCD"],                "VSORRES": row["VSORRES"],                "VSDTC": row["VSDTC"],                "EPOCH": derive_epoch(collection, elements),            }        )    fieldnames = [        "DOMAIN",        "STUDYID",        "USUBJID",        "VSSEQ",        "VSTESTCD",        "VSORRES",        "VSDTC",        "EPOCH",    ]    with open(f"{OUTPUT_DIR}/vs.csv", "w", newline="") as handle:        writer = csv.DictWriter(handle, fieldnames=fieldnames)        writer.writeheader()        writer.writerows(out_rows)if __name__ == "__main__":    main()

solutions/sdtm-vs-epoch-from-subject-elements/result.sas

Edit
29 lines
/* opensas reference solution for the yamaa benchmark sdtm-vs-epoch-from-subject-elements.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data se;  length STUDYID USUBJID ETCD ELEMENT EPOCH SESTDTC SEENDTC $1024;  infile "/app/input/se.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. ETCD : $char1024. ELEMENT : $char1024. EPOCH : $char1024. SESTDTC : $char1024. SEENDTC : $char1024.;run;data vs_raw;  length STUDYID USUBJID VSTESTCD VSORRES VSDTC $1024;  infile "/app/input/vs_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. VSSEQ VSTESTCD : $char1024. VSORRES : $char1024. VSDTC : $char1024.;run;/* A date-time is placed by moment. A date alone is compared by date, with no   time assumed: an element whose start date is on or before it and whose end   date is on or after it, which is an element starting by the end of that   day and ending at or after its start. */data collections; set vs_raw; length DTC KEYLO KEYHI $1024; DTC=VSDTC; KEYLO=''; KEYHI=''; if lengthn(DTC)=10 then do; KEYLO=cats(DTC,'T23:59:59'); KEYHI=cats(DTC,'T00:00:00'); end; else if lengthn(DTC)=16 then do; KEYLO=cats(DTC,':00'); KEYHI=KEYLO; end; else if lengthn(DTC)>=19 then do; KEYLO=substr(DTC,1,19); KEYHI=KEYLO; end; run;data elements; set se; length DTC MOMENT STARTMOMENT ENDMOMENT $1024; DTC=SESTDTC; MOMENT=''; if lengthn(DTC)=10 then MOMENT=cats(DTC,'T00:00:00'); else if lengthn(DTC)=16 then MOMENT=cats(DTC,':00'); else if lengthn(DTC)>=19 then MOMENT=substr(DTC,1,19); STARTMOMENT=MOMENT; DTC=SEENDTC; MOMENT=''; if lengthn(DTC)=10 then MOMENT=cats(DTC,'T00:00:00'); else if lengthn(DTC)=16 then MOMENT=cats(DTC,':00'); else if lengthn(DTC)>=19 then MOMENT=substr(DTC,1,19); ENDMOMENT=MOMENT; run;proc sql; create table candidates as select a.*,b.EPOCH,b.STARTMOMENT from collections a left join elements b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.KEYLO>=b.STARTMOMENT and a.KEYHI<=b.ENDMOMENT and not missing(a.KEYLO); quit;proc sort data=candidates; by STUDYID USUBJID VSSEQ descending STARTMOMENT; run;data result; length DOMAIN $2; set candidates; DOMAIN='VS'; by STUDYID USUBJID VSSEQ; if first.VSSEQ; run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, VSSEQ, VSTESTCD, VSORRES, VSDTC, EPOCH from result;quit;proc export data=final outfile="/app/output/vs.csv" dbms=csv replace; run;