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.
- 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.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- 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
README.mdGoal: rank severity and flag the worst-severity
treatment-emergent event for each subject and preferred term
(AEDECOD), adding ASEVN and AOCCPIFL.
Input: adverse event (AE) records carrying body system or organ
class (AEBODSYS), dictionary-derived term (AEDECOD), analysis
start date (ASTDT), severity (AESEV), and treatment-emergent
flag (TRTEMFL).
Variables:
ASEVN: numeric rank ofAESEV,1for MILD through3for SEVERE; blank when no severity was collected.AOCCPIFL:Yon the eligible event with the greatestASEVNfor the subject and preferred term (AEDECOD); blank otherwise. Ties break by earliestASTDT, then lowestAESEQ, so exactly one event per term is flagged.
Note: only a treatment-emergent event with a graded severity is
eligible, so a preferred term (AEDECOD) whose events are all
ineligible has no flagged event.
Inputs
Under review1 source fileinput/adae_raw.csv
Edit12 rows| STUDYID | USUBJID | AESEQ | AEBODSYS | AEDECOD | ASTDT | AESEV | TRTEMFL |
|---|---|---|---|---|---|---|---|
| CATH | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-01-12 | MILD | Y | |
| CATH | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-01-18 | SEVERE | Y | |
| CATH | 3 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-01-20 | MODERATE | Y | |
| CATH | 4 | GASTROINTESTINAL DISORDERS | NAUSEA | 2025-01-15 | MODERATE | Y | |
| CATH | 5 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2025-01-05 | SEVERE | — | |
| CATH | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-02-10 | MODERATE | Y | |
| CATH | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-02-10 | MODERATE | Y | |
| CATH | 3 | GASTROINTESTINAL DISORDERS | NAUSEA | 2025-02-12 | — | Y | |
| CATH | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-03-10 | SEVERE | Y | |
| CATH | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-03-05 | SEVERE | Y | |
| CATH | 3 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2025-03-06 | MODERATE | — | |
| CATH | 4 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2025-03-08 | — | Y |
Expected output
Under review12 expected rowsexpected/adae.csv
Edit12 rows| STUDYID | USUBJID | AESEQ | AEBODSYS | AEDECOD | ASTDT | AESEV | TRTEMFL | ASEVN | AOCCPIFL |
|---|---|---|---|---|---|---|---|---|---|
| CATH | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-01-12 | MILD | Y | 1 | — | |
| CATH | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-01-18 | SEVERE | Y | 3 | Y | |
| CATH | 3 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-01-20 | MODERATE | Y | 2 | — | |
| CATH | 4 | GASTROINTESTINAL DISORDERS | NAUSEA | 2025-01-15 | MODERATE | Y | 2 | Y | |
| CATH | 5 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2025-01-05 | SEVERE | — | 3 | — | |
| CATH | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-02-10 | MODERATE | Y | 2 | Y | |
| CATH | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-02-10 | MODERATE | Y | 2 | — | |
| CATH | 3 | GASTROINTESTINAL DISORDERS | NAUSEA | 2025-02-12 | — | Y | — | — | |
| CATH | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-03-10 | SEVERE | Y | 3 | — | |
| CATH | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2025-03-05 | SEVERE | Y | 3 | Y | |
| CATH | 3 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2025-03-06 | MODERATE | — | 2 | — | |
| CATH | 4 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2025-03-08 | — | Y | — | — |
Comments and assessment materials
| 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 | AESEV | Severity/Intensity | character | MILD, MODERATE, SEVERE | Copy value from ADAE_RAW.AESEV. | Predecessor | |
| ADAE | TRTEMFL | Treatment Emergent Analysis Flag | character | Y | Copy value from ADAE_RAW.TRTEMFL. | Predecessor | |
| ADAE | ASEVN | Severity/Intensity (N) | numeric | Recode AESEV: "MILD" → "1", "MODERATE" → "2", "SEVERE" → "3"; missing values stay missing; unlisted values are errors. | Derived | ||
| ADAE | AOCCPIFL | First Occurrence of Maximum Severity Flag | character | "Y" when AWSRNK = 1; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| AESEV | MILD, MODERATE, SEVERE |
| TRTEMFL | Y |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 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-worst-severity/full.md
Edit17 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, AESEV, TRTEMFL, ASEVN, AOCCPIFL
ASEVN is the numeric rank of AESEV: 1 for MILD through 3 for SEVERE, and has no value when no severity was collected. AOCCPIFL is Y on the eligible event with the greatest ASEVN for the subject and preferred term. Only a treatment-emergent event with a graded severity is eligible, so a preferred term whose events are all ineligible has no flagged event. Ties break by earliest ASTDT, then lowest AESEQ, so exactly one event per term is flagged.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-worst-severity/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, AESEV, TRTEMFL, ASEVN, AOCCPIFL
ASEVN is the numeric rank of AESEV: 1 for MILD through 3 for SEVERE. AOCCPIFL is Y on a flagged event.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-worst-severity/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, AESEV, TRTEMFL, ASEVN, AOCCPIFL
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
run.R
Edit4 lineslibrary(yamaa)adae <- yamaa_domain("spec.yaml")$outputadaerun.py
Edit4 linesimport yamaaadae = yamaa.yamaa_domain("spec.yaml").outputadaesolutions/adam-adae-worst-severity/result.R
Edit43 lines# Reference solution for the yamaa benchmark adam-adae-worst-severity (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)adae_raw <- read_csv( "/app/input/adae_raw.csv", col_types = cols(AESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))adae <- adae_raw |> mutate( ASEVN = case_when( AESEV == "MILD" ~ 1L, AESEV == "MODERATE" ~ 2L, AESEV == "SEVERE" ~ 3L ) )# The eligible event with the greatest rank per subject and term; ties break# by earliest date, then lowest sequence. Only a treatment-emergent event# with a graded severity is eligible.best <- adae |> filter(TRTEMFL == "Y", !is.na(ASEVN)) |> arrange(USUBJID, AEDECOD, desc(ASEVN), ASTDT, AESEQ) |> distinct(USUBJID, AEDECOD, .keep_all = TRUE) |> select(USUBJID, AEDECOD, AESEQ) |> mutate(BEST = "Y")adae <- adae |> left_join(best, by = c("USUBJID", "AEDECOD", "AESEQ")) |> mutate(AOCCPIFL = BEST) |> select( STUDYID, USUBJID, AESEQ, AEBODSYS, AEDECOD, ASTDT, AESEV, TRTEMFL, ASEVN, AOCCPIFL )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-worst-severity/result.py
Edit59 lines# Reference solution for the yamaa benchmark adam-adae-worst-severity (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 pladae_raw = ( pl.read_csv("/app/input/adae_raw.csv", infer_schema=False) .with_columns( pl.col("AESEQ").cast(pl.Int64), pl.col("ASTDT").str.to_date(strict=False), ))adae = adae_raw.with_columns( 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))# The eligible event with the greatest rank per subject and term; ties break# by earliest date, then lowest sequence. Only a treatment-emergent event# with a graded severity is eligible. ISO dates sort as text.best = ( adae.filter(pl.col("TRTEMFL") == "Y", pl.col("ASEVN").is_not_null()) .sort(["ASEVN", "ASTDT", "AESEQ"], descending=[True, False, False], nulls_last=True) .unique(["USUBJID", "AEDECOD"], keep="first", maintain_order=True) .select("USUBJID", "AEDECOD", "AESEQ") .with_columns(BEST=pl.lit("Y")))adae = ( adae.join(best, on=["USUBJID", "AEDECOD", "AESEQ"], how="left") .with_columns(AOCCPIFL=pl.col("BEST")) .select( "STUDYID", "USUBJID", "AESEQ", "AEBODSYS", "AEDECOD", "ASTDT", "AESEV", "TRTEMFL", "ASEVN", "AOCCPIFL", ))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")solutions/adam-adae-worst-severity/result.sas
Edit23 lines/* opensas reference solution for the yamaa benchmark adam-adae-worst-severity. 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 AESEV 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. AESEV : $char1024. TRTEMFL : $char1024.;run;data graded; length ASEV $20; set adae_raw; NODATE=missing(ASTDT); 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(where=(TRTEMFL='Y' and not missing(ASEVN))) out=eligible; by STUDYID USUBJID AEDECOD descending ASEVN NODATE ASTDT AESEQ; run;data worst; set eligible; by STUDYID USUBJID 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 AOCCPIFL from graded as a left join worst as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AESEQ=b.AESEQ; quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEBODSYS, AEDECOD, ASTDT, AESEV, TRTEMFL, ASEVN, AOCCPIFL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions