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
README.mdPublic 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:
MHTERMis the condition as written on the form.MHSTDTCis the start of the condition at the precision recorded: the year alone (for example2015) when only the year was known, or year and month (for example2019-03); empty when no year was recorded.MHENDTCis the date the condition ended, when an end was recorded.MHENRTPTsays how the condition's end relates to the screening visit:ONGOINGwhen the tick box said it was still active,BEFOREwhen 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).MHENTPTnames 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 review1 source fileinput/mh_form.csv
Edit7 rows| STUDYID | USUBJID | MHSEQ | MHTERM | MHSTYY | MHSTMM | MHENDTC | MHONGO | SCRFDTC |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | HYPERTENSION | 2015 | — | — | Y | 2021-06-01 | |
| YAMAA-01 | 2 | HYPERLIPIDEMIA | 2019 | 03 | 2020-11-30 | N | 2021-06-01 | |
| YAMAA-01 | 1 | ASTHMA | 2017 | 06 | — | N | 2022-05-10 | |
| YAMAA-01 | 2 | ECZEMA | 2020 | — | 2022-02-14 | N | 2022-05-10 | |
| YAMAA-01 | 1 | MIGRAINE | 2018 | 11 | — | Y | 2021-09-20 | |
| YAMAA-01 | 2 | TYPE 2 DIABETES MELLITUS | — | — | — | N | 2021-09-20 | |
| YAMAA-01 | 1 | GOUT | 2019 | 05 | 2021-07-15 | N | 2021-06-01 |
Expected output
Under review7 expected rowsexpected/mh.csv
Edit7 rows| STUDYID | USUBJID | MHSEQ | MHTERM | MHSTDTC | MHENDTC | MHENRTPT | MHENTPT |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | HYPERTENSION | 2015 | — | ONGOING | SCREENING | |
| YAMAA-01 | 2 | HYPERLIPIDEMIA | 2019-03 | 2020-11-30 | BEFORE | SCREENING | |
| YAMAA-01 | 1 | ASTHMA | 2017-06 | — | — | — | |
| YAMAA-01 | 2 | ECZEMA | 2020 | 2022-02-14 | BEFORE | SCREENING | |
| YAMAA-01 | 1 | MIGRAINE | 2018-11 | — | ONGOING | SCREENING | |
| YAMAA-01 | 2 | TYPE 2 DIABETES MELLITUS | — | — | — | — | |
| YAMAA-01 | 1 | GOUT | 2019-05 | 2021-07-15 | — | — |
Human review and assessment
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| STUDYID | Study Identifier | Char | Collected | Copy value from MH_FORM.STUDYID. | SDTM | 1 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from MH_FORM.USUBJID. | SDTM | 2 | ||||
| MHSEQ | Sequence Number | Num | Collected | Copy value from MH_FORM.MHSEQ. | SDTM | 3 | ||||
| MHTERM | Reported Term for the Medical History Condition | Char | Collected | Copy value from MH_FORM.MHTERM. | SDTM | 4 | ||||
| MHSTDTC | Start Date/Time of Medical History Condition | Char | Derived | Write 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. | SDTM | 5 | ||||
| MHENDTC | End Date/Time of Medical History Condition | Char | Collected | Copy value from MH_FORM.MHENDTC. | SDTM | 6 | ||||
| MHENRTPT | End Reference Relative to the Screening Visit | Char | ONGOING, BEFORE | Derived | If MH_FORM.MHONGO = 'Y' then "ONGOING"; If MHENDTC < MH_FORM.SCRFDTC then "BEFORE"; otherwise blank. | SDTM | 7 | |||
| MHENTPT | Reference Time Point Name | Char | Derived | If MHENRTPT IS NOT NULL then "SCREENING"; otherwise blank. | SDTM | 8 |
| Variable | Permitted values |
|---|---|
| MHENRTPT | ONGOING, BEFORE |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/sdtm-mh-ongoing-conditions/full.md
Edit22 linesFollowing 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
Edit14 linesFollowing 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
Edit8 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-mh-ongoing-conditions/result.R
Edit40 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
Edit88 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
Edit18 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;
yamaa