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: add one new record per subject (USUBJID) and analysis visit
(AVISIT) in study CATH-01 for each of three ECG measures: the
Bazett-corrected QT interval (QTCBR), the Fridericia-corrected QT
interval (QTCFR), and the RR duration recomputed from heart rate
(RRR).
Input: collected electrocardiogram records with parameter codes QT
(QT interval duration), RR (RR interval duration), and HR (heart
rate), each carrying its label (PARAM), result (AVAL), and unit
(AVALU). QT and RR results are in milliseconds (ms or msec);
heart rate is in beats per minute (beats/min).
Variables:
PARAMCD:QTCBR,QTCFR, orRRRon the new records;QT,RR, orHRon the collected ones. The input must not already containQTCBR,QTCFR, orRRR.PARAM: "QTcB - Bazett's Correction Formula Rederived (ms)", "QTcF - Fridericia's Correction Formula Rederived (ms)", or "RR Duration Rederived (ms)" on the new records.AVISIT: the analysis visit the record belongs to, for exampleBASELINEorWEEK 4.AVAL:QT / SQRT(RR / 1000)forQTCBR,QT / POWER(RR / 1000, 1 / 3)forQTCFR, and60000divided by the heart rate forRRR; for example, a heart rate of 60 gives 1000.AVALU:mson the new records.
Note: a QTc record is added only when both the QT and the RR
results are present at that visit; an RRR record is added only when
the heart rate is present and not zero. Collected QT and RR records in
a unit other than ms or msec fail the run, and each visit is
expected to carry at most one record per parameter code.
Inputs
Under review1 source fileinput/adeg.csv
Edit29 rows| STUDYID | USUBJID | PARAMCD | PARAM | AVISIT | AVAL | AVALU |
|---|---|---|---|---|---|---|
| CATH-01 | QT | QT Duration | BASELINE | 350 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 1000 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 60 | beats/min | |
| CATH-01 | QT | QT Duration | WEEK 4 | 362 | ms | |
| CATH-01 | RR | RR Duration | WEEK 4 | 950 | ms | |
| CATH-01 | HR | Heart Rate | WEEK 4 | 63 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 400 | msec | |
| CATH-01 | RR | RR Duration | BASELINE | 512 | msec | |
| CATH-01 | HR | Heart Rate | BASELINE | 70 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | — | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 920 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 72 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 388 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | — | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 60 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 410 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 880 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 0 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 375 | ms | |
| CATH-01 | QT | QT Duration | BASELINE | 340 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 1100 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 1 | beats/min | |
| CATH-01 | HR | Heart Rate | BASELINE | 55 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 395 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 980 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | — | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 600 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 1500 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 40 | beats/min |
Expected output
Under review51 expected rowsexpected/adeg.csv
Edit51 rows| STUDYID | USUBJID | PARAMCD | PARAM | AVISIT | AVAL | AVALU |
|---|---|---|---|---|---|---|
| CATH-01 | QT | QT Duration | BASELINE | 350 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 1000 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 60 | beats/min | |
| CATH-01 | QT | QT Duration | WEEK 4 | 362 | ms | |
| CATH-01 | RR | RR Duration | WEEK 4 | 950 | ms | |
| CATH-01 | HR | Heart Rate | WEEK 4 | 63 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 400 | msec | |
| CATH-01 | RR | RR Duration | BASELINE | 512 | msec | |
| CATH-01 | HR | Heart Rate | BASELINE | 70 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | — | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 920 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 72 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 388 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | — | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 60 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 410 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 880 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 0 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 375 | ms | |
| CATH-01 | QT | QT Duration | BASELINE | 340 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 1100 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 1 | beats/min | |
| CATH-01 | HR | Heart Rate | BASELINE | 55 | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 395 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 980 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | — | beats/min | |
| CATH-01 | QT | QT Duration | BASELINE | 600 | ms | |
| CATH-01 | RR | RR Duration | BASELINE | 1500 | ms | |
| CATH-01 | HR | Heart Rate | BASELINE | 40 | beats/min | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | BASELINE | 350 | ms | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | WEEK 4 | 371.4041634548258 | ms | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | BASELINE | 559.0169943749474 | ms | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | BASELINE | 437.0614685290014 | ms | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | BASELINE | 324.17728034350137 | ms | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | BASELINE | 399.01025509812325 | ms | |
| CATH-01 | QTCBR | QTcB - Bazett's Correction Formula Rederived (ms) | BASELINE | 489.89794855663564 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | BASELINE | 350 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | WEEK 4 | 368.2426060851786 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | BASELINE | 500 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | BASELINE | 427.8481245967625 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | BASELINE | 329.3679640914978 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | BASELINE | 397.6689998808046 | ms | |
| CATH-01 | QTCFR | QTcF - Fridericia's Correction Formula Rederived (ms) | BASELINE | 524.1482788417793 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 1000 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | WEEK 4 | 952.3809523809524 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 857.1428571428571 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 833.3333333333334 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 1000 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 60000 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 1090.909090909091 | ms | |
| CATH-01 | RRR | RR Duration Rederived (ms) | BASELINE | 1500 | ms |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADEG | STUDYID | Study Identifier | character | Copy value from ADEG_RAW.STUDYID. | Predecessor | ||
| ADEG | USUBJID | Unique Subject Identifier | character | Copy value from ADEG_RAW.USUBJID. | Predecessor | ||
| ADEG | PARAMCD | Parameter Code | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADEG | PARAM | Parameter | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADEG | AVISIT | Analysis Visit | character | Copy value from ADEG_RAW.AVISIT. | Predecessor | ||
| ADEG | AVAL | Analysis Value | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADEG | AVALU | Analysis Value Unit | character | Set per constructed row; see the Row construction sheet. | Derived |
| Template | Include when | PARAMCD | PARAM | QTVAL | RRVAL | AVAL | AVALU |
|---|---|---|---|---|---|---|---|
| collected | Copy ADEG_RAW.PARAMCD | Copy ADEG_RAW.PARAM | Constant "None" | Constant "None" | Copy ADEG_RAW.AVAL | Copy ADEG_RAW.AVALU | |
| qtc_bazett | QTVAL IS NOT NULL AND RRVAL IS NOT NULL | Constant "QTCBR" | Constant "QTcB - Bazett's Correction Formula Rederived (ms)" | Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'QT' | Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'RR' | Compute QTVAL / SQRT(RRVAL / 1000) | Constant "ms" |
| qtc_fridericia | QTVAL IS NOT NULL AND RRVAL IS NOT NULL | Constant "QTCFR" | Constant "QTcF - Fridericia's Correction Formula Rederived (ms)" | Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'QT' | Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'RR' | Compute QTVAL / POWER(RRVAL / 1000, 1 / 3) | Constant "ms" |
| rr_rederived | ADEG_RAW.PARAMCD = 'HR' AND ADEG_RAW.AVAL IS NOT NULL AND ADEG_RAW.AVAL <> 0 | Constant "RRR" | Constant "RR Duration Rederived (ms)" | Constant "None" | Constant "None" | Compute 60000 / NULLIF(ADEG_RAW.AVAL, 0) | Constant "ms" |
| 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-adeg-derived-intervals/full.md
Edit25 linesFollowing CDISC ADaM standards, use the provided ADEG_RAW dataset to create an ADEG 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, PARAM, AVISIT, AVAL, AVALU
Keep every collected record unchanged: QT, RR, and HR with their labels, results, and units. Add one new record per subject and visit for each measure the visit supports:
- "QTCBR" with PARAM "QTcB - Bazett's Correction Formula Rederived (ms)": the QT result divided by the square root of the RR result expressed in seconds;
- "QTCFR" with PARAM "QTcF - Fridericia's Correction Formula Rederived (ms)": the QT result divided by the cube root of the RR result expressed in seconds;
- "RRR" with PARAM "RR Duration Rederived (ms)": the RR duration in milliseconds matching the collected heart rate. A QTc record is added only when both the QT and the RR results are present at that visit. An RRR record is added only when the heart rate is present and not zero. New records use AVALU "ms", and their AVAL is not rounded. The input holds no QTCBR, QTCFR, or RRR records.
Read the source datasets from /app/input and save the completed dataset as /app/output/adeg.csv.
prompts/adam-adeg-derived-intervals/conventions.md
Edit16 linesFollowing CDISC ADaM standards, use the provided ADEG_RAW dataset to create an ADEG 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, PARAM, AVISIT, AVAL, AVALU
New records use these parameters:
- "QTCBR" with PARAM "QTcB - Bazett's Correction Formula Rederived (ms)";
- "QTCFR" with PARAM "QTcF - Fridericia's Correction Formula Rederived (ms)";
- "RRR" with PARAM "RR Duration Rederived (ms)". The AVAL of a new record is not rounded.
Read the source datasets from /app/input and save the completed dataset as /app/output/adeg.csv.
prompts/adam-adeg-derived-intervals/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided ADEG_RAW dataset to create an ADEG 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, PARAM, AVISIT, AVAL, AVALU
Read the source datasets from /app/input and save the completed dataset as /app/output/adeg.csv.
run.R
Edit4 lineslibrary(yamaa)adeg <- yamaa_domain("spec.yaml")$outputadegrun.py
Edit4 linesimport yamaaadeg = yamaa.yamaa_domain("spec.yaml").outputadegsolutions/adam-adeg-derived-intervals/result.R
Edit67 lines# Reference solution for the yamaa benchmark adam-adeg-derived-intervals (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)adeg <- read_csv( "/app/input/adeg.csv", col_types = cols(AVAL = col_double(), .default = col_character()))wide <- adeg |> select(STUDYID, USUBJID, AVISIT, PARAMCD, AVAL) |> pivot_wider(names_from = PARAMCD, values_from = AVAL)# A QTc record needs both QT and RR; RR in seconds is RR in ms over 1000.qtc <- wide |> filter(!is.na(QT), !is.na(RR)) |> mutate( RRSEC = RR / 1000, QTCBR = QT / sqrt(RRSEC), QTCFR = QT / (RRSEC^(1 / 3)) )qtcbr <- qtc |> transmute( STUDYID, USUBJID, AVISIT, PARAMCD = "QTCBR", PARAM = "QTcB - Bazett's Correction Formula Rederived (ms)", AVAL = QTCBR, AVALU = "ms" )qtcfr <- qtc |> transmute( STUDYID, USUBJID, AVISIT, PARAMCD = "QTCFR", PARAM = "QTcF - Fridericia's Correction Formula Rederived (ms)", AVAL = QTCFR, AVALU = "ms" )# An RRR record needs a present, nonzero heart rate.rrr <- wide |> filter(!is.na(HR), HR != 0) |> transmute( STUDYID, USUBJID, AVISIT, PARAMCD = "RRR", PARAM = "RR Duration Rederived (ms)", AVAL = 60000 / HR, AVALU = "ms" )adeg_out <- bind_rows( adeg |> select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU), qtcbr, qtcfr, rrr) |> select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU)dir.create("/app/output", showWarnings = FALSE)write_csv(adeg_out, "/app/output/adeg.csv", na = "")solutions/adam-adeg-derived-intervals/result.py
Edit102 lines# Reference solution for the yamaa benchmark adam-adeg-derived-intervals (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.import mathfrom pathlib import Pathimport polars as pldef format_number(value: float | None) -> str | None: if value is None or not math.isfinite(value): return None if float(value).is_integer(): return str(int(value)) return repr(float(value))base = pl.read_csv("/app/input/adeg.csv", infer_schema=False)numeric = base.with_columns(AVALNUM=pl.col("AVAL").cast(pl.Float64, strict=False))wide = numeric.group_by(["STUDYID", "USUBJID", "AVISIT"]).agg( QT=pl.col("AVALNUM").filter(pl.col("PARAMCD") == "QT").first(), RR=pl.col("AVALNUM").filter(pl.col("PARAMCD") == "RR").first(), HR=pl.col("AVALNUM").filter(pl.col("PARAMCD") == "HR").first(),)collected = base.select( "STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "AVALU")new_rows: list[dict] = []for record in wide.to_dicts(): studyid, usubjid, avisit = record["STUDYID"], record["USUBJID"], record["AVISIT"] qt, rr, hr = record["QT"], record["RR"], record["HR"] # A QTc record needs both QT and RR; RR in seconds is RR in ms over 1000. if qt is not None and rr is not None: rr_sec = rr / 1000 new_rows.append( { "STUDYID": studyid, "USUBJID": usubjid, "PARAMCD": "QTCBR", "PARAM": "QTcB - Bazett's Correction Formula Rederived (ms)", "AVISIT": avisit, "AVAL": format_number(qt / math.sqrt(rr_sec)), "AVALU": "ms", } ) if qt is not None and rr is not None: rr_sec = rr / 1000 new_rows.append( { "STUDYID": studyid, "USUBJID": usubjid, "PARAMCD": "QTCFR", "PARAM": "QTcF - Fridericia's Correction Formula Rederived (ms)", "AVISIT": avisit, "AVAL": format_number(qt / (rr_sec ** (1 / 3))), "AVALU": "ms", } ) # An RRR record needs a present, nonzero heart rate. if hr is not None and hr != 0: new_rows.append( { "STUDYID": studyid, "USUBJID": usubjid, "PARAMCD": "RRR", "PARAM": "RR Duration Rederived (ms)", "AVISIT": avisit, "AVAL": format_number(60000 / hr), "AVALU": "ms", } )# Collected rows first, then QTCBR, QTCFR, and RRR per visit.order = {"QTCBR": 0, "QTCFR": 1, "RRR": 2}new_rows.sort( key=lambda r: (order[r["PARAMCD"]], r["USUBJID"], r["AVISIT"]))derived = pl.DataFrame( new_rows, schema={ "STUDYID": pl.String, "USUBJID": pl.String, "PARAMCD": pl.String, "PARAM": pl.String, "AVISIT": pl.String, "AVAL": pl.String, "AVALU": pl.String, },)adeg = pl.concat([collected, derived], how="diagonal").select( "STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "AVALU")Path("/app/output").mkdir(exist_ok=True)adeg.write_csv("/app/output/adeg.csv")solutions/adam-adeg-derived-intervals/result.sas
Edit32 lines/* opensas reference solution for the yamaa benchmark adam-adeg-derived-intervals. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adeg; length STUDYID USUBJID PARAMCD PARAM AVISIT AVALU $1024; infile "/app/input/adeg.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. PARAMCD : $char1024. PARAM : $char1024. AVISIT : $char1024. AVAL AVALU : $char1024.;run;proc sql; create table qt as select a.*,b.AVAL as RRVAL from adeg as a inner join adeg as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AVISIT=b.AVISIT where a.PARAMCD='QT' and b.PARAMCD='RR' and not missing(a.AVAL) and not missing(b.AVAL);quit;data corrected; length PARAMCD PARAM AVALU $1024; set qt; QTVAL=AVAL; AVALU='ms'; PARAMCD='QTCBR'; PARAM="QTcB - Bazett's Correction Formula Rederived (ms)"; AVAL=QTVAL/sqrt(RRVAL/1000); output; PARAMCD='QTCFR'; PARAM="QTcF - Fridericia's Correction Formula Rederived (ms)"; AVAL=QTVAL/(RRVAL/1000)**(1/3); output;run;data heart; length PARAMCD PARAM $1024; set adeg; if PARAMCD='HR' and not missing(AVAL) and AVAL ne 0; AVAL=60000/AVAL; PARAMCD='RRR'; PARAM='RR Duration Rederived (ms)'; AVALU='ms';run;data result; set adeg corrected heart; run;proc sql; create table final as select STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU from result;quit;proc export data=final outfile="/app/output/adeg.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions