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 SDTM: 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: draftEditUnder review
What this benchmark means
README.md

Goal: create one adverse event (AE) record per reported event from long-form Operational Data Model (ODM) item data.

Input: each collected item has its own ODM row. Items belonging to one event share the subject, visit, visit repeat, form, and form repeat identifiers.

Variables:

  • AESEQ numbers the subject's events from 1 in visit order (screening, then baseline), then by visit repeat and form repeat; an event at any other visit stops the run.
  • AETERM keeps the free-text term exactly as reported.
  • AESTDTC and AEENDTC come from the same event occurrence; a missing end date stays blank.
  • AESEV and AESER come from that occurrence's severity and seriousness items.

Note: each form occurrence is its own event, so a form repeat number reused at a later visit, or the same term reported in two occurrences, still gives separate records. Only AE forms are read, and an occurrence without a reported term contributes no AE record.

Inputs

Under review
1 source file

input/odm.csv

Edit
26 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyFormOIDFormRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.DM1IG.DM1IT.DM.SEXF
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE1IT.AE.AETERMHeadache
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE1IT.AE.AESTDTC2025-01-02
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE1IT.AE.AEENDTC2025-01-03
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE1IT.AE.AESEVMILD
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE1IT.AE.AESERN
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE2IT.AE.AETERMNausea
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE2IT.AE.AESTDTC2025-01-04
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE2IT.AE.AEENDTC—
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE2IT.AE.AESEVMODERATE
YAMAA-01MDV.1YAMAA-01-0001SCREENING1FO.AE1IG.AE2IT.AE.AESERN
YAMAA-01MDV.1YAMAA-01-0001BASELINE1FO.AE1IG.AE1IT.AE.AETERMHeadache
YAMAA-01MDV.1YAMAA-01-0001BASELINE1FO.AE1IG.AE1IT.AE.AESTDTC2025-01-10
YAMAA-01MDV.1YAMAA-01-0001BASELINE1FO.AE1IG.AE1IT.AE.AEENDTC2025-01-11
YAMAA-01MDV.1YAMAA-01-0001BASELINE1FO.AE1IG.AE1IT.AE.AESEVMILD
YAMAA-01MDV.1YAMAA-01-0001BASELINE1FO.AE1IG.AE1IT.AE.AESERN
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE1IT.AE.AETERMRash
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE1IT.AE.AESTDTC2025-02-02
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE1IT.AE.AEENDTC2025-02-05
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE1IT.AE.AESEVSEVERE
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE1IT.AE.AESERY
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE2IT.AE.AETERM—
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE2IT.AE.AESTDTC2025-02-03
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE2IT.AE.AEENDTC—
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE2IT.AE.AESEV—
YAMAA-01MDV.1YAMAA-01-0002SCREENING1FO.AE1IG.AE2IT.AE.AESERN

Expected output

Under review
4 expected rows

expected/ae.csv

Edit
4 rows
expected/ae.csv
DOMAINSTUDYIDUSUBJIDAESEQAETERMAESTDTCAEENDTCAESEVAESER
AEYAMAA-011Headache2025-01-022025-01-03MILDN
AEYAMAA-012Nausea2025-01-04—MODERATEN
AEYAMAA-013Headache2025-01-102025-01-11MILDN
AEYAMAA-011Rash2025-02-022025-02-05SEVEREY
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

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "AE".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
AETERMReported Term for the Adverse EventCharDerivedSet per constructed row; see the Row construction sheet.SDTM4
AESTDTCStart Date/Time of Adverse EventCharISO 8601DerivedSet per constructed row; see the Row construction sheet.SDTM5
AEENDTCEnd Date/Time of Adverse EventCharISO 8601DerivedSet per constructed row; see the Row construction sheet.SDTM6
AESEVSeverity/IntensityCharMILD, MODERATE, SEVEREDerivedSet per constructed row; see the Row construction sheet.SDTM7
AESERSerious EventCharY, NDerivedSet per constructed row; see the Row construction sheet.SDTM8
AESEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by EVENTORD then EVENTREPEAT then REPEATKEY.SDTM9
TemplateInclude whenFORMAETERMAESTDTCAEENDTCAESEVAESER
collected-occurrenceFORM = 'IG.AE' AND AETERM IS NOT NULLCopy ODM.ItemGroupOIDRead collected ODM item IT.AE.AETERM; no identified record yields blankRead collected ODM item IT.AE.AESTDTC; no identified record yields blankRead collected ODM item IT.AE.AEENDTC; no identified record yields blankRead collected ODM item IT.AE.AESEV; no identified record yields blankRead collected ODM item IT.AE.AESER; no identified record yields blank
VariablePermitted values
AESEVMILD, MODERATE, SEVERE
AESERY, N
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/sdtm-ae-odm-repeated/full.md

Edit
22 lines

Following CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported adverse event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER

STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.

Each AE item group occurrence is its own event: items sharing subject, visit, visit repeat, item group, and item group repeat key (ItemGroupRepeatKey) belong to one event, so a repeat key reused at a later visit, or the same term reported in two occurrences, still gives separate records. Only AE items are read, and an occurrence without a reported term gives no record. AETERM keeps the free-text term exactly as reported. AESTDTC and AEENDTC come from the same occurrence; a missing end date has no value. AESEV and AESER keep that occurrence's severity and seriousness. AESEQ numbers the subject's events from 1 in visit order (screening, then baseline), then by visit repeat and item group repeat key.

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

prompts/sdtm-ae-odm-repeated/conventions.md

Edit
8 lines

Following CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported adverse event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER

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

prompts/sdtm-ae-odm-repeated/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported adverse event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)ae <- yamaa_domain("spec.yaml")$outputae

run.py

Edit
4 lines
import yamaaae = yamaa.yamaa_domain("spec.yaml").outputae

Solution without yamaa

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

solutions/sdtm-ae-odm-repeated/result.R

Edit
60 lines
# Reference solution for the yamaa benchmark sdtm-ae-odm-repeated (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(tidyr)odm <- read_csv(  "/app/input/odm.csv",  col_types = cols(.default = col_character()))# One event per AE item group occurrence: subject, visit, visit repeat, item# group, and item group repeat key. An occurrence without a reported term# gives no record; a repeat key reused at a later visit starts a new event.events <- odm |>  filter(ItemGroupOID == "IG.AE") |>  pivot_wider(    id_cols = c(      StudyOID, SubjectKey, StudyEventOID, StudyEventRepeatKey,      ItemGroupRepeatKey    ),    names_from = ItemOID,    values_from = Value,    values_fn = first  ) |>  mutate(    AETERM = `IT.AE.AETERM`,    AESTDTC = `IT.AE.AESTDTC`,    AEENDTC = `IT.AE.AEENDTC`,    AESEV = `IT.AE.AESEV`,    AESER = `IT.AE.AESER`  ) |>  filter(!is.na(AETERM) & AETERM != "") |>  # Visit order is screening, then baseline; then visit repeat and item  # group repeat key. The same term in two occurrences stays two records.  mutate(    VISITORD = case_when(      StudyEventOID == "SCREENING" ~ 0L,      StudyEventOID == "BASELINE" ~ 1L,      .default = 2L    ),    VISITREP = as.integer(StudyEventRepeatKey),    IGREP = as.integer(ItemGroupRepeatKey)  ) |>  arrange(SubjectKey, VISITORD, VISITREP, IGREP) |>  group_by(SubjectKey) |>  mutate(AESEQ = row_number()) |>  ungroup() |>  mutate(DOMAIN = "AE", STUDYID = StudyOID, USUBJID = SubjectKey) |>  select(    DOMAIN, STUDYID, USUBJID, AESEQ, AETERM,    AESTDTC, AEENDTC, AESEV, AESER  )dir.create("/app/output", showWarnings = FALSE)write_csv(events, "/app/output/ae.csv", na = "")

solutions/sdtm-ae-odm-repeated/result.py

Edit
66 lines
# Reference solution for the yamaa benchmark sdtm-ae-odm-repeated (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 plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)# One event per AE item group occurrence: subject, visit, visit repeat, item# group, and item group repeat key. An occurrence without a reported term# gives no record; a repeat key reused at a later visit starts a new event.events = (    odm.filter(pl.col("ItemGroupOID") == "IG.AE")    .pivot(        index=[            "StudyOID",            "SubjectKey",            "StudyEventOID",            "StudyEventRepeatKey",            "ItemGroupRepeatKey",        ],        on="ItemOID",        values="Value",        aggregate_function="first",    )    .with_columns(        AETERM=pl.col("IT.AE.AETERM"),        AESTDTC=pl.col("IT.AE.AESTDTC"),        AEENDTC=pl.col("IT.AE.AEENDTC"),        AESEV=pl.col("IT.AE.AESEV"),        AESER=pl.col("IT.AE.AESER"),    )    .filter(pl.col("AETERM").fill_null("") != "")    # Visit order is screening, then baseline; then visit repeat and item    # group repeat key. The same term in two occurrences stays two records.    .with_columns(        VISITORD=pl.when(pl.col("StudyEventOID") == "SCREENING")        .then(0)        .when(pl.col("StudyEventOID") == "BASELINE")        .then(1)        .otherwise(2),        VISITREP=pl.col("StudyEventRepeatKey").cast(pl.Int64),        IGREP=pl.col("ItemGroupRepeatKey").cast(pl.Int64),    )    .sort(["SubjectKey", "VISITORD", "VISITREP", "IGREP"])    .with_columns(AESEQ=pl.col("SubjectKey").cum_count().over("SubjectKey"))    .with_columns(DOMAIN=pl.lit("AE"), STUDYID=pl.col("StudyOID"), USUBJID=pl.col("SubjectKey"))    .select(        "DOMAIN",        "STUDYID",        "USUBJID",        "AESEQ",        "AETERM",        "AESTDTC",        "AEENDTC",        "AESEV",        "AESER",    ))Path("/app/output").mkdir(exist_ok=True)events.write_csv("/app/output/ae.csv")

solutions/sdtm-ae-odm-repeated/result.sas

Edit
41 lines
/* opensas reference solution for the yamaa benchmark sdtm-ae-odm-repeated.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm;  length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024;  infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. FormOID : $char1024. FormRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey; run;data wide;  length AETERM AESTDTC AEENDTC AESEV AESER $1024;  retain AETERM AESTDTC AEENDTC AESEV AESER;  set ordered;  where ItemGroupOID='IG.AE';  by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey;  if first.ItemGroupRepeatKey then do;    AETERM=''; AESTDTC=''; AEENDTC=''; AESEV=''; AESER='';  end;    if ItemOID='IT.AE.AETERM' then AETERM=Value;  if ItemOID='IT.AE.AESTDTC' then AESTDTC=Value;  if ItemOID='IT.AE.AEENDTC' then AEENDTC=Value;  if ItemOID='IT.AE.AESEV' then AESEV=Value;  if ItemOID='IT.AE.AESER' then AESER=Value;  if last.ItemGroupRepeatKey then output;run;data prepared; set wide; if not missing(AETERM);length DOMAIN $2 STUDYID USUBJID $1024; DOMAIN='AE'; STUDYID=StudyOID; USUBJID=SubjectKey;VISITORD=2; if StudyEventOID='SCREENING' then VISITORD=0; if StudyEventOID='BASELINE' then VISITORD=1;VISITREP=input(StudyEventRepeatKey,best32.); IGREP=input(ItemGroupRepeatKey,best32.); run;proc sort data=prepared; by STUDYID USUBJID VISITORD VISITREP IGREP; run;data result; set prepared; by STUDYID USUBJID; retain AESEQ;  if first.USUBJID then AESEQ=0;  AESEQ+1;run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER from result;quit;proc export data=final outfile="/app/output/ae.csv" dbms=csv replace; run;