Review ask

As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.

We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.

Summary

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: for each adverse event, name the subject's most recent earlier serious event (PRIOR_SAEFL, PRIOR_SAEDECOD, PRIOR_SAESEQ), the subject's first serious event (FIRST_SAEDECOD, FIRST_SAESEQ), and the subject's immediately preceding event (PREV_AEDECOD).

Input: adverse event records with study, subject, and sequence (STUDYID, USUBJID, AESEQ), the dictionary term (AEDECOD), and whether the event was serious (AESER).

Variables:

  • PRIOR_SAEFL: Y on a non-serious event when the subject had a serious event with a smaller sequence number, empty otherwise.
  • PRIOR_SAEDECOD / PRIOR_SAESEQ: the term and sequence number of that most recent earlier serious event, empty when there is none.
  • FIRST_SAEDECOD / FIRST_SAESEQ: the term and sequence number of the subject's first serious event, empty when the subject had no serious event.
  • PREV_AEDECOD: the term of the subject's event with the next smaller sequence number, serious or not; empty on the subject's first event, and empty when the preceding event has no coded term.

Note: a serious event with no coded term still counts: the prior flag is Y and its sequence number is named, while the term fields stay empty. The serious events are laid down first, so a serious event's own prior and first serious event fields stay empty, because they cannot look back at records that are still being written. The preceding event is named only after every event is in place, so it can name an event of either kind.

Inputs

Under review
1 source file

input/ae.csv

Edit
14 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAEDECODAESER
YAMAA-011HEADACHEY
YAMAA-012COUGHN
YAMAA-013NAUSEAY
YAMAA-014FATIGUEN
YAMAA-015RASHN
YAMAA-016—Y
YAMAA-017MYALGIAN
YAMAA-011DIZZINESSN
YAMAA-012FEVERY
YAMAA-013VOMITINGN
YAMAA-011BACK PAINN
YAMAA-012INFLUENZAN
YAMAA-011CHEST PAINY
YAMAA-011HYPERTENSIONN

Expected output

Under review
14 expected rows

expected/adae.csv

Edit
14 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAEDECODAESERPRIOR_SAEFLPRIOR_SAEDECODPRIOR_SAESEQFIRST_SAEDECODFIRST_SAESEQPREV_AEDECOD
YAMAA-011HEADACHEY——————
YAMAA-013NAUSEAY—————COUGH
YAMAA-016—Y—————RASH
YAMAA-012FEVERY—————DIZZINESS
YAMAA-011CHEST PAINY——————
YAMAA-012COUGHNYHEADACHE1HEADACHE1HEADACHE
YAMAA-014FATIGUENYNAUSEA3HEADACHE1NAUSEA
YAMAA-015RASHNYNAUSEA3HEADACHE1FATIGUE
YAMAA-017MYALGIANY—6HEADACHE1—
YAMAA-011DIZZINESSN———FEVER2—
YAMAA-013VOMITINGNYFEVER2FEVER2FEVER
YAMAA-011BACK PAINN——————
YAMAA-012INFLUENZAN—————BACK PAIN
YAMAA-011HYPERTENSIONN——————
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark 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
ADAEAESERSerious EventcharacterCopy value from AE.AESER.Predecessor
ADAEPRIOR_SAEFLPrior Serious Event FlagcharacterSet per constructed row; see the Row construction sheet.Derived
ADAEPRIOR_SAEDECODPrior Serious Event Dictionary-Derived TermcharacterSet per constructed row; see the Row construction sheet.Derived
ADAEPRIOR_SAESEQPrior Serious Event Sequence NumbernumericSet per constructed row; see the Row construction sheet.Derived
ADAEFIRST_SAEDECODFirst Serious Event Dictionary-Derived TermcharacterSet per constructed row; see the Row construction sheet.Derived
ADAEFIRST_SAESEQFirst Serious Event Sequence NumbernumericSet per constructed row; see the Row construction sheet.Derived
ADAEPREV_AEDECODPreceding Event Dictionary-Derived TermcharacterTake AEDECOD from the first already-derived row of this dataset matching on STUDYID and USUBJID, where AESEQ < AE.AESEQ, ordered by AESEQ descending, and no match yields blank.Derived
TemplateInclude whenPRIOR_SAEFLPRIOR_SAEDECODPRIOR_SAESEQFIRST_SAEDECODFIRST_SAESEQ
seriousAE.AESER = 'Y'Constant "None"Constant "None"Constant "None"Constant "None"Constant "None"
nonseriousAE.AESER = 'N'If AESEQ IS NOT NULL, with AESEQ taken from the first already-derived row of this dataset matching on STUDYID and USUBJID, where SELF.AESER = 'Y' AND SELF.AESEQ < AE.AESEQ, ordered by SELF.AESEQ descending, and no match yields blank then "Y"; otherwise "None"Copy AEDECOD from the first already-derived row of this dataset matching on STUDYID and USUBJID, where SELF.AESER = 'Y' AND SELF.AESEQ < AE.AESEQ, ordered by SELF.AESEQ descending, and no match yields blankCopy AESEQ from the first already-derived row of this dataset matching on STUDYID and USUBJID, where SELF.AESER = 'Y' AND SELF.AESEQ < AE.AESEQ, ordered by SELF.AESEQ descending, and no match yields blankCopy AEDECOD from the first already-derived row of this dataset matching on STUDYID and USUBJID, where SELF.AESER = 'Y', ordered by SELF.AESEQ, and no match yields blankCopy AESEQ from the first already-derived row of this dataset matching on STUDYID and USUBJID, where SELF.AESER = 'Y', ordered by SELF.AESEQ, and no match yields blank
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default
1.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part
1.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
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-prior-serious-event/full.md

Edit
29 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, AESER, PRIOR_SAEFL, PRIOR_SAEDECOD, PRIOR_SAESEQ, FIRST_SAEDECOD, FIRST_SAESEQ, PREV_AEDECOD

AESER is "Y" on a serious event and "N" on a non-serious event. On a serious event, PRIOR_SAEFL, PRIOR_SAEDECOD, PRIOR_SAESEQ, FIRST_SAEDECOD, and FIRST_SAESEQ all have no value. On a non-serious event, PRIOR_SAEFL is "Y" when the subject has a serious event with a smaller AESEQ, and it has no value when the subject has no such event. PRIOR_SAEDECOD and PRIOR_SAESEQ are the AEDECOD and the AESEQ of the subject's most recent earlier serious event, the earlier serious event with the largest AESEQ, and they have no value when the subject has no earlier serious event. FIRST_SAEDECOD and FIRST_SAESEQ are the AEDECOD and the AESEQ of the subject's first serious event, the serious event with the smallest AESEQ, and they have no value when the subject has no serious event. A serious event counts as an earlier serious event and as a first serious event even when its AEDECOD has no value: PRIOR_SAEFL is still "Y", PRIOR_SAESEQ and FIRST_SAESEQ still name its AESEQ, and PRIOR_SAEDECOD and FIRST_SAEDECOD have no value for such an event. PREV_AEDECOD is the AEDECOD of the subject's event with the next smaller AESEQ, whether that event is serious or not; it has no value on the subject's event with the smallest AESEQ, and it has no value when the event with the next smaller AESEQ has no AEDECOD.

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

prompts/adam-adae-prior-serious-event/conventions.md

Edit
11 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, AESER, PRIOR_SAEFL, PRIOR_SAEDECOD, PRIOR_SAESEQ, FIRST_SAEDECOD, FIRST_SAESEQ, PREV_AEDECOD

AESER is "Y" or "N". PRIOR_SAEFL 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-prior-serious-event/brief.md

Edit
9 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, AESER, PRIOR_SAEFL, PRIOR_SAEDECOD, PRIOR_SAESEQ, FIRST_SAEDECOD, FIRST_SAESEQ, PREV_AEDECOD

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

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

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

solutions/adam-adae-prior-serious-event/result.R

Edit
91 lines
# Reference solution for the yamaa benchmark adam-adae-prior-serious-event (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()))serious <- ae |>  filter(AESER %in% "Y") |>  arrange(USUBJID, AESEQ)# The subject's first serious event, whatever its term holds.first_sae <- serious |>  distinct(USUBJID, .keep_all = TRUE) |>  select(USUBJID, FIRST_SAEDECOD = AEDECOD, FIRST_SAESEQ = AESEQ)adae <- ae |>  left_join(first_sae, by = "USUBJID") |>  group_by(USUBJID) |>  arrange(AESEQ, .by_group = TRUE) |>  mutate(    # The most recent earlier serious event, by sequence number.    PRIOR_SAESEQ = sapply(      AESEQ,      function(s) {        earlier <- AESEQ[AESER %in% "Y" & AESEQ < s]        if (length(earlier) == 0L) NA_integer_ else max(earlier)      }    ),    PRIOR_SAEDECOD = sapply(      PRIOR_SAESEQ,      function(s) {        if (is.na(s)) NA_character_ else AEDECOD[match(s, AESEQ)]      }    ),    PREV_SEQ = sapply(      AESEQ,      function(s) {        earlier <- AESEQ[AESEQ < s]        if (length(earlier) == 0L) NA_integer_ else max(earlier)      }    ),    PREV_AEDECOD = sapply(      PREV_SEQ,      function(s) {        if (is.na(s)) NA_character_ else AEDECOD[match(s, AESEQ)]      }    ),    PREV_AEDECOD = if_else(      PREV_AEDECOD == "" | is.na(PREV_AEDECOD),      NA_character_,      PREV_AEDECOD    ),    PRIOR_SAEDECOD = if_else(      PRIOR_SAEDECOD == "" | is.na(PRIOR_SAEDECOD),      NA_character_,      PRIOR_SAEDECOD    ),    FIRST_SAEDECOD = if_else(      FIRST_SAEDECOD == "" | is.na(FIRST_SAEDECOD),      NA_character_,      FIRST_SAEDECOD    )  ) |>  ungroup() |>  mutate(    # A serious event leaves its own prior and first fields empty.    PRIOR_SAEFL = if_else(      AESER %in% "N" & !is.na(PRIOR_SAESEQ),      "Y",      NA_character_    ),    PRIOR_SAEDECOD = if_else(AESER %in% "N", PRIOR_SAEDECOD, NA_character_),    PRIOR_SAESEQ = if_else(AESER %in% "N", PRIOR_SAESEQ, NA_integer_),    FIRST_SAEDECOD = if_else(AESER %in% "N", FIRST_SAEDECOD, NA_character_),    FIRST_SAESEQ = if_else(AESER %in% "N", FIRST_SAESEQ, NA_integer_)  ) |>  select(    STUDYID, USUBJID, AESEQ, AEDECOD, AESER, PRIOR_SAEFL, PRIOR_SAEDECOD,    PRIOR_SAESEQ, FIRST_SAEDECOD, FIRST_SAESEQ, PREV_AEDECOD  )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")

solutions/adam-adae-prior-serious-event/result.py

Edit
72 lines
# Reference solution for the yamaa benchmark adam-adae-prior-serious-event (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))records = []for subject, group in ae.sort(["USUBJID", "AESEQ"]).group_by("USUBJID", maintain_order=True):    rows = group.sort("AESEQ").to_dicts()    serious_seqs = [r["AESEQ"] for r in rows if r["AESER"] == "Y"]    first_seq = min(serious_seqs) if serious_seqs else None    first_term = next(        (r["AEDECOD"] for r in rows if r["AESEQ"] == first_seq), None    )    by_seq = {r["AESEQ"]: r for r in rows}    for row in rows:        seq = row["AESEQ"]        earlier_serious = [s for s in serious_seqs if s < seq]        prior_seq = max(earlier_serious) if earlier_serious else None        prior_term = by_seq.get(prior_seq, {}).get("AEDECOD") if prior_seq else None        earlier_all = [r["AESEQ"] for r in rows if r["AESEQ"] < seq]        prev_seq = max(earlier_all) if earlier_all else None        prev_term = by_seq.get(prev_seq, {}).get("AEDECOD") if prev_seq else None        is_nonserious = row["AESER"] == "N"        # Only an explicit N receives prior and first serious-event fields. A        # serious event with no coded term still counts for the flag and        # the sequence number, while the term fields stay empty.        records.append(            {                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "AESEQ": seq,                "AEDECOD": row["AEDECOD"],                "AESER": row["AESER"],                "PRIOR_SAEFL": None                if not is_nonserious or prior_seq is None                else "Y",                "PRIOR_SAEDECOD": None if not is_nonserious else prior_term,                "PRIOR_SAESEQ": None if not is_nonserious else prior_seq,                "FIRST_SAEDECOD": None if not is_nonserious else first_term,                "FIRST_SAESEQ": None if not is_nonserious else first_seq,                "PREV_AEDECOD": prev_term,            }        )adae = pl.DataFrame(    records,    schema={        "STUDYID": pl.String,        "USUBJID": pl.String,        "AESEQ": pl.Int64,        "AEDECOD": pl.String,        "AESER": pl.String,        "PRIOR_SAEFL": pl.String,        "PRIOR_SAEDECOD": pl.String,        "PRIOR_SAESEQ": pl.Int64,        "FIRST_SAEDECOD": pl.String,        "FIRST_SAESEQ": pl.Int64,        "PREV_AEDECOD": pl.String,    },)Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

solutions/adam-adae-prior-serious-event/result.sas

Edit
33 lines
/* opensas reference solution for the yamaa benchmark adam-adae-prior-serious-event.   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 AESER $1024;  infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEDECOD : $char1024. AESER : $char1024.;run;proc sort data=ae(where=(AESER='Y')) out=serious; by STUDYID USUBJID AESEQ; run;data firsts; set serious; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table joined as select a.*,b.AEDECOD as firstterm,b.AESEQ as firstseq from ae as a left join firsts as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;proc sort data=joined; by STUDYID USUBJID AESEQ; run;data result;  length PRIOR_SAEFL $1 PRIOR_SAEDECOD FIRST_SAEDECOD PREV_AEDECOD lastterm prevterm $1024;  retain lastterm lastseq prevterm;  set joined; by STUDYID USUBJID;  if first.USUBJID then do; lastterm=''; lastseq=.; prevterm=''; end;  PREV_AEDECOD=prevterm;  if AESER='N' then do;    PRIOR_SAEDECOD=lastterm; PRIOR_SAESEQ=lastseq;    FIRST_SAEDECOD=firstterm; FIRST_SAESEQ=firstseq;    if not missing(lastseq) then PRIOR_SAEFL='Y';  end;  if AESER='Y' then do; lastterm=AEDECOD; lastseq=AESEQ; end;  prevterm=AEDECOD;run;proc sql;  create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, AESER, PRIOR_SAEFL, PRIOR_SAEDECOD, PRIOR_SAESEQ, FIRST_SAEDECOD, FIRST_SAESEQ, PREV_AEDECOD from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;