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: 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:

  • ASTDT is the onset date; empty when no onset was collected.
  • ASTDTM is 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.
  • DOSE24FL holds Y when 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.
  • DOSENUM is the number of the dose whose 24 hours hold the onset, counting the subject's doses 1, 2, 3 in order of start; empty when DOSE24FL is 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 review
2 source files

input/ae.csv

Edit
8 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAEDECODAESTDTC
YAMAA-011HEADACHE2030-03-04T08:15
YAMAA-012CHILLS2030-03-04T09:00
YAMAA-013PYREXIA2030-03-19T09:29:59
YAMAA-014FATIGUE2030-03-19T09:30
YAMAA-015RASH2030-04-02
YAMAA-016NAUSEA—
YAMAA-011FLUSHING2030-03-19T15:10
YAMAA-012URTICARIA2030-03-20T11:20

input/ex.csv

Edit
6 rows
input/ex.csv
STUDYIDUSUBJIDEXSEQEXTRTEXSTDTC
YAMAA-011DRUG A2030-03-04T09:00
YAMAA-012DRUG A2030-03-18T09:30
YAMAA-013DRUG A2030-04-01T10:00
YAMAA-011DRUG A2030-03-05T14:00
YAMAA-012DRUG A2030-03-19T14:00
YAMAA-013DRUG A2030-03-20T08:00

Expected output

Under review
8 expected rows

expected/adae.csv

Edit
8 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAEDECODASTDTASTDTMDOSE24FLDOSENUM
YAMAA-011HEADACHE2030-03-042030-03-04T08:15:00——
YAMAA-012CHILLS2030-03-042030-03-04T09:00:00Y1
YAMAA-013PYREXIA2030-03-192030-03-19T09:29:59Y2
YAMAA-014FATIGUE2030-03-192030-03-19T09:30:00——
YAMAA-015RASH2030-04-02———
YAMAA-016NAUSEA————
YAMAA-011FLUSHING2030-03-192030-03-19T15:10:00Y2
YAMAA-012URTICARIA2030-03-202030-03-20T11:20:00Y3
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

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADAESTUDYIDStudy IdentifiercharacterCopy value from AE.STUDYID.Predecessor
ADAEUSUBJIDUnique Subject IdentifiercharacterCopy value from AE.USUBJID.Predecessor
ADAEAESEQSequence NumbernumericCopy value from AE.AESEQ.Predecessor
ADAEAEDECODDictionary-Derived TermcharacterCopy value from AE.AEDECOD.Predecessor
ADAEASTDTAnalysis Start DatenumericISO 8601Take the date part of AE.AESTDTC, blank for a year or a year and month alone.Derived
ADAEASTDTMAnalysis Start Date/TimenumericISO 8601If ASTTPR IN ('minute', 'second') then "AE.AESTDTC"; otherwise blank.Derived
ADAEDOSENUMDose Number of the Window Holding OnsetnumericTake 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
ADAEDOSE24FLOnset Within 24 h of Dose Start FlagcharacterY"Y" when DOSENUM IS NOT NULL; blank otherwise.Derived
VariablePermitted values
DOSE24FLY
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/adam-adae-post-dose-window/full.md

Edit
23 lines

Following 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

Edit
10 lines

Following 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

Edit
8 lines

Following 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.

yamaa code

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

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

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

Solution without yamaa

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

solutions/adam-adae-post-dose-window/result.R

Edit
76 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

Edit
99 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

Edit
62 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;