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: one row per concomitant medication with an analysis end date (AENDT) completed from the collected end at whatever precision it was collected, never later than a date of death that falls within the collected month or year, and a flag (AENDTF) marking how much of the date was supplied.

Input: concomitant medication records, each identified by its sequence number (CMSEQ), carrying the reported name (CMTRT) and the collected end (CMENDTC): a full date, a year and month, a year alone, or nothing at all, plus the date of death (DTHDT) from the subject-level analysis dataset (ADSL), empty for a subject who has not died.

Variables:

  • AENDT is the analysis end date. A fully collected date is used as it stands. A year and month is completed to the last day of that month, and a year alone to December 31 of that year. A missing end gives no analysis date.
  • AENDTF is D when only the day was supplied and M when the month and day were supplied. It is empty when the date was collected in full and when no analysis date could be formed.
  • DTHDT is the subject's date of death, empty when the subject has not died.

Note: a supplied end is never placed after a death that falls inside the collected month or year. When the last day of the collected month or year falls after DTHDT, the date moves back to the date of death, which the collected month or year still allows, and the flag still records what was supplied. When the whole collected month begins after the date of death, no day it allows could reach it, so the end stays on the last day of that month rather than moving into a month nobody recorded. A fully collected date is left exactly as collected even when it falls after DTHDT.

Inputs

Under review
2 source files

input/adsl.csv

Edit
5 rows
input/adsl.csv
STUDYIDUSUBJIDDTHDT
YAMAA-012024-03-12
YAMAA-01—
YAMAA-012024-02-10
YAMAA-012024-04-20
YAMAA-012024-06-30

input/cm.csv

Edit
11 rows
input/cm.csv
STUDYIDUSUBJIDCMSEQCMTRTCMENDTC
YAMAA-011Paracetamol2024-03
YAMAA-012Omeprazole2024-03-08
YAMAA-013Loratadine2024-03-20
YAMAA-011Amoxicillin2024-03
YAMAA-012Cetirizine2024-02
YAMAA-011Atorvastatin2024
YAMAA-012Aspirin2023
YAMAA-011Simvastatin2024-05
YAMAA-012Ramipril2024-04
YAMAA-011Insulin glargine2024-06
YAMAA-012Warfarin—

Expected output

Under review
11 expected rows

expected/adcm.csv

Edit
11 rows
expected/adcm.csv
STUDYIDUSUBJIDCMSEQCMTRTCMENDTCAENDTAENDTFDTHDT
YAMAA-011Paracetamol2024-032024-03-12D2024-03-12
YAMAA-012Omeprazole2024-03-082024-03-08—2024-03-12
YAMAA-013Loratadine2024-03-202024-03-20—2024-03-12
YAMAA-011Amoxicillin2024-032024-03-31D—
YAMAA-012Cetirizine2024-022024-02-29D—
YAMAA-011Atorvastatin20242024-02-10M2024-02-10
YAMAA-012Aspirin20232023-12-31M2024-02-10
YAMAA-011Simvastatin2024-052024-05-31D2024-04-20
YAMAA-012Ramipril2024-042024-04-20D2024-04-20
YAMAA-011Insulin glargine2024-062024-06-30D2024-06-30
YAMAA-012Warfarin———2024-06-30
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
ADCMCMENDTCEnd Date/Time of MedicationcharacterCopy value from CM.CMENDTC.Predecessor
ADCMDTHDTDate of DeathnumericISO 8601Copy value from ADSL.DTHDT.Predecessor
ADCMAENDTAnalysis End DatenumericISO 8601Impute incomplete date from CMENDTC, defaulting month=12, day=last, never after DTHDT; a bound outside the collected period is ignored; invalid text → blank.Derived
ADCMAENDTFAnalysis End Date Imputation FlagcharacterD, MDate imputation flag for AENDT: "Y" when the whole date was imputed, "M" when the month and day were, "D" when only the day was; blank when the date was collected in full.Derived
VariablePermitted values
AENDTFD, M
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-end-date-bound/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, CMENDTC, AENDT, AENDTF, DTHDT

AENDT is the analysis end date, formed from the collected end date. A collected end date given in full is used exactly as collected, even when it falls after the subject's date of death. A collected end date that gives a year and month is completed to the last day of that month. A collected end date that gives a year alone is completed to December 31 of that year. A missing collected end date gives AENDT no value. When the completed end date falls after the subject's date of death, DTHDT, but the collected month or year also contains DTHDT, AENDT is DTHDT. When the whole collected month or year begins after DTHDT, AENDT stays on the last day of that month or year. AENDTF is "D" when only the day was supplied and "M" when the month and day were supplied. AENDTF has no value when the collected end date was given in full and when AENDT has no value. AENDTF still records what was supplied when AENDT moves back to the date of death. DTHDT is the subject's date of death from ADSL, and has no value when the subject has not died.

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

prompts/adam-adcm-end-date-bound/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, CMENDTC, AENDT, AENDTF, DTHDT

AENDTF is "D" or "M", or has no value.

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

prompts/adam-adcm-end-date-bound/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, CMENDTC, AENDT, AENDTF, DTHDT

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-end-date-bound/result.R

Edit
54 lines
# Reference solution for the yamaa benchmark adam-adcm-end-date-bound (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(lubridate, 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()))# A full date stands as collected; a year and month runs to its last day,# a year alone to December 31, never past a date of death that falls inside# the collected month or year. When the whole collected month or year lies# after death, the last day stands.adcm <- cm |>  left_join(select(adsl, STUDYID, USUBJID, DTHDT), by = c("STUDYID", "USUBJID")) |>  mutate(    LEN = nchar(CMENDTC),    FIRST = case_when(      LEN == 7 ~ ymd(paste0(CMENDTC, "-01"), quiet = TRUE),      LEN == 4 ~ ymd(paste0(CMENDTC, "-01-01"), quiet = TRUE)    ),    LAST = case_when(      LEN == 7 ~ ceiling_date(FIRST, "month") - days(1),      LEN == 4 ~ ymd(paste0(CMENDTC, "-12-31"), quiet = TRUE)    ),    DEATH = ymd(DTHDT, quiet = TRUE),    BOUNDED = case_when(      is.na(DEATH) ~ LAST,      DEATH < FIRST ~ LAST,      TRUE ~ pmin(LAST, DEATH)    ),    AENDT = case_when(      LEN == 10 ~ CMENDTC,      LEN %in% c(4, 7) & !is.na(BOUNDED) ~ format(BOUNDED, "%Y-%m-%d"),      TRUE ~ NA_character_    ),    AENDTF = case_when(      is.na(AENDT) ~ NA_character_,      LEN == 7 ~ "D",      LEN == 4 ~ "M",      TRUE ~ NA_character_    )  ) |>  select(STUDYID, USUBJID, CMSEQ, CMTRT, CMENDTC, AENDT, AENDTF, DTHDT)dir.create("/app/output", showWarnings = FALSE)write_csv(adcm, "/app/output/adcm.csv", na = "")

solutions/adam-adcm-end-date-bound/result.py

Edit
98 lines
# Reference solution for the yamaa benchmark adam-adcm-end-date-bound (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 ADCM from ADSL and CM, bounding partial end dates at death."""import calendarimport csvfrom datetime import dateINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def read_csv(path):    with open(path, newline="") as handle:        return list(csv.DictReader(handle))def parse_full(text):    year, month, day = (int(part) for part in text.split("-"))    return date(year, month, day)def derive_end(cmendtc, dthdt):    """Return (aendt, aendtf) for one collected end date."""    if not cmendtc:        return "", ""    parts = cmendtc.split("-")    if len(parts) == 3:        # A full date is used exactly as collected, even after death.        return cmendtc, ""    if len(parts) == 2:        year, month = int(parts[0]), int(parts[1])        last_day = calendar.monthrange(year, month)[1]        completed = date(year, month, last_day)        flag = "D"        period_start = date(year, month, 1)        period_end = completed    else:        year = int(parts[0])        completed = date(year, 12, 31)        flag = "M"        period_start = date(year, 1, 1)        period_end = completed    if dthdt and completed > dthdt and period_start <= dthdt <= period_end:        # The collected month or year also contains the death date;        # the flag still records what was supplied.        return dthdt.isoformat(), flag    # When the whole collected month or year begins after death, the last    # day stands.    return completed.isoformat(), flagdef main():    adsl = read_csv(f"{INPUT_DIR}/adsl.csv")    death = {}    for row in adsl:        death[row["USUBJID"]] = parse_full(row["DTHDT"]) if row["DTHDT"] else None    cm = read_csv(f"{INPUT_DIR}/cm.csv")    out_rows = []    for row in cm:        dthdt = death.get(row["USUBJID"])        aendt, aendtf = derive_end(row["CMENDTC"], dthdt)        out_rows.append(            {                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "CMSEQ": row["CMSEQ"],                "CMTRT": row["CMTRT"],                "CMENDTC": row["CMENDTC"],                "AENDT": aendt,                "AENDTF": aendtf,                "DTHDT": dthdt.isoformat() if dthdt else "",            }        )    fieldnames = [        "STUDYID",        "USUBJID",        "CMSEQ",        "CMTRT",        "CMENDTC",        "AENDT",        "AENDTF",        "DTHDT",    ]    with open(f"{OUTPUT_DIR}/adcm.csv", "w", newline="") as handle:        writer = csv.DictWriter(handle, fieldnames=fieldnames)        writer.writeheader()        writer.writerows(out_rows)if __name__ == "__main__":    main()

solutions/adam-adcm-end-date-bound/result.sas

Edit
59 lines
/* opensas reference solution for the yamaa benchmark adam-adcm-end-date-bound.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data cm;  length STUDYID USUBJID CMTRT CMENDTC $1024;  infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMENDTC : $char1024.;run;data adsl;  length STUDYID USUBJID DTHDT $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. DTHDT : $char1024.;run;proc sql;  create table joined as select a.*, b.DTHDT  from cm as a left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID  order by a.STUDYID, a.USUBJID, a.CMSEQ;quit;/* A full date stands as collected; a year and month runs to its last day,   a year alone to December 31, never past a date of death that falls inside   the collected month or year. When the whole collected month or year lies   after death, the last day stands. */data result;  length AENDT $10 AENDTF $1;  set joined;  AENDT=''; AENDTF='';  len=lengthn(CMENDTC);  death=.;  if not missing(DTHDT) then death=input(DTHDT, yymmdd10.);  if len=10 then AENDT=CMENDTC;  else if len in (4, 7) then do;    if len=7 then do;      first=input(cats(CMENDTC, '-01'), yymmdd10.);      last=intnx('month', first, 0, 'end');      flag='D';    end;    else do;      first=mdy(1, 1, input(CMENDTC, 4.));      last=mdy(12, 31, input(CMENDTC, 4.));      flag='M';    end;    if not missing(death) then do;      if death >= first then last=min(last, death);    end;    if not missing(last) then do;      AENDT=put(last, yymmdd10.);      AENDTF=flag;    end;  end;run;proc sql;  create table final as select STUDYID, USUBJID, CMSEQ, CMTRT, CMENDTC, AENDT, AENDTF, DTHDT from result;quit;proc export data=final outfile="/app/output/adcm.csv" dbms=csv replace; run;