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: one record per subject flagging any reported dose
adjustment (DOSADJFL).
Input: subject list plus exposure (EX) records carrying the
reason for a dose adjustment (EXADJ), exposure as collected
(EC) records carrying the same reason (ECADJ), and
findings-about (FA) records carrying a test code (FATESTCD),
the object of the finding (FAOBJ), and its result
(FASTRESC).
Variables:
DOSADJFLholdsYwhen any source holds a qualifying record: a filledEXADJvalue, a filledECADJvalue, or a findings-about row withFATESTCDofOCCUR,FAOBJofDOSE ADJUSTMENT, andFASTRESCofY. A pre-specified (PRESP) or non-dose-adjustment finding does not qualify. It holdsNwhen the subject has at least one record in any of the three sources but no qualifying record. It stays empty when the subject is absent from all three sources.
Note: a record belongs to a subject only when both the study and subject identifiers match, and a source record for a subject not in the subject list adds no record.
Inputs
Under review4 source filesinput/adsl.csv
Edit10 rows| STUDYID | USUBJID |
|---|---|
| AB42 | |
| AB42 | |
| AB42 | |
| AB42 | |
| AB42 | |
| AB42 | |
| AB42 | |
| AB42 | |
| AB42 | |
| AB43 |
input/ec.csv
Edit3 rows| STUDYID | USUBJID | ECADJ |
|---|---|---|
| AB42 | DOSE REDUCED | |
| AB42 | — | |
| AB42 | — |
input/ex.csv
Edit7 rows| STUDYID | USUBJID | EXADJ |
|---|---|---|
| AB42 | DOSE REDUCED | |
| AB42 | — | |
| AB42 | — | |
| AB42 | — | |
| AB42 | DOSE REDUCED | |
| AB42 | — | |
| AB42 | DOSE REDUCED |
input/fa.csv
Edit4 rows| STUDYID | USUBJID | FATESTCD | FAOBJ | FASTRESC |
|---|---|---|---|---|
| AB42 | OCCUR | DOSE ADJUSTMENT | Y | |
| AB42 | OCCUR | DOSE ADJUSTMENT | N | |
| AB42 | OCCUR | OTHER ASSESSMENT | Y | |
| AB42 | PRESP | DOSE ADJUSTMENT | Y |
Expected output
Under review10 expected rowsexpected/adsl.csv
Edit10 rows| STUDYID | USUBJID | DOSADJFL |
|---|---|---|
| AB42 | Y | |
| AB42 | N | |
| AB42 | Y | |
| AB42 | — | |
| AB42 | Y | |
| AB42 | N | |
| AB42 | Y | |
| AB42 | N | |
| AB42 | N | |
| AB43 | — |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from ADSL_RAW.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from ADSL_RAW.USUBJID. | Predecessor | ||
| ADSL | DOSADJFL | Dose Adjustment Flag | character | Y, N | If EX_ADJ_CNT > 0 OR EC_ADJ_CNT > 0 OR FA_ADJ_CNT > 0 then "Y"; If EX_ANY_CNT > 0 OR EC_ANY_CNT > 0 OR FA_ANY_CNT > 0 then "N"; otherwise blank. | Derived |
| Variable | Permitted values |
|---|---|
| DOSADJFL | Y, N |
| 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-adsl-dose-adjustment/full.md
Edit21 linesFollowing CDISC ADaM standards, use the provided ADSL_RAW, EX, EC, and FA datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, DOSADJFL
DOSADJFL is Y when any source reports an adjustment: a filled EXADJ value, a filled ECADJ value, or a findings-about row with test code OCCUR, object DOSE ADJUSTMENT, and result Y. A PRESP test code, or a row about anything but dose adjustment, does not qualify.
DOSADJFL is N when the subject has at least one record in any of the three sources but no qualifying record. It has no value when the subject is absent from all three sources.
A source record counts for a subject only when both identifiers match, and a source record for a subject outside the subject list adds no record.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-dose-adjustment/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided ADSL_RAW, EX, EC, and FA datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, DOSADJFL
DOSADJFL is Y, N, or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-dose-adjustment/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided ADSL_RAW, EX, EC, and FA datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, DOSADJFL
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-dose-adjustment/result.R
Edit63 lines# Reference solution for the yamaa benchmark adam-adsl-dose-adjustment (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)library(stringr)base <- read_csv( "/app/input/adsl.csv", col_types = cols(.default = col_character()))ex <- read_csv( "/app/input/ex.csv", col_types = cols(.default = col_character()))ec <- read_csv( "/app/input/ec.csv", col_types = cols(.default = col_character()))fa <- read_csv( "/app/input/fa.csv", col_types = cols(.default = col_character()))# A record reports an adjustment with a filled value; findings-about rows# qualify only for dose adjustment occurrences with a Y result.ex_adj <- ex |> filter(!is.na(EXADJ), str_trim(EXADJ) != "") |> distinct(STUDYID, USUBJID) |> mutate(.ex_adj = TRUE)ec_adj <- ec |> filter(!is.na(ECADJ), str_trim(ECADJ) != "") |> distinct(STUDYID, USUBJID) |> mutate(.ec_adj = TRUE)fa_adj <- fa |> filter(FATESTCD %in% "OCCUR", FAOBJ %in% "DOSE ADJUSTMENT", FASTRESC %in% "Y") |> distinct(STUDYID, USUBJID) |> mutate(.fa_adj = TRUE)ex_any <- ex |> distinct(STUDYID, USUBJID) |> mutate(.ex_any = TRUE)ec_any <- ec |> distinct(STUDYID, USUBJID) |> mutate(.ec_any = TRUE)fa_any <- fa |> distinct(STUDYID, USUBJID) |> mutate(.fa_any = TRUE)adsl <- base |> left_join(ex_adj, by = c("STUDYID", "USUBJID")) |> left_join(ec_adj, by = c("STUDYID", "USUBJID")) |> left_join(fa_adj, by = c("STUDYID", "USUBJID")) |> left_join(ex_any, by = c("STUDYID", "USUBJID")) |> left_join(ec_any, by = c("STUDYID", "USUBJID")) |> left_join(fa_any, by = c("STUDYID", "USUBJID")) |> mutate( DOSADJFL = case_when( .ex_adj %in% TRUE | .ec_adj %in% TRUE | .fa_adj %in% TRUE ~ "Y", .ex_any %in% TRUE | .ec_any %in% TRUE | .fa_any %in% TRUE ~ "N" ) ) |> select(STUDYID, USUBJID, DOSADJFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-dose-adjustment/result.py
Edit75 lines# Reference solution for the yamaa benchmark adam-adsl-dose-adjustment (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 plbase = pl.read_csv("/app/input/adsl.csv", infer_schema=False)ex = pl.read_csv("/app/input/ex.csv", infer_schema=False)ec = pl.read_csv("/app/input/ec.csv", infer_schema=False)fa = pl.read_csv("/app/input/fa.csv", infer_schema=False)keys = ["STUDYID", "USUBJID"]def adjusted(sub: pl.DataFrame, column: str) -> pl.DataFrame: return ( sub.filter(pl.col(column).fill_null("").str.strip_chars() != "") .select(keys) .unique() .with_columns(pl.lit(True).alias(f"__adj_{column}")) )def any_records(sub: pl.DataFrame, tag: str) -> pl.DataFrame: return ( sub.select(keys).unique().with_columns(pl.lit(True).alias(f"__any_{tag}")) )ex_adj = adjusted(ex, "EXADJ")ec_adj = adjusted(ec, "ECADJ")fa_adj = ( fa.filter( (pl.col("FATESTCD") == "OCCUR") & (pl.col("FAOBJ") == "DOSE ADJUSTMENT") & (pl.col("FASTRESC") == "Y") ) .select(keys) .unique() .with_columns(pl.lit(True).alias("__adj_FA")))ex_any = any_records(ex, "EX")ec_any = any_records(ec, "EC")fa_any = any_records(fa, "FA")adsl = ( base.join(ex_adj, on=keys, how="left", maintain_order="left") .join(ec_adj, on=keys, how="left", maintain_order="left") .join(fa_adj, on=keys, how="left", maintain_order="left") .join(ex_any, on=keys, how="left", maintain_order="left") .join(ec_any, on=keys, how="left", maintain_order="left") .join(fa_any, on=keys, how="left", maintain_order="left") .with_columns( DOSADJFL=pl.when( (pl.col("__adj_EXADJ") == True) | (pl.col("__adj_ECADJ") == True) | (pl.col("__adj_FA") == True) ) .then(pl.lit("Y")) .when( (pl.col("__any_EX") == True) | (pl.col("__any_EC") == True) | (pl.col("__any_FA") == True) ) .then(pl.lit("N")) .otherwise(None) ) .select("STUDYID", "USUBJID", "DOSADJFL"))Path("/app/output").mkdir(exist_ok=True)adsl.write_csv("/app/output/adsl.csv")solutions/adam-adsl-dose-adjustment/result.sas
Edit41 lines/* opensas reference solution for the yamaa benchmark adam-adsl-dose-adjustment. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl; length STUDYID USUBJID $1024; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024.;run;data ec; length STUDYID USUBJID ECADJ $1024; infile "/app/input/ec.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. ECADJ : $char1024.;run;data ex; length STUDYID USUBJID EXADJ $1024; infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. EXADJ : $char1024.;run;data fa; length STUDYID USUBJID FATESTCD FAOBJ FASTRESC $1024; infile "/app/input/fa.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. FATESTCD : $char1024. FAOBJ : $char1024. FASTRESC : $char1024.;run;proc sql; create table evidence as select STUDYID,USUBJID,case when not missing(EXADJ) then 1 else 0 end as adjusted from ex union all select STUDYID,USUBJID,case when not missing(ECADJ) then 1 else 0 end from ec union all select STUDYID,USUBJID,case when FATESTCD='OCCUR' and FAOBJ='DOSE ADJUSTMENT' and FASTRESC='Y' then 1 else 0 end from fa; create table flags as select STUDYID,USUBJID,max(adjusted) as adjusted,count(*) as records from evidence group by STUDYID,USUBJID; create table result as select a.*, case when b.adjusted=1 then 'Y' when b.records>0 then 'N' else '' end as DOSADJFL from adsl as a left join flags as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;proc sql; create table final as select STUDYID, USUBJID, DOSADJFL from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions