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.
- 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.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- 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
README.mdGoal: 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 | — | — |
Comments and assessment materials
| 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 | If 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. | 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.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 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
Edit11 linesFollowing 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
Edit8 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)mh <- yamaa_domain("spec.yaml")$outputmhrun.py
Edit4 linesimport yamaamh = yamaa.yamaa_domain("spec.yaml").outputmhsolutions/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
Edit81 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
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
Comments
Signed in with GitHub; saved in repository Discussions