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 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

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
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 ConditionCharDerivedWrite the collected year MH_FORM.MHSTYY, month MH_FORM.MHSTMM as ISO 8601 date text, stopping before the first blank part; blank when the year is blank; a part that is not its digits is an error.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.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-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 condition reported on the form.

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

MHSEQ is the sequence number of the condition as numbered 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 recorded, or the year and month (for example "2019-03") when the month was recorded too. MHSTDTC has no value when no start year was recorded. A condition still active at the screening visit carries no end date: the ongoing answer is the record of its end status. MHENRTPT is "ONGOING" when the ongoing tick box on the form said the condition was still active. MHENRTPT is "BEFORE" when the recorded end date comes before the screening visit date recorded on the form. MHENRTPT has no value otherwise, for example when the recorded end date is on or after the screening visit date. MHENTPT is "SCREENING" when MHENRTPT has a value, and 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
14 lines

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

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

MHSTDTC is the start of the condition at the precision recorded: the year alone (for example "2015") when only the year was recorded, or the year and month (for example "2019-03") when the month was recorded too. MHENRTPT is "ONGOING" or "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 condition reported on the form.

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

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-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
88 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."""Build the SDTM MH dataset from the collected MH_FORM dataset.One output record per condition reported on the form, with columns:STUDYID, USUBJID, MHSEQ, MHTERM, MHSTDTC, MHENDTC, MHENRTPT, MHENTPT."""import csvfrom datetime import dateINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = [    "STUDYID",    "USUBJID",    "MHSEQ",    "MHTERM",    "MHSTDTC",    "MHENDTC",    "MHENRTPT",    "MHENTPT",]def start_dtc(year, month):    """Start date at the precision recorded: year, or year and month."""    year = (year or "").strip()    month = (month or "").strip()    if not year:        return ""    if month:        return f"{year}-{int(month):02d}"    return yeardef main():    with open(f"{INPUT_DIR}/mh_form.csv", newline="", encoding="utf-8") as f:        rows = list(csv.DictReader(f))    out = []    for row in rows:        ongoing = (row.get("MHONGO") or "").strip() == "Y"        end_dtc = (row.get("MHENDTC") or "").strip()        screen_dtc = (row.get("SCRFDTC") or "").strip()        if ongoing:            # A condition still active at screening carries no end date;            # the ongoing answer is the record of its end status.            mh_end = ""            enrtpt = "ONGOING"        else:            mh_end = end_dtc            enrtpt = ""            if end_dtc and screen_dtc:                end_date = date.fromisoformat(end_dtc)                screen_date = date.fromisoformat(screen_dtc)                if end_date < screen_date:                    enrtpt = "BEFORE"        entpt = "SCREENING" if enrtpt else ""        out.append(            {                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "MHSEQ": row["MHSEQ"],                "MHTERM": row["MHTERM"],                "MHSTDTC": start_dtc(row.get("MHSTYY"), row.get("MHSTMM")),                "MHENDTC": mh_end,                "MHENRTPT": enrtpt,                "MHENTPT": entpt,            }        )    with open(f"{OUTPUT_DIR}/mh.csv", "w", newline="", encoding="utf-8") as f:        writer = csv.DictWriter(f, fieldnames=COLUMNS)        writer.writeheader()        writer.writerows(out)if __name__ == "__main__":    main()

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;