Review ask

As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.

  1. Task: Would a real study need this derivation, specified this way? Does it follow CDISC ADaM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. Expected output: Would independent QC programming reproduce every value from these inputs and rules?

The other tabs beside Comments are background for assessment, not under review.

Summary

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Goal: one row per adverse event (AE), marking treatment emergence (TRTEMFL) and the subject's earliest treatment-emergent event (AOCCFL) from onset, first exposure, and the study's 30-day post-last-exposure emergence window.

Input: adverse event records carrying the reported term (AETERM) and the collected onset moment (ASTDTM, empty when never collected), plus the moments of first and last exposure (TRTSDTM, TRTENDTM) from the subject-level analysis dataset (ADSL); the emergence window end (TEENDDTM, last exposure plus 30 days) is carried alongside. An untreated subject appears in ADSL with an empty TRTSDTM and none of their events get flagged.

Variables:

  • TEENDDTM is the end of the treatment-emergent window: 30 days after last exposure.
  • TRTEMFL holds Y when the event started inside the window - at or after first exposure and at or before the window end. It stays empty for an earlier or later event. A missing onset cannot be ruled pre-treatment, so the conservative convention flags it Y whenever the subject was treated; an untreated subject's events stay empty.
  • AOCCFL holds Y on the subject's earliest treatment-emergent event, ordered by onset moment with the lower sequence number (AESEQ) settling ties at the same second. All other rows stay empty; a treatment-emergent event with a missing onset is flagged but cannot be ordered, so it never carries the occurrence flag.

Note: emergence is decided at the moment, not the day: an event that started earlier on the day of first exposure and one that started later that same day fall on opposite sides, and a start date alone cannot tell them apart.

Note: a collected datetime without seconds is coerced to the second (seconds zero-filled) and compared at second precision. HEADACHE is collected as 2025-03-04T11:45 and VOMITING as 2025-03-04T11:45:00; both land on the same second, so the AOCCFL tie-break ("the lower sequence number settles ties at the same second") is what picks the earliest treatment-emergent event. No time-imputation flag is derived for the coerced value: the coercion happens inside the engine's datetime type, and the language's collected-precision model reports only day/second tiers, so a minute-precision source is not distinguishable from a second-precision one in spec language.

Inputs

Under review
2 source files

input/adsl.csv

Edit
3 rows
input/adsl.csv
STUDYIDUSUBJIDTRTSDTMTRTENDTMTEENDDTM
PILOT72025-03-04T09:00:002025-03-10T09:00:002025-04-09T09:00:00
PILOT72025-03-05T09:00:002025-03-05T09:00:002025-04-04T09:00:00
PILOT7———

input/ae.csv

Edit
10 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAETERMAESTDTC
PILOT71CHILLS2025-03-04T07:15:00
PILOT72HEADACHE2025-03-04T11:45
PILOT73NAUSEA2025-03-06T22:30:00
PILOT74VOMITING2025-03-04T11:45:00
PILOT75BACK PAIN2025-04-15T10:00:00
PILOT76COUGH2025-03-20T08:00:00
PILOT71RASH2025-03-05T09:00:00
PILOT72PRURITUS—
PILOT73DIZZINESS2025-04-04T09:00
PILOT71FATIGUE2025-03-07T13:05:00

Expected output

Under review
10 expected rows

expected/adae.csv

Edit
10 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAETERMASTDTMTRTSDTMTEENDDTMTRTEMFLAOCCFL
PILOT71CHILLS2025-03-04T07:15:002025-03-04T09:00:002025-04-09T09:00:00——
PILOT72HEADACHE2025-03-04T11:45:002025-03-04T09:00:002025-04-09T09:00:00YY
PILOT73NAUSEA2025-03-06T22:30:002025-03-04T09:00:002025-04-09T09:00:00Y—
PILOT74VOMITING2025-03-04T11:45:002025-03-04T09:00:002025-04-09T09:00:00Y—
PILOT75BACK PAIN2025-04-15T10:00:002025-03-04T09:00:002025-04-09T09:00:00——
PILOT76COUGH2025-03-20T08:00:002025-03-04T09:00:002025-04-09T09:00:00Y—
PILOT71RASH2025-03-05T09:00:002025-03-05T09:00:002025-04-04T09:00:00YY
PILOT72PRURITUS—2025-03-05T09:00:002025-04-04T09:00:00Y—
PILOT73DIZZINESS2025-04-04T09:00:002025-03-05T09:00:002025-04-04T09:00:00Y—
PILOT71FATIGUE2025-03-07T13:05:00————
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository 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
ADAEAETERMReported Term for the Adverse EventcharacterCopy value from AE.AETERM.Predecessor
ADAEASTDTMAnalysis Start Date/TimenumericISO 8601Copy value from AE.AESTDTC.Predecessor
ADAETRTSDTMDatetime of First Exposure to TreatmentnumericISO 8601Copy value from ADSL.TRTSDTM.Predecessor
ADAETEENDDTMEnd of Treatment-Emergent WindownumericISO 8601Copy value from ADSL.TEENDDTM.Predecessor
ADAETRTEMFLTreatment Emergent Analysis FlagcharacterYIf TRTSDTM IS NULL then "None"; If ASTDTM IS NULL then "Y"; If ASTDTM >= TRTSDTM AND ASTDTM <= TEENDDTM then "Y"; otherwise "None".Derived
ADAEAOCCFLFirst Occurrence Within Subject FlagcharacterY"Y" when AOCCSEQ = 1; blank otherwise.Derived
VariablePermitted values
TRTEMFLY
AOCCFLY
VersionDateAuthorDescriptionReviewerSign-off
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-onset-emergence/full.md

Edit
27 lines

Following CDISC ADaM standards, use the provided AE and ADSL 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, AETERM, ASTDTM, TRTSDTM, TEENDDTM, TRTEMFL, AOCCFL

ASTDTM is the collected onset moment, TRTSDTM is the moment of first exposure from ADSL, and TEENDDTM is the end of the treatment-emergent window (30 days after last exposure) from ADSL.

TRTEMFL is Y when the event started inside the window from first exposure through the window end, inclusive. It has no value for an event that started before first exposure or after the window end. A missing onset cannot be ruled pre-treatment, so a treated subject's event with a missing onset is flagged Y; a subject with no first exposure at all is never treatment-emergent. Emergence is decided at the moment, not the day: events starting earlier and later on the day of first exposure fall on opposite sides.

AOCCFL is Y on the subject's earliest treatment-emergent event with a known onset, ordered by onset moment with the lower AESEQ settling ties at the same second. Events with missing onset are excluded from this selection. All other rows have no value.

Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.

prompts/adam-adae-onset-emergence/conventions.md

Edit
11 lines

Following CDISC ADaM standards, use the provided AE and ADSL 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, AETERM, ASTDTM, TRTSDTM, TEENDDTM, TRTEMFL, AOCCFL

TRTEMFL is Y or has no value. AOCCFL 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-onset-emergence/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided AE and ADSL 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, AETERM, ASTDTM, TRTSDTM, TEENDDTM, TRTEMFL, AOCCFL

Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adae <- yamaa_domain("spec.yaml")$outputadae

run.py

Edit
4 lines
import yamaaadae = yamaa.yamaa_domain("spec.yaml").outputadae

Solution without yamaa

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

solutions/adam-adae-onset-emergence/result.R

Edit
73 lines
# Reference solution for the yamaa benchmark adam-adae-onset-emergence (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(readr)library(stringr)ae <- read_csv(  "/app/input/ae.csv",  col_types = cols(AESEQ = col_integer(), .default = col_character()))adsl <- read_csv(  "/app/input/adsl.csv",  col_types = cols(.default = col_character()))# Datetimes collected without seconds are completed to the second so the# onset and the first exposure compare at the moment, not the day.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  )}ae <- ae |>  mutate(ASTDTM = complete_seconds(AESTDTC)) |>  select(STUDYID, USUBJID, AESEQ, AETERM, ASTDTM)adsl <- adsl |>  mutate(TRTSDTM = complete_seconds(TRTSDTM), TEENDDTM = complete_seconds(TEENDDTM)) |>  select(USUBJID, TRTSDTM, TEENDDTM)# The window rule: onset inside [first exposure, window end] is# treatment-emergent. A missing onset cannot be ruled pre-treatment,# so a treated subject's event with a missing onset is flagged Y; an# untreated subject (no first exposure) is never treatment-emergent.adae <- ae |>  left_join(adsl, by = "USUBJID") |>  mutate(    TRTEMFL = case_when(      is.na(TRTSDTM) ~ NA_character_,      is.na(ASTDTM) ~ "Y",      ASTDTM >= TRTSDTM & ASTDTM <= TEENDDTM ~ "Y",      .default = NA_character_    )  )# The subject's earliest treatment-emergent event with a known onset,# ordered by onset moment with the lower AESEQ settling ties at the# same second.first <- adae |>  filter(TRTEMFL %in% "Y", !is.na(ASTDTM)) |>  arrange(USUBJID, ASTDTM, AESEQ) |>  distinct(USUBJID, .keep_all = TRUE) |>  select(USUBJID, FIRST_SEQ = AESEQ)adae <- adae |>  left_join(first, by = "USUBJID") |>  mutate(    AOCCFL = if_else(!is.na(FIRST_SEQ) & AESEQ == FIRST_SEQ, "Y", NA_character_)  ) |>  select(    STUDYID, USUBJID, AESEQ, AETERM, ASTDTM, TRTSDTM, TEENDDTM,    TRTEMFL, AOCCFL  )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")

solutions/adam-adae-onset-emergence/result.py

Edit
87 lines
# Reference solution for the yamaa benchmark adam-adae-onset-emergence (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.from pathlib import Pathimport polars as plae = pl.read_csv("/app/input/ae.csv", infer_schema=False).with_columns(    pl.col("AESEQ").cast(pl.Int64))adsl = pl.read_csv("/app/input/adsl.csv", infer_schema=False)def complete_seconds(frame: pl.DataFrame, name: str, out: str) -> pl.DataFrame:    # Datetimes collected without seconds are completed to the second so    # the onset and the first exposure compare at the moment, not the day.    return frame.with_columns(        pl.when(pl.col(name).str.contains(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$"))        .then(pl.col(name) + ":00")        .otherwise(pl.col(name))        .alias(out)    )ae = complete_seconds(ae, "AESTDTC", "ASTDTM").select(    "STUDYID", "USUBJID", "AESEQ", "AETERM", "ASTDTM")adsl = (    complete_seconds(adsl, "TRTSDTM", "TRTSDTM")    .pipe(complete_seconds, "TEENDDTM", "TEENDDTM")    .select("USUBJID", "TRTSDTM", "TEENDDTM"))# The window rule: onset inside [first exposure, window end] is# treatment-emergent. A missing onset cannot be ruled pre-treatment,# so a treated subject's event with a missing onset is flagged Y; an# untreated subject (no first exposure) is never treatment-emergent.adae = ae.join(adsl, on="USUBJID", how="left", maintain_order="left").with_columns(    TRTEMFL=pl.when(pl.col("TRTSDTM").is_null())    .then(None)    .when(pl.col("ASTDTM").is_null())    .then(pl.lit("Y"))    .when(        (pl.col("ASTDTM") >= pl.col("TRTSDTM"))        & (pl.col("ASTDTM") <= pl.col("TEENDDTM"))    )    .then(pl.lit("Y"))    .otherwise(None))# The subject's earliest treatment-emergent event with a known onset,# ordered by onset moment with the lower AESEQ settling ties at the# same second. ISO datetimes sort as text once seconds are completed.first = (    adae.filter(        (pl.col("TRTEMFL") == "Y") & pl.col("ASTDTM").is_not_null()    )    .sort(["USUBJID", "ASTDTM", "AESEQ"], nulls_last=True)    .unique("USUBJID", keep="first", maintain_order=True)    .select("USUBJID", FIRST_SEQ="AESEQ"))adae = (    adae.join(first, on="USUBJID", how="left")    .with_columns(        AOCCFL=pl.when(            pl.col("FIRST_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("FIRST_SEQ"))        ).then(pl.lit("Y"))    )    .select(        "STUDYID",        "USUBJID",        "AESEQ",        "AETERM",        "ASTDTM",        "TRTSDTM",        "TEENDDTM",        "TRTEMFL",        "AOCCFL",    ))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

solutions/adam-adae-onset-emergence/result.sas

Edit
41 lines
/* opensas reference solution for the yamaa benchmark adam-adae-onset-emergence.   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 TRTSDTM TRTENDTM TEENDDTM $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRTSDTM : $char1024. TRTENDTM : $char1024. TEENDDTM : $char1024.;run;data ae;  length STUDYID USUBJID AETERM AESTDTC $1024;  infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AESTDTC : $char1024.;run;proc sql; create table joined as select a.*,b.TRTSDTM,b.TEENDDTM from ae as a left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data events;  length ASTDTM $19 TRTEMFL $1;  set joined; ASTDTM=''; TRTEMFL='';  /* Datetimes collected without seconds are completed to the second so the     onset and the first exposure compare at the moment, not the day. */  if not missing(AESTDTC) then ASTDTM=cats(AESTDTC,ifc(lengthn(AESTDTC)=16,':00',''));  onset=input(ASTDTM,e8601dt.); treatment=input(TRTSDTM,e8601dt.); window_end=input(TEENDDTM,e8601dt.);  /* The window rule: onset inside [first exposure, window end] is     treatment-emergent. A missing onset cannot be ruled pre-treatment,     so a treated subject's event with a missing onset is flagged Y; an     untreated subject (no first exposure) is never treatment-emergent. */  if not missing(treatment) then do;    if missing(onset) then TRTEMFL='Y';    else if onset>=treatment and onset<=window_end then TRTEMFL='Y';  end;run;proc sort data=events(where=(TRTEMFL='Y' and not missing(onset))) out=eligible; by STUDYID USUBJID onset AESEQ; run;data firstevent; set eligible; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID AESEQ; run;proc sql; create table result as select a.*,case when not missing(b.AESEQ) then 'Y' else '' end as AOCCFL from events as a left join firstevent 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, AETERM, ASTDTM, TRTSDTM, TEENDDTM, TRTEMFL, AOCCFL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;