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
README.mdPublic 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:
AOCCFLisYfor the subject's first treatment-emergent event and missing otherwise.AOCCSFLisYfor the subject's first treatment-emergent event within each body system and missing otherwise.AOCCPFLisYfor 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 review1 source fileinput/adae_raw.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEBODSYS | AEDECOD | ASTDT | TRTEMFL |
|---|---|---|---|---|---|---|
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-05 | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-10 | Y | |
| CATH-01 | 3 | GASTROINTESTINAL DISORDERS | NAUSEA | 2024-01-10 | Y | |
| CATH-01 | 4 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-12 | Y | |
| CATH-01 | 5 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2024-01-21 | — | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | DIZZINESS | 2024-03-04 | Y | |
| CATH-01 | 1 | GASTROINTESTINAL DISORDERS | DIARRHOEA | 2024-04-02 | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-04-09 | — |
Expected output
Under review10 expected rowsexpected/adae.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEBODSYS | AEDECOD | ASTDT | TRTEMFL | AOCCFL | AOCCSFL | AOCCPFL |
|---|---|---|---|---|---|---|---|---|---|
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-05 | — | — | — | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-10 | Y | Y | Y | Y | |
| CATH-01 | 3 | GASTROINTESTINAL DISORDERS | NAUSEA | 2024-01-10 | Y | — | Y | Y | |
| CATH-01 | 4 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-12 | Y | — | — | — | |
| CATH-01 | 5 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2024-01-21 | — | — | — | — | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | Y | Y | Y | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | — | — | — | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | DIZZINESS | 2024-03-04 | Y | Y | Y | Y | |
| CATH-01 | 1 | GASTROINTESTINAL DISORDERS | DIARRHOEA | 2024-04-02 | — | — | — | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-04-09 | — | — | — | — |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADAE | STUDYID | Study Identifier | character | Copy value from ADAE_RAW.STUDYID. | Predecessor | ||
| ADAE | USUBJID | Unique Subject Identifier | character | Copy value from ADAE_RAW.USUBJID. | Predecessor | ||
| ADAE | AESEQ | Sequence Number | numeric | Copy value from ADAE_RAW.AESEQ. | Predecessor | ||
| ADAE | AEBODSYS | Body System or Organ Class | character | Copy value from ADAE_RAW.AEBODSYS. | Predecessor | ||
| ADAE | AEDECOD | Dictionary-Derived Term | character | Copy value from ADAE_RAW.AEDECOD. | Predecessor | ||
| ADAE | ASTDT | Analysis Start Date | numeric | ISO 8601 | Copy value from ADAE_RAW.ASTDT. | Predecessor | |
| ADAE | TRTEMFL | Treatment Emergent Analysis Flag | character | Y | Copy value from ADAE_RAW.TRTEMFL. | Predecessor | |
| ADAE | AOCCFL | 1st Occurrence within Subject Flag | character | "Y" when AOCCSEQ = 1; blank otherwise. | Derived | ||
| ADAE | AOCCSFL | 1st Occurrence of SOC Flag | character | "Y" when AOCCSSEQ = 1; blank otherwise. | Derived | ||
| ADAE | AOCCPFL | 1st Occurrence of Preferred Term Flag | character | "Y" when AOCCPSEQ = 1; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| TRTEMFL | Y |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/adam-adae-occurrence-flags/full.md
Edit26 linesFollowing 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
Edit12 linesFollowing 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
Edit9 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adae-occurrence-flags/result.R
Edit50 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
Edit79 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
Edit28 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;
yamaa