Review ask

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

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: add one total laboratory record per subject and visit whose analysis value (AVAL) is the collected component results added in the order the source records were stored, flagged with the record-type flag (DTYPE).

Input: collected laboratory records carrying the study identifier, subject identifier, sequence number, test code and name, visit, and standardized result. The component values are deliberately simple (0.1, 0.2, 0.3) so the floating-point rounding stays visible.

Variables:

  • PARAM: the collected test name on each component record; "Total of Components" on the new total record.
  • AVAL: the collected result on each component record; on the total record, the component results added in stored record order. A component with no collected result contributes nothing, and a subject and visit with no collected results at all leaves the total empty rather than zero.
  • DTYPE: empty on the collected records; CALCULATION on the total record, marking it as calculated rather than collected.

Note: binary floating-point addition makes the total sensitive to that order: one subject's records stored as 0.1, 0.2, 0.3 total 0.6000000000000001, while another subject's identical values stored as 0.3, 0.2, 0.1 total 0.6.

Inputs

Under review
1 source file

input/lb.csv

Edit
12 rows
input/lb.csv
STUDYIDUSUBJIDLBSEQLBTESTCDLBTESTVISITLBSTRESN
YAMAA-011COMP1Component 1WEEK 10.1
YAMAA-012COMP2Component 2WEEK 10.2
YAMAA-013COMP3Component 3WEEK 10.3
YAMAA-011COMP3Component 3WEEK 10.3
YAMAA-012COMP2Component 2WEEK 10.2
YAMAA-013COMP1Component 1WEEK 10.1
YAMAA-011COMP1Component 1WEEK 10.1
YAMAA-011COMP1Component 1WEEK 10.1
YAMAA-012COMP2Component 2WEEK 1—
YAMAA-013COMP3Component 3WEEK 10.3
YAMAA-011COMP1Component 1WEEK 1—
YAMAA-012COMP2Component 2WEEK 1—

Expected output

Under review
17 expected rows

expected/adlb.csv

Edit
17 rows
expected/adlb.csv
STUDYIDUSUBJIDPARAMCDPARAMAVISITAVALDTYPE
YAMAA-01COMP1Component 1WEEK 10.1—
YAMAA-01COMP2Component 2WEEK 10.2—
YAMAA-01COMP3Component 3WEEK 10.3—
YAMAA-01COMP3Component 3WEEK 10.3—
YAMAA-01COMP2Component 2WEEK 10.2—
YAMAA-01COMP1Component 1WEEK 10.1—
YAMAA-01COMP1Component 1WEEK 10.1—
YAMAA-01COMP1Component 1WEEK 10.1—
YAMAA-01COMP2Component 2WEEK 1——
YAMAA-01COMP3Component 3WEEK 10.3—
YAMAA-01COMP1Component 1WEEK 1——
YAMAA-01COMP2Component 2WEEK 1——
YAMAA-01TOTALTotal of ComponentsWEEK 10.6000000000000001CALCULATION
YAMAA-01TOTALTotal of ComponentsWEEK 10.6CALCULATION
YAMAA-01TOTALTotal of ComponentsWEEK 10.1CALCULATION
YAMAA-01TOTALTotal of ComponentsWEEK 10.4CALCULATION
YAMAA-01TOTALTotal of ComponentsWEEK 1—CALCULATION
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADLBSTUDYIDStudy IdentifiercharacterCopy value from LB.STUDYID.Predecessor
ADLBUSUBJIDUnique Subject IdentifiercharacterCopy value from LB.USUBJID.Predecessor
ADLBAVISITAnalysis VisitcharacterCopy value from LB.VISIT.Predecessor
ADLBPARAMCDParameter CodecharacterSet per constructed row; see the Row construction sheet.Derived
ADLBPARAMParametercharacterSet per constructed row; see the Row construction sheet.Derived
ADLBAVALAnalysis ValuenumericSet per constructed row; see the Row construction sheet.Derived
ADLBDTYPEDerivation TypecharacterSet per constructed row; see the Row construction sheet.Derived
TemplateInclude whenPARAMCDPARAMAVALDTYPE
collectedCopy LB.LBTESTCDCopy LB.LBTESTCopy LB.LBSTRESNConstant "None"
totalConstant "TOTAL"Constant "Total of Components"Aggregate SUM(LB.LBSTRESN) over records matching on the shared output keysConstant "CALCULATION"
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
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-adlb-ordered-sum/full.md

Edit
19 lines

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

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE

The output holds every collected laboratory record and adds one total record for each subject and visit. On a collected record, PARAMCD is the collected test code, PARAM is the collected test name, and AVAL is the collected standardized result. On the total record, PARAMCD is TOTAL and PARAM is "Total of Components". AVAL on the total record is that subject's collected component results for the visit, added in the order the source records were stored. A component with no collected result contributes nothing to the total. When a subject and visit has no collected results at all, AVAL on the total record has no value rather than zero. AVAL is not rounded. DTYPE has no value on the collected records and is CALCULATION on the total record.

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

prompts/adam-adlb-ordered-sum/conventions.md

Edit
11 lines

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

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE

On the total record, PARAMCD is TOTAL and PARAM is "Total of Components". AVAL is not rounded. DTYPE is CALCULATION or has no value.

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

prompts/adam-adlb-ordered-sum/brief.md

Edit
8 lines

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

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE

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

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

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

solutions/adam-adlb-ordered-sum/result.R

Edit
65 lines
# Reference solution for the yamaa benchmark adam-adlb-ordered-sum (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(    LBSEQ = col_integer(),    LBSTRESN = col_double(),    .default = col_character()  ))# Keep every collected component record; DTYPE has no value on these.components <- lb |>  transmute(    STUDYID, USUBJID,    PARAMCD = LBTESTCD,    PARAM = LBTEST,    AVISIT = VISIT,    AVAL = LBSTRESN,    DTYPE = NA_character_  )# One total record per subject and visit: the sum of the collected# component results in laboratory sequence order. No value, rather than# zero, when none of them has a collected result.ordered_sum <- function(x) {  vals <- x[!is.na(x)]  if (length(vals) == 0) {    return(NA_real_)  }  total <- vals[[1]]  if (length(vals) > 1) {    for (v in vals[-1]) {      total <- total + v    }  }  total}totals <- lb |>  arrange(USUBJID, VISIT, LBSEQ) |>  group_by(STUDYID, USUBJID, VISIT) |>  summarise(    AVAL = ordered_sum(LBSTRESN),    .groups = "drop"  ) |>  mutate(    PARAMCD = "TOTAL",    PARAM = "Total of Components",    AVISIT = VISIT,    DTYPE = "CALCULATION"  ) |>  select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE)adlb <- bind_rows(components, totals)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")

solutions/adam-adlb-ordered-sum/result.py

Edit
76 lines
# Reference solution for the yamaa benchmark adam-adlb-ordered-sum (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 ADLB from LB: every collected record plus one TOTAL recordper subject and visit, summed in the order the source records werestored."""import csvimport osINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = ["STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "DTYPE"]def main():    with open(os.path.join(INPUT_DIR, "lb.csv"), newline="") as f:        source = list(csv.DictReader(f))    collected = []  # (group key, output row) in stored order    totals = {}  # group key -> running total, None until a result is seen    last_index = {}  # group key -> index in `collected` of its last record    for row in source:        key = (row["STUDYID"], row["USUBJID"], row["VISIT"])        result = (row["LBSTRESN"] or "").strip()        totals.setdefault(key, None)        if result != "":            value = float(result)            totals[key] = value if totals[key] is None else totals[key] + value        collected.append(            (                key,                {                    "STUDYID": row["STUDYID"],                    "USUBJID": row["USUBJID"],                    "PARAMCD": row["LBTESTCD"],                    "PARAM": row["LBTEST"],                    "AVISIT": row["VISIT"],                    "AVAL": result,                    "DTYPE": "",                },            )        )        last_index[key] = len(collected) - 1    final_rows = []    for i, (key, row) in enumerate(collected):        final_rows.append(row)        if last_index[key] == i:            total = totals[key]            final_rows.append(                {                    "STUDYID": key[0],                    "USUBJID": key[1],                    "PARAMCD": "TOTAL",                    "PARAM": "Total of Components",                    "AVISIT": key[2],                    "AVAL": "" if total is None else repr(total),                    "DTYPE": "CALCULATION",                }            )    os.makedirs(OUTPUT_DIR, exist_ok=True)    with open(os.path.join(OUTPUT_DIR, "adlb.csv"), "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=COLUMNS)        writer.writeheader()        writer.writerows(final_rows)if __name__ == "__main__":    main()

solutions/adam-adlb-ordered-sum/result.sas

Edit
32 lines
/* opensas reference solution for the yamaa benchmark adam-adlb-ordered-sum.   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 LBTEST VISIT $1024;  infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. LBSEQ LBTESTCD : $char1024. LBTEST : $char1024. VISIT : $char1024. LBSTRESN;run;data collected;  length PARAMCD $16 PARAM $1024 AVISIT $1024 DTYPE $11;  set lb; PARAMCD=LBTESTCD; PARAM=LBTEST; AVISIT=VISIT; AVAL=LBSTRESN;run;proc sort data=collected; by STUDYID USUBJID AVISIT LBSEQ; run;data totals;  length PARAMCD $16 PARAM $1024 DTYPE $11;  set collected; by STUDYID USUBJID AVISIT;  if first.AVISIT then do; total=0; count=0; end;  if not missing(AVAL) then do; total+AVAL; count+1; end;  if last.AVISIT then do;    PARAMCD='TOTAL'; PARAM='Total of Components'; DTYPE='CALCULATION';    AVAL=.; if count>0 then AVAL=total;    output;  end;run;data result; set collected totals; run;proc sql;  create table final as select STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;