Review ask

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.

  1. 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.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. 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

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Goal: build the albumin change parameter _ALB, carrying each visit's previous result (PREV_AVAL), the change from it (CHG), and the previous visit's change (PREV2).

Input: laboratory (LB) records carrying a test code (LBTESTCD), a numeric result (LBSTRESN), and a visit number (VISITNUM). Six subjects: a four-visit chain that skips a visit number, a subject whose middle visit has no result, a single-visit subject, a two-visit subject, a subject with no change between two consecutive visits, and one whose hemoglobin record produces no row.

Variables:

  • AVISITN: the analysis visit number, taken from the lab visit number.
  • AVAL: the numeric albumin result for the visit.
  • PREV_AVAL: the AVAL of the visit just before in AVISITN order, for the same subject; blank on the subject's first visit.
  • CHG: AVAL - PREV_AVAL, the change since that visit; blank whenever PREV_AVAL is.
  • PREV2: the CHG of the visit just before, read after that change is complete; blank until two earlier visits carry results.

Note: the previous visit's change is carried from its completed value, so a record with no numeric result shortens the chain: it gets no row, and the change and its lag compare against the latest earlier visit with a result. CHG here is the change from the previous visit, not the ADaMIG "change from baseline" definition; a zero change is a real value (0), distinct from blank.

Inputs

Under review
1 source file

input/lb.csv

Edit
15 rows
input/lb.csv
STUDYIDUSUBJIDLBTESTCDLBSTRESNVISITNUM
YAMAA-01ALB4.01
YAMAA-01ALB4.52
YAMAA-01ALB5.54
YAMAA-01ALB7.05
YAMAA-01ALB4.01
YAMAA-01ALB—2
YAMAA-01ALB5.03
YAMAA-01ALB3.751
YAMAA-01ALB4.251
YAMAA-01ALB4.752
YAMAA-01ALB4.01
YAMAA-01HGB13.51
YAMAA-01ALB4.51
YAMAA-01ALB4.52
YAMAA-01ALB5.03

Expected output

Under review
13 expected rows

expected/adlbc.csv

Edit
13 rows
expected/adlbc.csv
STUDYIDUSUBJIDPARAMCDAVISITNAVALPREV_AVALCHGPREV2
YAMAA-01_ALB14———
YAMAA-01_ALB24.540.5—
YAMAA-01_ALB45.54.510.5
YAMAA-01_ALB575.51.51
YAMAA-01_ALB14———
YAMAA-01_ALB3541—
YAMAA-01_ALB13.75———
YAMAA-01_ALB14.25———
YAMAA-01_ALB24.754.250.5—
YAMAA-01_ALB14———
YAMAA-01_ALB14.5———
YAMAA-01_ALB24.54.50—
YAMAA-01_ALB354.50.50
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository Discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADLBCSTUDYIDStudy IdentifiercharacterCopy value from LB.STUDYID.Predecessor
ADLBCUSUBJIDUnique Subject IdentifiercharacterCopy value from LB.USUBJID.Predecessor
ADLBCPARAMCDParameter CodecharacterSet per constructed row; see the Row construction sheet.Derived
ADLBCAVISITNAnalysis Visit NumbernumericCopy value from LB.VISITNUM.Predecessor
ADLBCAVALAnalysis ValuenumericCopy value from LB.LBSTRESN.Predecessor
ADLBCPREV_AVALPrevious Analysis ValuenumericTake AVAL from 1 row earlier using window VISIT_ORDER.Derived
ADLBCCHGChange from Previous ValuenumericCompute AVAL - PREV_AVAL.Derived
ADLBCPREV2Lag of ChangenumericTake CHG from 1 row earlier using window VISIT_ORDER.Derived
TemplateInclude whenPARAMCD
change_albLB.LBTESTCD = 'ALB' AND LB.LBSTRESN IS NOT NULLConstant "_ALB"
VersionDateAuthorDescriptionReviewerSign-off
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-adlbc-window-chain/full.md

Edit
27 lines

Following CDISC ADaM standards, use the provided LB dataset to create an ADLBC dataset with one record per subject per parameter per analysis visit.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, AVISITN, AVAL, PREV_AVAL, CHG, PREV2

Build the albumin change parameter "_ALB" from the albumin lab results; any other test produces no rows.

AVISITN is the analysis visit number, taken from the lab visit number. AVAL is the numeric albumin result for the visit.

PREV_AVAL is the value of the visit just before in visit order, for the same subject. It has no value on the subject's first visit.

CHG is the change since that visit, not the change from baseline; it has no value whenever PREV_AVAL has none. PREV2 is the CHG of the previous visit; it has no value until two earlier visits carry results.

A record with no numeric result gets no row, so the change and its lag compare against the latest earlier visit with a result. A zero change is a real value (0), distinct from no value.

Read the source datasets from /app/input and save the completed dataset as /app/output/adlbc.csv.

prompts/adam-adlbc-window-chain/conventions.md

Edit
11 lines

Following CDISC ADaM standards, use the provided LB dataset to create an ADLBC dataset with one record per subject per parameter per analysis visit.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, AVISITN, AVAL, PREV_AVAL, CHG, PREV2

PARAMCD is "_ALB" for albumin.

Read the source datasets from /app/input and save the completed dataset as /app/output/adlbc.csv.

prompts/adam-adlbc-window-chain/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided LB dataset to create an ADLBC dataset with one record per subject per parameter per analysis visit.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, AVISITN, AVAL, PREV_AVAL, CHG, PREV2

Read the source datasets from /app/input and save the completed dataset as /app/output/adlbc.csv.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adlbc <- yamaa_domain("spec.yaml")$outputadlbc

run.py

Edit
4 lines
import yamaaadlbc = yamaa.yamaa_domain("spec.yaml").outputadlbc

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adlbc-window-chain/result.R

Edit
40 lines
# Reference solution for the yamaa benchmark adam-adlbc-window-chain (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)lb <- read_csv(  "/app/input/lb.csv",  col_types = cols(    LBSTRESN = col_double(),    VISITNUM = col_integer(),    .default = col_character()  ))# Albumin results with a numeric value; a record without one gets no row,# so the lag compares against the latest earlier visit with a result.alb <- lb |>  filter(LBTESTCD %in% "ALB", !is.na(LBSTRESN)) |>  mutate(PARAMCD = "_ALB", AVISITN = VISITNUM, AVAL = LBSTRESN) |>  arrange(STUDYID, USUBJID, AVISITN)# The change since the previous visit with a result, and its lag: the# previous visit's change. A zero change is a real value.adlbc <- alb |>  group_by(STUDYID, USUBJID) |>  mutate(    PREV_AVAL = lag(AVAL),    CHG = AVAL - PREV_AVAL,    PREV2 = lag(CHG)  ) |>  ungroup() |>  select(STUDYID, USUBJID, PARAMCD, AVISITN, AVAL, PREV_AVAL, CHG, PREV2) |>  arrange(STUDYID, USUBJID, AVISITN)dir.create("/app/output", showWarnings = FALSE)write_csv(adlbc, "/app/output/adlbc.csv", na = "")

solutions/adam-adlbc-window-chain/result.py

Edit
43 lines
# Reference solution for the yamaa benchmark adam-adlbc-window-chain (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 pllb = pl.read_csv("/app/input/lb.csv", infer_schema=False).with_columns(    pl.col("LBSTRESN").cast(pl.Float64),    pl.col("VISITNUM").cast(pl.Int64),)# Albumin results with a numeric value; a record without one gets no row,# so the lag compares against the latest earlier visit with a result.alb = (    lb.filter(pl.col("LBTESTCD") == "ALB", pl.col("LBSTRESN").is_not_null())    .with_columns(        PARAMCD=pl.lit("_ALB"),        AVISITN=pl.col("VISITNUM"),        AVAL=pl.col("LBSTRESN"),    )    .sort(["STUDYID", "USUBJID", "AVISITN"]))# The change since the previous visit with a result, and its lag: the# previous visit's change. A zero change is a real value.adlbc = (    alb.with_columns(        PREV_AVAL=pl.col("AVAL").shift(1).over(["STUDYID", "USUBJID"]),    )    .with_columns(CHG=pl.col("AVAL") - pl.col("PREV_AVAL"))    .with_columns(PREV2=pl.col("CHG").shift(1).over(["STUDYID", "USUBJID"]))    .select(        "STUDYID", "USUBJID", "PARAMCD", "AVISITN",        "AVAL", "PREV_AVAL", "CHG", "PREV2",    ))Path("/app/output").mkdir(exist_ok=True)adlbc.write_csv("/app/output/adlbc.csv")

solutions/adam-adlbc-window-chain/result.sas

Edit
28 lines
/* opensas reference solution for the yamaa benchmark adam-adlbc-window-chain.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data lb;  length STUDYID USUBJID LBTESTCD $1024;  infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. LBTESTCD : $char1024. LBSTRESN VISITNUM;run;data collected;  length PARAMCD $8;  set lb; if LBTESTCD in ('ALB') and not missing(LBSTRESN);  PARAMCD=cats('_',LBTESTCD); AVISITN=VISITNUM; AVAL=LBSTRESN;run;proc sort data=collected; by STUDYID USUBJID PARAMCD AVISITN; run;data result;  retain previous priorchange;  set collected; by STUDYID USUBJID PARAMCD;  if first.PARAMCD then do; previous=.; priorchange=.; end;  PREV_AVAL=previous; CHG=AVAL-PREV_AVAL; PREV2=priorchange;  previous=AVAL; priorchange=CHG;run;proc sql;  create table final as select STUDYID, USUBJID, PARAMCD, AVISITN, AVAL, PREV_AVAL, CHG, PREV2 from result;quit;proc export data=final outfile="/app/output/adlbc.csv" dbms=csv replace; run;