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-graded clinical event
(CE) for each subject, adding ASEV, ASEVN, ATOXGRN and
AOCCFL.
Input: clinical event records carrying sequence number
(CESEQ), reported term (CETERM), collected severity
(CESEV), and analysis start date (ASTDT).
Variables:
ASEV: analysis severity, carrying the collected severity (CESEV); blank when none was collected.ASEVN: numeric rank ofASEV,1for MILD through3for SEVERE; blank when no severity was collected.ATOXGRN: toxicity grade, equal toASEVN, so a moderate event reads grade2; blank when no severity was collected.AOCCFL:Yon the graded event with the greatestATOXGRNfor the subject; blank otherwise. Ties break by earliestASTDT, then lowestCESEQ, so at most one event per subject is flagged.
Note: an event without a grade can never be flagged, so a subject with no graded event has no flagged event. Grading stays separate from flagging so the grade means the same thing on every event while the flag answers a question about the subject.
Inputs
Under review1 source fileinput/ce.csv
Edit11 rows| STUDYID | USUBJID | CESEQ | CETERM | CESEV | ASTDT |
|---|---|---|---|---|---|
| KN189 | 1 | FEVER | MILD | 2024-01-11 | |
| KN189 | 2 | FATIGUE | SEVERE | 2024-01-12 | |
| KN189 | 3 | CHILLS | SEVERE | 2024-01-13 | |
| KN189 | 4 | FATIGUE | SEVERE | 2024-01-12 | |
| KN189 | 1 | FEVER | — | 2024-02-06 | |
| KN189 | 2 | FEVER | MODERATE | 2024-02-06 | |
| KN189 | 1 | REDNESS | MODERATE | 2024-03-02 | |
| KN189 | 1 | FEVER | — | 2024-05-01 | |
| KN189 | 2 | HEADACHE | — | 2024-05-03 | |
| KN189 | 1 | PAIN | MODERATE | 2024-04-10 | |
| KN189 | 2 | HEADACHE | MODERATE | 2024-04-05 |
Expected output
Under review11 expected rowsexpected/adce.csv
Edit11 rows| STUDYID | USUBJID | CESEQ | CETERM | ASTDT | ASEV | ASEVN | ATOXGRN | AOCCFL |
|---|---|---|---|---|---|---|---|---|
| KN189 | 1 | FEVER | 2024-01-11 | MILD | 1 | 1 | — | |
| KN189 | 2 | FATIGUE | 2024-01-12 | SEVERE | 3 | 3 | Y | |
| KN189 | 3 | CHILLS | 2024-01-13 | SEVERE | 3 | 3 | — | |
| KN189 | 4 | FATIGUE | 2024-01-12 | SEVERE | 3 | 3 | — | |
| KN189 | 1 | FEVER | 2024-02-06 | — | — | — | — | |
| KN189 | 2 | FEVER | 2024-02-06 | MODERATE | 2 | 2 | Y | |
| KN189 | 1 | REDNESS | 2024-03-02 | MODERATE | 2 | 2 | Y | |
| KN189 | 1 | FEVER | 2024-05-01 | — | — | — | — | |
| KN189 | 2 | HEADACHE | 2024-05-03 | — | — | — | — | |
| KN189 | 1 | PAIN | 2024-04-10 | MODERATE | 2 | 2 | — | |
| KN189 | 2 | HEADACHE | 2024-04-05 | MODERATE | 2 | 2 | Y |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADCE | STUDYID | Study Identifier | character | Copy value from CE.STUDYID. | Predecessor | ||
| ADCE | USUBJID | Unique Subject Identifier | character | Copy value from CE.USUBJID. | Predecessor | ||
| ADCE | CESEQ | Sequence Number | numeric | Copy value from CE.CESEQ. | Predecessor | ||
| ADCE | CETERM | Reported Term for Clinical Event | character | Copy value from CE.CETERM. | Predecessor | ||
| ADCE | ASTDT | Analysis Start Date | numeric | ISO 8601 | Copy value from CE.ASTDT. | Predecessor | |
| ADCE | ASEV | Analysis Severity/Intensity | character | MILD, MODERATE, SEVERE | Copy value from CE.CESEV. | Predecessor | |
| ADCE | ASEVN | Analysis Severity/Intensity (N) | numeric | 1, 2, 3 | Recode ASEV: "MILD" → "1", "MODERATE" → "2", "SEVERE" → "3"; missing values stay missing; unlisted values are errors. | Derived | |
| ADCE | ATOXGRN | Analysis Toxicity Grade (N) | numeric | 1, 2, 3 | Copy value from ASEVN. | Derived | |
| ADCE | AOCCFL | Worst Grade Occurrence Flag | character | Y | "Y" when WGRSEQ = 1; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| ASEV | MILD, MODERATE, SEVERE |
| ASEVN | 1, 2, 3 |
| ATOXGRN | 1, 2, 3 |
| AOCCFL | 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-adce-worst-toxicity/full.md
Edit18 linesFollowing CDISC ADaM standards, use the provided CE dataset to create an ADCE dataset with one record per clinical event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL
ASEV is the collected severity, and has no value when none was collected. ASEVN is the numeric rank of ASEV: 1 for MILD through 3 for SEVERE, and has no value when none was collected. ATOXGRN is the toxicity grade, equal to ASEVN, so a moderate event reads grade 2; it has no value when none was collected. AOCCFL is Y on the graded event with the greatest ATOXGRN for the subject, and has no value otherwise. Ties break by earliest ASTDT, then lowest CESEQ, so at most one event per subject is flagged. An event without a grade can never be flagged, so a subject with no graded event has no flagged event.
Read the source datasets from /app/input and save the completed dataset as /app/output/adce.csv.
prompts/adam-adce-worst-toxicity/conventions.md
Edit12 linesFollowing CDISC ADaM standards, use the provided CE dataset to create an ADCE dataset with one record per clinical event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL
ASEVN is the numeric rank of ASEV: 1 for MILD through 3 for SEVERE. ATOXGRN is the toxicity grade, equal to ASEVN, so a moderate event reads grade 2. AOCCFL is Y or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adce.csv.
prompts/adam-adce-worst-toxicity/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided CE dataset to create an ADCE dataset with one record per clinical event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL
Read the source datasets from /app/input and save the completed dataset as /app/output/adce.csv.
run.R
Edit4 lineslibrary(yamaa)adce <- yamaa_domain("spec.yaml")$outputadcerun.py
Edit4 linesimport yamaaadce = yamaa.yamaa_domain("spec.yaml").outputadcesolutions/adam-adce-worst-toxicity/result.R
Edit41 lines# Reference solution for the yamaa benchmark adam-adce-worst-toxicity (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)ce <- read_csv( "/app/input/ce.csv", col_types = cols(CESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))adce <- ce |> mutate( ASEV = CESEV, ASEVN = case_when( ASEV == "MILD" ~ 1L, ASEV == "MODERATE" ~ 2L, ASEV == "SEVERE" ~ 3L ), ATOXGRN = ASEVN )# The graded event with the greatest grade per subject; ties break by# earliest date, then lowest sequence, so at most one per subject.best <- adce |> filter(!is.na(ATOXGRN)) |> arrange(USUBJID, desc(ATOXGRN), ASTDT, CESEQ) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, CESEQ) |> mutate(BEST = "Y")adce <- adce |> left_join(best, by = c("USUBJID", "CESEQ")) |> mutate(AOCCFL = BEST) |> select(STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adce, "/app/output/adce.csv", na = "")solutions/adam-adce-worst-toxicity/result.py
Edit58 lines# Reference solution for the yamaa benchmark adam-adce-worst-toxicity (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 plce = ( pl.read_csv("/app/input/ce.csv", infer_schema=False) .with_columns( pl.col("CESEQ").cast(pl.Int64), pl.col("ASTDT").str.to_date(strict=False), ))adce = ce.with_columns( ASEV=pl.col("CESEV"), ASEVN=pl.when(pl.col("CESEV") == "MILD") .then(1) .when(pl.col("CESEV") == "MODERATE") .then(2) .when(pl.col("CESEV") == "SEVERE") .then(3) .otherwise(None) .cast(pl.Int64),).with_columns(ATOXGRN=pl.col("ASEVN"))# The graded event with the greatest grade per subject; ties break by# earliest date, then lowest sequence, so at most one per subject.best = ( adce.filter(pl.col("ATOXGRN").is_not_null()) .sort(["ATOXGRN", "ASTDT", "CESEQ"], descending=[True, False, False], nulls_last=True) .unique("USUBJID", keep="first", maintain_order=True) .select("USUBJID", "CESEQ") .with_columns(BEST=pl.lit("Y")))adce = ( adce.join(best, on=["USUBJID", "CESEQ"], how="left") .with_columns(AOCCFL=pl.col("BEST")) .select( "STUDYID", "USUBJID", "CESEQ", "CETERM", "ASTDT", "ASEV", "ASEVN", "ATOXGRN", "AOCCFL", ))Path("/app/output").mkdir(exist_ok=True)adce.write_csv("/app/output/adce.csv")solutions/adam-adce-worst-toxicity/result.sas
Edit24 lines/* opensas reference solution for the yamaa benchmark adam-adce-worst-toxicity. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ce; length STUDYID USUBJID CETERM CESEV ASTDT $1024; infile "/app/input/ce.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CESEQ CETERM : $char1024. CESEV : $char1024. ASTDT : $char1024.;run;data graded; length ASEV $1024; set ce; NODATE=missing(ASTDT); ASEV=CESEV; select(ASEV); when('MILD') ASEVN=1; when('MODERATE') ASEVN=2; when('SEVERE') ASEVN=3; otherwise ASEVN=.; end; ATOXGRN=ASEVN;run;proc sort data=graded(where=(not missing(ATOXGRN))) out=eligible; by STUDYID USUBJID descending ATOXGRN NODATE ASTDT CESEQ; run;data worst; set eligible; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID CESEQ; run;proc sql; create table result as select a.*,case when not missing(b.CESEQ) then 'Y' else '' end as AOCCFL from graded as a left join worst as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.CESEQ=b.CESEQ; quit;proc sql; create table final as select STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL from result;quit;proc export data=final outfile="/app/output/adce.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions