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: derive FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, and FADTC for each solicited reaction on a vaccine reactogenicity diary in Findings About (FA).

Input: one row per diary day per solicited reaction, carrying the diary day label, the collection date, the reaction, whether the reaction is local or systemic, the occurrence and severity recorded for completed days, the measured diameter for redness and swelling, and whether the diary day was completed.

Variables:

  • FASEQ numbers the subject's records by diary day, reaction name, and test order (OCCUR, SEV, LDIAM). Output records are grouped by subject, then ordered by that number.
  • FATESTCD is OCCUR for the occurrence record, one per reaction per diary day; SEV for the severity record, on completed days only; and LDIAM for the longest-diameter record, only for redness or swelling that occurred on a completed day.
  • FATEST is Occurrence Indicator, Severity/Intensity, and Longest Diameter respectively.
  • FAOBJ copies the solicited reaction.
  • FACAT is always REACTOGENICITY.
  • FASCAT is ADMINISTRATION SITE for local reactions and SYSTEMIC for systemic reactions.
  • FAORRES is the recorded Y/N for OCCUR, the recorded severity for SEV (NONE unless the reaction occurred), and the measured diameter for LDIAM; it is blank on a missed diary day.
  • FAORRESU is the diameter unit, on LDIAM records only.
  • FASTRESC copies FAORRES.
  • FASTRESN is the measured diameter as a number, on LDIAM records only.
  • FASTRESU copies the diameter unit, on LDIAM records only.
  • FASTAT is NOT DONE for a missed diary day, and blank otherwise.
  • FATPT is the diary day label (END DAY 1, ...).
  • FADTC is the diary collection date.

Note: temperature stays in Vital Signs (VS) and is not a reactogenicity diary record, so it never becomes an FA record here.

Inputs

Under review
1 source file

input/diary.csv

Edit
16 rows
input/diary.csv
STUDYIDUSUBJIDDIARYDAYTPTDTCREACTIONCATSRCOCCURSEVDIAMETERDIAMUNITCOMPLETED
VAX011END DAY 12025-03-02PAINLOCALYMILD——Y
VAX011END DAY 12025-03-02REDNESSLOCALYMODERATE35mmY
VAX011END DAY 12025-03-02SWELLINGLOCALNNONE——Y
VAX011END DAY 12025-03-02HEADACHESYSTEMICYMILD——Y
VAX011END DAY 12025-03-02FATIGUESYSTEMICNNONE——Y
VAX012END DAY 22025-03-03PAINLOCALNNONE——Y
VAX012END DAY 22025-03-03REDNESSLOCALYMILD25mmY
VAX012END DAY 22025-03-03SWELLINGLOCALNNONE——Y
VAX012END DAY 22025-03-03HEADACHESYSTEMICNNONE——Y
VAX012END DAY 22025-03-03FATIGUESYSTEMICYMODERATE——Y
VAX013END DAY 32025-03-04PAINLOCAL————N
VAX013END DAY 32025-03-04REDNESSLOCAL————N
VAX013END DAY 32025-03-04SWELLINGLOCAL————N
VAX013END DAY 32025-03-04HEADACHESYSTEMIC————N
VAX013END DAY 32025-03-04FATIGUESYSTEMIC————N
VAX011END DAY 12025-03-02PAINLOCALYMILD——Y

Expected output

Under review
29 expected rows

expected/fa.csv

Edit
29 rows
expected/fa.csv
DOMAINSTUDYIDUSUBJIDFASEQFATESTCDFATESTFAOBJFACATFASCATFAORRESFAORRESUFASTRESCFASTRESNFASTRESUFASTATFATPTFADTC
FAVAX011OCCUROccurrence IndicatorFATIGUEREACTOGENICITYSYSTEMICN—N———END DAY 12025-03-02
FAVAX012SEVSeverity/IntensityFATIGUEREACTOGENICITYSYSTEMICNONE—NONE———END DAY 12025-03-02
FAVAX013OCCUROccurrence IndicatorHEADACHEREACTOGENICITYSYSTEMICY—Y———END DAY 12025-03-02
FAVAX014SEVSeverity/IntensityHEADACHEREACTOGENICITYSYSTEMICMILD—MILD———END DAY 12025-03-02
FAVAX015OCCUROccurrence IndicatorPAINREACTOGENICITYADMINISTRATION SITEY—Y———END DAY 12025-03-02
FAVAX016SEVSeverity/IntensityPAINREACTOGENICITYADMINISTRATION SITEMILD—MILD———END DAY 12025-03-02
FAVAX017OCCUROccurrence IndicatorREDNESSREACTOGENICITYADMINISTRATION SITEY—Y———END DAY 12025-03-02
FAVAX018SEVSeverity/IntensityREDNESSREACTOGENICITYADMINISTRATION SITEMODERATE—MODERATE———END DAY 12025-03-02
FAVAX019LDIAMLongest DiameterREDNESSREACTOGENICITYADMINISTRATION SITE35mm3535mm—END DAY 12025-03-02
FAVAX0110OCCUROccurrence IndicatorSWELLINGREACTOGENICITYADMINISTRATION SITEN—N———END DAY 12025-03-02
FAVAX0111SEVSeverity/IntensitySWELLINGREACTOGENICITYADMINISTRATION SITENONE—NONE———END DAY 12025-03-02
FAVAX0112OCCUROccurrence IndicatorFATIGUEREACTOGENICITYSYSTEMICY—Y———END DAY 22025-03-03
FAVAX0113SEVSeverity/IntensityFATIGUEREACTOGENICITYSYSTEMICMODERATE—MODERATE———END DAY 22025-03-03
FAVAX0114OCCUROccurrence IndicatorHEADACHEREACTOGENICITYSYSTEMICN—N———END DAY 22025-03-03
FAVAX0115SEVSeverity/IntensityHEADACHEREACTOGENICITYSYSTEMICNONE—NONE———END DAY 22025-03-03
FAVAX0116OCCUROccurrence IndicatorPAINREACTOGENICITYADMINISTRATION SITEN—N———END DAY 22025-03-03
FAVAX0117SEVSeverity/IntensityPAINREACTOGENICITYADMINISTRATION SITENONE—NONE———END DAY 22025-03-03
FAVAX0118OCCUROccurrence IndicatorREDNESSREACTOGENICITYADMINISTRATION SITEY—Y———END DAY 22025-03-03
FAVAX0119SEVSeverity/IntensityREDNESSREACTOGENICITYADMINISTRATION SITEMILD—MILD———END DAY 22025-03-03
FAVAX0120LDIAMLongest DiameterREDNESSREACTOGENICITYADMINISTRATION SITE25mm2525mm—END DAY 22025-03-03
FAVAX0121OCCUROccurrence IndicatorSWELLINGREACTOGENICITYADMINISTRATION SITEN—N———END DAY 22025-03-03
FAVAX0122SEVSeverity/IntensitySWELLINGREACTOGENICITYADMINISTRATION SITENONE—NONE———END DAY 22025-03-03
FAVAX0123OCCUROccurrence IndicatorFATIGUEREACTOGENICITYSYSTEMIC—————NOT DONEEND DAY 32025-03-04
FAVAX0124OCCUROccurrence IndicatorHEADACHEREACTOGENICITYSYSTEMIC—————NOT DONEEND DAY 32025-03-04
FAVAX0125OCCUROccurrence IndicatorPAINREACTOGENICITYADMINISTRATION SITE—————NOT DONEEND DAY 32025-03-04
FAVAX0126OCCUROccurrence IndicatorREDNESSREACTOGENICITYADMINISTRATION SITE—————NOT DONEEND DAY 32025-03-04
FAVAX0127OCCUROccurrence IndicatorSWELLINGREACTOGENICITYADMINISTRATION SITE—————NOT DONEEND DAY 32025-03-04
FAVAX011OCCUROccurrence IndicatorPAINREACTOGENICITYADMINISTRATION SITEY—Y———END DAY 12025-03-02
FAVAX012SEVSeverity/IntensityPAINREACTOGENICITYADMINISTRATION SITEMILD—MILD———END DAY 12025-03-02
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

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "FA".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from DIARY.STUDYID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from DIARY.USUBJID.SDTM3
FATESTCDFindings About Test Short NameCharDerivedSet per constructed row; see the Row construction sheet.SDTM4
FATESTFindings About Test NameCharDerivedSet per constructed row; see the Row construction sheet.SDTM5
FASEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by DIARY.DIARYDAY then DIARY.REACTION then TESTORD.SDTM6
FAOBJObject of the ObservationCharCollectedCopy value from DIARY.REACTION.SDTM7
FACATCategory for Findings AboutCharAssignedSet constant value "REACTOGENICITY".SDTM8
FASCATSubcategory for Findings AboutCharDerivedIf DIARY.CATSRC = 'LOCAL' then "ADMINISTRATION SITE"; otherwise "SYSTEMIC".SDTM9
FAORRESResult or Finding in Original UnitsCharDerivedSet per constructed row; see the Row construction sheet.SDTM10
FAORRESUOriginal UnitsCharDerivedIf FATESTCD = 'LDIAM' then "DIARY.DIAMUNIT"; otherwise blank.SDTM11
FASTRESCCharacter Result/Finding in Std FormatCharDerivedCopy value from FAORRES.SDTM12
FASTRESNNumeric Result/Finding in Standard UnitsNumDerivedIf FATESTCD = 'LDIAM' then "DIARY.DIAMETER"; otherwise blank.SDTM13
FASTRESUStandard UnitsCharDerivedCopy value from FAORRESU.SDTM14
FASTATCompletion StatusCharDerivedIf DIARY.COMPLETED = 'N' then "NOT DONE"; otherwise blank.SDTM15
FATPTPlanned Time Point NameCharCollectedCopy value from DIARY.TPT.SDTM16
FADTCDate/Time of CollectionCharISO 8601CollectedCopy value from DIARY.DTC.SDTM17
TemplateInclude whenFATESTCDFATESTFAORRES
occurrenceConstant "OCCUR"Constant "Occurrence Indicator"If DIARY.COMPLETED = 'Y' then "DIARY.OCCUR"; otherwise blank
severityDIARY.COMPLETED = 'Y'Constant "SEV"Constant "Severity/Intensity"If DIARY.OCCUR = 'Y' then "DIARY.SEV"; otherwise "NONE"
longest-diameterDIARY.COMPLETED = 'Y' AND DIARY.OCCUR = 'Y' AND DIARY.REACTION IN ('REDNESS', 'SWELLING')Constant "LDIAM"Constant "Longest Diameter"Copy DIARY.DIAMETER
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/sdtm-fa-reactogenicity-diary/full.md

Edit
31 lines

Following CDISC SDTM standards, use the provided DIARY dataset to create an FA dataset with one record per test for each solicited reaction on each diary day.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC

DOMAIN is "FA". STUDYID and USUBJID are the study and subject identifiers as given in the diary. Every reaction on every diary day gives an "OCCUR" record and, on a completed day, a "SEV" record; redness or swelling that occurred on a completed day also gives an "LDIAM" record. FATEST is "Occurrence Indicator" for "OCCUR", "Severity/Intensity" for "SEV", and "Longest Diameter" for "LDIAM". FAOBJ is the solicited reaction. FACAT is "REACTOGENICITY" on every record. FASCAT is "ADMINISTRATION SITE" for a local reaction and "SYSTEMIC" for a systemic reaction. FAORRES on an "OCCUR" record is the recorded occurrence, "Y" or "N", on a completed day, and has no value on a missed diary day. FAORRES on a "SEV" record is the recorded severity, or "NONE" when the reaction did not occur. FAORRES on an "LDIAM" record is the measured diameter as recorded. FASTRESC is the same value as FAORRES. FAORRESU and FASTRESU are the diameter unit on an "LDIAM" record and have no value on any other record. FASTRESN is the measured diameter as a number on an "LDIAM" record and has no value on any other record. FASTAT is "NOT DONE" for a missed diary day and has no value otherwise. FATPT is the diary day label, such as "END DAY 1". FADTC is the diary collection date. FASEQ numbers each subject's records from 1 by diary day, then reaction name, then test order ("OCCUR", "SEV", "LDIAM").

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

prompts/sdtm-fa-reactogenicity-diary/conventions.md

Edit
18 lines

Following CDISC SDTM standards, use the provided DIARY dataset to create an FA dataset with one record per test for each solicited reaction on each diary day.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC

DOMAIN is "FA". FATEST is "Occurrence Indicator" for "OCCUR", "Severity/Intensity" for "SEV", and "Longest Diameter" for "LDIAM". FACAT is "REACTOGENICITY" on every record. FASCAT is "ADMINISTRATION SITE" or "SYSTEMIC". FAORRES on an "OCCUR" record is "Y" or "N", or has no value. FAORRES on a "SEV" record is the recorded severity, or "NONE". FASTAT is "NOT DONE" or has no value. FATPT is the diary day label, such as "END DAY 1".

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

prompts/sdtm-fa-reactogenicity-diary/brief.md

Edit
10 lines

Following CDISC SDTM standards, use the provided DIARY dataset to create an FA dataset with one record per test for each solicited reaction on each diary day.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC

Read the source datasets from /app/input and save the completed dataset as /app/output/fa.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/sdtm-fa-reactogenicity-diary/result.R

Edit
114 lines
# Reference solution for the yamaa benchmark sdtm-fa-reactogenicity-diary (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(purrr)diary <- read_csv(  "/app/input/diary.csv",  col_types = cols(DIARYDAY = col_integer(), .default = col_character()))local_reactions <- c("PAIN", "REDNESS", "SWELLING")one_row <- function(r) {  fascat <- if (r$CATSRC %in% "LOCAL") {    "ADMINISTRATION SITE"  } else if (r$CATSRC %in% "SYSTEMIC") {    "SYSTEMIC"  } else if (r$REACTION %in% local_reactions) {    "ADMINISTRATION SITE"  } else {    "SYSTEMIC"  }  base <- tibble(    DOMAIN = "FA",    STUDYID = r$STUDYID,    USUBJID = r$USUBJID,    DAY = r$DIARYDAY,    REACTION = r$REACTION,    FAOBJ = r$REACTION,    FACAT = "REACTOGENICITY",    FASCAT = fascat,    FATPT = r$TPT,    FADTC = r$DTC  )  clean <- function(x) {    if (is.na(x) || x == "") NA_character_ else x  }  if (is.na(r$COMPLETED) || r$COMPLETED != "Y") {    return(base |> mutate(      ORDER = 0L, FATESTCD = "OCCUR",      FATEST = "Occurrence Indicator",      FAORRES = NA_character_, FAORRESU = NA_character_,      FASTRESC = NA_character_, FASTRESN = NA_real_,      FASTRESU = NA_character_, FASTAT = "NOT DONE"    ))  }  occur <- clean(r$OCCUR)  sev <- if (occur %in% "Y") clean(r$SEV) else "NONE"  diam <- clean(r$DIAMETER)  unit <- clean(r$DIAMUNIT)  out <- base |> mutate(    ORDER = 0L, FATESTCD = "OCCUR",    FATEST = "Occurrence Indicator",    FAORRES = occur, FAORRESU = NA_character_,    FASTRESC = occur, FASTRESN = NA_real_,    FASTRESU = NA_character_, FASTAT = NA_character_  )  out <- bind_rows(    out,    base |> mutate(      ORDER = 1L, FATESTCD = "SEV",      FATEST = "Severity/Intensity",      FAORRES = sev, FAORRESU = NA_character_,      FASTRESC = sev, FASTRESN = NA_real_,      FASTRESU = NA_character_, FASTAT = NA_character_    )  )  if (r$REACTION %in% c("REDNESS", "SWELLING") && !is.na(occur) && occur == "Y") {    out <- bind_rows(      out,      base |> mutate(        ORDER = 2L, FATESTCD = "LDIAM",        FATEST = "Longest Diameter",        FAORRES = diam, FAORRESU = unit,        FASTRESC = diam,        FASTRESN = suppressWarnings(as.numeric(diam)),        FASTRESU = unit, FASTAT = NA_character_      )    )  }  out}selected <- diary |> filter(REACTION != "TEMPERATURE")empty <- tibble(  DOMAIN = character(), STUDYID = character(), USUBJID = character(),  DAY = integer(), REACTION = character(), FAOBJ = character(),  FACAT = character(), FASCAT = character(), FATPT = character(),  FADTC = character(), ORDER = integer(), FATESTCD = character(),  FATEST = character(), FAORRES = character(), FAORRESU = character(),  FASTRESC = character(), FASTRESN = double(), FASTRESU = character(),  FASTAT = character())fa <- bind_rows(  empty,  map(seq_len(nrow(selected)), ~ one_row(as.list(selected[.x, ])))) |>  arrange(STUDYID, USUBJID, DAY, REACTION, ORDER) |>  group_by(STUDYID, USUBJID) |>  mutate(FASEQ = row_number()) |>  ungroup() |>  select(    DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT,    FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT,    FATPT, FADTC  )dir.create("/app/output", showWarnings = FALSE)write_csv(fa, "/app/output/fa.csv", na = "")

solutions/sdtm-fa-reactogenicity-diary/result.py

Edit
172 lines
# Reference solution for the yamaa benchmark sdtm-fa-reactogenicity-diary (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 pldiary = pl.read_csv("/app/input/diary.csv", infer_schema=False).with_columns(    pl.col("DIARYDAY").cast(pl.Int64),)test_order = {"OCCUR": 0, "SEV": 1, "LDIAM": 2}test_name = {    "OCCUR": "Occurrence Indicator",    "SEV": "Severity/Intensity",    "LDIAM": "Longest Diameter",}local_reactions = {"PAIN", "REDNESS", "SWELLING"}def is_local(reaction, catsrc):    # Local reactions map to ADMINISTRATION SITE; systemic stay SYSTEMIC.    if catsrc == "LOCAL":        return True    if catsrc == "SYSTEMIC":        return False    return reaction in local_reactionsrows = []for r in diary.filter(pl.col("REACTION") != "TEMPERATURE").to_dicts():    study, subj = r["STUDYID"], r["USUBJID"]    day, tpt, dtc = r["DIARYDAY"], r["TPT"], r["DTC"]    reaction = r["REACTION"]    completed = r["COMPLETED"]    missed = completed != "Y"    fascat = "ADMINISTRATION SITE" if is_local(reaction, r["CATSRC"]) else "SYSTEMIC"    base = {        "DOMAIN": "FA",        "STUDYID": study,        "USUBJID": subj,        "DAY": day,        "REACTION": reaction,        "FAOBJ": reaction,        "FACAT": "REACTOGENICITY",        "FASCAT": fascat,        "FATPT": tpt,        "FADTC": dtc,    }    if missed:        rows.append(            {                **base,                "ORDER": 0,                "FATESTCD": "OCCUR",                "FATEST": test_name["OCCUR"],                "FAORRES": None,                "FAORRESU": None,                "FASTRESC": None,                "FASTRESN": None,                "FASTRESU": None,                "FASTAT": "NOT DONE",            }        )        continue    occur = r["OCCUR"] if r["OCCUR"] not in (None, "") else None    sev = (r["SEV"] if r["SEV"] not in (None, "") else None) if occur == "Y" else "NONE"    diam = r["DIAMETER"] if r["DIAMETER"] not in (None, "") else None    unit = r["DIAMUNIT"] if r["DIAMUNIT"] not in (None, "") else None    rows.append(        {            **base,            "ORDER": 0,            "FATESTCD": "OCCUR",            "FATEST": test_name["OCCUR"],            "FAORRES": occur,            "FAORRESU": None,            "FASTRESC": occur,            "FASTRESN": None,            "FASTRESU": None,            "FASTAT": None,        }    )    rows.append(        {            **base,            "ORDER": 1,            "FATESTCD": "SEV",            "FATEST": test_name["SEV"],            "FAORRES": sev,            "FAORRESU": None,            "FASTRESC": sev,            "FASTRESN": None,            "FASTRESU": None,            "FASTAT": None,        }    )    if reaction in ("REDNESS", "SWELLING") and occur == "Y":        try:            num = float(diam) if diam is not None else None        except ValueError:            num = None        rows.append(            {                **base,                "ORDER": 2,                "FATESTCD": "LDIAM",                "FATEST": test_name["LDIAM"],                "FAORRES": diam,                "FAORRESU": unit,                "FASTRESC": diam,                "FASTRESN": num,                "FASTRESU": unit,                "FASTAT": None,            }        )fa = (    pl.DataFrame(        rows,        schema={            "DOMAIN": pl.String,            "STUDYID": pl.String,            "USUBJID": pl.String,            "DAY": pl.Int64,            "REACTION": pl.String,            "FAOBJ": pl.String,            "FACAT": pl.String,            "FASCAT": pl.String,            "FATPT": pl.String,            "FADTC": pl.String,            "ORDER": pl.Int64,            "FATESTCD": pl.String,            "FATEST": pl.String,            "FAORRES": pl.String,            "FAORRESU": pl.String,            "FASTRESC": pl.String,            "FASTRESN": pl.Float64,            "FASTRESU": pl.String,            "FASTAT": pl.String,        },    )    .sort(["STUDYID", "USUBJID", "DAY", "REACTION", "ORDER"])    .with_columns(        pl.int_range(1, pl.len() + 1).over(["STUDYID", "USUBJID"]).alias("FASEQ")    )    .select(        "DOMAIN",        "STUDYID",        "USUBJID",        "FASEQ",        "FATESTCD",        "FATEST",        "FAOBJ",        "FACAT",        "FASCAT",        "FAORRES",        "FAORRESU",        "FASTRESC",        "FASTRESN",        "FASTRESU",        "FASTAT",        "FATPT",        "FADTC",    ))Path("/app/output").mkdir(parents=True, exist_ok=True)fa.write_csv("/app/output/fa.csv")

solutions/sdtm-fa-reactogenicity-diary/result.sas

Edit
27 lines
/* opensas reference solution for the yamaa benchmark sdtm-fa-reactogenicity-diary.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data diary;  length STUDYID USUBJID DIARYDAY TPT DTC REACTION CATSRC OCCUR SEV DIAMETER DIAMUNIT COMPLETED $1024;  infile "/app/input/diary.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. DIARYDAY : $char1024. TPT : $char1024. DTC : $char1024. REACTION : $char1024. CATSRC : $char1024. OCCUR : $char1024. SEV : $char1024. DIAMETER : $char1024. DIAMUNIT : $char1024. COMPLETED : $char1024.;run;data prepared; set diary; if REACTION ne 'TEMPERATURE'; length DOMAIN $2 FATESTCD FATEST FAOBJ FACAT FASCAT FAORRES FAORRESU FASTRESC FASTRESU FASTAT FATPT FADTC $1024;DOMAIN='FA'; FAOBJ=REACTION; FACAT='REACTOGENICITY'; FASCAT=CATSRC; if CATSRC='LOCAL' then FASCAT='ADMINISTRATION SITE'; FATPT=TPT; FADTC=DTC; DAYORD=input(DIARYDAY,best32.);FAORRESU=''; FASTRESU=''; FASTRESN=.; FASTAT=''; FAORRES=''; FATESTCD='OCCUR'; FATEST='Occurrence Indicator'; TESTORD=1;if COMPLETED='Y' then FAORRES=OCCUR; else FASTAT='NOT DONE'; FASTRESC=FAORRES; output;if COMPLETED='Y' then do;FATESTCD='SEV'; FATEST='Severity/Intensity'; TESTORD=2; FAORRES='NONE'; if OCCUR='Y' then FAORRES=SEV; FASTRESC=FAORRES; output;if REACTION in ('REDNESS','SWELLING') and OCCUR='Y' then do; FATESTCD='LDIAM'; FATEST='Longest Diameter'; TESTORD=3; FASTRESN=input(DIAMETER,best32.); FAORRES=strip(put(FASTRESN,best32.)); FASTRESC=FAORRES; FAORRESU=DIAMUNIT; FASTRESU=DIAMUNIT; output; end; end; run;proc sort data=prepared; by STUDYID USUBJID DAYORD REACTION TESTORD; run;data result; set prepared; by STUDYID USUBJID; retain FASEQ;  if first.USUBJID then FASEQ=0;  FASEQ+1;run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC from result;quit;proc export data=final outfile="/app/output/fa.csv" dbms=csv replace; run;