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 SDTM: 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: create one supplemental record per collected qualifier,
carrying IDVARVAL, QLABEL, QVAL, QORIG, and QEVAL.
Input: two tables sharing study and subject identifiers: a parent medical history (MH) table with one record per condition, and a qualifier table with one record per condition carrying the two collected qualifiers.
Variables:
IDVARVALis the parent sequence number as text, matched on subject and condition term.QLABELis the qualifier label:Family HistoryforMHFAMHX,Confirmed by Medical RecordsforMHCONF.QVALis the collected answer,YorN.QORIGis the origin, alwaysCollected(Define-XML 2.1) for collected values.QEVALis blank, since a collected value is not an assessment.
Note: a qualifier that finds no parent record is an error rather than a record with an empty link, so every supplemental record points at a real parent. A parent record with no collected qualifiers simply contributes nothing.
Inputs
Under review2 source filesExpected output
Under review7 expected rowsexpected/suppmh.csv
Edit7 rows| STUDYID | RDOMAIN | USUBJID | IDVAR | IDVARVAL | QNAM | QLABEL | QVAL | QORIG | QEVAL |
|---|---|---|---|---|---|---|---|---|---|
| CATH | MH | MHSEQ | 1 | MHFAMHX | Family History | Y | Collected | — | |
| CATH | MH | MHSEQ | 2 | MHFAMHX | Family History | N | Collected | — | |
| CATH | MH | MHSEQ | 2 | MHFAMHX | Family History | Y | Collected | — | |
| CATH | MH | MHSEQ | 1 | MHFAMHX | Family History | N | Collected | — | |
| CATH | MH | MHSEQ | 1 | MHCONF | Confirmed by Medical Records | Y | Collected | — | |
| CATH | MH | MHSEQ | 2 | MHCONF | Confirmed by Medical Records | N | Collected | — | |
| CATH | MH | MHSEQ | 1 | MHCONF | Confirmed by Medical Records | Y | Collected | — |
Comments and assessment materials
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| STUDYID | Study Identifier | Char | Collected | Copy value from MH_SUPP_RAW.STUDYID. | SUPP | 1 | ||||
| RDOMAIN | Related Domain Abbreviation | Char | Assigned | Set constant value "MH". | SUPP | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from MH_SUPP_RAW.USUBJID. | SUPP | 3 | ||||
| IDVAR | Identifying Variable | Char | Assigned | Set constant value "MHSEQ". | SUPP | 4 | ||||
| IDVARVAL | Identifying Variable Value | Char | Derived | Take MHSEQ from the MH record whose USUBJID equals MH_SUPP_RAW.USUBJID and MHTERM equals MH_SUPP_RAW.MHTERM, and a row with no match is an error. | SUPP | 5 | ||||
| QNAM | Qualifier Variable Name | Char | MHFAMHX, MHCONF | Derived | Set per constructed row; see the Row construction sheet. | SUPP | 6 | |||
| QLABEL | Qualifier Label | Char | Derived | Set per constructed row; see the Row construction sheet. | SUPP | 7 | ||||
| QVAL | Data Value | Char | Y, N | Derived | Set per constructed row; see the Row construction sheet. | SUPP | 8 | |||
| QORIG | Origin | Char | Assigned | Set constant value "Collected". | SUPP | 9 | ||||
| QEVAL | Evaluator | Char | Assigned | Set constant value "None". | SUPP | 10 |
| Template | Include when | QNAM | QLABEL | QVAL |
|---|---|---|---|---|
| family_history | MH_SUPP_RAW.MHFAMHX IS NOT NULL | Constant "MHFAMHX" | Constant "Family History" | Copy MH_SUPP_RAW.MHFAMHX |
| medical_record_confirmation | MH_SUPP_RAW.MHCONF IS NOT NULL | Constant "MHCONF" | Constant "Confirmed by Medical Records" | Copy MH_SUPP_RAW.MHCONF |
| Variable | Permitted values |
|---|---|
| QNAM | MHFAMHX, MHCONF |
| QVAL | Y, N |
| 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/sdtm-suppmh-linkage/full.md
Edit20 linesFollowing CDISC SDTM standards, use the provided MH_SUPP_RAW and MH datasets to create a SUPPMH dataset with one supplemental record per collected qualifier.
The output dataset should contain the following columns in this order: STUDYID, RDOMAIN, USUBJID, IDVAR, IDVARVAL, QNAM, QLABEL, QVAL, QORIG, QEVAL
RDOMAIN is MH and IDVAR is MHSEQ. IDVARVAL is the parent sequence number as text, matched on subject and condition term. QNAM is the qualifier name, MHFAMHX or MHCONF. QLABEL is Family History for MHFAMHX and Confirmed by Medical Records for MHCONF. QVAL is the collected answer, Y or N. QORIG is Collected for collected values. QEVAL has no value, since a collected value is not an assessment.
A qualifier left blank gives no record, and a parent record with no collected qualifiers contributes nothing.
Read the source datasets from /app/input and save the completed dataset as /app/output/suppmh.csv.
prompts/sdtm-suppmh-linkage/conventions.md
Edit15 linesFollowing CDISC SDTM standards, use the provided MH_SUPP_RAW and MH datasets to create a SUPPMH dataset with one supplemental record per collected qualifier.
The output dataset should contain the following columns in this order: STUDYID, RDOMAIN, USUBJID, IDVAR, IDVARVAL, QNAM, QLABEL, QVAL, QORIG, QEVAL
RDOMAIN is MH and IDVAR is MHSEQ. IDVARVAL is the parent sequence number as text. QNAM is the qualifier name, MHFAMHX or MHCONF. QLABEL is Family History for MHFAMHX and Confirmed by Medical Records for MHCONF. QVAL is Y or N. QORIG is Collected for collected values. QEVAL has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/suppmh.csv.
prompts/sdtm-suppmh-linkage/brief.md
Edit10 linesFollowing CDISC SDTM standards, use the provided MH_SUPP_RAW and MH datasets to create a SUPPMH dataset with one supplemental record per collected qualifier.
The output dataset should contain the following columns in this order: STUDYID, RDOMAIN, USUBJID, IDVAR, IDVARVAL, QNAM, QLABEL, QVAL, QORIG, QEVAL
Read the source datasets from /app/input and save the completed dataset as /app/output/suppmh.csv.
run.R
Edit4 lineslibrary(yamaa)suppmh <- yamaa_domain("spec.yaml")$outputsuppmhrun.py
Edit4 linesimport yamaasuppmh = yamaa.yamaa_domain("spec.yaml").outputsuppmhsolutions/sdtm-suppmh-linkage/result.R
Edit48 lines# Reference solution for the yamaa benchmark sdtm-suppmh-linkage (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)mh <- read_csv( "/app/input/mh.csv", col_types = cols(.default = col_character()))raw <- read_csv( "/app/input/mh_supp_raw.csv", col_types = cols(.default = col_character()))# The parent sequence number, matched on subject and condition term.parents <- mh |> select(STUDYID, USUBJID, MHSEQ, MHTERM)suppmh <- raw |> pivot_longer( cols = c(MHFAMHX, MHCONF), names_to = "QNAM", values_to = "QVAL" ) |> filter(!is.na(QVAL) & QVAL != "") |> inner_join(parents, by = c("STUDYID", "USUBJID", "MHTERM")) |> mutate( RDOMAIN = "MH", IDVAR = "MHSEQ", IDVARVAL = MHSEQ, QLABEL = case_when( QNAM == "MHFAMHX" ~ "Family History", QNAM == "MHCONF" ~ "Confirmed by Medical Records" ), QORIG = "Collected", QEVAL = NA_character_ ) |> arrange(USUBJID, suppressWarnings(as.integer(MHSEQ)), QNAM) |> select( STUDYID, RDOMAIN, USUBJID, IDVAR, IDVARVAL, QNAM, QLABEL, QVAL, QORIG, QEVAL )dir.create("/app/output", showWarnings = FALSE)write_csv(suppmh, "/app/output/suppmh.csv", na = "")solutions/sdtm-suppmh-linkage/result.py
Edit61 lines# Reference solution for the yamaa benchmark sdtm-suppmh-linkage (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 plmh = pl.read_csv("/app/input/mh.csv", infer_schema=False)raw = pl.read_csv("/app/input/mh_supp_raw.csv", infer_schema=False)labels = {"MHFAMHX": "Family History", "MHCONF": "Confirmed by Medical Records"}# The parent sequence number, matched on subject and condition term.parents = mh.select("STUDYID", "USUBJID", "MHSEQ", "MHTERM")records = []for qnam in ("MHFAMHX", "MHCONF"): collected = ( raw.filter(pl.col(qnam).is_not_null() & (pl.col(qnam) != "")) .join(parents, on=["STUDYID", "USUBJID", "MHTERM"], how="inner") .select( "STUDYID", "USUBJID", "MHSEQ", QNAM=pl.lit(qnam), QLABEL=pl.lit(labels[qnam]), QVAL=pl.col(qnam), ) ) records.append(collected)suppmh = ( pl.concat(records) .with_columns( RDOMAIN=pl.lit("MH"), IDVAR=pl.lit("MHSEQ"), IDVARVAL=pl.col("MHSEQ"), QORIG=pl.lit("Collected"), QEVAL=pl.lit(None, dtype=pl.String), ) .with_columns(pl.col("MHSEQ").cast(pl.Int64).alias("_seq")) .sort(["USUBJID", "_seq", "QNAM"]) .select( "STUDYID", "RDOMAIN", "USUBJID", "IDVAR", "IDVARVAL", "QNAM", "QLABEL", "QVAL", "QORIG", "QEVAL", ))Path("/app/output").mkdir(exist_ok=True)suppmh.write_csv("/app/output/suppmh.csv")solutions/sdtm-suppmh-linkage/result.sas
Edit24 lines/* opensas reference solution for the yamaa benchmark sdtm-suppmh-linkage. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data mh; length STUDYID USUBJID MHTERM $1024; infile "/app/input/mh.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. MHSEQ MHTERM : $char1024.;run;data mh_supp_raw; length STUDYID USUBJID MHTERM MHFAMHX MHCONF $1024; infile "/app/input/mh_supp_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. MHTERM : $char1024. MHFAMHX : $char1024. MHCONF : $char1024.;run;proc sql; create table qualified as select a.*,b.MHSEQ from mh_supp_raw a inner join mh b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.MHTERM=b.MHTERM; quit;data result; set qualified; length RDOMAIN IDVAR IDVARVAL QNAM QLABEL QVAL QORIG QEVAL $1024; RDOMAIN='MH'; IDVAR='MHSEQ'; IDVARVAL=strip(put(MHSEQ,best32.)); QORIG='Collected'; QEVAL='';if not missing(MHFAMHX) then do; QNAM='MHFAMHX'; QLABEL='Family History'; QVAL=MHFAMHX; output; end;if not missing(MHCONF) then do; QNAM='MHCONF'; QLABEL='Confirmed by Medical Records'; QVAL=MHCONF; output; end; run;proc sql; create table final as select STUDYID, RDOMAIN, USUBJID, IDVAR, IDVARVAL, QNAM, QLABEL, QVAL, QORIG, QEVAL from result;quit;proc export data=final outfile="/app/output/suppmh.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions