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: mark each subject's end-of-treatment record for every laboratory test (EOTFL), carrying the protocol endpoint qualifier it rests on (ENDPOINT).

Input: laboratory (LB) records carry a numeric sequence number, a test code (LBTESTCD), a visit number (VISITNUM), and a numeric result. Supplemental laboratory qualifier (SUPPLB) records carry the same sequence as eight-character, space-padded text, one qualifier name and value per record; only the protocol endpoint qualifier is read.

Variables:

  • AVAL is the numeric laboratory result.
  • ENDPOINT is Y when a supplemental endpoint qualifier with the same study, subject, and sequence number marks the record; empty otherwise.
  • EOTFL is Y on one record per subject and test: the endpoint-marked record when there is one, otherwise the record from the latest visit. Every other record is empty.

Note: the endpoint qualifier decides the choice even when a later visit exists, so the flag can sit before the subject's last visit. A record wins the flag even when its result is missing, and a group with a single record still gets the flag. Other qualifiers on the same record, and endpoint qualifiers for records the laboratory data does not hold, change nothing.

Inputs

Under review
2 source files

input/lb.csv

Edit
12 rows
input/lb.csv
STUDYIDUSUBJIDLBSEQLBTESTCDVISITNUMLBSTRESN
YAMAA-011ALB14
YAMAA-012ALB24.2
YAMAA-013ALB34.1
YAMAA-014CREAT180
YAMAA-015CREAT282
YAMAA-016CREAT385
YAMAA-011ALB13.9
YAMAA-012ALB24
YAMAA-011ALB14.3
YAMAA-011ALB1—
YAMAA-012ALB24.4
YAMAA-011CREAT395

input/supplb.csv

Edit
6 rows
input/supplb.csv
STUDYIDRDOMAINUSUBJIDIDVARIDVARVALQNAMQLABELQVAL
YAMAA-01LBLBSEQ 2ENDPOINTProtocol Endpoint RecordY
YAMAA-01LBLBSEQ 2LBTMSHIResult to Upper Limit Ratio0.9
YAMAA-01LBLBSEQ 1LBTMSHIResult to Upper Limit Ratio0.8
YAMAA-01LBLBSEQ 7ENDPOINTProtocol Endpoint RecordY
YAMAA-01LBLBSEQ 1ENDPOINTProtocol Endpoint RecordY
YAMAA-01LBLBSEQ 1ENDPOINTProtocol Endpoint RecordY

Expected output

Under review
12 expected rows

expected/adlb.csv

Edit
12 rows
expected/adlb.csv
STUDYIDUSUBJIDLBSEQLBTESTCDVISITNUMAVALENDPOINTEOTFL
YAMAA-011ALB14——
YAMAA-012ALB24.2YY
YAMAA-013ALB34.1——
YAMAA-014CREAT180——
YAMAA-015CREAT282——
YAMAA-016CREAT385—Y
YAMAA-011ALB13.9——
YAMAA-012ALB24—Y
YAMAA-011ALB14.3—Y
YAMAA-011ALB1—YY
YAMAA-012ALB24.4——
YAMAA-011CREAT395YY
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
ADLBSTUDYIDStudy IdentifiercharacterCopy value from LB.STUDYID.Predecessor
ADLBUSUBJIDUnique Subject IdentifiercharacterCopy value from LB.USUBJID.Predecessor
ADLBLBSEQSequence NumbernumericCopy value from LB.LBSEQ.Predecessor
ADLBLBTESTCDLab Test or Examination Short NamecharacterCopy value from LB.LBTESTCD.Predecessor
ADLBVISITNUMVisit NumbernumericCopy value from LB.VISITNUM.Predecessor
ADLBAVALAnalysis ValuenumericCopy value from LB.LBSTRESN.Predecessor
ADLBENDPOINTProtocol Endpoint RecordcharacterTake ENDPOINT from the LB record matching on STUDYID, USUBJID and LBSEQ, where ENDPOINT is derived as QVAL from the SUPPLB record whose STUDYID equals LB.STUDYID, USUBJID equals LB.USUBJID and IDVARVAL equals LB.LBSEQ padded on the left with spaces to at least 8 characters, where SUPPLB.QNAM = 'ENDPOINT', blank when unmatched, and a row with no match is an error.Derived
ADLBEOTFLEnd of Treatment Record Flagcharacter"Y" when EOT_SEQ = 1, with EOT_SEQ taken from the LB record matching on STUDYID, USUBJID and LBSEQ, where EOT_SEQ is derived as row number within each group of LB.USUBJID, LB.LBTESTCD, ordered by ENDPOINT descending then LB.VISITNUM descending, and a row with no match is an error; blank otherwise.Derived
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-adlb-end-of-treatment/full.md

Edit
21 lines

Following CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL

AVAL is the numeric laboratory result. ENDPOINT is "Y" when SUPPLB holds a qualifier with QNAM "ENDPOINT" for the same study, subject, and sequence number as the record; ENDPOINT has no value otherwise. In SUPPLB the sequence number is eight-character, space-padded text. EOTFL is "Y" on one record per subject and test: the endpoint-marked record when there is one, otherwise the record from the latest visit. Every other record has no value for EOTFL. The endpoint mark decides the choice even when a later visit exists, so the flag can sit before the subject's last visit. A record wins the flag even when its result is missing, and a subject and test with a single record still gets the flag. Other qualifiers on the same record, and endpoint qualifiers for records the laboratory data does not hold, change nothing.

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

prompts/adam-adlb-end-of-treatment/conventions.md

Edit
11 lines

Following CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL

ENDPOINT is "Y" or has no value. EOTFL is "Y" or has no value. In SUPPLB the sequence number is eight-character, space-padded text.

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

prompts/adam-adlb-end-of-treatment/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL

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

Edit
67 lines
# Reference solution for the yamaa benchmark adam-adlb-end-of-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)library(stringr)lb <- read_csv(  "/app/input/lb.csv",  col_types = cols(    LBSEQ = col_integer(),    VISITNUM = col_integer(),    LBSTRESN = col_double(),    .default = col_character()  ))supp <- read_csv(  "/app/input/supplb.csv",  col_types = cols(.default = col_character()))# ENDPOINT is Y when a supplemental endpoint qualifier with the same# study, subject, and sequence number marks the record. Only the protocol# endpoint qualifier is read.endpoint_keys <- supp |>  filter(QNAM %in% "ENDPOINT") |>  transmute(    STUDYID, USUBJID,    SEQ_TRIM = str_trim(IDVARVAL),    ENDPOINT = "Y"  )marked <- lb |>  mutate(SEQ_TRIM = as.character(LBSEQ), AVAL = LBSTRESN) |>  left_join(endpoint_keys, by = c("STUDYID", "USUBJID", "SEQ_TRIM")) |>  select(-SEQ_TRIM)# EOTFL is Y on one record per subject and test: the endpoint-marked# record when there is one, otherwise the record from the latest visit.endpoint_winners <- marked |>  filter(ENDPOINT %in% "Y") |>  group_by(STUDYID, USUBJID, LBTESTCD) |>  summarise(WIN_ENDPOINT = min(LBSEQ), .groups = "drop")latest_winners <- marked |>  arrange(desc(VISITNUM), desc(LBSEQ)) |>  distinct(STUDYID, USUBJID, LBTESTCD, .keep_all = TRUE) |>  transmute(STUDYID, USUBJID, LBTESTCD, WIN_LATEST = LBSEQ)winners <- latest_winners |>  left_join(endpoint_winners, by = c("STUDYID", "USUBJID", "LBTESTCD")) |>  mutate(WIN_LBSEQ = coalesce(WIN_ENDPOINT, WIN_LATEST), EOTFL = "Y") |>  select(STUDYID, USUBJID, LBTESTCD, WIN_LBSEQ, EOTFL)adlb <- marked |>  left_join(    winners,    by = c("STUDYID", "USUBJID", "LBTESTCD", "LBSEQ" = "WIN_LBSEQ")  ) |>  arrange(USUBJID, LBTESTCD, LBSEQ) |>  select(STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")

solutions/adam-adlb-end-of-treatment/result.py

Edit
70 lines
# Reference solution for the yamaa benchmark adam-adlb-end-of-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.import csvINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = ["STUDYID", "USUBJID", "LBSEQ", "LBTESTCD", "VISITNUM",           "AVAL", "ENDPOINT", "EOTFL"]def read_csv(path):    with open(path, newline="") as f:        return list(csv.DictReader(f))def main():    lb = read_csv(INPUT_DIR + "/lb.csv")    supplb = read_csv(INPUT_DIR + "/supplb.csv")    # Endpoint-marked keys: (STUDYID, USUBJID, LBSEQ as int). In SUPPLB the    # sequence number is eight-character, space-padded text.    endpoint_keys = set()    for row in supplb:        if row["QNAM"] == "ENDPOINT":            endpoint_keys.add(                (row["STUDYID"], row["USUBJID"], int(row["IDVARVAL"].strip()))            )    records = []    for row in lb:        key = (row["STUDYID"], row["USUBJID"], int(row["LBSEQ"]))        records.append({            "STUDYID": row["STUDYID"],            "USUBJID": row["USUBJID"],            "LBSEQ": row["LBSEQ"],            "LBTESTCD": row["LBTESTCD"],            "VISITNUM": row["VISITNUM"],            "AVAL": row["LBSTRESN"],            "ENDPOINT": "Y" if key in endpoint_keys else "",            "EOTFL": "",            "_visit": int(row["VISITNUM"]),        })    # One EOTFL "Y" per subject and test: the endpoint-marked record when    # there is one, otherwise the record from the latest visit.    groups = {}    for i, rec in enumerate(records):        groups.setdefault((rec["USUBJID"], rec["LBTESTCD"]), []).append(i)    for idxs in groups.values():        marked = [i for i in idxs if records[i]["ENDPOINT"] == "Y"]        if marked:            winner = marked[0]        else:            winner = max(idxs, key=lambda i: records[i]["_visit"])        records[winner]["EOTFL"] = "Y"    with open(OUTPUT_DIR + "/adlb.csv", "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=COLUMNS)        writer.writeheader()        for rec in records:            writer.writerow({c: rec[c] for c in COLUMNS})if __name__ == "__main__":    main()

solutions/adam-adlb-end-of-treatment/result.sas

Edit
29 lines
/* opensas reference solution for the yamaa benchmark adam-adlb-end-of-treatment.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data lb;  length STUDYID USUBJID LBTESTCD $1024;  infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. LBSEQ LBTESTCD : $char1024. VISITNUM LBSTRESN;run;data supplb;  length STUDYID RDOMAIN USUBJID IDVAR IDVARVAL QNAM QLABEL QVAL $1024;  infile "/app/input/supplb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. RDOMAIN : $char1024. USUBJID : $char1024. IDVAR : $char1024. IDVARVAL : $char1024. QNAM : $char1024. QLABEL : $char1024. QVAL : $char1024.;run;data supplb_key; set supplb; PARENTSEQ=input(IDVARVAL,?? best32.); run;proc sql;  create table joined as select a.*,a.LBSTRESN as AVAL,b.QVAL as ENDPOINT from lb as a left join supplb_key as b    on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and b.RDOMAIN='LB' and b.IDVAR='LBSEQ' and a.LBSEQ=b.PARENTSEQ and b.QNAM='ENDPOINT';quit;data ordered; set joined; priority=0; if ENDPOINT='Y' then priority=1; run;proc sort data=ordered; by STUDYID USUBJID LBTESTCD descending priority descending VISITNUM LBSEQ; run;data result; length EOTFL $1; set ordered; by STUDYID USUBJID LBTESTCD; if first.LBTESTCD then EOTFL='Y'; run;proc sql;  create table final as select STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;