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 SDTM: 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: reviewedEditUnder review
What this benchmark means
README.md

Goal: build one record per collected calcium and creatinine result with LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT and LBDTC.

Input: long-form Operational Data Model (ODM) rows, one row per collected item, grouped by study, subject and visit. Each visit group carries a collection-date item plus one calcium item and one creatinine item, whichever were collected.

Variables:

  • LBSEQ numbers the records within a subject by collection date, then test code.
  • LBTESTCD is CA for calcium rows and CREAT for creatinine rows.
  • LBTEST is Calcium when the test code is CA and Creatinine when it is CREAT.
  • LBORRES is the collected entry, kept exactly as reported; empty when the test was not done.
  • LBORRESU is mg/dL for every record with a result; empty when the test was not done.
  • LBSTRESN is the numeric form of the collected entry; missing when the entry is text rather than a number, or when the test was not done.
  • LBSTRESU is mg/dL for every record with a result; empty when the test was not done.
  • LBSTAT is NOT DONE when the collected entry says the test was not done; blank otherwise.
  • LBDTC is the collection date from the same visit group.

Note: a test with no collected entry produces no record, so the records are only results actually reported. A NOT DONE entry does produce a record: the result and units stay empty and LBSTAT carries NOT DONE.

Inputs

Under review
1 source file

input/odm.csv

Edit
17 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1YAMAA-01-101BASELINE1IG.LB1IT.LB.LBDTC2025-01-01
YAMAA-01MDV.1YAMAA-01-101BASELINE1IG.LB1IT.LB.CALCIUM9.2
YAMAA-01MDV.1YAMAA-01-101BASELINE1IG.LB1IT.LB.CREAT0.8
YAMAA-01MDV.1YAMAA-01-101DAY81IG.LB1IT.LB.LBDTC2025-01-08
YAMAA-01MDV.1YAMAA-01-101DAY81IG.LB1IT.LB.CALCIUM—
YAMAA-01MDV.1YAMAA-01-101DAY81IG.LB1IT.LB.CREAT0.9
YAMAA-01MDV.1YAMAA-01-101DAY151IG.LB1IT.LB.LBDTC2025-01-15
YAMAA-01MDV.1YAMAA-01-101DAY151IG.LB1IT.LB.CREATNOT DONE
YAMAA-01MDV.1YAMAA-01-102BASELINE1IG.LB1IT.LB.LBDTC2025-02-03
YAMAA-01MDV.1YAMAA-01-102BASELINE1IG.LB1IT.LB.CALCIUM10.1
YAMAA-01MDV.1YAMAA-01-102BASELINE1IG.LB1IT.LB.CREAT1.1
YAMAA-01MDV.1YAMAA-01-103BASELINE1IG.LB1IT.LB.LBDTC2025-03-10
YAMAA-01MDV.1YAMAA-01-103BASELINE1IG.LB1IT.LB.CALCIUM8.4
YAMAA-01MDV.1YAMAA-01-103BASELINE1IG.LB1IT.LB.CREAT1.3
YAMAA-01MDV.1YAMAA-01-103DAY81IG.LB1IT.LB.LBDTC2025-03-17
YAMAA-01MDV.1YAMAA-01-103DAY81IG.LB1IT.LB.CALCIUM10.5
YAMAA-01MDV.1YAMAA-01-103DAY81IG.LB1IT.LB.CREAT—

Expected output

Under review
9 expected rows

expected/lb.csv

Edit
9 rows
expected/lb.csv
DOMAINSTUDYIDUSUBJIDLBSEQLBTESTCDLBTESTLBORRESLBORRESULBSTRESNLBSTRESULBSTATLBDTC
LBYAMAA-011CACalcium9.2mg/dL9.2mg/dL—2025-01-01
LBYAMAA-011CACalcium10.1mg/dL10.1mg/dL—2025-02-03
LBYAMAA-011CACalcium8.4mg/dL8.4mg/dL—2025-03-10
LBYAMAA-013CACalcium10.5mg/dL10.5mg/dL—2025-03-17
LBYAMAA-012CREATCreatinine0.8mg/dL0.8mg/dL—2025-01-01
LBYAMAA-013CREATCreatinine0.9mg/dL0.9mg/dL—2025-01-08
LBYAMAA-014CREATCreatinine————NOT DONE2025-01-15
LBYAMAA-012CREATCreatinine1.1mg/dL1.1mg/dL—2025-02-03
LBYAMAA-012CREATCreatinine1.3mg/dL1.3mg/dL—2025-03-10
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

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "LB".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
LBORRESResult or Finding in Original UnitsCharDerivedIf RAWORRES = 'NOT DONE' then "None"; otherwise "RAWORRES".SDTM4
LBORRESUOriginal UnitsCharDerivedIf RAWORRES = 'NOT DONE' then "None"; otherwise "mg/dL".SDTM5
LBSTRESUStandard UnitsCharDerivedIf RAWORRES = 'NOT DONE' then "None"; otherwise "mg/dL".SDTM6
LBSTATCompletion StatusCharNOT DONEDerivedIf RAWORRES = 'NOT DONE' then "NOT DONE"; otherwise blank.SDTM7
LBTESTCDLab Test or Examination Short NameCharDerivedSet per constructed row; see the Row construction sheet.SDTM8
LBTESTLab Test or Examination NameCharDerivedSet per constructed row; see the Row construction sheet.SDTM9
LBSTRESNNumeric Result/Finding in Standard UnitsNumDerivedCopy value from LBORRES; a value that cannot be converted → blank.SDTM10
LBDTCDate/Time of Specimen CollectionCharISO 8601DerivedSet per constructed row; see the Row construction sheet.SDTM11
LBSEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by LBDTC then LBTESTCD.SDTM12
TemplateInclude whenLBTESTCDLBTESTRAWORRESLBDTC
calciumRAWORRES IS NOT NULLConstant "CA"Constant "Calcium"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.LB.CALCIUM'Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.LB.LBDTC'
creatinineRAWORRES IS NOT NULLConstant "CREAT"Constant "Creatinine"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.LB.CREAT'Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.LB.LBDTC'
VariablePermitted values
LBSTATNOT DONE
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/sdtm-lb-findings/full.md

Edit
28 lines

Following CDISC SDTM standards, use the provided ODM dataset to create an LB dataset with one record per collected calcium and creatinine result.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC

STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.

LBSEQ numbers the records within a subject by collection date, then test code. LBTESTCD is CA for calcium rows and CREAT for creatinine rows; LBTEST is Calcium when the test code is CA and Creatinine when it is CREAT.

LBORRES is the collected entry, kept exactly as reported, and has no value when the test was not done. LBORRESU and LBSTRESU are mg/dL for every record with a result, and have no value when the test was not done. LBSTRESN is the numeric form of the collected entry, and has no value when the entry is text rather than a number or when the test was not done. LBSTAT is NOT DONE when the collected entry says the test was not done, and has no value otherwise. LBDTC is the collection date from the same visit group.

A test with no collected entry produces no record. An entry of NOT DONE does produce a record, with no value in the result and unit fields.

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

prompts/sdtm-lb-findings/conventions.md

Edit
14 lines

Following CDISC SDTM standards, use the provided ODM dataset to create an LB dataset with one record per collected calcium and creatinine result.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC

LBTESTCD is CA for calcium rows and CREAT for creatinine rows; LBTEST is Calcium when the test code is CA and Creatinine when it is CREAT.

LBSTAT is NOT DONE or has no value.

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

prompts/sdtm-lb-findings/brief.md

Edit
9 lines

Following CDISC SDTM standards, use the provided ODM dataset to create an LB dataset with one record per collected calcium and creatinine result.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)lb <- yamaa_domain("spec.yaml")$outputlb

run.py

Edit
4 lines
import yamaalb = yamaa.yamaa_domain("spec.yaml").outputlb

Solution without yamaa

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

solutions/sdtm-lb-findings/result.R

Edit
55 lines
# Reference solution for the yamaa benchmark sdtm-lb-findings (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(tidyr)odm <- read_csv(  "/app/input/odm.csv",  col_types = cols(.default = col_character()))key_cols <- c(  "StudyOID", "SubjectKey", "StudyEventOID", "StudyEventRepeatKey",  "ItemGroupOID", "ItemGroupRepeatKey")dates <- odm |>  filter(ItemOID == "IT.LB.LBDTC") |>  select(all_of(key_cols), LBDTC = Value)lb <- odm |>  filter(ItemOID %in% c("IT.LB.CALCIUM", "IT.LB.CREAT")) |>  left_join(dates, by = key_cols) |>  mutate(Value = na_if(Value, "")) |>  filter(!is.na(Value)) |>  mutate(    LBTESTCD = if_else(ItemOID == "IT.LB.CALCIUM", "CA", "CREAT"),    LBTEST = if_else(ItemOID == "IT.LB.CALCIUM", "Calcium", "Creatinine"),    NOTDONE = Value == "NOT DONE",    DOMAIN = "LB",    STUDYID = StudyOID,    USUBJID = SubjectKey,    LBORRES = if_else(NOTDONE, NA_character_, Value),    LBORRESU = if_else(NOTDONE, NA_character_, "mg/dL"),    LBSTRESN = if_else(      NOTDONE, NA_real_, suppressWarnings(as.numeric(Value))    ),    LBSTRESU = if_else(NOTDONE, NA_character_, "mg/dL"),    LBSTAT = if_else(NOTDONE, "NOT DONE", NA_character_)  ) |>  arrange(STUDYID, USUBJID, LBDTC, LBTESTCD) |>  group_by(STUDYID, USUBJID) |>  mutate(LBSEQ = row_number()) |>  ungroup() |>  select(    DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES,    LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC  )dir.create("/app/output", showWarnings = FALSE)write_csv(lb, "/app/output/lb.csv", na = "")

solutions/sdtm-lb-findings/result.py

Edit
113 lines
# Reference solution for the yamaa benchmark sdtm-lb-findings (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 plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)key_cols = [    "StudyOID",    "SubjectKey",    "StudyEventOID",    "StudyEventRepeatKey",    "ItemGroupOID",    "ItemGroupRepeatKey",]wide = (    odm.group_by(key_cols)    .agg(pl.struct("ItemOID", "Value").alias("items"))    .with_columns(        pl.col("items")        .list.eval(            pl.element().filter(                pl.element().struct.field("ItemOID") == "IT.LB.LBDTC"            )        )        .list.get(0)        .struct.field("Value")        .alias("LBDTC"),    )    .drop("items"))tests = odm.filter(pl.col("ItemOID").is_in(["IT.LB.CALCIUM", "IT.LB.CREAT"]))code_of = {"IT.LB.CALCIUM": "CA", "IT.LB.CREAT": "CREAT"}name_of = {"CA": "Calcium", "CREAT": "Creatinine"}joined = tests.join(wide, on=key_cols, how="left")def as_number(text):    if text is None or text == "" or text == "NOT DONE":        return None    try:        return float(text)    except ValueError:        return Nonerows = []for r in joined.to_dicts():    value = r["Value"]    # A test with no collected entry produces no record.    if value is None or value == "":        continue    code = code_of[r["ItemOID"]]    not_done = value == "NOT DONE"    rows.append(        {            "DOMAIN": "LB",            "STUDYID": r["StudyOID"],            "USUBJID": r["SubjectKey"],            "LBDTC": r["LBDTC"],            "LBTESTCD": code,            "LBTEST": name_of[code],            "LBORRES": None if not_done else value,            "LBORRESU": None if not_done else "mg/dL",            "LBSTRESN": None if not_done else as_number(value),            "LBSTRESU": None if not_done else "mg/dL",            "LBSTAT": "NOT DONE" if not_done else None,        }    )lb = pl.DataFrame(    rows,    schema={        "DOMAIN": pl.String,        "STUDYID": pl.String,        "USUBJID": pl.String,        "LBDTC": pl.String,        "LBTESTCD": pl.String,        "LBTEST": pl.String,        "LBORRES": pl.String,        "LBORRESU": pl.String,        "LBSTRESN": pl.Float64,        "LBSTRESU": pl.String,        "LBSTAT": pl.String,    },).sort(["STUDYID", "USUBJID", "LBDTC", "LBTESTCD"]).with_columns(    pl.int_range(1, pl.len() + 1).over(["STUDYID", "USUBJID"]).alias("LBSEQ")).select(    "DOMAIN",    "STUDYID",    "USUBJID",    "LBSEQ",    "LBTESTCD",    "LBTEST",    "LBORRES",    "LBORRESU",    "LBSTRESN",    "LBSTRESU",    "LBSTAT",    "LBDTC",)Path("/app/output").mkdir(parents=True, exist_ok=True)lb.write_csv("/app/output/lb.csv")

solutions/sdtm-lb-findings/result.sas

Edit
40 lines
/* opensas reference solution for the yamaa benchmark sdtm-lb-findings.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm;  length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024;  infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; run;data dates;  length LBDTC $1024;  retain LBDTC;  set ordered;  by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey;  if first.ItemGroupRepeatKey then do;    LBDTC='';  end;    if ItemOID='IT.LB.LBDTC' then LBDTC=Value;  if last.ItemGroupRepeatKey then output;run;proc sql;create table joined as select a.*,b.LBDTC from odm a inner join dates b on a.StudyOID=b.StudyOID and a.SubjectKey=b.SubjectKey and a.StudyEventOID=b.StudyEventOID and a.StudyEventRepeatKey=b.StudyEventRepeatKey and a.ItemGroupRepeatKey=b.ItemGroupRepeatKey where a.ItemOID in ('IT.LB.CALCIUM','IT.LB.CREAT') and not missing(a.Value); quit;data prepared; set joined; length DOMAIN $2 STUDYID USUBJID LBTESTCD LBTEST LBORRES LBORRESU LBSTRESU LBSTAT $1024;DOMAIN='LB'; STUDYID=StudyOID; USUBJID=SubjectKey; LBORRES=Value; LBORRESU='mg/dL'; LBSTRESU='mg/dL'; LBSTRESN=.; LBSTAT='';if Value ne 'NOT DONE' then LBSTRESN=input(Value,?? best32.);if ItemOID='IT.LB.CREAT' then do; LBTESTCD='CREAT'; LBTEST='Creatinine'; end; else do; LBTESTCD='CA'; LBTEST='Calcium'; end;if Value='NOT DONE' then do; LBORRES=''; LBORRESU=''; LBSTRESU=''; LBSTRESN=.; LBSTAT='NOT DONE'; end; run;proc sort data=prepared; by STUDYID USUBJID LBDTC LBTESTCD; run;data result; set prepared; by STUDYID USUBJID; retain LBSEQ;  if first.USUBJID then LBSEQ=0;  LBSEQ+1;run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC from result;quit;proc export data=final outfile="/app/output/lb.csv" dbms=csv replace; run;