Review ask

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

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

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

Human review and assessment

Your review

3 questions and your comments · View benchmark 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.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
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
32 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per prior-procedure form.

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

DOMAIN is "PR". STUDYID is the ODM study OID as given, and USUBJID is the study OID and the subject key joined with a hyphen. One record is written for each prior-procedure form collected for a subject: the prior cancer surgery form and the prior radiotherapy form. PRTRT is the procedure name as reported on the form. PRCAT is "PRIOR CANCER SURGERY" on the surgery record and "PRIOR RADIOTHERAPY" on the radiotherapy record. The radiotherapy form asks the pre-specified question "Any prior radiotherapy?"; PRPRESP is "Y" on the radiotherapy record and has no value on the surgery record. PROCCUR is the answer to that question, "Y" or "N", on the radiotherapy record and has no value on the surgery record. The radiotherapy record is written even when the answer is "N": a "No" answer is still a record, and it carries no dose and no dates. PRLOC is the location of the procedure and PRLAT its laterality, as collected on the surgery form; both have no value on the radiotherapy record. PRDOSE is the dose per administration of the radiotherapy and PRDOSU its unit, as collected when the radiotherapy occurred; both have no value when the procedure did not occur and on the surgery record. PRSTDTC is the start date of the procedure and PRENDTC its end date, each keeping the precision collected, so a date collected as a year and month stays a year and month. PRSEQ numbers each subject's records from 1 by start date, then by procedure name.

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

prompts/sdtm-pr-procedures/conventions.md

Edit
14 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per prior-procedure form.

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

DOMAIN is "PR". PRCAT is "PRIOR CANCER SURGERY" or "PRIOR RADIOTHERAPY". PRPRESP is "Y" or has no value. PROCCUR is "Y" or "N", or has no value. PRSTDTC and PRENDTC each keep the precision collected, so a date collected as a year and month stays a year and month.

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

prompts/sdtm-pr-procedures/brief.md

Edit
9 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per prior-procedure form.

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

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

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
105 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."""Build the SDTM PR dataset from the ODM extract.One record per prior-procedure form (prior cancer surgery form andprior radiotherapy form) collected for a subject."""import csvimport osfrom collections import OrderedDictINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = [    "DOMAIN", "STUDYID", "USUBJID", "PRSEQ", "PRTRT", "PRCAT",    "PRPRESP", "PROCCUR", "PRLOC", "PRLAT", "PRDOSE", "PRDOSU",    "PRSTDTC", "PRENDTC",]def item_name(item_oid):    """Last component of an item OID, e.g. IT.PR.PRTRT -> PRTRT."""    return item_oid.rsplit(".", 1)[-1]def main():    with open(os.path.join(INPUT_DIR, "odm.csv"), newline="") as f:        rows = list(csv.DictReader(f))    # Group item values by subject and form instance.    forms = OrderedDict()    for row in rows:        key = (            row["StudyOID"],            row["SubjectKey"],            row["ItemGroupOID"],            row["ItemGroupRepeatKey"],        )        form = forms.setdefault(            key,            {                "study": row["StudyOID"],                "subject": row["SubjectKey"],                "group": row["ItemGroupOID"],                "items": {},            },        )        form["items"][item_name(row["ItemOID"])] = row["Value"]    records = []    for form in forms.values():        items = form["items"]        if "PRTRT" not in items and "RTPRSP" not in items:            continue        rec = {c: "" for c in COLUMNS}        rec["DOMAIN"] = "PR"        rec["STUDYID"] = form["study"]        rec["USUBJID"] = form["study"] + "-" + form["subject"]        rec["PRTRT"] = items.get("PRTRT", "")        if "RTPRSP" in items or "RADIOTHERAPY" in form["group"]:            # Prior radiotherapy form: pre-specified question asked.            rec["PRCAT"] = "PRIOR RADIOTHERAPY"            rec["PRPRESP"] = "Y"            rec["PROCCUR"] = items.get("RTPRSP", "")            rec["PRDOSE"] = items.get("PRDOSE", "")            rec["PRDOSU"] = items.get("PRDOSU", "")        else:            # Prior cancer surgery form.            rec["PRCAT"] = "PRIOR CANCER SURGERY"            rec["PRLOC"] = items.get("PRLOC", "")            rec["PRLAT"] = items.get("PRLAT", "")        # Dates keep the precision collected.        rec["PRSTDTC"] = items.get("PRSTDTC", "")        rec["PRENDTC"] = items.get("PRENDTC", "")        records.append(rec)    # PRSEQ numbers each subject's records from 1 by start date,    # then by procedure name.    by_subject = OrderedDict()    for rec in records:        by_subject.setdefault(rec["USUBJID"], []).append(rec)    ordered = []    for group in by_subject.values():        group.sort(            key=lambda r: (r["PRSTDTC"] == "", r["PRSTDTC"], r["PRTRT"])        )        for i, rec in enumerate(group, start=1):            rec["PRSEQ"] = str(i)        ordered.extend(group)    os.makedirs(OUTPUT_DIR, exist_ok=True)    with open(os.path.join(OUTPUT_DIR, "pr.csv"), "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=COLUMNS)        writer.writeheader()        writer.writerows(ordered)if __name__ == "__main__":    main()

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;