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

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

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

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.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
18 lines

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

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

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, and has no value otherwise. A medication ending before treatment starts, or starting after treatment ends, is left unflagged. 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.

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 CM and ADSL datasets to create an ADCM dataset with one record per 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 CM and ADSL datasets to create an ADCM dataset with one record per 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

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

run.R

Edit
4 lines
library(yamaa)adcm <- yamaa_domain("spec.yaml")$outputadcm

run.py

Edit
4 lines
import yamaaadcm = yamaa.yamaa_domain("spec.yaml").outputadcm

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
59 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.from pathlib import Pathimport polars as plcm = pl.read_csv("/app/input/cm.csv", infer_schema=False).with_columns(    pl.col("CMSEQ").cast(pl.Int64))adsl = pl.read_csv("/app/input/adsl.csv", infer_schema=False).select(    "USUBJID", "TRTSDT", "TRTEDT")adcm = cm.join(adsl, on="USUBJID", how="left").with_columns(    ASTDT=pl.col("CMSTDTC"), AENDT=pl.col("CMENDTC"))# 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.# ISO dates sort as text.adcm = (    adcm.with_columns(        ONTRTFL=pl.when(pl.col("TRTSDT").is_null() | (pl.col("TRTSDT") == ""))        .then(None)        .when(            pl.col("AENDT").is_not_null()            & (pl.col("AENDT") != "")            & (pl.col("AENDT") < pl.col("TRTSDT"))        )        .then(None)        .when(            pl.col("ASTDT").is_not_null()            & (pl.col("ASTDT") != "")            & pl.col("TRTEDT").is_not_null()            & (pl.col("TRTEDT") != "")            & (pl.col("ASTDT") > pl.col("TRTEDT"))        )        .then(None)        .otherwise(pl.lit("Y"))    ).select(        "STUDYID",        "USUBJID",        "CMSEQ",        "CMTRT",        "ASTDT",        "AENDT",        "TRTSDT",        "TRTEDT",        "ONTRTFL",    ))Path("/app/output").mkdir(exist_ok=True)adcm.write_csv("/app/output/adcm.csv")

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;