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

Goal: emit related-records rows for whole-dataset relationships alongside record-level rows, carrying IDVAR, IDVARVAL, and RELID.

Input: collected tumor identification (TU) and tumor results (TR) records each carrying a link identifier, plus adverse event (AE) and concomitant medication (CM) records, where an AE and a CM record sharing a link identifier are related. An AE or CM record without a link identifier gets no row.

Variables:

  • USUBJID is empty on a dataset-level row, which relates whole domains rather than subject records; it names the subject on a record-level row.
  • IDVAR names the link variable on a dataset-level row (TULNKID, TRLNKID) and the sequence variable on a record-level row (AESEQ, CMSEQ).
  • IDVARVAL is empty on a dataset-level row and carries the sequence number of the related record as text on a record-level row.
  • RELTYPE carries ONE on the TU row and MANY on the TR row: one tumor identification relates to many tumor results. This is the only use of RELTYPE in SDTM; the record-level AE/CM rows leave it blank.
  • RELID names the relationship the row takes part in; rows sharing a value are related to one another, and every row carries one. The dataset-level rows share 1; each record-level row carries its record's link identifier, so records with different link identifiers land in distinct relationships instead of folding into one.

Note: rows sharing a RELID are related to one another whether they point at whole datasets or single records; a dataset-level row never names a subject or a record value.

Inputs

Under review
4 source files

input/ae.csv

Edit
2 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAETERMAELNKID
YAMAA-011HEADACHEREL-1
YAMAA-012NAUSEAREL-2

input/cm.csv

Edit
2 rows
input/cm.csv
STUDYIDUSUBJIDCMSEQCMTRTCMLNKID
YAMAA-011IBUPROFENREL-1
YAMAA-012ONDANSETRONREL-2

input/tr.csv

Edit
3 rows
input/tr.csv
STUDYIDUSUBJIDTRSEQTRTESTCDTRLNKID
YAMAA-011LDIAMLNK-A
YAMAA-012LDIAMLNK-A
YAMAA-011LDIAMLNK-B

input/tu.csv

Edit
3 rows
input/tu.csv
STUDYIDUSUBJIDTUSEQTUTESTCDTULNKID
YAMAA-011NEWTUMORLNK-A
YAMAA-012NEWTUMORLNK-A
YAMAA-011NEWTUMORLNK-B

Expected output

Under review
6 expected rows

expected/relrec.csv

Edit
6 rows
expected/relrec.csv
STUDYIDUSUBJIDRDOMAINIDVARIDVARVALRELTYPERELID
YAMAA-01—TUTULNKID—ONE1
YAMAA-01—TRTRLNKID—MANY1
YAMAA-01AEAESEQ1—REL-1
YAMAA-01AEAESEQ2—REL-2
YAMAA-01CMCMSEQ1—REL-1
YAMAA-01CMCMSEQ2—REL-2
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
STUDYIDStudy IdentifierCharDerivedSet per constructed row; see the Row construction sheet.SDTM1
USUBJIDUnique Subject IdentifierCharDerivedSet per constructed row; see the Row construction sheet.SDTM2
RDOMAINRelated Domain AbbreviationCharDerivedSet per constructed row; see the Row construction sheet.SDTM3
IDVARIdentifying VariableCharDerivedSet per constructed row; see the Row construction sheet.SDTM4
IDVARVALIdentifying Variable ValueCharDerivedSet per constructed row; see the Row construction sheet.SDTM5
RELTYPERelationship TypeCharDerivedSet per constructed row; see the Row construction sheet.SDTM6
RELIDRelationship IdentifierCharDerivedSet per constructed row; see the Row construction sheet.SDTM7
TemplateInclude whenSTUDYIDUSUBJIDRDOMAINIDVARIDVARVALRELTYPERELID
tu_datasetCopy TU.STUDYIDConstant "None"Constant "TU"Constant "TULNKID"Constant "None"Constant "ONE"Constant "1"
tr_datasetCopy TR.STUDYIDConstant "None"Constant "TR"Constant "TRLNKID"Constant "None"Constant "MANY"Constant "1"
ae_linkAE.AELNKID IS NOT NULLCopy AE.STUDYIDCopy AE.USUBJIDConstant "AE"Constant "AESEQ"Copy AE.AESEQConstant "None"Copy AE.AELNKID
cm_linkCM.CMLNKID IS NOT NULLCopy CM.STUDYIDCopy CM.USUBJIDConstant "CM"Constant "CMSEQ"Copy CM.CMSEQConstant "None"Copy CM.CMLNKID
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-relrec-dataset-level/full.md

Edit
25 lines

Following CDISC SDTM standards, use the provided TU, TR, AE, and CM datasets to create a RELREC dataset with one row per dataset-level relationship and per related record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID

RDOMAIN names the related domain. A dataset-level row relates whole domains rather than subject records: USUBJID has no value, IDVAR names the link variable (TULNKID or TRLNKID), IDVARVAL has no value, and RELTYPE carries ONE on the TU row and MANY on the TR row, since one tumor identification relates to many tumor results. The dataset-level rows share RELID 1.

A record-level row names the subject in USUBJID, the sequence variable in IDVAR (AESEQ or CMSEQ), and the sequence number of the related record as text in IDVARVAL; RELTYPE has no value. RELID is the record's link identifier, so records with different link identifiers land in distinct relationships. An AE or CM record without a link identifier gets no row.

Rows sharing a RELID are related to one another, whether they point at whole datasets or single records.

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

prompts/sdtm-relrec-dataset-level/conventions.md

Edit
15 lines

Following CDISC SDTM standards, use the provided TU, TR, AE, and CM datasets to create a RELREC dataset with one row per dataset-level relationship and per related record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID

On a dataset-level row, IDVAR names the link variable (TULNKID or TRLNKID), and RELTYPE carries ONE on the TU row and MANY on the TR row. The dataset- level rows share RELID 1.

A record-level row has IDVAR AESEQ or CMSEQ, with IDVARVAL written as text.

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

prompts/sdtm-relrec-dataset-level/brief.md

Edit
9 lines

Following CDISC SDTM standards, use the provided TU, TR, AE, and CM datasets to create a RELREC dataset with one row per dataset-level relationship and per related record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)relrec <- yamaa_domain("spec.yaml")$outputrelrec

run.py

Edit
4 lines
import yamaarelrec = yamaa.yamaa_domain("spec.yaml").outputrelrec

Solution without yamaa

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

solutions/sdtm-relrec-dataset-level/result.R

Edit
64 lines
# Reference solution for the yamaa benchmark sdtm-relrec-dataset-level (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)ae <- read_csv(  "/app/input/ae.csv",  col_types = cols(.default = col_character()))cm <- read_csv(  "/app/input/cm.csv",  col_types = cols(.default = col_character()))tr <- read_csv(  "/app/input/tr.csv",  col_types = cols(.default = col_character()))# AE can be empty after subject removal; the dataset relationship remains.studyid <- if (nrow(ae) > 0) ae$STUDYID[[1]] else tr$STUDYID[[1]]# Whole domains rather than subject records: one tumor identification# relates to many tumor results.dataset_rows <- tibble(  STUDYID = studyid,  USUBJID = NA_character_,  RDOMAIN = c("TU", "TR"),  IDVAR = c("TULNKID", "TRLNKID"),  IDVARVAL = NA_character_,  RELTYPE = c("ONE", "MANY"),  RELID = c("1", "1"))ae_rows <- ae |>  filter(!is.na(AELNKID) & trimws(AELNKID) != "") |>  mutate(    RDOMAIN = "AE",    IDVAR = "AESEQ",    IDVARVAL = trimws(AESEQ),    RELTYPE = NA_character_,    RELID = trimws(AELNKID)  ) |>  select(STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID)cm_rows <- cm |>  filter(!is.na(CMLNKID) & trimws(CMLNKID) != "") |>  mutate(    RDOMAIN = "CM",    IDVAR = "CMSEQ",    IDVARVAL = trimws(CMSEQ),    RELTYPE = NA_character_,    RELID = trimws(CMLNKID)  ) |>  select(STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID)relrec <- bind_rows(dataset_rows, ae_rows, cm_rows) |>  select(STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID)dir.create("/app/output", showWarnings = FALSE)write_csv(relrec, "/app/output/relrec.csv", na = "")

solutions/sdtm-relrec-dataset-level/result.py

Edit
89 lines
# Reference solution for the yamaa benchmark sdtm-relrec-dataset-level (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 pldef _present(value) -> bool:    return value is not None and str(value).strip() != ""ae = pl.read_csv("/app/input/ae.csv", infer_schema=False)cm = pl.read_csv("/app/input/cm.csv", infer_schema=False)tr = pl.read_csv("/app/input/tr.csv", infer_schema=False)tu = pl.read_csv("/app/input/tu.csv", infer_schema=False)studyid = str(ae["STUDYID"][0]) if len(ae) else str(tr["STUDYID"][0])rows = [    # Whole domains rather than subject records: one tumor identification    # relates to many tumor results.    {        "STUDYID": studyid,        "USUBJID": None,        "RDOMAIN": "TU",        "IDVAR": "TULNKID",        "IDVARVAL": None,        "RELTYPE": "ONE",        "RELID": "1",    },    {        "STUDYID": studyid,        "USUBJID": None,        "RDOMAIN": "TR",        "IDVAR": "TRLNKID",        "IDVARVAL": None,        "RELTYPE": "MANY",        "RELID": "1",    },]for row in ae.to_dicts():    if not _present(row.get("AELNKID")):        continue    rows.append(        {            "STUDYID": row["STUDYID"],            "USUBJID": row["USUBJID"],            "RDOMAIN": "AE",            "IDVAR": "AESEQ",            "IDVARVAL": str(row["AESEQ"]).strip(),            "RELTYPE": None,            "RELID": str(row["AELNKID"]).strip(),        }    )for row in cm.to_dicts():    if not _present(row.get("CMLNKID")):        continue    rows.append(        {            "STUDYID": row["STUDYID"],            "USUBJID": row["USUBJID"],            "RDOMAIN": "CM",            "IDVAR": "CMSEQ",            "IDVARVAL": str(row["CMSEQ"]).strip(),            "RELTYPE": None,            "RELID": str(row["CMLNKID"]).strip(),        }    )relrec = pl.DataFrame(    rows,    schema={        "STUDYID": pl.String,        "USUBJID": pl.String,        "RDOMAIN": pl.String,        "IDVAR": pl.String,        "IDVARVAL": pl.String,        "RELTYPE": pl.String,        "RELID": pl.String,    },).select("STUDYID", "USUBJID", "RDOMAIN", "IDVAR", "IDVARVAL", "RELTYPE", "RELID")Path("/app/output").mkdir(exist_ok=True)relrec.write_csv("/app/output/relrec.csv")

solutions/sdtm-relrec-dataset-level/result.sas

Edit
41 lines
/* opensas reference solution for the yamaa benchmark sdtm-relrec-dataset-level.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ae;  length STUDYID USUBJID AETERM AELNKID $1024;  infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AELNKID : $char1024.;run;data cm;  length STUDYID USUBJID CMTRT CMLNKID $1024;  infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMLNKID : $char1024.;run;data tr;  length STUDYID USUBJID TRTESTCD TRLNKID $1024;  infile "/app/input/tr.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRSEQ TRTESTCD : $char1024. TRLNKID : $char1024.;run;data tu;  length STUDYID USUBJID TUTESTCD TULNKID $1024;  infile "/app/input/tu.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TUSEQ TUTESTCD : $char1024. TULNKID : $char1024.;run;data aelinks; set ae; length RDOMAIN IDVAR IDVARVAL RELTYPE RELID $1024; RDOMAIN='AE'; IDVAR='AESEQ'; IDVARVAL=strip(put(AESEQ,best32.)); RELTYPE='';if not missing(AELNKID) then do; RELID=AELNKID; output; end;run;data cmlinks; set cm; length RDOMAIN IDVAR IDVARVAL RELTYPE RELID $1024; RDOMAIN='CM'; IDVAR='CMSEQ'; IDVARVAL=strip(put(CMSEQ,best32.)); RELTYPE='';if not missing(CMLNKID) then do; RELID=CMLNKID; output; end;run;proc sql; create table studies as select distinct STUDYID from tu union select distinct STUDYID from tr; quit;data datasets; set studies; length USUBJID RDOMAIN IDVAR IDVARVAL RELTYPE RELID $1024; USUBJID=''; IDVARVAL=''; RELID='1'; RDOMAIN='TU'; IDVAR='TULNKID'; RELTYPE='ONE'; output; RDOMAIN='TR'; IDVAR='TRLNKID'; RELTYPE='MANY'; output; run;data result; set datasets aelinks cmlinks; run;proc sql;  create table final as select STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID from result;quit;proc export data=final outfile="/app/output/relrec.csv" dbms=csv replace; run;