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

Goal: mark each Analysis Data Model (ADaM) adverse event record with AFTIDXFL when it starts after the subject's index event -- the subject's first occurrence of a designated term (in the sample data, COVID-19).

Input: one record per adverse event (AE), carrying the coded term AEDECOD and the event start date AESTDTC (kept in the output as ASTDT).

Variables:

  • AFTIDXFL: Y for an event ordered strictly after the subject's index event: a later start date, or the same start date with a higher sequence number. Blank otherwise: the index event itself, every record of a subject with no index event, and any record with no start date.

Note: ordering is within each subject by start date, with the sequence number (AESEQ) breaking ties on the same date.

Inputs

Under review
1 source file

input/ae.csv

Edit
11 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAEDECODAESTDTC
YAMAA-011HEADACHE2023-01-10
YAMAA-012COVID-192023-01-15
YAMAA-013COUGH2023-01-15
YAMAA-014FATIGUE2023-01-20
YAMAA-015NAUSEA—
YAMAA-011NAUSEA2023-02-01
YAMAA-012FATIGUE2023-02-04
YAMAA-011COVID-192023-03-01
YAMAA-012COVID-192023-03-01
YAMAA-013PYREXIA2023-03-03
YAMAA-011COVID-192023-04-05

Expected output

Under review
11 expected rows

expected/adae.csv

Edit
11 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAEDECODASTDTAFTIDXFL
YAMAA-011HEADACHE2023-01-10—
YAMAA-012COVID-192023-01-15—
YAMAA-013COUGH2023-01-15Y
YAMAA-014FATIGUE2023-01-20Y
YAMAA-015NAUSEA——
YAMAA-011NAUSEA2023-02-01—
YAMAA-012FATIGUE2023-02-04—
YAMAA-011COVID-192023-03-01—
YAMAA-012COVID-192023-03-01Y
YAMAA-013PYREXIA2023-03-03Y
YAMAA-011COVID-192023-04-05—
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
ADAEAEDECODDictionary-Derived TermcharacterCopy value from AE.AEDECOD.Predecessor
ADAEASTDTAnalysis Start DatenumericISO 8601Copy value from AE.AESTDTC.Predecessor
ADAEAFTIDXFLAfter Index Event Flagcharacter"Y" when ASTDT > AESTDTC OR (ASTDT = AESTDTC AND AESEQ > AESEQ), with AESTDTC taken from the first AE record matching on STUDYID and USUBJID, where AE.AEDECOD = 'COVID-19', ordered by AE.AESTDTC then AE.AESEQ, and no match yields blank and AESEQ taken from the first AE record matching on STUDYID and USUBJID, where AE.AEDECOD = 'COVID-19', ordered by AE.AESTDTC then AE.AESEQ, and no match yields blank; blank otherwise.Derived
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-post-index/full.md

Edit
17 lines

Following CDISC ADaM standards, use the provided AE dataset 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, AFTIDXFL

ASTDT is the event start date. AFTIDXFL is Y for an event ordered strictly after the subject's index event -- the subject's first occurrence of the designated index term (COVID-19 in this dataset): a later start date, or the same start date with a higher sequence number. It has no value on the index event itself, on every record of a subject with no index event, and on any record with no start date. Ordering is within each subject by start date, with AESEQ breaking ties on the same date.

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

prompts/adam-adae-post-index/conventions.md

Edit
10 lines

Following CDISC ADaM standards, use the provided AE dataset 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, AFTIDXFL

AFTIDXFL 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-index/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided AE dataset 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, AFTIDXFL

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-post-index/result.R

Edit
37 lines
# Reference solution for the yamaa benchmark adam-adae-post-index (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)ae <- read_csv(  "/app/input/ae.csv",  col_types = cols(AESEQ = col_integer(), .default = col_character()))# Each subject's index event: the earliest start date, with the# higher sequence number ordered after on the same date.first_index <- ae |>  filter(AEDECOD %in% "COVID-19", !is.na(AESTDTC), AESTDTC != "") |>  arrange(USUBJID, AESTDTC, AESEQ) |>  distinct(USUBJID, .keep_all = TRUE) |>  select(USUBJID, FIRST_DT = AESTDTC, FIRST_SEQ = AESEQ)adae <- ae |>  left_join(first_index, by = "USUBJID") |>  mutate(    ASTDT = if_else(is.na(AESTDTC) | AESTDTC == "", NA_character_, AESTDTC),    AFTIDXFL = if_else(      !is.na(ASTDT) & !is.na(FIRST_DT) &        (ASTDT > FIRST_DT | (ASTDT == FIRST_DT & AESEQ > FIRST_SEQ)),      "Y",      NA_character_    )  ) |>  select(STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")

solutions/adam-adae-post-index/result.py

Edit
47 lines
# Reference solution for the yamaa benchmark adam-adae-post-index (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))# Each subject's index event: the earliest start date, with the# higher sequence number ordered after on the same date. ISO dates sort# as text.first_index = (    ae.filter(        (pl.col("AEDECOD") == "COVID-19") & pl.col("AESTDTC").is_not_null()    )    .sort(["USUBJID", "AESTDTC", "AESEQ"], nulls_last=True)    .unique("USUBJID", keep="first", maintain_order=True)    .select("USUBJID", FIRST_DT="AESTDTC", FIRST_SEQ="AESEQ"))adae = (    ae.join(first_index, on="USUBJID", how="left", maintain_order="left")    .with_columns(ASTDT=pl.col("AESTDTC"))    .with_columns(        AFTIDXFL=pl.when(            pl.col("ASTDT").is_not_null()            & pl.col("FIRST_DT").is_not_null()            & (                (pl.col("ASTDT") > pl.col("FIRST_DT"))                | (                    (pl.col("ASTDT") == pl.col("FIRST_DT"))                    & (pl.col("AESEQ") > pl.col("FIRST_SEQ"))                )            )        ).then(pl.lit("Y"))    )    .select("STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "AFTIDXFL"))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

solutions/adam-adae-post-index/result.sas

Edit
22 lines
/* opensas reference solution for the yamaa benchmark adam-adae-post-index.   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;proc sort data=ae(where=(AEDECOD='COVID-19' and AESTDTC ne '')) out=indices; by STUDYID USUBJID AESTDTC AESEQ; run;data firstindex; set indices; by STUDYID USUBJID; if first.USUBJID; run;proc sql;  create table result as select a.*,a.AESTDTC as ASTDT,  case when not missing(a.AESTDTC) and not missing(b.AESTDTC) and (a.AESTDTC>b.AESTDTC or (a.AESTDTC=b.AESTDTC and a.AESEQ>b.AESEQ)) then 'Y' else '' end as AFTIDXFL  from ae as a left join firstindex as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;proc sql;  create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;