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 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:
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 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.TRTAis the actual treatment of that period:TRT01Ain period 1 andTRT02Ain period 2; empty when the record has no period.
Inputs
Under review2 source filesinput/adsl.csv
Edit3 rows| STUDYID | USUBJID | TRT01A | TRT02A | AP01SDT | AP01SDTM | AP02SDT | AP02SDTM |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | DRUG A | PLACEBO | 2026-04-06 | 2026-04-06T08:00:00 | 2026-04-20 | 2026-04-20T08:30:00 | |
| YAMAA-01 | PLACEBO | DRUG A | 2026-04-07 | 2026-04-07T09:10:00 | 2026-04-21 | 2026-04-21T09:00:00 | |
| YAMAA-01 | DRUG A | — | 2026-04-08 | 2026-04-08T08:15:00 | — | — |
input/vs.csv
Edit8 rows| STUDYID | USUBJID | VSSEQ | VSTESTCD | VSSTRESN | VSDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | SYSBP | 124 | 2026-03-30T10:00 | |
| YAMAA-01 | 2 | SYSBP | 121 | 2026-04-20T08:29:59 | |
| YAMAA-01 | 3 | SYSBP | 126 | 2026-04-20T08:30:00 | |
| YAMAA-01 | 1 | SYSBP | 131 | 2026-04-08T09:10 | |
| YAMAA-01 | 2 | SYSBP | 128 | 2026-04-21 | |
| YAMAA-01 | 3 | SYSBP | 125 | 2026-04-22T09:00 | |
| YAMAA-01 | 4 | SYSBP | 129 | — | |
| YAMAA-01 | 1 | SYSBP | 122 | 2026-05-06T10:00 |
Expected output
Under review8 expected rowsexpected/advs.csv
Edit8 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-20 | 2026-04-20T08:29:59 | 1 | DRUG A | |
| YAMAA-01 | 3 | SYSBP | 126 | 2026-04-20 | 2026-04-20T08:30:00 | 2 | PLACEBO | |
| YAMAA-01 | 1 | SYSBP | 131 | 2026-04-08 | 2026-04-08T09:10:00 | 1 | PLACEBO | |
| YAMAA-01 | 2 | SYSBP | 128 | 2026-04-21 | — | 2 | DRUG A | |
| YAMAA-01 | 3 | SYSBP | 125 | 2026-04-22 | 2026-04-22T09:00:00 | 2 | DRUG A | |
| YAMAA-01 | 4 | SYSBP | 129 | — | — | — | — | |
| YAMAA-01 | 1 | SYSBP | 122 | 2026-05-06 | 2026-05-06T10:00:00 | 1 | DRUG A |
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 >= 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 | |
| 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.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
Edit22 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. 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
Edit11 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
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
Edit72 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
Edit117 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
Edit54 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;
yamaa