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: 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:
PARAMCDandAVALcarry the test code and the numeric result.ADTis the collection date; empty when no date was collected.ADTMis the collection date and time; empty when only a date was collected, since no time is supplied.APERIODis 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.TRTAis the actual treatment of that period:TRT01Ain period 1 andTRT02Ain 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 review2 source filesinput/adsl.csv
Edit3 rows| STUDYID | USUBJID | TRT01A | TRT02A | AP01SDT | AP01SDTM | AP01EDT | AP01EDTM | AP02SDT | AP02SDTM | AP02EDT | AP02EDTM |
|---|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | DRUG A | PLACEBO | 2026-04-06 | 2026-04-06T08:00:00 | 2026-04-13 | 2026-04-13T08:00:00 | 2026-04-20 | 2026-04-20T08:30:00 | 2026-04-27 | 2026-04-27T08:30:00 | |
| YAMAA-01 | PLACEBO | DRUG A | 2026-04-07 | 2026-04-07T09:10:00 | 2026-04-14 | 2026-04-14T09:10:00 | 2026-04-21 | 2026-04-21T09:00:00 | 2026-04-28 | 2026-04-28T09:00:00 | |
| YAMAA-01 | DRUG A | — | 2026-04-08 | — | 2026-04-15 | — | — | — | — | — |
input/vs.csv
Edit12 rows| STUDYID | USUBJID | VSSEQ | VSTESTCD | VSSTRESN | VSDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | SYSBP | 124 | 2026-03-30T10:00 | |
| YAMAA-01 | 2 | SYSBP | 121 | 2026-04-13T08:00:00 | |
| YAMAA-01 | 3 | SYSBP | 119 | 2026-04-13T10:00 | |
| YAMAA-01 | 4 | SYSBP | 123 | 2026-04-20T08:29:59 | |
| YAMAA-01 | 5 | SYSBP | 126 | 2026-04-20T08:30:00 | |
| YAMAA-01 | 6 | SYSBP | 122 | 2026-04-28T09:00 | |
| YAMAA-01 | 1 | SYSBP | 131 | 2026-04-08T09:10 | |
| YAMAA-01 | 2 | SYSBP | 127 | 2026-04-14 | |
| YAMAA-01 | 3 | SYSBP | 128 | 2026-04-21 | |
| YAMAA-01 | 4 | SYSBP | 129 | — | |
| YAMAA-01 | 1 | SYSBP | 120 | 2026-04-15T10:00 | |
| YAMAA-01 | 2 | SYSBP | 122 | 2026-05-06T10:00 |
Expected output
Under review12 expected rowsexpected/advs.csv
Edit12 rows| STUDYID | USUBJID | VSSEQ | PARAMCD | AVAL | ADT | ADTM | APERIOD | TRTA |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | SYSBP | 124 | 2026-03-30 | 2026-03-30T10:00:00 | — | — | |
| YAMAA-01 | 2 | SYSBP | 121 | 2026-04-13 | 2026-04-13T08:00:00 | 1 | DRUG A | |
| YAMAA-01 | 3 | SYSBP | 119 | 2026-04-13 | 2026-04-13T10:00:00 | — | — | |
| YAMAA-01 | 4 | SYSBP | 123 | 2026-04-20 | 2026-04-20T08:29:59 | — | — | |
| YAMAA-01 | 5 | SYSBP | 126 | 2026-04-20 | 2026-04-20T08:30:00 | 2 | PLACEBO | |
| YAMAA-01 | 6 | SYSBP | 122 | 2026-04-28 | 2026-04-28T09:00:00 | — | — | |
| YAMAA-01 | 1 | SYSBP | 131 | 2026-04-08 | 2026-04-08T09:10:00 | 1 | PLACEBO | |
| YAMAA-01 | 2 | SYSBP | 127 | 2026-04-14 | — | 1 | PLACEBO | |
| YAMAA-01 | 3 | SYSBP | 128 | 2026-04-21 | — | 2 | DRUG A | |
| YAMAA-01 | 4 | SYSBP | 129 | — | — | — | — | |
| YAMAA-01 | 1 | SYSBP | 120 | 2026-04-15 | 2026-04-15T10:00:00 | 1 | DRUG A | |
| YAMAA-01 | 2 | SYSBP | 122 | 2026-05-06 | 2026-05-06T10:00:00 | — | — |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADVS | STUDYID | Study Identifier | character | Copy value from VS.STUDYID. | Predecessor | ||
| ADVS | USUBJID | Unique Subject Identifier | character | Copy value from VS.USUBJID. | Predecessor | ||
| ADVS | VSSEQ | Sequence Number | numeric | Copy value from VS.VSSEQ. | Predecessor | ||
| ADVS | PARAMCD | Parameter Code | character | Copy value from VS.VSTESTCD. | Predecessor | ||
| ADVS | AVAL | Analysis Value | numeric | Copy value from VS.VSSTRESN. | Predecessor | ||
| ADVS | ADT | Analysis Date | numeric | ISO 8601 | Take the date part of VS.VSDTC, blank for a year or a year and month alone. | Derived | |
| ADVS | ADTM | Analysis Datetime | numeric | ISO 8601 | If str_contains(VS.VSDTC, 'T') then "VS.VSDTC"; otherwise blank. | Derived | |
| ADVS | APERIOD | Period | numeric | 1, 2 | If ((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 | |
| ADVS | TRTA | Actual Treatment | character | DRUG A, PLACEBO | If APERIOD = 1 then "ADSL.TRT01A"; If APERIOD = 2 then "ADSL.TRT02A"; otherwise blank. | Derived |
| Variable | Permitted values |
|---|---|
| APERIOD | 1, 2 |
| TRTA | DRUG A, PLACEBO |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.8 | 2026-11-19 | yamaa docs build | State open and closed range endpoints, including bounds of zero | ||
| 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/adam-advs-crossover-period-records/full.md
Edit27 linesFollowing 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
Edit13 linesFollowing 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
Edit8 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-advs-crossover-period-records/result.R
Edit82 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
Edit124 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
Edit65 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;
yamaa