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
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
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:
LBSEQnumbers the records within a subject by collection date, then test code.LBTESTCDisCAfor calcium rows andCREATfor creatinine rows.LBTESTisCalciumwhen the test code isCAandCreatininewhen it isCREAT.LBORRESis the collected entry, kept exactly as reported; empty when the test was not done.LBORRESUismg/dLfor every record with a result; empty when the test was not done.LBSTRESNis the numeric form of the collected entry; missing when the entry is text rather than a number, or when the test was not done.LBSTRESUismg/dLfor every record with a result; empty when the test was not done.LBSTATisNOT DONEwhen the collected entry says the test was not done; blank otherwise.LBDTCis 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 review1 source fileinput/odm.csv
Edit17 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-101 | BASELINE | 1 | IG.LB | 1 | IT.LB.LBDTC | 2025-01-01 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | BASELINE | 1 | IG.LB | 1 | IT.LB.CALCIUM | 9.2 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | BASELINE | 1 | IG.LB | 1 | IT.LB.CREAT | 0.8 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | DAY8 | 1 | IG.LB | 1 | IT.LB.LBDTC | 2025-01-08 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | DAY8 | 1 | IG.LB | 1 | IT.LB.CALCIUM | — |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | DAY8 | 1 | IG.LB | 1 | IT.LB.CREAT | 0.9 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | DAY15 | 1 | IG.LB | 1 | IT.LB.LBDTC | 2025-01-15 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | DAY15 | 1 | IG.LB | 1 | IT.LB.CREAT | NOT DONE |
| YAMAA-01 | MDV.1 | YAMAA-01-102 | BASELINE | 1 | IG.LB | 1 | IT.LB.LBDTC | 2025-02-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-102 | BASELINE | 1 | IG.LB | 1 | IT.LB.CALCIUM | 10.1 |
| YAMAA-01 | MDV.1 | YAMAA-01-102 | BASELINE | 1 | IG.LB | 1 | IT.LB.CREAT | 1.1 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | BASELINE | 1 | IG.LB | 1 | IT.LB.LBDTC | 2025-03-10 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | BASELINE | 1 | IG.LB | 1 | IT.LB.CALCIUM | 8.4 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | BASELINE | 1 | IG.LB | 1 | IT.LB.CREAT | 1.3 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | DAY8 | 1 | IG.LB | 1 | IT.LB.LBDTC | 2025-03-17 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | DAY8 | 1 | IG.LB | 1 | IT.LB.CALCIUM | 10.5 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | DAY8 | 1 | IG.LB | 1 | IT.LB.CREAT | — |
Expected output
Under review9 expected rowsexpected/lb.csv
Edit9 rows| DOMAIN | STUDYID | USUBJID | LBSEQ | LBTESTCD | LBTEST | LBORRES | LBORRESU | LBSTRESN | LBSTRESU | LBSTAT | LBDTC |
|---|---|---|---|---|---|---|---|---|---|---|---|
| LB | YAMAA-01 | 1 | CA | Calcium | 9.2 | mg/dL | 9.2 | mg/dL | — | 2025-01-01 | |
| LB | YAMAA-01 | 1 | CA | Calcium | 10.1 | mg/dL | 10.1 | mg/dL | — | 2025-02-03 | |
| LB | YAMAA-01 | 1 | CA | Calcium | 8.4 | mg/dL | 8.4 | mg/dL | — | 2025-03-10 | |
| LB | YAMAA-01 | 3 | CA | Calcium | 10.5 | mg/dL | 10.5 | mg/dL | — | 2025-03-17 | |
| LB | YAMAA-01 | 2 | CREAT | Creatinine | 0.8 | mg/dL | 0.8 | mg/dL | — | 2025-01-01 | |
| LB | YAMAA-01 | 3 | CREAT | Creatinine | 0.9 | mg/dL | 0.9 | mg/dL | — | 2025-01-08 | |
| LB | YAMAA-01 | 4 | CREAT | Creatinine | — | — | — | — | NOT DONE | 2025-01-15 | |
| LB | YAMAA-01 | 2 | CREAT | Creatinine | 1.1 | mg/dL | 1.1 | mg/dL | — | 2025-02-03 | |
| LB | YAMAA-01 | 2 | CREAT | Creatinine | 1.3 | mg/dL | 1.3 | mg/dL | — | 2025-03-10 |
Human review and assessment
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "LB". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| LBORRES | Result or Finding in Original Units | Char | Derived | If RAWORRES = 'NOT DONE' then "None"; otherwise "RAWORRES". | SDTM | 4 | ||||
| LBORRESU | Original Units | Char | Derived | If RAWORRES = 'NOT DONE' then "None"; otherwise "mg/dL". | SDTM | 5 | ||||
| LBSTRESU | Standard Units | Char | Derived | If RAWORRES = 'NOT DONE' then "None"; otherwise "mg/dL". | SDTM | 6 | ||||
| LBSTAT | Completion Status | Char | NOT DONE | Derived | If RAWORRES = 'NOT DONE' then "NOT DONE"; otherwise blank. | SDTM | 7 | |||
| LBTESTCD | Lab Test or Examination Short Name | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 8 | ||||
| LBTEST | Lab Test or Examination Name | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 9 | ||||
| LBSTRESN | Numeric Result/Finding in Standard Units | Num | Derived | Copy value from LBORRES; a value that cannot be converted → blank. | SDTM | 10 | ||||
| LBDTC | Date/Time of Specimen Collection | Char | ISO 8601 | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 11 | |||
| LBSEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by LBDTC then LBTESTCD. | SDTM | 12 |
| Template | Include when | LBTESTCD | LBTEST | RAWORRES | LBDTC |
|---|---|---|---|---|---|
| calcium | RAWORRES IS NOT NULL | Constant "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' |
| creatinine | RAWORRES IS NOT NULL | Constant "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' |
| Variable | Permitted values |
|---|---|
| LBSTAT | NOT DONE |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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/sdtm-lb-findings/full.md
Edit26 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an LB dataset with one record per collected lab result.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC
DOMAIN is "LB". STUDYID is the ODM study OID and USUBJID the ODM subject key, each as given. The records are only the results actually reported: a test with no collected entry gives no record. An entry of "NOT DONE" does give a record. LBTESTCD is "CA" for a calcium record and "CREAT" for a creatinine record. LBTEST is "Calcium" when LBTESTCD is "CA" and "Creatinine" when it is "CREAT". LBORRES is the collected entry, kept exactly as reported, and has no value when the entry is "NOT DONE". LBORRESU is "mg/dL" for every record with a result and has 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. LBSTRESU is "mg/dL" for every record with a result and has no value 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. LBSEQ numbers the records within a subject from 1 by collection date, then by test code.
Read the source datasets from /app/input and save the completed dataset as /app/output/lb.csv.
prompts/sdtm-lb-findings/conventions.md
Edit13 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an LB dataset with one record per collected lab result.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, LBSEQ, LBTESTCD, LBTEST, LBORRES, LBORRESU, LBSTRESN, LBSTRESU, LBSTAT, LBDTC
DOMAIN is "LB". LBTESTCD is "CA" for a calcium record and "CREAT" for a creatinine record. LBTEST is "Calcium" when LBTESTCD 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
Edit9 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an LB dataset with one record per collected lab 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-lb-findings/result.R
Edit55 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
Edit129 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."""Build the SDTM LB dataset from the ODM extract.One record per collected lab result in the IG.LB item groups: a testwith no collected entry gives no record, while an entry of "NOT DONE"gives a record carrying LBSTAT."""import csvimport osINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"TESTS = { "IT.LB.CALCIUM": ("CA", "Calcium"), "IT.LB.CREAT": ("CREAT", "Creatinine"),}DATE_ITEM = "IT.LB.LBDTC"UNIT = "mg/dL"COLUMNS = [ "DOMAIN", "STUDYID", "USUBJID", "LBSEQ", "LBTESTCD", "LBTEST", "LBORRES", "LBORRESU", "LBSTRESN", "LBSTRESU", "LBSTAT", "LBDTC",]def numeric_text(value): """Numeric form of a collected entry, or "" when it is not a number.""" try: number = float(value) except ValueError: return "" if number.is_integer(): return str(int(number)) return str(number)def main(): with open(os.path.join(INPUT_DIR, "odm.csv"), newline="") as handle: rows = list(csv.DictReader(handle)) # Group the LB items by subject and visit group. groups = {} for row in rows: if row["ItemGroupOID"] != "IG.LB": continue key = ( row["StudyOID"], row["SubjectKey"], row["StudyEventOID"], row["StudyEventRepeatKey"], row["ItemGroupOID"], row["ItemGroupRepeatKey"], ) groups.setdefault(key, {})[row["ItemOID"]] = row["Value"] records = [] for (study_id, subject, *_), items in groups.items(): lbdtc = items.get(DATE_ITEM, "") for item_oid, (testcd, test) in TESTS.items(): entry = items.get(item_oid) if entry is None or entry == "": continue # no collected entry: no record record = { "DOMAIN": "LB", "STUDYID": study_id, "USUBJID": subject, "LBTESTCD": testcd, "LBTEST": test, "LBDTC": lbdtc, } if entry == "NOT DONE": record.update( LBORRES="", LBORRESU="", LBSTRESN="", LBSTRESU="", LBSTAT="NOT DONE", ) else: record.update( LBORRES=entry, LBORRESU=UNIT, LBSTRESN=numeric_text(entry), LBSTRESU=UNIT, LBSTAT="", ) records.append(record) # LBSEQ numbers each subject's records from 1 by collection date, # then by test code. by_subject = {} for record in records: by_subject.setdefault(record["USUBJID"], []).append(record) ordered = [] for subject in sorted(by_subject): subject_records = sorted( by_subject[subject], key=lambda r: (r["LBDTC"], r["LBTESTCD"]), ) for index, record in enumerate(subject_records, start=1): record["LBSEQ"] = str(index) ordered.append(record) os.makedirs(OUTPUT_DIR, exist_ok=True) with open(os.path.join(OUTPUT_DIR, "lb.csv"), "w", newline="") as handle: writer = csv.DictWriter(handle, fieldnames=COLUMNS) writer.writeheader() writer.writerows(ordered)if __name__ == "__main__": main()solutions/sdtm-lb-findings/result.sas
Edit40 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;
yamaa