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) with an analysis start date (ASTDT) completed from the collected start at whatever precision it was collected, a flag (ASTDTF) marking the dates whose day was supplied, and a treatment emergence flag (TRTEMFL).

Input: adverse event records carrying the reported term (AETERM) and the collected start (AESTDTC): a full date, a year and month, a year alone, non-date text, or nothing at all, plus the first-exposure date (TRTSDT) from the subject-level analysis dataset (ADSL), empty when the subject has no ADSL record.

Variables:

  • ASTDT is the analysis start date. A fully collected date is used as it stands. A year and month is completed to the 15th. A year alone, non-date text, and a missing value give no analysis date.
  • ASTDTC is the same analysis date written as text, empty when there is no analysis date.
  • ASTDTF is D when the day was supplied to complete the date. It is empty when the date was collected in full and when no analysis date could be formed, so the flag always matches the date shown. In CDISC terms only the day was imputed, which is the level of imputation the flag records.
  • TRTEMFL is Y when the analysis start falls on or after TRTSDT. It stays empty when there is no analysis date, when the event started before first exposure, or when the subject's first-exposure date is unknown. A supplied day counts exactly as a collected one would, so ASTDTF tells a reader which flagged events rested on a supplied day.

Note: a completed date is never placed before first exposure. When the 15th would fall before TRTSDT, the date moves forward to the exposure date, which the collected month still allows. When the whole collected month ends before the exposure date, no day it allows can satisfy that, so the event is left without an analysis date rather than moved into a month nobody recorded. A fully collected date is left exactly as collected even when it falls before TRTSDT, because there is nothing about it to choose.

Inputs

Under review
2 source files

input/adsl.csv

Edit
3 rows
input/adsl.csv
STUDYIDUSUBJIDTRTSDT
CATH2025-01-10
CATH2025-03-20
CATH2025-02-15

input/ae.csv

Edit
13 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAETERMAESTDTC
CATH1HEADACHE2025-01-15
CATH2NAUSEA2025-01
CATH3ECZEMA FLARE2025
CATH4DIZZINESSUNKNOWN
CATH5FATIGUE—
CATH6RASH2025-02-20
CATH1PYREXIA2025-03
CATH2COUGH2025-02
CATH3INSOMNIA2025-04-05
CATH4MIGRAINE2025-01-05
CATH7FLUSHING2025-01-10
CATH1BACK PAIN2025-04
CATH1VOMITING2025-02

Expected output

Under review
13 expected rows

expected/adae.csv

Edit
13 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAETERMAESTDTCASTDTASTDTCASTDTFTRTSDTTRTEMFL
CATH1HEADACHE2025-01-152025-01-152025-01-15—2025-01-10Y
CATH2NAUSEA2025-012025-01-152025-01-15D2025-01-10Y
CATH3ECZEMA FLARE2025———2025-01-10—
CATH4DIZZINESSUNKNOWN———2025-01-10—
CATH5FATIGUE————2025-01-10—
CATH6RASH2025-02-202025-02-202025-02-20—2025-01-10Y
CATH1PYREXIA2025-032025-03-202025-03-20D2025-03-20Y
CATH2COUGH2025-02———2025-03-20—
CATH3INSOMNIA2025-04-052025-04-052025-04-05—2025-03-20Y
CATH4MIGRAINE2025-01-052025-01-052025-01-05—2025-03-20—
CATH7FLUSHING2025-01-102025-01-102025-01-10—2025-01-10Y
CATH1BACK PAIN2025-042025-04-152025-04-15D——
CATH1VOMITING2025-022025-02-152025-02-15D2025-02-15Y
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
ADAEAESTDTCStart Date/Time of Adverse EventcharacterCopy value from AE.AESTDTC.Predecessor
ADAETRTSDTDate of First Exposure to TreatmentnumericISO 8601Copy value from ADSL.TRTSDT.Predecessor
ADAEASTDTAnalysis Start DatenumericISO 8601Impute incomplete date from AESTDTC, defaulting day=15, never before TRTSDT; a missing source → blank; invalid text → blank.Derived
ADAEASTDTCAnalysis Start Date (C)characterCopy value from ASTDT.Derived
ADAEASTDTFAnalysis Start Date Imputation FlagcharacterDIf ASTDTPR = 'M' then "D"; otherwise blank.Derived
ADAETRTEMFLTreatment Emergent Analysis FlagcharacterY"Y" when ASTDT >= TRTSDT; blank otherwise.Derived
VariablePermitted values
ASTDTFD
TRTEMFLY
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-partial-dates/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, AESTDTC, ASTDT, ASTDTC, ASTDTF, TRTSDT, TRTEMFL

ASTDT is the analysis start date. A fully collected date is used as it stands. A collected year and month is completed to the 15th. A year alone, non-date text, and a missing value give no analysis date. ASTDTC is the same analysis date written as YYYY-MM-DD text, and has no value when there is no analysis date. ASTDTF is D when the day was supplied to complete the date, and has no value otherwise.

A completed date is never placed before first exposure. When the 15th would fall before TRTSDT, the date moves forward to the exposure date. When the whole collected month ends before the exposure date, the event is left without an analysis date. A fully collected date stays exactly as collected even when it falls before TRTSDT.

TRTEMFL is Y when the analysis start falls on or after TRTSDT. It has no value when there is no analysis date, when the event started before first exposure, or when the first-exposure date is unknown. A supplied day counts exactly as a collected one would.

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

prompts/adam-adae-partial-dates/conventions.md

Edit
14 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, AESTDTC, ASTDT, ASTDTC, ASTDTF, TRTSDT, TRTEMFL

ASTDTC is the analysis date written as YYYY-MM-DD text. ASTDTF is D or has no value.

TRTEMFL 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-partial-dates/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, AESTDTC, ASTDT, ASTDTC, ASTDTF, TRTSDT, TRTEMFL

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-partial-dates/result.R

Edit
63 lines
# Reference solution for the yamaa benchmark adam-adae-partial-dates (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()))adsl <- read_csv(  "/app/input/adsl.csv",  col_types = cols(TRTSDT = col_date(), .default = col_character())) |>  select(USUBJID, TRTSDT)adae <- ae |>  left_join(adsl, by = "USUBJID") |>  mutate(    is_full = str_detect(AESTDTC, "^\\d{4}-\\d{2}-\\d{2}$"),    is_month = str_detect(AESTDTC, "^\\d{4}-\\d{2}$"),    # A year and month is completed to the 15th.    completed = if_else(      is_month,      ymd(paste0(AESTDTC, "-15"), quiet = TRUE),      ymd(AESTDTC, quiet = TRUE)    ),    completed = if_else(is_full | is_month, completed, as.Date(NA)),    # A completed date is never placed before first exposure. When the    # whole collected month ends before the exposure date, no day it    # allows can satisfy that, so the event is left without a date.    month_end = if_else(      is_month,      completed + days(days_in_month(completed) - 15L),      completed    ),    month_before_trt = is_month &      !is.na(month_end) & !is.na(TRTSDT) & month_end < TRTSDT,    ASTDT = case_when(      month_before_trt ~ as.Date(NA),      is_month & !is.na(completed) & !is.na(TRTSDT) & completed < TRTSDT ~ TRTSDT,      .default = completed    ),    ASTDTC = if_else(is.na(ASTDT), NA_character_, as.character(ASTDT)),    ASTDTF = if_else(is_month & !is.na(ASTDT), "D", NA_character_),    TRTEMFL = if_else(      !is.na(ASTDT) & !is.na(TRTSDT) & ASTDT >= TRTSDT,      "Y",      NA_character_    )  ) |>  select(    STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, ASTDT, ASTDTC, ASTDTF,    TRTSDT, TRTEMFL  )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")

solutions/adam-adae-partial-dates/result.py

Edit
94 lines
# Reference solution for the yamaa benchmark adam-adae-partial-dates (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 calendarfrom 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).select("USUBJID", "TRTSDT")def complete_row(collected: str | None, trt: str | None) -> tuple[str | None, str | None]:    """The analysis date and its imputation flag for one collected start."""    if collected is None:        return None, None    full = len(collected) == 10 and collected[4] == "-" and collected[7] == "-"    month = len(collected) == 7 and collected[4] == "-"    try:        if full:            year, mon, day = int(collected[0:4]), int(collected[5:7]), int(collected[8:10])            last_day = calendar.monthrange(year, mon)[1]            if day < 1 or day > last_day:                return None, None            completed = f"{year:04d}-{mon:02d}-{day:02d}"            # A fully collected date stays exactly as collected.            return completed, None        if not month:            return None, None        year, mon = int(collected[0:4]), int(collected[5:7])        completed = f"{year:04d}-{mon:02d}-15"        if trt is None:            return completed, "D"        # A completed date is never placed before first exposure. When        # the whole collected month ends before the exposure date, the        # event is left without an analysis date.        last_day = calendar.monthrange(year, mon)[1]        month_end = f"{year:04d}-{mon:02d}-{last_day:02d}"        if month_end < trt:            return None, None        if completed < trt:            return trt, "D"        return completed, "D"    except ValueError:        return None, Nonejoined = ae.join(adsl, on="USUBJID", how="left", maintain_order="left")records = []for row in joined.to_dicts():    ast, flag = complete_row(row["AESTDTC"], row["TRTSDT"])    trtemfl = (        "Y"        if ast is not None and row["TRTSDT"] is not None and ast >= row["TRTSDT"]        else None    )    records.append(        {            "STUDYID": row["STUDYID"],            "USUBJID": row["USUBJID"],            "AESEQ": row["AESEQ"],            "AETERM": row["AETERM"],            "AESTDTC": row["AESTDTC"],            "ASTDT": ast,            "ASTDTC": ast,            "ASTDTF": flag,            "TRTSDT": row["TRTSDT"],            "TRTEMFL": trtemfl,        }    )adae = pl.DataFrame(    records,    schema={        "STUDYID": pl.String,        "USUBJID": pl.String,        "AESEQ": pl.Int64,        "AETERM": pl.String,        "AESTDTC": pl.String,        "ASTDT": pl.String,        "ASTDTC": pl.String,        "ASTDTF": pl.String,        "TRTSDT": pl.String,        "TRTEMFL": pl.String,    },)Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

solutions/adam-adae-partial-dates/result.sas

Edit
39 lines
/* opensas reference solution for the yamaa benchmark adam-adae-partial-dates.   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 TRTSDT $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $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.TRTSDT from ae as a left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data result;  length ASTDT ASTDTC $10 ASTDTF TRTEMFL $1;  set joined;  treatment=input(TRTSDT,yymmdd10.); analysis=.;  if prxmatch('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',strip(AESTDTC)) then analysis=input(AESTDTC,yymmdd10.);  else if prxmatch('/^[0-9]{4}-[0-9]{2}$/',strip(AESTDTC)) then do;    analysis=input(cats(AESTDTC,'-15'),yymmdd10.);    if not missing(analysis) then do;      if not missing(treatment) and intnx('month',analysis,0,'end')<treatment then analysis=.;      else do; analysis=max(analysis,treatment); ASTDTF='D'; end;    end;  end;  if not missing(analysis) then do;    ASTDT=put(analysis,yymmdd10.); ASTDTC=ASTDT;    if not missing(treatment) and analysis>=treatment then TRTEMFL='Y';  end;run;proc sql;  create table final as select STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, ASTDT, ASTDTC, ASTDTF, TRTSDT, TRTEMFL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;