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: reviewedEditUnder review
What this benchmark means
README.md

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

Goal: flag each concomitant medication taken while the subject is on treatment, adding ONTRTFL.

Input: the subject's medication records (input/cm.csv) with the collected start and end dates, plus the subject-level records (input/adsl.csv) carrying each subject's first and last treatment dates. A subject whose subject-level record carries empty treatment dates keeps both treatment dates empty.

Variables:

  • STUDYID, USUBJID, CMSEQ are carried through as collected.
  • CMTRT is the reported medication name, carried through as collected.
  • ASTDT and AENDT are the medication's analysis start and end dates.
  • TRTSDT and TRTEDT are the subject's first and last treatment dates.
  • ONTRTFL is Y when the medication dates overlap the treatment period; blank otherwise. A medication ending before treatment starts, or starting after treatment ends, is left unflagged.

Note: a medication with a missing start or end date is assumed to overlap unless its known dates rule overlap out. A missing treatment end date leaves the period open-ended, while a subject with no treatment start date is never flagged. The fixture also covers the negative side: a medication with a missing start date that ends before treatment starts is left unflagged.

Inputs

Under review
2 source files

input/adsl.csv

Edit
3 rows
input/adsl.csv
STUDYIDUSUBJIDTRTSDTTRTEDT
YAMAA-012023-03-012023-06-30
YAMAA-01——
YAMAA-012023-05-15—

input/cm.csv

Edit
13 rows
input/cm.csv
STUDYIDUSUBJIDCMSEQCMTRTCMSTDTCCMENDTC
YAMAA-011Ibuprofen2023-02-202023-02-28
YAMAA-012Acetaminophen2023-02-252023-03-01
YAMAA-013Metformin2023-03-012023-06-30
YAMAA-014Lisinopril2023-04-102023-04-24
YAMAA-015Omeprazole2023-06-302023-07-15
YAMAA-016Atorvastatin2023-07-01—
YAMAA-017Alendronate2023-05-01—
YAMAA-018Calcium carbonate——
YAMAA-019Aspirin—2023-02-15
YAMAA-011Gabapentin2023-04-012023-04-15
YAMAA-011Sertraline2023-04-012023-05-10
YAMAA-012Levothyroxine2023-05-20—
YAMAA-013Vitamin D—2023-06-01

Expected output

Under review
13 expected rows

expected/adcm.csv

Edit
13 rows
expected/adcm.csv
STUDYIDUSUBJIDCMSEQCMTRTASTDTAENDTTRTSDTTRTEDTONTRTFL
YAMAA-011Ibuprofen2023-02-202023-02-282023-03-012023-06-30—
YAMAA-012Acetaminophen2023-02-252023-03-012023-03-012023-06-30Y
YAMAA-013Metformin2023-03-012023-06-302023-03-012023-06-30Y
YAMAA-014Lisinopril2023-04-102023-04-242023-03-012023-06-30Y
YAMAA-015Omeprazole2023-06-302023-07-152023-03-012023-06-30Y
YAMAA-016Atorvastatin2023-07-01—2023-03-012023-06-30—
YAMAA-017Alendronate2023-05-01—2023-03-012023-06-30Y
YAMAA-018Calcium carbonate——2023-03-012023-06-30Y
YAMAA-019Aspirin—2023-02-152023-03-012023-06-30—
YAMAA-011Gabapentin2023-04-012023-04-15———
YAMAA-011Sertraline2023-04-012023-05-102023-05-15——
YAMAA-012Levothyroxine2023-05-20—2023-05-15—Y
YAMAA-013Vitamin D—2023-06-012023-05-15—Y
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

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADCMSTUDYIDStudy IdentifiercharacterCopy value from CM.STUDYID.Predecessor
ADCMUSUBJIDUnique Subject IdentifiercharacterCopy value from CM.USUBJID.Predecessor
ADCMCMSEQSequence NumbernumericCopy value from CM.CMSEQ.Predecessor
ADCMCMTRTReported Name of Drug, Medication, or TherapycharacterCopy value from CM.CMTRT.Predecessor
ADCMASTDTAnalysis Start DatenumericISO 8601Copy value from CM.CMSTDTC.Predecessor
ADCMAENDTAnalysis End DatenumericISO 8601Copy value from CM.CMENDTC.Predecessor
ADCMTRTSDTDate of First Exposure to TreatmentnumericISO 8601Copy value from ADSL.TRTSDT.Predecessor
ADCMTRTEDTDate of Last Exposure to TreatmentnumericISO 8601Copy value from ADSL.TRTEDT.Predecessor
ADCMONTRTFLOn Treatment Record FlagcharacterY"Y" when TRTSDT IS NOT NULL AND (TRTEDT IS NULL OR ASTDT IS NULL OR ASTDT <= TRTEDT) AND (AENDT IS NULL OR AENDT >= TRTSDT) ; blank otherwise.Derived
VariablePermitted values
ONTRTFLY
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/adam-adcm-on-treatment/full.md

Edit
25 lines

Following CDISC ADaM standards, use the provided ADSL and CM datasets to create an ADCM dataset with one record per concomitant medication.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL

ASTDT is the medication's analysis start date, the date collected as CMSTDTC, and AENDT is the medication's analysis end date, the date collected as CMENDTC. TRTSDT is the subject's first treatment date and TRTEDT the subject's last treatment date, both from the subject's subject-level record; a subject whose subject-level record has no treatment dates has no value for TRTSDT or TRTEDT. ONTRTFL is "Y" when the medication's dates overlap the subject's treatment period, from TRTSDT through TRTEDT, and has no value otherwise. A medication that ends before TRTSDT, or that starts after TRTEDT, has no value for ONTRTFL; a medication that starts on TRTEDT or ends on TRTSDT does overlap. A medication with no ASTDT or no AENDT is treated as overlapping unless its known dates rule overlap out, so a medication with no ASTDT that ends before TRTSDT has no value for ONTRTFL. A missing TRTEDT leaves the treatment period open-ended. A subject with no TRTSDT is never flagged: ONTRTFL has no value on every record for that subject.

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

prompts/adam-adcm-on-treatment/conventions.md

Edit
10 lines

Following CDISC ADaM standards, use the provided ADSL and CM datasets to create an ADCM dataset with one record per concomitant medication.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL

ONTRTFL is "Y" or has no value.

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

prompts/adam-adcm-on-treatment/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL and CM datasets to create an ADCM dataset with one record per concomitant medication.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL

Read the source datasets from /app/input and save the completed dataset as /app/output/adcm.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/adam-adcm-on-treatment/result.R

Edit
39 lines
# Reference solution for the yamaa benchmark adam-adcm-on-treatment (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)cm <- read_csv(  "/app/input/cm.csv",  col_types = cols(CMSEQ = col_integer(), .default = col_character()))adsl <- read_csv(  "/app/input/adsl.csv",  col_types = cols(.default = col_character()))adcm <- cm |>  mutate(ASTDT = CMSTDTC, AENDT = CMENDTC) |>  left_join(adsl |> select(USUBJID, TRTSDT, TRTEDT), by = "USUBJID") |>  mutate(    # The medication overlaps the treatment period. A missing medication    # date is assumed to overlap unless the known dates rule it out; a    # missing treatment end leaves the period open, while no treatment    # start is never flagged.    ONTRTFL = case_when(      is.na(TRTSDT) ~ NA_character_,      !is.na(AENDT) & AENDT < TRTSDT ~ NA_character_,      !is.na(ASTDT) & !is.na(TRTEDT) & ASTDT > TRTEDT ~ NA_character_,      .default = "Y"    )  ) |>  select(    STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL  )dir.create("/app/output", showWarnings = FALSE)write_csv(adcm, "/app/output/adcm.csv", na = "")

solutions/adam-adcm-on-treatment/result.py

Edit
99 lines
# Reference solution for the yamaa benchmark adam-adcm-on-treatment (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."""Create ADCM (one record per concomitant medication) from ADSL and CM.ONTRTFL is "Y" when the medication's analysis dates overlap the subject'streatment period (TRTSDT through TRTEDT, inclusive). A medication with amissing start or end date is treated as overlapping unless its known datesrule overlap out. A missing TRTEDT leaves the period open-ended, and asubject with no TRTSDT is never flagged."""import polars as plINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = [    "STUDYID",    "USUBJID",    "CMSEQ",    "CMTRT",    "ASTDT",    "AENDT",    "TRTSDT",    "TRTEDT",    "ONTRTFL",]def read_csv(name):    frame = pl.read_csv(        f"{INPUT_DIR}/{name}",        schema_overrides={            "STUDYID": pl.String,            "USUBJID": pl.String,            "CMSEQ": pl.String,            "CMTRT": pl.String,            "CMSTDTC": pl.String,            "CMENDTC": pl.String,            "TRTSDT": pl.String,            "TRTEDT": pl.String,        },    )    return frame.fill_null("")def main():    adsl = read_csv("adsl.csv")    cm = read_csv("cm.csv")    trt = {        row["USUBJID"]: (row["TRTSDT"], row["TRTEDT"])        for row in adsl.iter_rows(named=True)    }    records = []    for row in cm.iter_rows(named=True):        astdt, aendt = row["CMSTDTC"], row["CMENDTC"]        trtsdt, trtedt = trt.get(row["USUBJID"], ("", ""))        ontrtfl = ""        if trtsdt:            ends_before_start = bool(aendt) and aendt < trtsdt            starts_after_end = bool(astdt) and bool(trtedt) and astdt > trtedt            if not ends_before_start and not starts_after_end:                ontrtfl = "Y"        records.append(            {                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "CMSEQ": row["CMSEQ"],                "CMTRT": row["CMTRT"],                "ASTDT": astdt,                "AENDT": aendt,                "TRTSDT": trtsdt,                "TRTEDT": trtedt,                "ONTRTFL": ontrtfl,            }        )    adcm = pl.DataFrame(records, schema={name: pl.String for name in COLUMNS})    # Write empty values as bare empty fields, not quoted "" strings.    adcm = adcm.select(        pl.when(pl.col(name) == "")        .then(pl.lit(None, dtype=pl.String))        .otherwise(pl.col(name))        .alias(name)        for name in COLUMNS    )    adcm.write_csv(f"{OUTPUT_DIR}/adcm.csv")if __name__ == "__main__":    main()

solutions/adam-adcm-on-treatment/result.sas

Edit
27 lines
/* opensas reference solution for the yamaa benchmark adam-adcm-on-treatment.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl;  length STUDYID USUBJID TRTSDT TRTEDT $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024. TRTEDT : $char1024.;run;data cm;  length STUDYID USUBJID CMTRT CMSTDTC CMENDTC $1024;  infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMSTDTC : $char1024. CMENDTC : $char1024.;run;proc sql; create table joined as select a.*,b.TRTSDT,b.TRTEDT from cm as a left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data result;  length ASTDT AENDT $10 ONTRTFL $1;  set joined; ASTDT=CMSTDTC; AENDT=CMENDTC;  if not missing(TRTSDT) and (missing(AENDT) or AENDT>=TRTSDT) and (missing(TRTEDT) or missing(ASTDT) or ASTDT<=TRTEDT) then ONTRTFL='Y';run;proc sql;  create table final as select STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL from result;quit;proc export data=final outfile="/app/output/adcm.csv" dbms=csv replace; run;