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: mark each adverse event (AE) that started within 24 hours after
the start of one of the subject's doses (DOSE24FL), and carry the number
of that dose (DOSENUM).
Input: AE records carrying the coded term (AEDECOD) and the collected
onset (AESTDTC, a date with or without a time of day), plus one exposure
(EX) record per dose with the date and time the dose started (EXSTDTC).
Variables:
ASTDTis the onset date; empty when no onset was collected.ASTDTMis the onset date and time, filled only when a time of day was collected. No time is imputed, so an onset recorded as a date alone stays empty here.DOSE24FLholdsYwhen the onset is at or after a dose start and before 24 hours have passed since that start: an onset exactly at the start is inside, one exactly 24 hours later is outside. An onset before the first dose, an onset without a time and a missing onset stay empty.DOSENUMis the number of the dose whose 24 hours hold the onset, counting the subject's doses 1, 2, 3 in order of start; empty whenDOSE24FLis empty. When two doses start less than 24 hours apart and the onset falls within both, the later dose is counted.
Note: the 24-hour length, the open end at exactly 24 hours and counting the later of two overlapping doses are this contract's stated choices. Times compare to the second; a time collected without seconds counts as second zero.
Inputs
Under review2 source filesinput/ae.csv
Edit8 rows| STUDYID | USUBJID | AESEQ | AEDECOD | AESTDTC |
|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | 2030-03-04T08:15 | |
| YAMAA-01 | 2 | CHILLS | 2030-03-04T09:00 | |
| YAMAA-01 | 3 | PYREXIA | 2030-03-19T09:29:59 | |
| YAMAA-01 | 4 | FATIGUE | 2030-03-19T09:30 | |
| YAMAA-01 | 5 | RASH | 2030-04-02 | |
| YAMAA-01 | 6 | NAUSEA | — | |
| YAMAA-01 | 1 | FLUSHING | 2030-03-19T15:10 | |
| YAMAA-01 | 2 | URTICARIA | 2030-03-20T11:20 |
input/ex.csv
Edit6 rows| STUDYID | USUBJID | EXSEQ | EXTRT | EXSTDTC |
|---|---|---|---|---|
| YAMAA-01 | 1 | DRUG A | 2030-03-04T09:00 | |
| YAMAA-01 | 2 | DRUG A | 2030-03-18T09:30 | |
| YAMAA-01 | 3 | DRUG A | 2030-04-01T10:00 | |
| YAMAA-01 | 1 | DRUG A | 2030-03-05T14:00 | |
| YAMAA-01 | 2 | DRUG A | 2030-03-19T14:00 | |
| YAMAA-01 | 3 | DRUG A | 2030-03-20T08:00 |
Expected output
Under review8 expected rowsexpected/adae.csv
Edit8 rows| STUDYID | USUBJID | AESEQ | AEDECOD | ASTDT | ASTDTM | DOSE24FL | DOSENUM |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | 2030-03-04 | 2030-03-04T08:15:00 | — | — | |
| YAMAA-01 | 2 | CHILLS | 2030-03-04 | 2030-03-04T09:00:00 | Y | 1 | |
| YAMAA-01 | 3 | PYREXIA | 2030-03-19 | 2030-03-19T09:29:59 | Y | 2 | |
| YAMAA-01 | 4 | FATIGUE | 2030-03-19 | 2030-03-19T09:30:00 | — | — | |
| YAMAA-01 | 5 | RASH | 2030-04-02 | — | — | — | |
| YAMAA-01 | 6 | NAUSEA | — | — | — | — | |
| YAMAA-01 | 1 | FLUSHING | 2030-03-19 | 2030-03-19T15:10:00 | Y | 2 | |
| YAMAA-01 | 2 | URTICARIA | 2030-03-20 | 2030-03-20T11:20:00 | Y | 3 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADAE | STUDYID | Study Identifier | character | Copy value from AE.STUDYID. | Predecessor | ||
| ADAE | USUBJID | Unique Subject Identifier | character | Copy value from AE.USUBJID. | Predecessor | ||
| ADAE | AESEQ | Sequence Number | numeric | Copy value from AE.AESEQ. | Predecessor | ||
| ADAE | AEDECOD | Dictionary-Derived Term | character | Copy value from AE.AEDECOD. | Predecessor | ||
| ADAE | ASTDT | Analysis Start Date | numeric | ISO 8601 | Take the date part of AE.AESTDTC, blank for a year or a year and month alone. | Derived | |
| ADAE | ASTDTM | Analysis Start Date/Time | numeric | ISO 8601 | If ASTTPR IN ('minute', 'second') then "AE.AESTDTC"; otherwise blank. | Derived | |
| ADAE | DOSENUM | Dose Number of the Window Holding Onset | numeric | Take DOSENUM from the last EX record matching on STUDYID and USUBJID, where ASTDTM falls within EXSTDTC to WINLAST, ordered by EX.EXSTDTC, where DOSENUM is derived as row number within each group of EX.STUDYID, EX.USUBJID, ordered by EX.EXSTDTC then EX.EXSEQ, and no match yields blank. | Derived | ||
| ADAE | DOSE24FL | Onset Within 24 h of Dose Start Flag | character | Y | "Y" when DOSENUM IS NOT NULL; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| DOSE24FL | Y |
| 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-adae-post-dose-window/full.md
Edit23 linesFollowing CDISC ADaM standards, use the provided AE and EX datasets to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, ASTDTM, DOSE24FL, DOSENUM
ASTDT is the date of the collected onset, and has no value when no onset was collected. ASTDTM is the collected onset date and time, and has no value when the onset was collected as a date alone; no time is imputed. DOSE24FL is "Y" when the onset is at or after the start of one of the subject's doses and before 24 hours have passed since that start: an onset exactly at a dose start is inside, and an onset exactly 24 hours after a dose start is outside. DOSE24FL has no value for an onset before the subject's first dose, for an onset collected without a time, and when no onset was collected. DOSENUM is the number of the dose whose 24 hours hold the onset, counting the subject's doses 1, 2, 3 in order of their start, and has no value when DOSE24FL has no value. When two doses start less than 24 hours apart and the onset falls within 24 hours of both, DOSENUM is the number of the later dose. Times compare to the second, and a time collected without seconds counts as second zero.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-post-dose-window/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided AE and EX datasets to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, ASTDTM, DOSE24FL, DOSENUM
DOSE24FL is "Y" or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-post-dose-window/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided AE and EX datasets to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, ASTDTM, DOSE24FL, DOSENUM
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adae-post-dose-window/result.R
Edit76 lines# Reference solution for the yamaa benchmark adam-adae-post-dose-window (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, warn.conflicts = FALSE)library(readr)library(stringr)ae <- read_csv( "/app/input/ae.csv", col_types = cols(AESEQ = col_integer(), .default = col_character()))ex <- read_csv( "/app/input/ex.csv", col_types = cols(EXSEQ = col_integer(), .default = col_character()))# Datetimes collected without seconds are completed to the second so# onsets and dose starts compare at the moment, to the second.complete_seconds <- function(x) { if_else( !is.na(x) & str_detect(x, "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}$"), paste0(x, ":00"), x )}events <- ae |> mutate( ASTDT = if_else(is.na(AESTDTC), NA_character_, substr(AESTDTC, 1, 10)), ASTDTM = if_else( !is.na(AESTDTC) & nchar(AESTDTC) > 10, complete_seconds(AESTDTC), NA_character_ ) ) |> select(STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, ASTDTM)# The subject's doses, numbered 1, 2, 3 in order of start.doses <- ex |> mutate(START = complete_seconds(EXSTDTC)) |> arrange(STUDYID, USUBJID, START, EXSEQ) |> group_by(STUDYID, USUBJID) |> mutate( DOSENUM = row_number(), STARTM = ymd_hms(START, tz = "UTC"), ENDM = STARTM + hours(24) ) |> ungroup() |> select(STUDYID, USUBJID, DOSENUM, STARTM, ENDM)# A window opens at the dose start and closes 24 hours later, the# closing moment itself outside. When two windows hold the onset, the# later dose is counted.picked <- events |> mutate(ONSETM = ymd_hms(ASTDTM, tz = "UTC")) |> inner_join(doses, by = c("STUDYID", "USUBJID"), relationship = "many-to-many") |> filter(!is.na(ONSETM), ONSETM >= STARTM, ONSETM < ENDM) |> arrange(STUDYID, USUBJID, AESEQ, STARTM) |> group_by(STUDYID, USUBJID, AESEQ) |> slice_tail(n = 1) |> ungroup() |> select(STUDYID, USUBJID, AESEQ, DOSENUM)adae <- events |> left_join(picked, by = c("STUDYID", "USUBJID", "AESEQ")) |> mutate(DOSE24FL = if_else(is.na(DOSENUM), NA_character_, "Y")) |> select( STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, ASTDTM, DOSE24FL, DOSENUM )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-post-dose-window/result.py
Edit99 lines# Reference solution for the yamaa benchmark adam-adae-post-dose-window (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."""ADAE post-dose window: flag events starting within 24 hours of a dose."""import csvfrom datetime import datetime, timedeltafrom pathlib import PathINPUT = Path("/app/input")OUTPUT = Path("/app/output")def parse_dtc(text): """Parse an ISO datetime that may be a date alone or lack seconds. Returns (datetime or None, has_time). A time collected without seconds counts as second zero. """ text = (text or "").strip() if not text: return None, False if "T" not in text: return datetime.strptime(text, "%Y-%m-%d"), False for fmt in ("%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M"): try: return datetime.strptime(text, fmt), True except ValueError: continue raise ValueError(f"unrecognised datetime: {text!r}")def main(): with open(INPUT / "ae.csv", newline="") as fh: ae_rows = list(csv.DictReader(fh)) with open(INPUT / "ex.csv", newline="") as fh: ex_rows = list(csv.DictReader(fh)) doses = {} for row in ex_rows: start, _ = parse_dtc(row["EXSTDTC"]) if start is not None: doses.setdefault(row["USUBJID"], []).append(start) for subject_doses in doses.values(): subject_doses.sort() out_rows = [] for row in ae_rows: onset, has_time = parse_dtc(row["AESTDTC"]) astdt = onset.strftime("%Y-%m-%d") if onset is not None else "" astdtm = row["AESTDTC"].strip() if has_time else "" dose24fl = "" dosenum = "" if onset is not None and has_time: subject_doses = doses.get(row["USUBJID"], []) if subject_doses and onset >= subject_doses[0]: holding = [ number for number, start in enumerate(subject_doses, start=1) if start <= onset < start + timedelta(hours=24) ] if holding: dose24fl = "Y" dosenum = str(max(holding)) out_rows.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "AESEQ": row["AESEQ"], "AEDECOD": row["AEDECOD"], "ASTDT": astdt, "ASTDTM": astdtm, "DOSE24FL": dose24fl, "DOSENUM": dosenum, } ) OUTPUT.mkdir(parents=True, exist_ok=True) columns = [ "STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "ASTDTM", "DOSE24FL", "DOSENUM", ] with open(OUTPUT / "adae.csv", "w", newline="") as fh: writer = csv.DictWriter(fh, fieldnames=columns) writer.writeheader() writer.writerows(out_rows)if __name__ == "__main__": main()solutions/adam-adae-post-dose-window/result.sas
Edit62 lines/* opensas reference solution for the yamaa benchmark adam-adae-post-dose-window. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ae; length STUDYID USUBJID AEDECOD AESTDTC $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEDECOD : $char1024. AESTDTC : $char1024.;run;data ex; length STUDYID USUBJID EXTRT EXSTDTC $1024; infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. EXSEQ EXTRT : $char1024. EXSTDTC : $char1024.;run;/* Datetimes collected without seconds are completed to the second so onsets and dose starts compare at the moment, to the second. */data events; length ASTDT ASTDTM $19; set ae; ASTDT=''; ASTDTM=''; if not missing(AESTDTC) then ASTDT=substr(AESTDTC,1,10); if lengthn(AESTDTC)>10 then ASTDTM=cats(AESTDTC,ifc(lengthn(AESTDTC)=16,':00',''));run;/* The subject's doses, numbered 1, 2, 3 in order of start. */proc sort data=ex out=dosesorted; by STUDYID USUBJID EXSTDTC EXSEQ; run;data doses; length DSTART $19; set dosesorted; by STUDYID USUBJID; if first.USUBJID then DOSENUM=0; DOSENUM+1; DSTART=cats(EXSTDTC,ifc(lengthn(EXSTDTC)=16,':00','')); keep STUDYID USUBJID DOSENUM DSTART;run;proc sql; create table joined as select a.*,b.DOSENUM,b.DSTART from events as a left join doses as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data window; set joined; onset=input(ASTDTM,e8601dt.); start=input(DSTART,e8601dt.); /* A window opens at the dose start and closes 24 hours later, the closing moment itself outside. */ if not missing(onset) and not missing(start) and onset>=start and onset<start+86400;run;proc sort data=window; by STUDYID USUBJID AESEQ start; run;data picked; set window; by STUDYID USUBJID AESEQ; if last.AESEQ; keep STUDYID USUBJID AESEQ DOSENUM;run;proc sql; create table result as select a.*,b.DOSENUM,case when not missing(b.DOSENUM) then 'Y' else '' end as DOSE24FL from events as a left join picked as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AESEQ=b.AESEQ;quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, ASTDTM, DOSE24FL, DOSENUM from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;
yamaa