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: build one Procedures (PR) record from each of two prior-procedure forms carried in a single ODM item extract: a prior cancer surgery form and a prior radiotherapy form. PRTRT keeps the reported procedure name, PRCAT names the form, PRLOC/PRLAT carry the surgery site, and the radiotherapy record carries its dose in PRDOSE/PRDOSU. PRSTDTC/PRENDTC keep the precision collected, so a year-month surgery date stays 2023-11. The pre-specified question "Any prior radiotherapy?" always writes a record: PRPRESP is Y, and PROCCUR is Y or N.

Input: one ODM file (input/odm.csv) with one row per collected item value, keyed by study, subject, study event, form and item. Subject 001 reports a lumpectomy with only a year-month date and a radiotherapy course of 50 Gy from 2024-02-10 to 2024-03-20. Subject 002 answers "No" to prior radiotherapy, so only the question and its answer are collected for that subject.

Variables:

  • PRSEQ numbers each subject's records by PRSTDTC and then by PRTRT; with STUDYID and USUBJID it identifies the record.
  • PRCAT names the form: PRIOR CANCER SURGERY or PRIOR RADIOTHERAPY.
  • PRPRESP is Y for the pre-specified radiotherapy question and blank for the reported surgery.
  • PROCCUR is Y or N for the pre-specified question and blank for the reported surgery.
  • PRLOC and PRLAT carry the surgery site; they are blank for radiotherapy.
  • PRDOSE and PRDOSU carry the radiotherapy dose; they are blank when the procedure did not occur and for surgery.
  • PRSTDTC and PRENDTC keep the collected precision: the lumpectomy date stays 2023-11, while the radiotherapy course carries full start and end dates.

Note: a "No" answer is still a record. It lets the study tell "no prior radiotherapy" apart from "never asked", and it carries no dose and no dates.

Provenance: PRPRESP/PROCCUR follow the SDTMIG pre-specified pattern (an asked question with an occurrence flag). All subjects, procedures and dates are invented fixtures.

Inputs

Under review
1 source file

input/odm.csv

Edit
12 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1001SCREENING1IG.PR.SURGERY1IT.PR.PRTRTLUMPECTOMY
YAMAA-01MDV.1001SCREENING1IG.PR.SURGERY1IT.PR.PRLOCBREAST
YAMAA-01MDV.1001SCREENING1IG.PR.SURGERY1IT.PR.PRLATLEFT
YAMAA-01MDV.1001SCREENING1IG.PR.SURGERY1IT.PR.PRSTDTC2023-11
YAMAA-01MDV.1001SCREENING1IG.PR.RADIOTHERAPY1IT.PR.RTPRSPY
YAMAA-01MDV.1001SCREENING1IG.PR.RADIOTHERAPY1IT.PR.PRTRTRADIOTHERAPY
YAMAA-01MDV.1001SCREENING1IG.PR.RADIOTHERAPY1IT.PR.PRDOSE50
YAMAA-01MDV.1001SCREENING1IG.PR.RADIOTHERAPY1IT.PR.PRDOSUGy
YAMAA-01MDV.1001SCREENING1IG.PR.RADIOTHERAPY1IT.PR.PRSTDTC2024-02-10
YAMAA-01MDV.1001SCREENING1IG.PR.RADIOTHERAPY1IT.PR.PRENDTC2024-03-20
YAMAA-01MDV.1002SCREENING1IG.PR.RADIOTHERAPY1IT.PR.RTPRSPN
YAMAA-01MDV.1002SCREENING1IG.PR.RADIOTHERAPY1IT.PR.PRTRTRADIOTHERAPY

Expected output

Under review
3 expected rows

expected/pr.csv

Edit
3 rows
expected/pr.csv
DOMAINSTUDYIDUSUBJIDPRSEQPRTRTPRCATPRPRESPPROCCURPRLOCPRLATPRDOSEPRDOSUPRSTDTCPRENDTC
PRYAMAA-011LUMPECTOMYPRIOR CANCER SURGERY——BREASTLEFT——2023-11—
PRYAMAA-012RADIOTHERAPYPRIOR RADIOTHERAPYYY——50Gy2024-02-102024-03-20
PRYAMAA-011RADIOTHERAPYPRIOR RADIOTHERAPYYN——————
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 AbbreviationCharPRAssignedSet constant value "PR".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharDerivedFill the template "{STUDYID}-{SUBJKEY}".SDTM3
PRTRTReported Name of the ProcedureCharDerivedSet per constructed row; see the Row construction sheet.SDTM4
PRCATCategory for ProceduresCharDerivedSet per constructed row; see the Row construction sheet.SDTM5
PRPRESPPre-Specified Procedure IndicatorCharYDerivedSet per constructed row; see the Row construction sheet.SDTM6
PROCCURProcedure OccurrenceCharY, NDerivedSet per constructed row; see the Row construction sheet.SDTM7
PRLOCLocation of ProcedureCharDerivedSet per constructed row; see the Row construction sheet.SDTM8
PRLATLateralityCharLEFT, RIGHT, BILATERAL, UNILATERALDerivedSet per constructed row; see the Row construction sheet.SDTM9
PRDOSEDose per AdministrationNumDerivedSet per constructed row; see the Row construction sheet.SDTM10
PRDOSUDose UnitsCharDerivedSet per constructed row; see the Row construction sheet.SDTM11
PRSTDTCStart Date/Time of ProcedureCharDerivedSet per constructed row; see the Row construction sheet.SDTM12
PRENDTCEnd Date/Time of ProcedureCharDerivedSet per constructed row; see the Row construction sheet.SDTM13
PRSEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by PRSTDTC then PRTRT.SDTM14
TemplateInclude whenFORMPRTRTPRCATANSWERPRPRESPPROCCURPRLOCPRLATPRDOSEPRDOSUPRSTDTCPRENDTC
surgeryFORM = 'IG.PR.SURGERY'Copy ODM.ItemGroupOIDAggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRTRT'Constant "PRIOR CANCER SURGERY"Constant "None"Constant "None"Constant "None"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRLOC'Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRLAT'Constant "None"Constant "None"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRSTDTC'Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRENDTC'
radiotherapyFORM = 'IG.PR.RADIOTHERAPY'Copy ODM.ItemGroupOIDAggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRTRT'Constant "PRIOR RADIOTHERAPY"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.RTPRSP'Constant "Y"If ANSWER = 'Y' then "Y"; If ANSWER = 'N' then "N"; otherwise "None"Constant "None"Constant "None"If PROCCUR = 'Y' then aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRDOSE'; otherwise "None"If PROCCUR = 'Y' then aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRDOSU'; otherwise "None"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRSTDTC'Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRENDTC'
VariablePermitted values
DOMAINPR
PRPRESPY
PROCCURY, N
PRLATLEFT, RIGHT, BILATERAL, UNILATERAL
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-pr-procedures/full.md

Edit
28 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per reported procedure and per answer to the pre-specified radiotherapy question.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC

STUDYID is the ODM StudyOID. USUBJID is the study and subject identifiers with a hyphen between them.

PRSEQ numbers each subject's records by PRSTDTC and then by PRTRT. PRTRT is the reported procedure name. PRCAT names the form: PRIOR CANCER SURGERY or PRIOR RADIOTHERAPY. PRPRESP is Y for the pre-specified radiotherapy question and has no value for the reported surgery. PROCCUR is Y or N for the pre-specified question and has no value for the reported surgery. PRLOC and PRLAT carry the surgery site, and have no value for radiotherapy. PRDOSE and PRDOSU carry the radiotherapy dose, and have no value when the procedure did not occur and for surgery. PRSTDTC and PRENDTC keep the collected precision: a year-month surgery date stays year-month, while the radiotherapy course carries full start and end dates.

A "No" answer is still a record, with no dose and no dates: it tells "no prior radiotherapy" apart from "never asked".

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

prompts/sdtm-pr-procedures/conventions.md

Edit
13 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per reported procedure and per answer to the pre-specified radiotherapy question.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC

PRCAT names the form: PRIOR CANCER SURGERY or PRIOR RADIOTHERAPY. PRPRESP is Y or has no value. PROCCUR is Y or N, or has no value.

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

prompts/sdtm-pr-procedures/brief.md

Edit
10 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per reported procedure and per answer to the pre-specified radiotherapy question.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)pr <- yamaa_domain("spec.yaml")$outputpr

run.py

Edit
4 lines
import yamaapr = yamaa.yamaa_domain("spec.yaml").outputpr

Solution without yamaa

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

solutions/sdtm-pr-procedures/result.R

Edit
74 lines
# Reference solution for the yamaa benchmark sdtm-pr-procedures (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()))wide <- odm |>  mutate(Value = na_if(Value, "")) |>  pivot_wider(    id_cols = c(StudyOID, SubjectKey, StudyEventOID, ItemGroupOID, ItemGroupRepeatKey),    names_from = ItemOID,    values_from = Value,    values_fn = function(x) x[[1]]  )pr <- wide |>  mutate(    STUDYID = StudyOID,    # USUBJID carries the study prefix when the ODM subject key does not.    USUBJID = if_else(      startsWith(SubjectKey, paste0(StudyOID, "-")),      SubjectKey, paste0(StudyOID, "-", SubjectKey)    ),    DOMAIN = "PR",    PRTRT = IT.PR.PRTRT,    PRCAT = case_when(      ItemGroupOID == "IG.PR.SURGERY" ~ "PRIOR CANCER SURGERY",      ItemGroupOID == "IG.PR.RADIOTHERAPY" ~ "PRIOR RADIOTHERAPY"    ),    PRPRESP = if_else(ItemGroupOID == "IG.PR.RADIOTHERAPY", "Y", NA_character_),    PROCCUR = if_else(      ItemGroupOID == "IG.PR.RADIOTHERAPY", IT.PR.RTPRSP, NA_character_    ),    PRLOC = if_else(ItemGroupOID == "IG.PR.SURGERY", IT.PR.PRLOC, NA_character_),    PRLAT = if_else(ItemGroupOID == "IG.PR.SURGERY", IT.PR.PRLAT, NA_character_),    PRDOSE = if_else(      ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y",      IT.PR.PRDOSE, NA_character_    ),    PRDOSU = if_else(      ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y",      IT.PR.PRDOSU, NA_character_    ),    PRSTDTC = case_when(      ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y" ~ IT.PR.PRSTDTC,      ItemGroupOID == "IG.PR.SURGERY" ~ IT.PR.PRSTDTC,      TRUE ~ NA_character_    ),    PRENDTC = if_else(      ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y",      IT.PR.PRENDTC, NA_character_    )  ) |>  arrange(USUBJID, is.na(PRSTDTC), PRSTDTC, PRTRT) |>  group_by(USUBJID) |>  mutate(PRSEQ = row_number()) |>  ungroup() |>  arrange(USUBJID, PRSEQ) |>  select(    DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR,    PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC  )dir.create("/app/output", showWarnings = FALSE)write_csv(pr, "/app/output/pr.csv", na = "")

solutions/sdtm-pr-procedures/result.py

Edit
121 lines
# Reference solution for the yamaa benchmark sdtm-pr-procedures (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) != ""odm = pl.read_csv("/app/input/odm.csv", infer_schema=False)# One record per reported procedure and per answer to the pre-specified# radiotherapy question: each form occurrence is a record.groups: dict[tuple, dict] = {}for row in odm.to_dicts():    key = (        str(row["StudyOID"]),        str(row["SubjectKey"]),        str(row["StudyEventOID"]),        str(row["ItemGroupOID"]),        str(row["ItemGroupRepeatKey"]),    )    groups.setdefault(key, {})[str(row["ItemOID"])] = row["Value"]cat_by_group = {    "IG.PR.SURGERY": "PRIOR CANCER SURGERY",    "IG.PR.RADIOTHERAPY": "PRIOR RADIOTHERAPY",}rows = []for (studyid, subjkey, _event, group_oid, _rep), values in groups.items():    # USUBJID carries the study prefix when the ODM subject key does not.    usubjid = subjkey if subjkey.startswith(studyid + "-") else f"{studyid}-{subjkey}"    is_radio = group_oid == "IG.PR.RADIOTHERAPY"    occurs = str(values.get("IT.PR.RTPRSP") or "") if is_radio else ""    prtrt = str(values.get("IT.PR.PRTRT") or "")    if is_radio:        prpresp, procur = "Y", occurs if _present(occurs) else None    else:        prpresp, procur = None, None    # Dose only when the procedure occurred; a "No" keeps no dose or dates.    if is_radio and procur == "Y":        dose = str(values.get("IT.PR.PRDOSE") or "")        dose = dose if _present(dose) else None        dosu = str(values.get("IT.PR.PRDOSU") or "")        dosu = dosu if _present(dosu) else None        stdtc = str(values.get("IT.PR.PRSTDTC") or "")        stdtc = stdtc if _present(stdtc) else None        endtc = str(values.get("IT.PR.PRENDTC") or "")        endtc = endtc if _present(endtc) else None    elif not is_radio:        dose = dosu = None        stdtc = str(values.get("IT.PR.PRSTDTC") or "")        stdtc = stdtc if _present(stdtc) else None        endtc = None        # Surgery has no end date in the form.        if "IT.PR.PRENDTC" in values and _present(values.get("IT.PR.PRENDTC")):            endtc = str(values.get("IT.PR.PRENDTC"))    else:        dose = dosu = stdtc = endtc = None    rows.append(        {            "DOMAIN": "PR",            "STUDYID": studyid,            "USUBJID": usubjid,            "PRTRT": prtrt,            "PRCAT": cat_by_group[group_oid],            "PRPRESP": prpresp,            "PROCCUR": procur,            "PRLOC": str(values.get("IT.PR.PRLOC") or "") or None,            "PRLAT": str(values.get("IT.PR.PRLAT") or "") or None,            "PRDOSE": dose,            "PRDOSU": dosu,            "PRSTDTC": stdtc,            "PRENDTC": endtc,        }    )# PRSEQ numbers each subject's records by start date, then procedure name.rows.sort(key=lambda r: (r["USUBJID"], r["PRSTDTC"] is None, r["PRSTDTC"] or "", r["PRTRT"]))seq_by_subject: dict[str, int] = {}for row in rows:    seq_by_subject[row["USUBJID"]] = seq_by_subject.get(row["USUBJID"], 0) + 1    row["PRSEQ"] = str(seq_by_subject[row["USUBJID"]])pr = (    pl.DataFrame(        rows,        schema={            "DOMAIN": pl.String,            "STUDYID": pl.String,            "USUBJID": pl.String,            "PRSEQ": pl.String,            "PRTRT": pl.String,            "PRCAT": pl.String,            "PRPRESP": pl.String,            "PROCCUR": pl.String,            "PRLOC": pl.String,            "PRLAT": pl.String,            "PRDOSE": pl.String,            "PRDOSU": pl.String,            "PRSTDTC": pl.String,            "PRENDTC": pl.String,        },    )    .with_columns(pl.col("PRSEQ").cast(pl.Int64).alias("_seq"))    .sort(["USUBJID", "_seq"])    .select(        "DOMAIN", "STUDYID", "USUBJID", "PRSEQ", "PRTRT", "PRCAT", "PRPRESP",        "PROCCUR", "PRLOC", "PRLAT", "PRDOSE", "PRDOSU", "PRSTDTC", "PRENDTC",    ))Path("/app/output").mkdir(exist_ok=True)pr.write_csv("/app/output/pr.csv")

solutions/sdtm-pr-procedures/result.sas

Edit
44 lines
/* opensas reference solution for the yamaa benchmark sdtm-pr-procedures.   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 ItemGroupOID ItemGroupRepeatKey; run;data wide;  length PRTRT PRLOC PRLAT PRDOSU PRSTDTC PRENDTC RTPRSP DOSETEXT $1024;  retain PRTRT PRLOC PRLAT PRDOSU PRSTDTC PRENDTC RTPRSP DOSETEXT;  set ordered;  by StudyOID SubjectKey ItemGroupOID ItemGroupRepeatKey;  if first.ItemGroupRepeatKey then do;    PRTRT=''; PRLOC=''; PRLAT=''; PRDOSU=''; PRSTDTC=''; PRENDTC=''; RTPRSP=''; DOSETEXT='';  end;    if ItemOID='IT.PR.PRTRT' then PRTRT=Value;  if ItemOID='IT.PR.PRLOC' then PRLOC=Value;  if ItemOID='IT.PR.PRLAT' then PRLAT=Value;  if ItemOID='IT.PR.PRDOSU' then PRDOSU=Value;  if ItemOID='IT.PR.PRSTDTC' then PRSTDTC=Value;  if ItemOID='IT.PR.PRENDTC' then PRENDTC=Value;  if ItemOID='IT.PR.RTPRSP' then RTPRSP=Value;  if ItemOID='IT.PR.PRDOSE' then DOSETEXT=Value;  if last.ItemGroupRepeatKey then output;run;data prepared; set wide; length DOMAIN $2 STUDYID USUBJID PRCAT PRPRESP PROCCUR $1024;DOMAIN='PR'; STUDYID=StudyOID; USUBJID=catx('-',StudyOID,SubjectKey); PRPRESP=''; PROCCUR=''; PRDOSE=.;if ItemGroupOID='IG.PR.SURGERY' then do; PRCAT='PRIOR CANCER SURGERY'; PRENDTC=''; end;else if ItemGroupOID='IG.PR.RADIOTHERAPY' then do; PRCAT='PRIOR RADIOTHERAPY'; PRPRESP='Y'; PROCCUR=RTPRSP; PRLOC=''; PRLAT=''; if RTPRSP='Y' then PRDOSE=input(DOSETEXT,best32.); else do; PRDOSU=''; PRSTDTC=''; PRENDTC=''; end; end; else delete; run;proc sort data=prepared; by STUDYID USUBJID PRSTDTC PRTRT; run;data result; set prepared; by STUDYID USUBJID; retain PRSEQ;  if first.USUBJID then PRSEQ=0;  PRSEQ+1;run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC from result;quit;proc export data=final outfile="/app/output/pr.csv" dbms=csv replace; run;