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

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

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

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 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.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-occurrence-flags/full.md

Edit
26 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

An event is treatment-emergent when TRTEMFL is "Y", and only such events are eligible to be flagged: an event that is not treatment-emergent is never flagged at any level, and a subject with no treatment-emergent events has no value for AOCCFL, AOCCSFL, or AOCCPFL on every record. AOCCFL is "Y" for the subject's first treatment-emergent event and has no value on every other record. AOCCSFL is "Y" for the subject's first treatment-emergent event within each body system and has no value on every other record. AOCCPFL is "Y" for the subject's first treatment-emergent event within each dictionary-derived term, counted inside its body system, and has no value on every other record. The first event at each level is the treatment-emergent event with the earliest ASTDT, and the lower AESEQ breaks a tie between events on the same date. A subject's first treatment-emergent event is also the first in its body system and the first in its dictionary-derived term, so all three flags are "Y" on that record.

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
12 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 is "Y" or has no value. AOCCSFL is "Y" or has no value. AOCCPFL 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-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

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-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
79 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."""Create ADAE with occurrence flags from ADAE_RAW.One record per adverse event. Treatment-emergent events (TRTEMFL = "Y")are flagged at three levels:- AOCCFL:  the subject's first treatment-emergent event.- AOCCSFL: the subject's first treatment-emergent event within each  body system.- AOCCPFL: the subject's first treatment-emergent event within each  dictionary-derived term, counted inside its body system.The first event at each level is the treatment-emergent event with theearliest ASTDT; a lower AESEQ breaks a tie between events on the samedate. Non-treatment-emergent events are never flagged, and subjectswith no treatment-emergent events have no flags at all."""import csvINPUT_PATH = "/app/input/adae_raw.csv"OUTPUT_PATH = "/app/output/adae.csv"COLUMNS = [    "STUDYID",    "USUBJID",    "AESEQ",    "AEBODSYS",    "AEDECOD",    "ASTDT",    "TRTEMFL",    "AOCCFL",    "AOCCSFL",    "AOCCPFL",]def main() -> None:    with open(INPUT_PATH, newline="") as handle:        rows = list(csv.DictReader(handle))    for row in rows:        row["AOCCFL"] = ""        row["AOCCSFL"] = ""        row["AOCCPFL"] = ""    # Rank treatment-emergent events by start date, then sequence.    emergent = [row for row in rows if row["TRTEMFL"] == "Y"]    emergent.sort(key=lambda row: (row["USUBJID"], row["ASTDT"], int(row["AESEQ"])))    def flag_first(key_of, flag_column: str) -> None:        seen = set()        for row in emergent:            key = key_of(row)            if key not in seen:                seen.add(key)                row[flag_column] = "Y"    flag_first(lambda row: row["USUBJID"], "AOCCFL")    flag_first(lambda row: (row["USUBJID"], row["AEBODSYS"]), "AOCCSFL")    flag_first(        lambda row: (row["USUBJID"], row["AEBODSYS"], row["AEDECOD"]),        "AOCCPFL",    )    with open(OUTPUT_PATH, "w", newline="") as handle:        writer = csv.DictWriter(handle, fieldnames=COLUMNS)        writer.writeheader()        for row in rows:            writer.writerow({column: row[column] for column in COLUMNS})if __name__ == "__main__":    main()

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;