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
README.mdPublic 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:
VSDTCis the collection date-time, carried over unchanged; missing when no date was collected.EPOCHis 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 review2 source filesinput/se.csv
Edit8 rows| STUDYID | USUBJID | ETCD | ELEMENT | EPOCH | SESTDTC | SEENDTC |
|---|---|---|---|---|---|---|
| YAMAA-01 | SCRN | Screening | SCREENING | 2026-01-02T00:00 | 2026-01-06T09:30 | |
| YAMAA-01 | TRTA | Treatment A | TREATMENT | 2026-01-06T09:30 | 2026-02-02T00:00 | |
| YAMAA-01 | FUP | Follow-up | FOLLOW-UP | 2026-02-02T00:00 | 2026-02-17T00:00 | |
| YAMAA-01 | SCRN | Screening | SCREENING | 2026-01-03T00:00 | 2026-01-06T09:30 | |
| YAMAA-01 | TRTB | Treatment B | TREATMENT | 2026-01-06T09:30 | 2026-01-20T00:00 | |
| YAMAA-01 | FUP | Follow-up | FOLLOW-UP | 2026-01-20T00:00 | 2026-02-17T00:00 | |
| YAMAA-01 | SCRN | Screening | SCREENING | 2026-03-01T00:00 | 2026-03-05T10:00 | |
| YAMAA-01 | TRTA | Treatment A | TREATMENT | 2026-03-05T10:00 | 2026-03-19T00:00 |
input/vs_raw.csv
Edit10 rows| STUDYID | USUBJID | VSSEQ | VSTESTCD | VSORRES | VSDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | SYSBP | 128 | 2026-01-06T08:00 | |
| YAMAA-01 | 2 | SYSBP | 132 | 2026-01-06T10:30 | |
| YAMAA-01 | 3 | SYSBP | 130 | 2026-01-06 | |
| YAMAA-01 | 4 | SYSBP | 126 | — | |
| YAMAA-01 | 5 | SYSBP | 134 | 2026-02-02T00:00 | |
| YAMAA-01 | 6 | SYSBP | 120 | 2026-01 | |
| YAMAA-01 | 1 | SYSBP | 118 | 2026-01-06T09:30 | |
| YAMAA-01 | 2 | SYSBP | 122 | 2026-01-02 | |
| YAMAA-01 | 3 | SYSBP | 125 | 2026-01-25 | |
| YAMAA-01 | 1 | SYSBP | 135 | 2026-03-05T14:00 |
Expected output
Under review10 expected rowsexpected/vs.csv
Edit10 rows| DOMAIN | STUDYID | USUBJID | VSSEQ | VSTESTCD | VSORRES | VSDTC | EPOCH |
|---|---|---|---|---|---|---|---|
| VS | YAMAA-01 | 1 | SYSBP | 128 | 2026-01-06T08:00 | SCREENING | |
| VS | YAMAA-01 | 2 | SYSBP | 132 | 2026-01-06T10:30 | TREATMENT | |
| VS | YAMAA-01 | 3 | SYSBP | 130 | 2026-01-06 | TREATMENT | |
| VS | YAMAA-01 | 4 | SYSBP | 126 | — | — | |
| VS | YAMAA-01 | 5 | SYSBP | 134 | 2026-02-02T00:00 | FOLLOW-UP | |
| VS | YAMAA-01 | 6 | SYSBP | 120 | 2026-01 | — | |
| VS | YAMAA-01 | 1 | SYSBP | 118 | 2026-01-06T09:30 | TREATMENT | |
| VS | YAMAA-01 | 2 | SYSBP | 122 | 2026-01-02 | — | |
| VS | YAMAA-01 | 3 | SYSBP | 125 | 2026-01-25 | FOLLOW-UP | |
| VS | YAMAA-01 | 1 | SYSBP | 135 | 2026-03-05T14:00 | TREATMENT |
Human review and assessment
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | 2 | Assigned | Req | Set constant value "VS". | SDTM | 1 | ||
| STUDYID | Study Identifier | Char | 20 | Protocol | Req | Copy value from VS_RAW.STUDYID. | SDTM | 2 | ||
| USUBJID | Unique Subject Identifier | Char | 30 | Assigned | Req | Copy value from VS_RAW.USUBJID. | SDTM | 3 | ||
| VSSEQ | Sequence Number | Num | 8 | Assigned | Req | Copy value from VS_RAW.VSSEQ. | SDTM | 4 | ||
| VSTESTCD | Vital Signs Test Short Name | Char | 8 | Assigned | Req | Copy value from VS_RAW.VSTESTCD. | SDTM | 5 | ||
| VSORRES | Result or Finding in Original Units | Char | 20 | Collected | Exp | Copy value from VS_RAW.VSORRES. | SDTM | 6 | ||
| VSDTC | Date/Time of Measurements | Char | ISO 8601 | Collected | Exp | Copy value from VS_RAW.VSDTC. | SDTM | 7 | ||
| EPOCH | Epoch | Char | 10 | Epoch | Derived | Perm | Take 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. | SDTM | 8 |
| Codelist ID | Name | Value | Decode | Codelist NCI alias | Value NCI alias | Extensible | Extended value | SAS format | Dictionary | Version |
|---|---|---|---|---|---|---|---|---|---|---|
| EPOCH | Epoch | SCREENING | Yes | |||||||
| EPOCH | Epoch | TREATMENT | Yes | |||||||
| EPOCH | Epoch | FOLLOW-UP | Yes |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/sdtm-vs-epoch-from-subject-elements/full.md
Edit20 linesFollowing 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
Edit10 linesFollowing 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
Edit8 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_project("project.yaml")$spec("VS")$run()$outputPython
Edit3 linesimport yamaayamaa.project("project.yaml").spec("VS").run().outputsolutions/sdtm-vs-epoch-from-subject-elements/result.R
Edit97 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
Edit131 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
Edit29 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;
yamaa