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: mark the first treatment-emergent adverse event (AE) for each subject with three flags: one for the subject overall, one within each body system, and one within each dictionary-derived term.

Input: one record per adverse event carrying AEBODSYS (body system), AEDECOD (dictionary-derived term), ASTDT (analysis start date), and TRTEMFL (treatment-emergent flag: Y when the event is treatment-emergent).

Variables:

  • AOCCFL is Y for the subject's first treatment-emergent event and missing otherwise.
  • AOCCSFL is Y for the subject's first treatment-emergent event within each body system and missing otherwise.
  • AOCCPFL is Y for the subject's first treatment-emergent event within each dictionary-derived term (counted inside its body system) and missing otherwise.

Note: first means the earliest analysis start date, with the lower AE sequence number breaking ties on the same day. Only treatment-emergent events are eligible, so an event that started before treatment is never flagged at any level -- a subject with no treatment-emergent events has all three flags missing on every record. The levels nest: a subject's first event is also the first in its body system and in its dictionary-derived term. Sponsors use these flags to trace summary-table counts back to their source records.

Inputs

Under review
1 source file

input/adae_raw.csv

Edit
10 rows
input/adae_raw.csv
STUDYIDUSUBJIDAESEQAEBODSYSAEDECODASTDTTRTEMFL
CATH-011NERVOUS SYSTEM DISORDERSHEADACHE2024-01-05—
CATH-012NERVOUS SYSTEM DISORDERSHEADACHE2024-01-10Y
CATH-013GASTROINTESTINAL DISORDERSNAUSEA2024-01-10Y
CATH-014NERVOUS SYSTEM DISORDERSHEADACHE2024-01-12Y
CATH-015SKIN AND SUBCUTANEOUS TISSUE DISORDERSRASH2024-01-21—
CATH-011NERVOUS SYSTEM DISORDERSHEADACHE2024-02-01Y
CATH-012NERVOUS SYSTEM DISORDERSHEADACHE2024-02-01Y
CATH-011NERVOUS SYSTEM DISORDERSDIZZINESS2024-03-04Y
CATH-011GASTROINTESTINAL DISORDERSDIARRHOEA2024-04-02—
CATH-012NERVOUS SYSTEM DISORDERSHEADACHE2024-04-09—

Expected output

Under review
10 expected rows

expected/adae.csv

Edit
10 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAEBODSYSAEDECODASTDTTRTEMFLAOCCFLAOCCSFLAOCCPFL
CATH-011NERVOUS SYSTEM DISORDERSHEADACHE2024-01-05————
CATH-012NERVOUS SYSTEM DISORDERSHEADACHE2024-01-10YYYY
CATH-013GASTROINTESTINAL DISORDERSNAUSEA2024-01-10Y—YY
CATH-014NERVOUS SYSTEM DISORDERSHEADACHE2024-01-12Y———
CATH-015SKIN AND SUBCUTANEOUS TISSUE DISORDERSRASH2024-01-21————
CATH-011NERVOUS SYSTEM DISORDERSHEADACHE2024-02-01YYYY
CATH-012NERVOUS SYSTEM DISORDERSHEADACHE2024-02-01Y———
CATH-011NERVOUS SYSTEM DISORDERSDIZZINESS2024-03-04YYYY
CATH-011GASTROINTESTINAL DISORDERSDIARRHOEA2024-04-02————
CATH-012NERVOUS SYSTEM DISORDERSHEADACHE2024-04-09————
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 ADAE_RAW.STUDYID.Predecessor
ADAEUSUBJIDUnique Subject IdentifiercharacterCopy value from ADAE_RAW.USUBJID.Predecessor
ADAEAESEQSequence NumbernumericCopy value from ADAE_RAW.AESEQ.Predecessor
ADAEAEBODSYSBody System or Organ ClasscharacterCopy value from ADAE_RAW.AEBODSYS.Predecessor
ADAEAEDECODDictionary-Derived TermcharacterCopy value from ADAE_RAW.AEDECOD.Predecessor
ADAEASTDTAnalysis Start DatenumericISO 8601Copy value from ADAE_RAW.ASTDT.Predecessor
ADAETRTEMFLTreatment Emergent Analysis FlagcharacterYCopy value from ADAE_RAW.TRTEMFL.Predecessor
ADAEAOCCFL1st Occurrence within Subject Flagcharacter"Y" when AOCCSEQ = 1; blank otherwise.Derived
ADAEAOCCSFL1st Occurrence of SOC Flagcharacter"Y" when AOCCSSEQ = 1; blank otherwise.Derived
ADAEAOCCPFL1st Occurrence of Preferred Term Flagcharacter"Y" when AOCCPSEQ = 1; blank otherwise.Derived
VariablePermitted values
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-occurrence-flags/full.md

Edit
22 lines

Following CDISC ADaM standards, use the provided ADAE_RAW 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, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL

Flag the first treatment-emergent event at three levels. Only an event with TRTEMFL Y is eligible:

  • AOCCFL is Y for the subject's first treatment-emergent event.
  • AOCCSFL is Y for the subject's first treatment-emergent event in each body system.
  • AOCCPFL is Y for the subject's first treatment-emergent event for each dictionary-derived term within its body system. First means the earliest analysis start date, with the lower AESEQ breaking ties on the same day. All three flags have no value on any other event, and on every event of a subject with no treatment-emergent events. The levels nest: the subject's first event is also the first in its body system and term.

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

prompts/adam-adae-occurrence-flags/conventions.md

Edit
11 lines

Following CDISC ADaM standards, use the provided ADAE_RAW 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, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL

AOCCFL, AOCCSFL, and AOCCPFL are Y or have no value.

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

prompts/adam-adae-occurrence-flags/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided ADAE_RAW 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, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL

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-occurrence-flags/result.R

Edit
50 lines
# Reference solution for the yamaa benchmark adam-adae-occurrence-flags (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/adae_raw.csv",  col_types = cols(AESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))# The first treatment-emergent event at each level: the earliest start# date, with the lower AESEQ breaking ties on the same day.first_overall <- ae |>  filter(TRTEMFL %in% "Y") |>  arrange(USUBJID, ASTDT, AESEQ) |>  distinct(USUBJID, .keep_all = TRUE) |>  select(USUBJID, FIRST_SEQ = AESEQ)first_soc <- ae |>  filter(TRTEMFL %in% "Y") |>  arrange(USUBJID, AEBODSYS, ASTDT, AESEQ) |>  distinct(USUBJID, AEBODSYS, .keep_all = TRUE) |>  select(USUBJID, AEBODSYS, SOC_SEQ = AESEQ)first_pt <- ae |>  filter(TRTEMFL %in% "Y") |>  arrange(USUBJID, AEBODSYS, AEDECOD, ASTDT, AESEQ) |>  distinct(USUBJID, AEBODSYS, AEDECOD, .keep_all = TRUE) |>  select(USUBJID, AEBODSYS, AEDECOD, PT_SEQ = AESEQ)adae <- ae |>  left_join(first_overall, by = "USUBJID") |>  left_join(first_soc, by = c("USUBJID", "AEBODSYS")) |>  left_join(first_pt, by = c("USUBJID", "AEBODSYS", "AEDECOD")) |>  mutate(    AOCCFL = if_else(!is.na(FIRST_SEQ) & AESEQ == FIRST_SEQ, "Y", NA_character_),    AOCCSFL = if_else(!is.na(SOC_SEQ) & AESEQ == SOC_SEQ, "Y", NA_character_),    AOCCPFL = if_else(!is.na(PT_SEQ) & AESEQ == PT_SEQ, "Y", NA_character_)  ) |>  select(    STUDYID, USUBJID, AESEQ, AEBODSYS, AEDECOD, ASTDT, TRTEMFL,    AOCCFL, AOCCSFL, AOCCPFL  )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")

solutions/adam-adae-occurrence-flags/result.py

Edit
66 lines
# Reference solution for the yamaa benchmark adam-adae-occurrence-flags (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/adae_raw.csv", infer_schema=False).with_columns(    pl.col("AESEQ").cast(pl.Int64))# The first treatment-emergent event at each level: the earliest start# date, with the lower AESEQ breaking ties on the same day. ISO dates# sort as text.first_overall = (    ae.filter(pl.col("TRTEMFL") == "Y")    .sort(["USUBJID", "ASTDT", "AESEQ"], nulls_last=True)    .unique("USUBJID", keep="first", maintain_order=True)    .select("USUBJID", FIRST_SEQ="AESEQ"))first_soc = (    ae.filter(pl.col("TRTEMFL") == "Y")    .sort(["USUBJID", "AEBODSYS", "ASTDT", "AESEQ"], nulls_last=True)    .unique(["USUBJID", "AEBODSYS"], keep="first", maintain_order=True)    .select("USUBJID", "AEBODSYS", SOC_SEQ="AESEQ"))first_pt = (    ae.filter(pl.col("TRTEMFL") == "Y")    .sort(["USUBJID", "AEBODSYS", "AEDECOD", "ASTDT", "AESEQ"], nulls_last=True)    .unique(["USUBJID", "AEBODSYS", "AEDECOD"], keep="first", maintain_order=True)    .select("USUBJID", "AEBODSYS", "AEDECOD", PT_SEQ="AESEQ"))adae = (    ae.join(first_overall, on="USUBJID", how="left")    .join(first_soc, on=["USUBJID", "AEBODSYS"], how="left")    .join(first_pt, on=["USUBJID", "AEBODSYS", "AEDECOD"], how="left")    .with_columns(        AOCCFL=pl.when(pl.col("FIRST_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("FIRST_SEQ")))        .then(pl.lit("Y")),        AOCCSFL=pl.when(pl.col("SOC_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("SOC_SEQ")))        .then(pl.lit("Y")),        AOCCPFL=pl.when(pl.col("PT_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("PT_SEQ")))        .then(pl.lit("Y")),    )    .select(        "STUDYID",        "USUBJID",        "AESEQ",        "AEBODSYS",        "AEDECOD",        "ASTDT",        "TRTEMFL",        "AOCCFL",        "AOCCSFL",        "AOCCPFL",    ))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

solutions/adam-adae-occurrence-flags/result.sas

Edit
28 lines
/* opensas reference solution for the yamaa benchmark adam-adae-occurrence-flags.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adae_raw;  length STUDYID USUBJID AEBODSYS AEDECOD ASTDT TRTEMFL $1024;  infile "/app/input/adae_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEBODSYS : $char1024. AEDECOD : $char1024. ASTDT : $char1024. TRTEMFL : $char1024.;run;proc sort data=adae_raw(where=(TRTEMFL='Y')) out=eligible; by STUDYID USUBJID ASTDT AESEQ; run;data subject; set eligible; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID AESEQ; run;proc sort data=eligible; by STUDYID USUBJID AEBODSYS ASTDT AESEQ; run;data system; set eligible; by STUDYID USUBJID AEBODSYS; if first.AEBODSYS; keep STUDYID USUBJID AESEQ; run;proc sort data=eligible; by STUDYID USUBJID AEBODSYS AEDECOD ASTDT AESEQ; run;data term; set eligible; by STUDYID USUBJID AEBODSYS AEDECOD; if first.AEDECOD; keep STUDYID USUBJID AESEQ; run;proc sql; create table result as select a.*,  case when not missing(b.AESEQ) then 'Y' else '' end as AOCCFL,  case when not missing(c.AESEQ) then 'Y' else '' end as AOCCSFL,  case when not missing(d.AESEQ) then 'Y' else '' end as AOCCPFL  from adae_raw as a left join subject as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AESEQ=b.AESEQ  left join system as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID and a.AESEQ=c.AESEQ  left join term as d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID and a.AESEQ=d.AESEQ; quit;proc sql;  create table final as select STUDYID, USUBJID, AESEQ, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;