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
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
Goal: put a subject's dose administrations and pharmacokinetic (PK)
concentration samples in one dataset, one record per event in time order,
as a population PK model reads them: the event type (EVID), the
compartment (CMT), the dose amount (AMT), the concentration (DV),
whether a record has no concentration (MDV), a subject number (ID) and
the record's place in the subject's sequence (ASEQ).
Input: exposure (EX) records, one per administration, with the dose
(EXDOSE) and its date/time (EXSTDTC), and PK concentration (PC)
records, one per sample and analyte, with the numeric result (PCSTRESN,
empty when the result is below the limit of quantification), the
completion status (PCSTAT) and the collection date/time (PCDTC).
Variables:
ID: the subject's number among the subjects in the dataset, counted from 1 in the order ofUSUBJID, with no number skipped.ASEQ: the record's number within the subject, from 1 in the order ofADTM. At one date/time a sample comes before a dose, since it was drawn before the dose was given, and samples follow theirCMT.ADTM: the date/time of the administration or of the sample.EVID: 1 for a dose record and 0 for a concentration record.CMT: 1 for a dose, the compartment the drug is given into; 2 for a concentration of the parent drug (DRGX) and 3 for one of its metabolite (MET1).PARAMCD:DOSEfor a dose record and the analyte for a concentration record.AMT: the dose given; empty on a concentration record.DV: the concentration; empty on a dose record and for a result below the limit of quantification.MDV: 1 whenDVis empty and 0 otherwise.
Note: an administration with a dose of zero is no event and gives no record, a sample that was not done gives none, and a subject with no administration of an amount, such as a placebo subject, has no records at all.
Inputs
Under review2 source filesinput/ex.csv
Edit6 rows| STUDYID | USUBJID | EXSEQ | EXTRT | EXDOSE | EXDOSU | EXSTDTC |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | DRUG X | 100 | mg | 2025-03-10T08:00 | |
| YAMAA-01 | 2 | DRUG X | 100 | mg | 2025-03-11T08:00 | |
| YAMAA-01 | 1 | DRUG X | 50 | mg | 2025-03-10T09:00 | |
| YAMAA-01 | 1 | DRUG X | 100 | mg | 2025-03-12T08:30 | |
| YAMAA-01 | 2 | DRUG X | 0 | mg | 2025-03-13T08:30 | |
| YAMAA-01 | 1 | PLACEBO | 0 | mg | 2025-03-10T08:15 |
input/pc.csv
Edit11 rows| STUDYID | USUBJID | PCSEQ | PCTESTCD | PCSTRESC | PCSTRESN | PCSTRESU | PCSTAT | PCTPT | PCDTC |
|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | DRGX | <1.00 | — | ng/mL | — | Pre-dose | 2025-03-10T07:40 | |
| YAMAA-01 | 2 | MET1 | <0.50 | — | ng/mL | — | Pre-dose | 2025-03-10T07:40 | |
| YAMAA-01 | 3 | DRGX | 4.69 | 4.69 | ng/mL | — | 1 h | 2025-03-10T09:00 | |
| YAMAA-01 | 4 | MET1 | 1.21 | 1.21 | ng/mL | — | 1 h | 2025-03-10T09:00 | |
| YAMAA-01 | 5 | DRGX | 1.15 | 1.15 | ng/mL | — | 24 h | 2025-03-11T08:00 | |
| YAMAA-01 | 6 | MET1 | 0.90 | 0.9 | ng/mL | — | 24 h | 2025-03-11T08:00 | |
| YAMAA-01 | 1 | DRGX | 2.78 | 2.78 | ng/mL | — | 2 h | 2025-03-10T11:00 | |
| YAMAA-01 | 2 | DRGX | — | — | — | NOT DONE | 4 h | 2025-03-10T13:00 | |
| YAMAA-01 | 1 | DRGX | 4.52 | 4.52 | ng/mL | — | 1 h | 2025-03-12T09:30 | |
| YAMAA-01 | 1 | DRGX | <1.00 | — | ng/mL | — | Pre-dose | 2025-03-10T08:00 | |
| YAMAA-01 | 2 | DRGX | <1.00 | — | ng/mL | — | 1 h | 2025-03-10T09:15 |
Expected output
Under review12 expected rowsexpected/adppk.csv
Edit12 rows| STUDYID | USUBJID | ID | ASEQ | ADTM | EVID | CMT | PARAMCD | AMT | DV | MDV |
|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | 1 | 2025-03-10T07:40:00 | 0 | 2 | DRGX | — | — | 1 | |
| YAMAA-01 | 1 | 2 | 2025-03-10T07:40:00 | 0 | 3 | MET1 | — | — | 1 | |
| YAMAA-01 | 1 | 3 | 2025-03-10T08:00:00 | 1 | 1 | DOSE | 100 | — | 1 | |
| YAMAA-01 | 1 | 4 | 2025-03-10T09:00:00 | 0 | 2 | DRGX | — | 4.69 | 0 | |
| YAMAA-01 | 1 | 5 | 2025-03-10T09:00:00 | 0 | 3 | MET1 | — | 1.21 | 0 | |
| YAMAA-01 | 1 | 6 | 2025-03-11T08:00:00 | 0 | 2 | DRGX | — | 1.15 | 0 | |
| YAMAA-01 | 1 | 7 | 2025-03-11T08:00:00 | 0 | 3 | MET1 | — | 0.9 | 0 | |
| YAMAA-01 | 1 | 8 | 2025-03-11T08:00:00 | 1 | 1 | DOSE | 100 | — | 1 | |
| YAMAA-01 | 2 | 1 | 2025-03-10T09:00:00 | 1 | 1 | DOSE | 50 | — | 1 | |
| YAMAA-01 | 2 | 2 | 2025-03-10T11:00:00 | 0 | 2 | DRGX | — | 2.78 | 0 | |
| YAMAA-01 | 3 | 1 | 2025-03-12T08:30:00 | 1 | 1 | DOSE | 100 | — | 1 | |
| YAMAA-01 | 3 | 2 | 2025-03-12T09:30:00 | 0 | 2 | DRGX | — | 4.52 | 0 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADPPK | STUDYID | Study Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | USUBJID | Unique Subject Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | ADTM | Analysis Date/Time | numeric | ISO 8601 | Set per constructed row; see the Row construction sheet. | Derived | |
| ADPPK | EVID | Event ID | numeric | 0, 1 | Set per constructed row; see the Row construction sheet. | Derived | |
| ADPPK | CMT | Compartment | numeric | 1, 2, 3 | Set per constructed row; see the Row construction sheet. | Derived | |
| ADPPK | PARAMCD | Parameter Code | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | AMT | Actual Amount of Dose Received | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | DV | Dependent Variable Result | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | MDV | Missing Dependent Variable Result | numeric | If DV IS NULL then "1"; otherwise "0". | Derived | ||
| ADPPK | ID | Subject Identifier for the Analysis | numeric | Rank rows from 1 ordered by STUDYID then USUBJID; ties share a number and the next distinct value follows without a gap. | Derived | ||
| ADPPK | ASEQ | Analysis Sequence Number | numeric | Row number within each group of STUDYID, USUBJID, ordered by ADTM then EVID then CMT. | Derived |
| Template | Include when | STUDYID | USUBJID | ADTM | EVID | CMT | PARAMCD | AMT | DV |
|---|---|---|---|---|---|---|---|---|---|
| dose | EX.EXDOSE > 0 | Copy EX.STUDYID | Copy EX.USUBJID | Copy EX.EXSTDTC | Constant "1" | Constant "1" | Constant "DOSE" | Copy EX.EXDOSE | Constant "None" |
| observation | PC.PCSTAT IS NULL AND DOSED.EXSEQ IS NOT NULL | Copy PC.STUDYID | Copy PC.USUBJID | Copy PC.PCDTC | Constant "0" | Recode PC.PCTESTCD: "DRGX" → "2", "MET1" → "3"; missing values stay missing; unlisted values are errors | Copy PC.PCTESTCD | Constant "None" | Copy PC.PCSTRESN |
| Variable | Permitted values |
|---|---|
| EVID | 0, 1 |
| CMT | 1, 2, 3 |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.8 | 2026-11-19 | yamaa docs build | State open and closed range endpoints, including bounds of zero | ||
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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/adam-adppk-event-records/full.md
Edit39 linesFollowing CDISC ADaM standards, use the provided EX and PC datasets to create an ADPPK dataset with one record per event of a subject: a dose administration, or a PK concentration sample of one analyte.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ID, ASEQ, ADTM, EVID, CMT, PARAMCD, AMT, DV, MDV
The dataset holds the events as a population PK model reads them: a dose record for each EX record and a concentration record for each PC record, with these exceptions.
- An administration with a dose of zero is no event and gives no record.
- A sample that was not done (PCSTAT is "NOT DONE") gives no record.
- A subject with no administration of a dose above zero, such as a placebo subject, has no records at all, concentration records included.
- Every other PC record gives a concentration record, a sample drawn before the subject's first dose and a result below the limit of quantification included.
The columns hold:
- ID is the subject's number among the subjects in the output dataset, counted from 1 in the order of USUBJID, with no number skipped.
- ASEQ is the record's number within the subject, from 1 in the order of ADTM. At one date/time a concentration record comes before a dose record, and concentration records follow their CMT.
- ADTM is the date/time of the administration (EXSTDTC) or of the sample (PCDTC), written as YYYY-MM-DDThh:mm:ss with the seconds always shown.
- EVID is 1 for a dose record and 0 for a concentration record.
- CMT is 1 for a dose record, and for a concentration record 2 when PCTESTCD is "DRGX", the parent drug, and 3 when it is "MET1", its metabolite.
- PARAMCD is "DOSE" for a dose record and PCTESTCD for a concentration record.
- AMT is the dose given (EXDOSE) and has no value on a concentration record.
- DV is the concentration (PCSTRESN), not rounded, and has no value on a dose record or for a result below the limit of quantification.
- MDV is 1 when DV has no value, on every dose record too, and 0 otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.
prompts/adam-adppk-event-records/conventions.md
Edit18 linesFollowing CDISC ADaM standards, use the provided EX and PC datasets to create an ADPPK dataset with one record per event of a subject: a dose administration, or a PK concentration sample of one analyte.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ID, ASEQ, ADTM, EVID, CMT, PARAMCD, AMT, DV, MDV
ID is the subject's number among the subjects in the output dataset, counted from 1 in the order of USUBJID, with no number skipped. ADTM is written as YYYY-MM-DDThh:mm:ss with the seconds always shown. EVID is 1 for a dose record and 0 for a concentration record. CMT is 1 for a dose record, and for a concentration record 2 when PCTESTCD is "DRGX", the parent drug, and 3 when it is "MET1", its metabolite. PARAMCD is "DOSE" for a dose record and PCTESTCD for a concentration record. DV is not rounded. MDV is 1 when DV has no value and 0 otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.
prompts/adam-adppk-event-records/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided EX and PC datasets to create an ADPPK dataset with one record per event of a subject: a dose administration, or a PK concentration sample of one analyte.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ID, ASEQ, ADTM, EVID, CMT, PARAMCD, AMT, DV, MDV
Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adppk-event-records/result.R
Edit62 lines# Reference solution for the yamaa benchmark adam-adppk-event-records (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.suppressPackageStartupMessages({ library(dplyr) library(readr) library(stringr)})ex <- read_csv("/app/input/ex.csv", col_types = cols(.default = col_character()), na = c("", "NA"))pc <- read_csv("/app/input/pc.csv", col_types = cols(.default = col_character()), na = c("", "NA"))full_dtm <- function(x) { x <- str_trim(x) d <- "[0-9]{4}-[0-9]{2}-[0-9]{2}" case_when( is.na(x) ~ NA_character_, str_detect(x, paste0("^", d, "$")) ~ paste0(x, "T00:00:00"), str_detect(x, paste0("^", d, "T[0-9]{2}$")) ~ paste0(x, ":00:00"), str_detect(x, paste0("^", d, "T[0-9]{2}:[0-9]{2}$")) ~ paste0(x, ":00"), TRUE ~ str_sub(x, 1, 19) )}doses <- ex %>% mutate(AMT = as.numeric(EXDOSE)) %>% filter(!is.na(AMT), AMT > 0) %>% transmute( STUDYID, USUBJID, ADTM = full_dtm(EXSTDTC), EVID = 1L, CMT = 1L, PARAMCD = "DOSE", AMT, DV = NA_real_, SRCSEQ = as.numeric(EXSEQ) )concs <- pc %>% filter(is.na(PCSTAT) | str_to_upper(str_trim(PCSTAT)) != "NOT DONE") %>% semi_join(doses, by = "USUBJID") %>% transmute( STUDYID, USUBJID, ADTM = full_dtm(PCDTC), EVID = 0L, CMT = case_when(PCTESTCD == "DRGX" ~ 2L, PCTESTCD == "MET1" ~ 3L, TRUE ~ NA_integer_), PARAMCD = PCTESTCD, AMT = NA_real_, DV = if_else(!is.na(PCSTRESC) & str_detect(PCSTRESC, "^ *<"), NA_real_, as.numeric(PCSTRESN)), SRCSEQ = as.numeric(PCSEQ) )adppk <- bind_rows(doses, concs) %>% mutate(MDV = if_else(is.na(DV), 1L, 0L)) %>% arrange(USUBJID, ADTM, EVID, CMT, SRCSEQ) %>% mutate(ID = dense_rank(USUBJID)) %>% group_by(USUBJID) %>% mutate(ASEQ = row_number()) %>% ungroup() %>% select(STUDYID, USUBJID, ID, ASEQ, ADTM, EVID, CMT, PARAMCD, AMT, DV, MDV)write_csv(adppk, "/app/output/adppk.csv", na = "")solutions/adam-adppk-event-records/result.py
Edit60 lines# Reference solution for the yamaa benchmark adam-adppk-event-records (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 pandas as pdCOLUMNS = ["STUDYID", "USUBJID", "ID", "ASEQ", "ADTM", "EVID", "CMT", "PARAMCD", "AMT", "DV", "MDV"]CMT = {"DRGX": 2, "MET1": 3}def read(name): frame = pd.read_csv(f"/app/input/{name}.csv", dtype=str, keep_default_na=False) return frame.apply(lambda column: column.str.strip())def adtm(values): return pd.to_datetime(values, format="ISO8601").dt.strftime("%Y-%m-%dT%H:%M:%S")ex = read("ex")ex = ex[pd.to_numeric(ex["EXDOSE"], errors="coerce") > 0]dose = pd.DataFrame( { "STUDYID": ex["STUDYID"], "USUBJID": ex["USUBJID"], "ADTM": adtm(ex["EXSTDTC"]), "EVID": 1, "CMT": 1, "PARAMCD": "DOSE", "AMT": ex["EXDOSE"], "DV": "", "SEQ": pd.to_numeric(ex["EXSEQ"], errors="coerce"), })pc = read("pc")pc = pc[(pc["PCSTAT"].str.upper() != "NOT DONE") & pc["USUBJID"].isin(dose["USUBJID"])]conc = pd.DataFrame( { "STUDYID": pc["STUDYID"], "USUBJID": pc["USUBJID"], "ADTM": adtm(pc["PCDTC"]), "EVID": 0, "CMT": pc["PCTESTCD"].map(CMT).astype("Int64"), "PARAMCD": pc["PCTESTCD"], "AMT": "", "DV": pc["PCSTRESN"], "SEQ": pd.to_numeric(pc["PCSEQ"], errors="coerce"), })adppk = pd.concat([dose, conc], ignore_index=True)adppk["CMT"] = adppk["CMT"].astype("Int64")adppk["MDV"] = (adppk["DV"] == "").astype(int)adppk = adppk.sort_values(["USUBJID", "ADTM", "EVID", "CMT", "SEQ"], kind="stable").reset_index(drop=True)adppk["ID"] = adppk.groupby("USUBJID", sort=True).ngroup() + 1adppk["ASEQ"] = adppk.groupby("USUBJID").cumcount() + 1adppk[COLUMNS].to_csv("/app/output/adppk.csv", index=False)solutions/adam-adppk-event-records/result.sas
Edit86 lines/* opensas reference solution for the yamaa benchmark adam-adppk-event-records. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */options missing='';data ex; infile '/app/input/ex.csv' dsd dlm=',' firstobs=2 truncover; length STUDYID $40 USUBJID $40 EXSEQ 8 EXTRT $40 EXDOSE 8 EXDOSU $20 EXSTDTC $25; input STUDYID $ USUBJID $ EXSEQ EXTRT $ EXDOSE EXDOSU $ EXSTDTC $;run;data pc; infile '/app/input/pc.csv' dsd dlm=',' firstobs=2 truncover; length STUDYID $40 USUBJID $40 PCSEQ 8 PCTESTCD $8 PCSTRESC $20 PCSTRESN 8 PCSTRESU $20 PCSTAT $20 PCTPT $40 PCDTC $25; input STUDYID $ USUBJID $ PCSEQ PCTESTCD $ PCSTRESC $ PCSTRESN PCSTRESU $ PCSTAT $ PCTPT $ PCDTC $;run;data dose; set ex; where EXDOSE > 0; length ADTM $19 PARAMCD $8; ADTM = strip(compress(EXSTDTC, "0D"x)); if length(ADTM) = 16 then ADTM = cats(ADTM, ':00'); else if length(ADTM) = 13 then ADTM = cats(ADTM, ':00:00'); else if length(ADTM) = 10 then ADTM = cats(ADTM, 'T00:00:00'); EVID = 1; CMT = 1; PARAMCD = 'DOSE'; AMT = EXDOSE; DV = .; MDV = 1; keep STUDYID USUBJID ADTM EVID CMT PARAMCD AMT DV MDV;run;proc sort data=dose(keep=USUBJID) out=dosed nodupkey; by USUBJID;run;proc sort data=pc out=pcs; by USUBJID;run;data conc; merge pcs(in=inpc) dosed(in=indose); by USUBJID; if inpc and indose; if upcase(strip(PCSTAT)) = 'NOT DONE' then delete; length ADTM $19 PARAMCD $8; ADTM = strip(compress(PCDTC, "0D"x)); if length(ADTM) = 16 then ADTM = cats(ADTM, ':00'); else if length(ADTM) = 13 then ADTM = cats(ADTM, ':00:00'); else if length(ADTM) = 10 then ADTM = cats(ADTM, 'T00:00:00'); EVID = 0; if PCTESTCD = 'DRGX' then CMT = 2; else if PCTESTCD = 'MET1' then CMT = 3; PARAMCD = PCTESTCD; AMT = .; DV = PCSTRESN; if missing(DV) then MDV = 1; else MDV = 0; keep STUDYID USUBJID ADTM EVID CMT PARAMCD AMT DV MDV;run;data events; set dose conc;run;proc sort data=events; by USUBJID ADTM EVID CMT;run;data adppk; retain STUDYID USUBJID ID ASEQ ADTM EVID CMT PARAMCD AMT DV MDV; set events; by USUBJID; if first.USUBJID then do; ID + 1; ASEQ = 0; end; ASEQ + 1;run;proc export data=adppk outfile='/app/output/adppk.csv' dbms=csv replace;run;
yamaa