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: rank each subject's adverse events (AEs) from worst to mildest: the numeric severity ASEVN orders events into a rank SEVRANK and a dense rank SEVLVL in an Analysis Data Model (ADaM) adverse event analysis dataset.

Input: collected Study Data Tabulation Model (SDTM) adverse event records with the reported term and severity; the reported severity is carried through as ASEV (empty when severity was not reported).

Variables:

  • ASEVN is the numeric form of ASEV: 1 for MILD, 2 for MODERATE, and 3 for SEVERE; empty when ASEV is empty.
  • SEVRANK is the rank of the event among the subject's events ordered by ASEVN, worst first. Events with equal severity share a rank and the ranks they would otherwise fill are skipped, so a rank of 1 means the subject reported nothing worse.
  • SEVLVL is the dense rank of the event: it numbers the distinct severities the subject reported, worst first with each severity counted once, so its largest value is how many different severities the subject has, an unreported severity counting as one more.

Note: an event with no reported severity sorts after every event with a reported severity, and events with no reported severity share one rank with each other because nothing tells them apart. A subject with a single event carries rank 1, and when none of a subject's events has a reported severity every event shares rank 1.

Inputs

Under review
1 source file

input/ae.csv

Edit
12 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAETERMAESEV
PILOT71NauseaSEVERE
PILOT72FatigueMILD
PILOT73PneumonitisSEVERE
PILOT74RashMODERATE
PILOT71HeadacheMODERATE
PILOT72InsomniaMODERATE
PILOT71DiarrhoeaMODERATE
PILOT72Cough—
PILOT73Pyrexia—
PILOT71SyncopeSEVERE
PILOT71Headache—
PILOT72Nausea—

Expected output

Under review
12 expected rows

expected/adae.csv

Edit
12 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQASEVASEVNSEVRANKSEVLVL
PILOT71SEVERE311
PILOT72MILD143
PILOT73SEVERE311
PILOT74MODERATE232
PILOT71MODERATE211
PILOT72MODERATE211
PILOT71MODERATE211
PILOT72——22
PILOT73——22
PILOT71SEVERE311
PILOT71——11
PILOT72——11
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
ADAEASEVAnalysis Severity/IntensitycharacterMILD, MODERATE, SEVERECopy value from AE.AESEV.Predecessor
ADAEASEVNAnalysis Severity/Intensity (N)numericRecode ASEV: "MILD" → "1", "MODERATE" → "2", "SEVERE" → "3"; missing values stay missing; unlisted values are errors.Derived
ADAESEVRANKSeverity RanknumericRank rows from 1 using window SEVERITY_ORDER; ties share a number and the next distinct value skips the gap.Derived
ADAESEVLVLSeverity LevelnumericRank rows from 1 using window SEVERITY_ORDER; ties share a number and the next distinct value follows without a gap.Derived
VariablePermitted values
ASEVMILD, MODERATE, SEVERE
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-severity-rank/full.md

Edit
21 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, ASEV, ASEVN, SEVRANK, SEVLVL

ASEV is the reported severity, and is empty when severity was not reported. ASEVN is the numeric form of ASEV: 1 for MILD, 2 for MODERATE, and 3 for SEVERE, and is empty when ASEV is empty. SEVRANK ranks the subject's events by ASEVN, worst first. Events with equal severity share a rank and the ranks they would otherwise fill are skipped, so a rank of 1 means the subject reported nothing worse. SEVLVL numbers the distinct severities the subject reported, worst first with each severity counted once. An event with no reported severity sorts after every reported one, and unreported events share one rank with each other. A subject with a single event carries rank 1, and when none of a subject's events has a reported severity every event shares rank 1.

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

prompts/adam-adae-severity-rank/conventions.md

Edit
16 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, ASEV, ASEVN, SEVRANK, SEVLVL

ASEVN is the numeric form of ASEV: 1 for MILD, 2 for MODERATE, and 3 for SEVERE. SEVRANK ranks the subject's events by ASEVN, worst first. Events with equal severity share a rank and the ranks they would otherwise fill are skipped. SEVLVL numbers the distinct severities the subject reported, worst first with each severity counted once. An event with no reported severity sorts after every reported one, and unreported events share one rank with each other.

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

prompts/adam-adae-severity-rank/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, ASEV, ASEVN, SEVRANK, SEVLVL

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-severity-rank/result.R

Edit
43 lines
# Reference solution for the yamaa benchmark adam-adae-severity-rank (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(purrr)library(readr)ae <- read_csv(  "/app/input/ae.csv",  col_types = cols(AESEQ = col_integer(), .default = col_character()))adae <- ae |>  mutate(    ASEV = AESEV,    ASEVN = case_when(      ASEV == "MILD" ~ 1L,      ASEV == "MODERATE" ~ 2L,      ASEV == "SEVERE" ~ 3L    )  ) |>  group_by(USUBJID) |>  mutate(    # Competition rank, worst first; unreported sorts after every reported    # one and shares one rank. Rank is one plus the count of worse events.    SEVRANK = map_int(ASEVN, function(v) {      if (is.na(v)) sum(!is.na(ASEVN)) + 1L else sum(ASEVN > v, na.rm = TRUE) + 1L    }),    # Dense rank of the distinct severities, worst first, with unreported    # as one level after every reported one.    SEVLVL = map_int(ASEVN, function(v) {      reported <- unique(ASEVN[!is.na(ASEVN)])      if (is.na(v)) length(reported) + 1L else sum(reported > v) + 1L    })  ) |>  ungroup() |>  select(STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")

solutions/adam-adae-severity-rank/result.py

Edit
44 lines
# Reference solution for the yamaa benchmark adam-adae-severity-rank (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))asevn = (    pl.when(pl.col("AESEV") == "MILD")    .then(1)    .when(pl.col("AESEV") == "MODERATE")    .then(2)    .when(pl.col("AESEV") == "SEVERE")    .then(3)    .otherwise(None)    .cast(pl.Int64))base = ae.with_columns(ASEV=pl.col("AESEV"), ASEVN=asevn)# Competition rank (worst first, gaps after ties) and dense rank of the# distinct severities. Polars ranks only non-null values, so unreported# events take one rank after every reported one.rank_min = pl.col("ASEVN").rank("min", descending=True).over("USUBJID")rank_dense = pl.col("ASEVN").rank("dense", descending=True).over("USUBJID")n_reported = pl.col("ASEVN").count().over("USUBJID")max_dense = rank_dense.max().over("USUBJID")adae = (    base.with_columns(        SEVRANK=(rank_min.fill_null(n_reported + 1)).cast(pl.Int64),        SEVLVL=(rank_dense.fill_null(max_dense.fill_null(0) + 1)).cast(pl.Int64),    ).select("STUDYID", "USUBJID", "AESEQ", "ASEV", "ASEVN", "SEVRANK", "SEVLVL"))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

solutions/adam-adae-severity-rank/result.sas

Edit
28 lines
/* opensas reference solution for the yamaa benchmark adam-adae-severity-rank.   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 AETERM AESEV $1024;  infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AESEV : $char1024.;run;data graded;  length ASEV $20;  set ae; ASEV=AESEV;  select(ASEV); when('MILD') ASEVN=1; when('MODERATE') ASEVN=2; when('SEVERE') ASEVN=3; when('LIFE-THREATENING') ASEVN=4; otherwise ASEVN=.; end;run;proc sort data=graded; by STUDYID USUBJID descending ASEVN AESEQ; run;data result;  set graded; by STUDYID USUBJID descending ASEVN;  retain count SEVRANK SEVLVL;  if first.USUBJID then do; count=0; SEVRANK=0; SEVLVL=0; end;  count+1;  if first.ASEVN then do; SEVRANK=count; SEVLVL+1; end;run;proc sql;  create table final as select STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;