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 the medical history (MH) records from the history form, keeping each condition's start at the precision it was recorded and showing whether it ended before, or was still going at, the screening visit.

Input: one record per condition reported on the form, each numbered by its record sequence (MHSEQ), with the collected start year and month, the collected end date, the ongoing tick box, and the screening visit date recorded on the same form.

Variables:

  • MHTERM is the condition as written on the form.
  • MHSTDTC is the start of the condition at the precision recorded: the year alone (for example 2015) when only the year was known, or year and month (for example 2019-03); empty when no year was recorded.
  • MHENDTC is the date the condition ended, when an end was recorded.
  • MHENRTPT says how the condition's end relates to the screening visit: ONGOING when the tick box said it was still active, BEFORE when the recorded end date comes before the screening visit date recorded on the form; empty otherwise (for example when the recorded end date is on or after the screening visit date).
  • MHENTPT names the visit the end reference is measured against, SCREENING; empty when there is no end reference.

Note: a condition still active at the screening visit carries no end date: the ongoing answer is the record of its end status, and the screening visit is named as the reference for both ONGOING and BEFORE.

Inputs

Under review
1 source file

input/mh_form.csv

Edit
7 rows
input/mh_form.csv
STUDYIDUSUBJIDMHSEQMHTERMMHSTYYMHSTMMMHENDTCMHONGOSCRFDTC
YAMAA-011HYPERTENSION2015——Y2021-06-01
YAMAA-012HYPERLIPIDEMIA2019032020-11-30N2021-06-01
YAMAA-011ASTHMA201706—N2022-05-10
YAMAA-012ECZEMA2020—2022-02-14N2022-05-10
YAMAA-011MIGRAINE201811—Y2021-09-20
YAMAA-012TYPE 2 DIABETES MELLITUS———N2021-09-20
YAMAA-011GOUT2019052021-07-15N2021-06-01

Expected output

Under review
7 expected rows

expected/mh.csv

Edit
7 rows
expected/mh.csv
STUDYIDUSUBJIDMHSEQMHTERMMHSTDTCMHENDTCMHENRTPTMHENTPT
YAMAA-011HYPERTENSION2015—ONGOINGSCREENING
YAMAA-012HYPERLIPIDEMIA2019-032020-11-30BEFORESCREENING
YAMAA-011ASTHMA2017-06———
YAMAA-012ECZEMA20202022-02-14BEFORESCREENING
YAMAA-011MIGRAINE2018-11—ONGOINGSCREENING
YAMAA-012TYPE 2 DIABETES MELLITUS————
YAMAA-011GOUT2019-052021-07-15——
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 IdentifierCharCollectedCopy value from MH_FORM.STUDYID.SDTM1
USUBJIDUnique Subject IdentifierCharCollectedCopy value from MH_FORM.USUBJID.SDTM2
MHSEQSequence NumberNumCollectedCopy value from MH_FORM.MHSEQ.SDTM3
MHTERMReported Term for the Medical History ConditionCharCollectedCopy value from MH_FORM.MHTERM.SDTM4
MHSTDTCStart Date/Time of Medical History ConditionCharDerivedIf MH_FORM.MHSTYY IS NOT NULL AND MH_FORM.MHSTMM IS NULL then "MH_FORM.MHSTYY"; If MH_FORM.MHSTYY IS NOT NULL AND MH_FORM.MHSTMM IS NOT NULL then fill the template "{MH_FORM.MHSTYY}-{MH_FORM.MHSTMM}"; otherwise blank.SDTM5
MHENDTCEnd Date/Time of Medical History ConditionCharCollectedCopy value from MH_FORM.MHENDTC.SDTM6
MHENRTPTEnd Reference Relative to the Screening VisitCharONGOING, BEFOREDerivedIf MH_FORM.MHONGO = 'Y' then "ONGOING"; If MHENDTC < MH_FORM.SCRFDTC then "BEFORE"; otherwise blank.SDTM7
MHENTPTReference Time Point NameCharDerivedIf MHENRTPT IS NOT NULL then "SCREENING"; otherwise blank.SDTM8
VariablePermitted values
MHENRTPTONGOING, BEFORE
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-mh-ongoing-conditions/full.md

Edit
22 lines

Following CDISC SDTM standards, use the provided MH_FORM dataset to create an MH dataset with one record per reported condition.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, MHSEQ, MHTERM, MHSTDTC, MHENDTC, MHENRTPT, MHENTPT

MHTERM is the condition as written on the form. MHSTDTC is the start of the condition at the precision recorded: the year alone when only the year was known, or year and month; it has no value when no year was recorded. MHENDTC is the date the condition ended, when an end was recorded; a condition still active at the screening visit carries no end date.

MHENRTPT says how the condition's end relates to the screening visit: ONGOING when the tick box said it was still active, BEFORE when the recorded end date comes before the screening visit date recorded on the form, and no value otherwise (for example when the recorded end date is on or after the screening visit date). MHENTPT names the visit the end reference is measured against, SCREENING; it has no value when there is no end reference.

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

prompts/sdtm-mh-ongoing-conditions/conventions.md

Edit
11 lines

Following CDISC SDTM standards, use the provided MH_FORM dataset to create an MH dataset with one record per reported condition.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, MHSEQ, MHTERM, MHSTDTC, MHENDTC, MHENRTPT, MHENTPT

MHENRTPT is ONGOING, BEFORE, or has no value. MHENTPT is SCREENING or has no value.

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

prompts/sdtm-mh-ongoing-conditions/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided MH_FORM dataset to create an MH dataset with one record per reported condition.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, MHSEQ, MHTERM, MHSTDTC, MHENDTC, MHENRTPT, MHENTPT

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)mh <- yamaa_domain("spec.yaml")$outputmh

run.py

Edit
4 lines
import yamaamh = yamaa.yamaa_domain("spec.yaml").outputmh

Solution without yamaa

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

solutions/sdtm-mh-ongoing-conditions/result.R

Edit
40 lines
# Reference solution for the yamaa benchmark sdtm-mh-ongoing-conditions (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)mh_form <- read_csv(  "/app/input/mh_form.csv",  col_types = cols(MHSEQ = col_integer(), .default = col_character()))mh <- mh_form |>  mutate(    MHSTDTC = case_when(      is.na(MHSTYY) | MHSTYY == "" ~ NA_character_,      is.na(MHSTMM) | MHSTMM == "" ~ MHSTYY,      TRUE ~ paste0(MHSTYY, "-", sprintf("%02d", as.integer(MHSTMM)))    ),    # A condition still active at screening carries no end date.    MHENDTC = if_else(MHONGO == "Y" | is.na(MHENDTC) | MHENDTC == "",      NA_character_, MHENDTC    ),    MHENRTPT = case_when(      MHONGO == "Y" ~ "ONGOING",      !is.na(MHENDTC) & MHENDTC != "" &        !is.na(SCRFDTC) & MHENDTC < SCRFDTC ~ "BEFORE",      TRUE ~ NA_character_    ),    MHENTPT = if_else(is.na(MHENRTPT), NA_character_, "SCREENING")  ) |>  arrange(USUBJID, MHSEQ) |>  select(    STUDYID, USUBJID, MHSEQ, MHTERM, MHSTDTC, MHENDTC, MHENRTPT, MHENTPT  )dir.create("/app/output", showWarnings = FALSE)write_csv(mh, "/app/output/mh.csv", na = "")

solutions/sdtm-mh-ongoing-conditions/result.py

Edit
81 lines
# Reference solution for the yamaa benchmark sdtm-mh-ongoing-conditions (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) != ""mh_form = pl.read_csv("/app/input/mh_form.csv", infer_schema=False)rows = []for row in mh_form.to_dicts():    year, month = row.get("MHSTYY"), row.get("MHSTMM")    if not _present(year):        mhstdtc = None    elif not _present(month):        mhstdtc = str(year)    else:        mhstdtc = f"{year}-{str(month).zfill(2)}"    # A condition still active at screening carries no end date.    ongoing = str(row.get("MHONGO") or "") == "Y"    endtc = row.get("MHENDTC")    if ongoing or not _present(endtc):        mhendtc = None    else:        mhendtc = str(endtc)    scrfdtc = str(row.get("SCRFDTC") or "")    if ongoing:        mhenrtpt = "ONGOING"    elif _present(endtc) and _present(scrfdtc) and str(endtc) < scrfdtc:        mhenrtpt = "BEFORE"    else:        mhenrtpt = None    mhentpt = "SCREENING" if mhenrtpt is not None else None    rows.append(        {            "STUDYID": row["STUDYID"],            "USUBJID": row["USUBJID"],            "MHSEQ": row["MHSEQ"],            "MHTERM": row["MHTERM"],            "MHSTDTC": mhstdtc,            "MHENDTC": mhendtc,            "MHENRTPT": mhenrtpt,            "MHENTPT": mhentpt,        }    )mh = (    pl.DataFrame(        rows,        schema={            "STUDYID": pl.String,            "USUBJID": pl.String,            "MHSEQ": pl.String,            "MHTERM": pl.String,            "MHSTDTC": pl.String,            "MHENDTC": pl.String,            "MHENRTPT": pl.String,            "MHENTPT": pl.String,        },    )    .with_columns(pl.col("MHSEQ").cast(pl.Int64).alias("_seq"))    .sort(["USUBJID", "_seq"])    .select(        "STUDYID", "USUBJID", "MHSEQ", "MHTERM", "MHSTDTC", "MHENDTC",        "MHENRTPT", "MHENTPT",    ))Path("/app/output").mkdir(exist_ok=True)mh.write_csv("/app/output/mh.csv")

solutions/sdtm-mh-ongoing-conditions/result.sas

Edit
18 lines
/* opensas reference solution for the yamaa benchmark sdtm-mh-ongoing-conditions.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data mh_form;  length STUDYID USUBJID MHTERM MHSTYY MHSTMM MHENDTC MHONGO SCRFDTC $1024;  infile "/app/input/mh_form.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. MHSEQ MHTERM : $char1024. MHSTYY : $char1024. MHSTMM : $char1024. MHENDTC : $char1024. MHONGO : $char1024. SCRFDTC : $char1024.;run;data result; set mh_form; length DOMAIN $2 MHSTDTC MHENRTPT MHENTPT $1024; DOMAIN='MH'; MHSTDTC=''; MHENRTPT=''; MHENTPT='';if not missing(MHSTYY) then do; MHSTDTC=MHSTYY; if not missing(MHSTMM) then MHSTDTC=catx('-',MHSTYY,MHSTMM); end;if MHONGO='Y' then do; MHENDTC=''; MHENRTPT='ONGOING'; end; else if not missing(MHENDTC) and not missing(SCRFDTC) and MHENDTC<SCRFDTC then MHENRTPT='BEFORE';if not missing(MHENRTPT) then MHENTPT='SCREENING'; run;proc sql;  create table final as select STUDYID, USUBJID, MHSEQ, MHTERM, MHSTDTC, MHENDTC, MHENRTPT, MHENTPT from result;quit;proc export data=final outfile="/app/output/mh.csv" dbms=csv replace; run;