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: carry each collected vital-signs result with its actual
collection datetime, and add the planned time point it was
scheduled for and the dose it is timed from: VSTESTCD,
VSORRES, VSTPT, VSTPTNUM, VSELTM, VSTPTREF, VSRFTDTC,
VSDTC, and VSDY.
Input: long-form Operational Data Model (ODM) data with one row
per collected item, carrying the collection form (FormOID), the
item (ItemOID), and the stored value (Value); a small test
dictionary (vs_mapping.csv) translating each vital-signs item
into its test short name, test name, and unit; plus
demographics rows carrying the reference start date. Each planned
time point arrives as its own vital-signs form, so the form tells
which scheduled reading a result belongs to. The first-dose
datetime rides along on the dosing form FO.EX.
Variables:
VSSEQnumbers the records per subject in schedule order, then pulse, systolic, and diastolic blood pressure within each time point.VSTPTis the planned time point name for the collection form:PRE-DOSE,30 MIN POST-DOSE,1 H POST-DOSE, or4 H POST-DOSE.VSTPTNUMis the planned time point number for the form: 1 through 4 in schedule order.VSELTMis the planned elapsed time since the first dose for the form, in ISO 8601 duration form:-PT15Mbefore the dose, thenPT30M,PT1H, andPT4Hafter it.VSTPTREFnames the reference time point the planned elapsed time counts from:FIRST DOSEon every record.VSRFTDTCis the date and time of that reference time point, the first-dose datetime from the subject's dosing form.VSTESTCDis the test short name, looked up from the test dictionary by item:PULSE,SYSBP, orDIABP. Items with no dictionary entry (the datetime and dosing items) give no record.VSORRESis the result in original units, the value on the test's item row within the form.VSORRESUis the original unit from the test dictionary:beats/minormmHg.VSSTRESNis the numeric result in standard units; pulse and blood pressure were collected in standard units, so it equals the original result.VSSTRESUis the standard unit, carried from the original unit.VSDTCis the actual collection datetime from the form's datetime item row, shared by every result on that form; a form with no datetime item stops the run.VSDYis the study day of the collection datetime, counted from the subject's reference start date: that date is day 1, there is no day zero, and dates before it count back from -1; missing when the subject has no reference start date.
Note: the planned elapsed time stays in duration form next to
the actual collection datetime, so a reading taken later than
planned keeps its late actual datetime and the gap shows when the
two are compared. Each reading is also checked against the
first-dose datetime in VSRFTDTC: a post-dose reading dated before
the dose, or a pre-dose reading dated after it, stops the run.
Inputs
Under review3 source filesinput/dm.csv
Edit2 rows| STUDYID | USUBJID | RFSTDTC |
|---|---|---|
| YAMAA-01 | 2025-01-08 | |
| YAMAA-01 | 2025-01-15 |
input/odm.csv
Edit34 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | FormOID | FormRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-08T08:45:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.PULSE | 72 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.SYSBP | 118 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.DIABP | 76 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-08T09:31:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.PULSE | 74 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.SYSBP | 120 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.DIABP | 78 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-08T10:02:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.PULSE | 70 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.SYSBP | 116 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.DIABP | 74 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-08T13:05:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.PULSE | 68 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.SYSBP | 114 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.DIABP | 72 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | SE.D1 | 1 | FO.EX | 1 | IG.EX | 1 | IT.EX.EXSTDTC | 2025-01-08T09:00:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-15T08:44:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.PULSE | 80 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.SYSBP | 124 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_PREDOSE | 1 | IG.VS | 1 | IT.VS.DIABP | 82 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-15T09:52:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.PULSE | 88 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.SYSBP | 128 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_30MIN | 1 | IG.VS | 1 | IT.VS.DIABP | 84 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-15T10:03:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.PULSE | 78 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.SYSBP | 122 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_1H | 1 | IG.VS | 1 | IT.VS.DIABP | 80 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.VSDTC | 2025-01-15T13:01:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.PULSE | 76 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.SYSBP | 120 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.VS_4H | 1 | IG.VS | 1 | IT.VS.DIABP | 78 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | SE.D1 | 1 | FO.EX | 1 | IG.EX | 1 | IT.EX.EXSTDTC | 2025-01-15T09:00:00 |
input/vs_mapping.csv
Edit3 rows| ItemOID | VSTESTCD | VSTEST | UNIT |
|---|---|---|---|
| IT.VS.PULSE | PULSE | Pulse | beats/min |
| IT.VS.SYSBP | SYSBP | Systolic Blood Pressure | mmHg |
| IT.VS.DIABP | DIABP | Diastolic Blood Pressure | mmHg |
Expected output
Under review24 expected rowsexpected/vs.csv
Edit24 rows| DOMAIN | STUDYID | USUBJID | VSSEQ | VISIT | VSTPT | VSTPTNUM | VSELTM | VSTPTREF | VSRFTDTC | VSTESTCD | VSORRES | VSORRESU | VSSTRESN | VSSTRESU | VSDTC | VSDY |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| VS | YAMAA-01 | 1 | DAY 1 | PRE-DOSE | 1 | -PT15M | FIRST DOSE | 2025-01-08T09:00:00 | PULSE | 72 | beats/min | 72 | beats/min | 2025-01-08T08:45:00 | 1 | |
| VS | YAMAA-01 | 2 | DAY 1 | PRE-DOSE | 1 | -PT15M | FIRST DOSE | 2025-01-08T09:00:00 | SYSBP | 118 | mmHg | 118 | mmHg | 2025-01-08T08:45:00 | 1 | |
| VS | YAMAA-01 | 3 | DAY 1 | PRE-DOSE | 1 | -PT15M | FIRST DOSE | 2025-01-08T09:00:00 | DIABP | 76 | mmHg | 76 | mmHg | 2025-01-08T08:45:00 | 1 | |
| VS | YAMAA-01 | 4 | DAY 1 | 30 MIN POST-DOSE | 2 | PT30M | FIRST DOSE | 2025-01-08T09:00:00 | PULSE | 74 | beats/min | 74 | beats/min | 2025-01-08T09:31:00 | 1 | |
| VS | YAMAA-01 | 5 | DAY 1 | 30 MIN POST-DOSE | 2 | PT30M | FIRST DOSE | 2025-01-08T09:00:00 | SYSBP | 120 | mmHg | 120 | mmHg | 2025-01-08T09:31:00 | 1 | |
| VS | YAMAA-01 | 6 | DAY 1 | 30 MIN POST-DOSE | 2 | PT30M | FIRST DOSE | 2025-01-08T09:00:00 | DIABP | 78 | mmHg | 78 | mmHg | 2025-01-08T09:31:00 | 1 | |
| VS | YAMAA-01 | 7 | DAY 1 | 1 H POST-DOSE | 3 | PT1H | FIRST DOSE | 2025-01-08T09:00:00 | PULSE | 70 | beats/min | 70 | beats/min | 2025-01-08T10:02:00 | 1 | |
| VS | YAMAA-01 | 8 | DAY 1 | 1 H POST-DOSE | 3 | PT1H | FIRST DOSE | 2025-01-08T09:00:00 | SYSBP | 116 | mmHg | 116 | mmHg | 2025-01-08T10:02:00 | 1 | |
| VS | YAMAA-01 | 9 | DAY 1 | 1 H POST-DOSE | 3 | PT1H | FIRST DOSE | 2025-01-08T09:00:00 | DIABP | 74 | mmHg | 74 | mmHg | 2025-01-08T10:02:00 | 1 | |
| VS | YAMAA-01 | 10 | DAY 1 | 4 H POST-DOSE | 4 | PT4H | FIRST DOSE | 2025-01-08T09:00:00 | PULSE | 68 | beats/min | 68 | beats/min | 2025-01-08T13:05:00 | 1 | |
| VS | YAMAA-01 | 11 | DAY 1 | 4 H POST-DOSE | 4 | PT4H | FIRST DOSE | 2025-01-08T09:00:00 | SYSBP | 114 | mmHg | 114 | mmHg | 2025-01-08T13:05:00 | 1 | |
| VS | YAMAA-01 | 12 | DAY 1 | 4 H POST-DOSE | 4 | PT4H | FIRST DOSE | 2025-01-08T09:00:00 | DIABP | 72 | mmHg | 72 | mmHg | 2025-01-08T13:05:00 | 1 | |
| VS | YAMAA-01 | 1 | DAY 1 | PRE-DOSE | 1 | -PT15M | FIRST DOSE | 2025-01-15T09:00:00 | PULSE | 80 | beats/min | 80 | beats/min | 2025-01-15T08:44:00 | 1 | |
| VS | YAMAA-01 | 2 | DAY 1 | PRE-DOSE | 1 | -PT15M | FIRST DOSE | 2025-01-15T09:00:00 | SYSBP | 124 | mmHg | 124 | mmHg | 2025-01-15T08:44:00 | 1 | |
| VS | YAMAA-01 | 3 | DAY 1 | PRE-DOSE | 1 | -PT15M | FIRST DOSE | 2025-01-15T09:00:00 | DIABP | 82 | mmHg | 82 | mmHg | 2025-01-15T08:44:00 | 1 | |
| VS | YAMAA-01 | 4 | DAY 1 | 30 MIN POST-DOSE | 2 | PT30M | FIRST DOSE | 2025-01-15T09:00:00 | PULSE | 88 | beats/min | 88 | beats/min | 2025-01-15T09:52:00 | 1 | |
| VS | YAMAA-01 | 5 | DAY 1 | 30 MIN POST-DOSE | 2 | PT30M | FIRST DOSE | 2025-01-15T09:00:00 | SYSBP | 128 | mmHg | 128 | mmHg | 2025-01-15T09:52:00 | 1 | |
| VS | YAMAA-01 | 6 | DAY 1 | 30 MIN POST-DOSE | 2 | PT30M | FIRST DOSE | 2025-01-15T09:00:00 | DIABP | 84 | mmHg | 84 | mmHg | 2025-01-15T09:52:00 | 1 | |
| VS | YAMAA-01 | 7 | DAY 1 | 1 H POST-DOSE | 3 | PT1H | FIRST DOSE | 2025-01-15T09:00:00 | PULSE | 78 | beats/min | 78 | beats/min | 2025-01-15T10:03:00 | 1 | |
| VS | YAMAA-01 | 8 | DAY 1 | 1 H POST-DOSE | 3 | PT1H | FIRST DOSE | 2025-01-15T09:00:00 | SYSBP | 122 | mmHg | 122 | mmHg | 2025-01-15T10:03:00 | 1 | |
| VS | YAMAA-01 | 9 | DAY 1 | 1 H POST-DOSE | 3 | PT1H | FIRST DOSE | 2025-01-15T09:00:00 | DIABP | 80 | mmHg | 80 | mmHg | 2025-01-15T10:03:00 | 1 | |
| VS | YAMAA-01 | 10 | DAY 1 | 4 H POST-DOSE | 4 | PT4H | FIRST DOSE | 2025-01-15T09:00:00 | PULSE | 76 | beats/min | 76 | beats/min | 2025-01-15T13:01:00 | 1 | |
| VS | YAMAA-01 | 11 | DAY 1 | 4 H POST-DOSE | 4 | PT4H | FIRST DOSE | 2025-01-15T09:00:00 | SYSBP | 120 | mmHg | 120 | mmHg | 2025-01-15T13:01:00 | 1 | |
| VS | YAMAA-01 | 12 | DAY 1 | 4 H POST-DOSE | 4 | PT4H | FIRST DOSE | 2025-01-15T09:00:00 | DIABP | 78 | mmHg | 78 | mmHg | 2025-01-15T13:01:00 | 1 |
Human review and assessment
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "VS". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| VISIT | Visit Name | Char | Collected | Recode ODM.StudyEventOID: "SE.D1" → "DAY 1"; missing values stay missing; unlisted values are errors. | SDTM | 4 | ||||
| VSTPT | Planned Time Point Name | Char | Collected | Recode ODM.FormOID: "FO.VS_PREDOSE" → "PRE-DOSE", "FO.VS_30MIN" → "30 MIN POST-DOSE", "FO.VS_1H" → "1 H POST-DOSE", "FO.VS_4H" → "4 H POST-DOSE"; missing values stay missing; unlisted values are errors. | SDTM | 5 | ||||
| VSTPTNUM | Planned Time Point Number | Num | Collected | Recode ODM.FormOID: "FO.VS_PREDOSE" → "1", "FO.VS_30MIN" → "2", "FO.VS_1H" → "3", "FO.VS_4H" → "4"; missing values stay missing; unlisted values are errors. | SDTM | 6 | ||||
| VSELTM | Planned Elapsed Time | Char | Collected | Recode ODM.FormOID: "FO.VS_PREDOSE" → "-PT15M", "FO.VS_30MIN" → "PT30M", "FO.VS_1H" → "PT1H", "FO.VS_4H" → "PT4H"; missing values stay missing; unlisted values are errors. | SDTM | 7 | ||||
| VSTPTREF | Time Point Reference | Char | Assigned | Set constant value "FIRST DOSE". | SDTM | 8 | ||||
| VSRFTDTC | Date/Time of Reference Time Point | Char | ISO 8601 | Derived | Take Value from the ODM record whose StudyOID equals STUDYID and SubjectKey equals USUBJID, where ODM.FormOID = 'FO.EX' AND ODM.ItemOID = 'IT.EX.EXSTDTC', and a row with no match is an error. | SDTM | 9 | |||
| VSTESTCD | Vital Signs Test Short Name | Char | PULSE, SYSBP, DIABP | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 10 | |||
| VSSEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by VSTPTNUM then ORD_TEST. | SDTM | 11 | ||||
| VSORRES | Result or Finding in Original Units | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 12 | ||||
| VSORRESU | Original Units | Char | beats/min, mmHg | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 13 | |||
| VSSTRESN | Numeric Result/Finding in Standard Units | Num | Derived | Copy value from VSORRES. | SDTM | 14 | ||||
| VSSTRESU | Standard Units | Char | Derived | Copy value from VSORRESU. | SDTM | 15 | ||||
| VSDTC | Date/Time of Measurements | Char | ISO 8601 | Derived | Aggregate ONLY(ODM.Value) over records whose StudyOID equals ODM.StudyOID, SubjectKey equals ODM.SubjectKey, StudyEventOID equals ODM.StudyEventOID and FormOID equals ODM.FormOID, where ODM.ItemOID = 'IT.VS.VSDTC'. | SDTM | 16 | |||
| VSDY | Study Day of Vital Signs | Num | Derived | CDISC study day of VSDT against RFSTDTC as day 1; there is no day zero. | SDTM | 17 |
| Template | Include when | VSTESTCD | VSORRES | VSORRESU |
|---|---|---|---|---|
| vs_reading | VSTESTCD IS NOT NULL | Copy VSTESTCD from the VS_MAPPING record whose ItemOID equals ODM.ItemOID, and no match yields blank | Aggregate ONLY(ODM.Value) over records matching on the shared output keys | Copy UNIT from the VS_MAPPING record whose ItemOID equals ODM.ItemOID, and no match yields blank |
| Variable | Permitted values |
|---|---|
| VSTESTCD | PULSE, SYSBP, DIABP |
| VSORRESU | beats/min, mmHg |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 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/sdtm-vs-planned-time-points/full.md
Edit38 linesFollowing CDISC SDTM standards, use the provided DM, ODM, and VS_MAPPING datasets to create a VS dataset with one record per collected vital-signs result.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, VSSEQ, VISIT, VSTPT, VSTPTNUM, VSELTM, VSTPTREF, VSRFTDTC, VSTESTCD, VSORRES, VSORRESU, VSSTRESN, VSSTRESU, VSDTC, VSDY
DOMAIN is "VS". STUDYID is the ODM study OID and USUBJID is the ODM subject key, each as given. VISIT is "DAY 1" on every record. Each planned time point is collected on its own vital-signs form, and the form fixes the planned time point of every result on it: VSTPT is "PRE-DOSE", "30 MIN POST-DOSE", "1 H POST-DOSE", or "4 H POST-DOSE" for the form. VSTPTNUM is the planned time point number for the form: 1, 2, 3, or 4 in schedule order. VSELTM is the planned elapsed time since the first dose for the form, in ISO 8601 duration form: "-PT15M" before the dose, then "PT30M", "PT1H", and "PT4H" after it. VSTPTREF is "FIRST DOSE" on every record, the reference time point VSELTM counts from. VSRFTDTC is the datetime of that first dose, the start datetime on the subject's dosing form, as given. VSTESTCD is the test short name the test dictionary gives for the result's item: "PULSE", "SYSBP", or "DIABP". An item with no dictionary entry, such as the collection datetime item or a dosing item, gives no record. VSORRES is the result in original units, the value on the test's item row within the form. VSORRESU is the original unit from the test dictionary: "beats/min" for pulse and "mmHg" for blood pressure. VSSTRESN is the numeric result in standard units; pulse and blood pressure were collected in standard units, so it equals the original result. VSSTRESU is the standard unit, the same as the original unit. VSDTC is the actual collection datetime from the form's datetime item row, the same for every result on that form. VSDY is the study day of the collection datetime, counted from the subject's reference start date in DM, and has no value when the subject has no reference start date. VSSEQ numbers each subject's records from 1 in schedule order by planned time point, then pulse, systolic blood pressure, and diastolic blood pressure within each time point. The planned elapsed time stays next to the actual collection datetime, so a reading taken later than planned keeps its late actual datetime.
Read the source datasets from /app/input and save the completed dataset as /app/output/vs.csv.
prompts/sdtm-vs-planned-time-points/conventions.md
Edit17 linesFollowing CDISC SDTM standards, use the provided DM, ODM, and VS_MAPPING datasets to create a VS dataset with one record per collected vital-signs result.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, VSSEQ, VISIT, VSTPT, VSTPTNUM, VSELTM, VSTPTREF, VSRFTDTC, VSTESTCD, VSORRES, VSORRESU, VSSTRESN, VSSTRESU, VSDTC, VSDY
DOMAIN is "VS". VISIT is "DAY 1" on every record. VSTPT is "PRE-DOSE", "30 MIN POST-DOSE", "1 H POST-DOSE", or "4 H POST-DOSE". VSTPTNUM is 1, 2, 3, or 4 in schedule order. VSELTM is in ISO 8601 duration form: "-PT15M", "PT30M", "PT1H", or "PT4H". VSTPTREF is "FIRST DOSE". VSTESTCD is "PULSE", "SYSBP", or "DIABP". VSDY is the study day of the collection datetime, counted from the subject's reference start date in DM, or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/vs.csv.
prompts/sdtm-vs-planned-time-points/brief.md
Edit10 linesFollowing CDISC SDTM standards, use the provided DM, ODM, and VS_MAPPING datasets to create a VS dataset with one record per collected vital-signs result.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, VSSEQ, VISIT, VSTPT, VSTPTNUM, VSELTM, VSTPTREF, VSRFTDTC, VSTESTCD, VSORRES, VSORRESU, VSSTRESN, VSSTRESU, VSDTC, VSDY
Read the source datasets from /app/input and save the completed dataset as /app/output/vs.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-vs-planned-time-points/result.R
Edit114 lines# Reference solution for the yamaa benchmark sdtm-vs-planned-time-points (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)library(readr)library(tidyr)study_day <- function(ref, coll) { if (is.na(ref) || is.na(coll)) { return(NA_integer_) } delta <- as.integer(coll - ref) if (delta >= 0L) delta + 1L else delta}time_point <- function(form) { name <- toupper(form) if (grepl("PREDOSE", name, fixed = TRUE)) { list(vstpt = "PRE-DOSE", vstptnum = 1L, vseltm = "-PT15M") } else if (grepl("30MIN", name, fixed = TRUE)) { list(vstpt = "30 MIN POST-DOSE", vstptnum = 2L, vseltm = "PT30M") } else if (grepl("1H", name, fixed = TRUE)) { list(vstpt = "1 H POST-DOSE", vstptnum = 3L, vseltm = "PT1H") } else if (grepl("4H", name, fixed = TRUE)) { list(vstpt = "4 H POST-DOSE", vstptnum = 4L, vseltm = "PT4H") } else { NULL }}dm <- read_csv( "/app/input/dm.csv", col_types = cols(.default = col_character()))odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))mapping <- read_csv( "/app/input/vs_mapping.csv", col_types = cols(.default = col_character()))ref_map <- setNames(suppressWarnings(ymd(dm$RFSTDTC)), dm$USUBJID)# The first-dose datetime on each subject's dosing form is the reference# time point every planned elapsed time counts from.doses <- odm |> filter(FormOID == "FO.EX", ItemOID == "IT.EX.EXSTDTC") |> select(SubjectKey, VSRFTDTC = Value)test_map <- setNames(mapping$VSTESTCD, mapping$ItemOID)unit_map <- setNames(mapping$UNIT, mapping$ItemOID)forms <- odm |> filter(StudyEventOID == "SE.D1", grepl("^FO\\.VS_", FormOID)) |> group_by(SubjectKey, FormOID, StudyOID) |> summarise( vsdtc = Value[ItemOID == "IT.VS.VSDTC"][1], .groups = "drop" )results <- odm |> filter( StudyEventOID == "SE.D1", grepl("^FO\\.VS_", FormOID), ItemOID %in% names(test_map), !is.na(Value) & Value != "" ) |> left_join(forms, by = c("SubjectKey", "FormOID", "StudyOID")) |> left_join(doses, by = "SubjectKey") |> rowwise() |> mutate( point = list(time_point(FormOID)), VSTPT = point$vstpt, VSTPTNUM = point$vstptnum, VSELTM = point$vseltm, VSTPTREF = "FIRST DOSE", VSTESTCD = test_map[[ItemOID]], VSORRES = Value, VSORRESU = unit_map[[ItemOID]], VSSTRESN = suppressWarnings(as.numeric(Value)), VSSTRESU = VSORRESU, VSDTC = vsdtc, ref = ref_map[[SubjectKey]], VSDY = study_day(ref, suppressWarnings(as_date(ymd_hms(VSDTC)))), test_ord = case_when( VSTESTCD == "PULSE" ~ 1L, VSTESTCD == "SYSBP" ~ 2L, .default = 3L ) ) |> ungroup() |> filter(!is.na(VSTPT), !is.na(VSDTC) & VSDTC != "") |> arrange(SubjectKey, VSTPTNUM, test_ord) |> group_by(SubjectKey) |> mutate(VSSEQ = row_number()) |> ungroup() |> arrange(SubjectKey, VSSEQ) |> transmute( DOMAIN = "VS", STUDYID = StudyOID, USUBJID = SubjectKey, VSSEQ, VISIT = "DAY 1", VSTPT, VSTPTNUM, VSELTM, VSTPTREF, VSRFTDTC, VSTESTCD, VSORRES, VSORRESU, VSSTRESN, VSSTRESU, VSDTC, VSDY )dir.create("/app/output", showWarnings = FALSE)write_csv(results, "/app/output/vs.csv", na = "")solutions/sdtm-vs-planned-time-points/result.py
Edit152 lines# Reference solution for the yamaa benchmark sdtm-vs-planned-time-points (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 the SDTM VS dataset from DM, ODM, and VS_MAPPING.One record per collected vital-signs result. Each vital-signs form fixesthe planned time point of every result on it; the form's datetime itemgives the actual collection datetime for all results on that form."""import csvfrom datetime import date, datetimefrom pathlib import PathINPUT = Path("/app/input")OUTPUT = Path("/app/output")# Form OID -> (VSTPT, VSTPTNUM, VSELTM)FORM_TIMEPOINTS = { "FO.VS_PREDOSE": ("PRE-DOSE", 1, "-PT15M"), "FO.VS_30MIN": ("30 MIN POST-DOSE", 2, "PT30M"), "FO.VS_1H": ("1 H POST-DOSE", 3, "PT1H"), "FO.VS_4H": ("4 H POST-DOSE", 4, "PT4H"),}# Test order within a time point for VSSEQ.TEST_ORDER = {"PULSE": 0, "SYSBP": 1, "DIABP": 2}COLUMNS = [ "DOMAIN", "STUDYID", "USUBJID", "VSSEQ", "VISIT", "VSTPT", "VSTPTNUM", "VSELTM", "VSTPTREF", "VSRFTDTC", "VSTESTCD", "VSORRES", "VSORRESU", "VSSTRESN", "VSSTRESU", "VSDTC", "VSDY",]def read_csv(path): with open(path, newline="", encoding="utf-8") as handle: return list(csv.DictReader(handle))def study_day(collection, reference): """SDTM study day: reference day is day 1, no day zero.""" if not collection or not reference: return "" delta = (collection - reference).days return delta + 1 if delta >= 0 else deltadef numeric_text(value): number = float(value) return str(int(number)) if number == int(number) else str(number)def main(): dm_rows = read_csv(INPUT / "dm.csv") odm_rows = read_csv(INPUT / "odm.csv") mapping_rows = read_csv(INPUT / "vs_mapping.csv") reference_start = {} for row in dm_rows: value = (row.get("RFSTDTC") or "").strip() reference_start[row["USUBJID"]] = ( datetime.strptime(value[:10], "%Y-%m-%d").date() if value else None ) dictionary = { row["ItemOID"]: (row["VSTESTCD"], row["UNIT"]) for row in mapping_rows } # The first-dose datetime on each subject's dosing form is the reference # time point every planned elapsed time counts from. first_dose = { row["SubjectKey"]: row["Value"].strip() for row in odm_rows if row["FormOID"] == "FO.EX" and row["ItemOID"] == "IT.EX.EXSTDTC" } # Group ODM item rows by subject and form occurrence. forms = {} for row in odm_rows: form_oid = row["FormOID"] if form_oid not in FORM_TIMEPOINTS: continue key = ( row["StudyOID"], row["SubjectKey"], row["StudyEventOID"], row["StudyEventRepeatKey"], form_oid, row["FormRepeatKey"], row["ItemGroupOID"], row["ItemGroupRepeatKey"], ) forms.setdefault(key, {})[row["ItemOID"]] = row["Value"] records = [] for key, items in forms.items(): study_id, subject = key[0], key[1] vstpt, vstptnum, vseltm = FORM_TIMEPOINTS[key[4]] vsdtc = (items.get("IT.VS.VSDTC") or "").strip() collection_date = ( datetime.strptime(vsdtc[:10], "%Y-%m-%d").date() if vsdtc else None ) vsdy = study_day(collection_date, reference_start.get(subject)) for item_oid, (testcd, unit) in dictionary.items(): if item_oid not in items: continue value = items[item_oid] records.append( { "DOMAIN": "VS", "STUDYID": study_id, "USUBJID": subject, "VISIT": "DAY 1", "VSTPT": vstpt, "VSTPTNUM": vstptnum, "VSELTM": vseltm, "VSTPTREF": "FIRST DOSE", "VSRFTDTC": first_dose.get(subject, ""), "VSTESTCD": testcd, "VSORRES": value, "VSORRESU": unit, "VSSTRESN": numeric_text(value), "VSSTRESU": unit, "VSDTC": vsdtc, "VSDY": vsdy, "_test_order": TEST_ORDER[testcd], } ) records.sort( key=lambda r: (r["USUBJID"], r["VSTPTNUM"], r["_test_order"]) ) counters = {} for record in records: subject = record["USUBJID"] counters[subject] = counters.get(subject, 0) + 1 record["VSSEQ"] = counters[subject] del record["_test_order"] OUTPUT.mkdir(parents=True, exist_ok=True) with open(OUTPUT / "vs.csv", "w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=COLUMNS) writer.writeheader() writer.writerows(records)if __name__ == "__main__": main()solutions/sdtm-vs-planned-time-points/result.sas
Edit55 lines/* opensas reference solution for the yamaa benchmark sdtm-vs-planned-time-points. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data dm; length STUDYID USUBJID RFSTDTC $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. RFSTDTC : $char1024.;run;data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. FormOID : $char1024. FormRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;data vs_mapping; length ItemOID VSTESTCD VSTEST UNIT $1024; infile "/app/input/vs_mapping.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input ItemOID : $char1024. VSTESTCD : $char1024. VSTEST : $char1024. UNIT : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey; run;data dates; length VSDTC $1024; retain VSDTC; set ordered; where ItemGroupOID='IG.VS'; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey; if first.FormRepeatKey then do; VSDTC=''; end; if ItemOID='IT.VS.VSDTC' then VSDTC=Value; if last.FormRepeatKey then output;run;/* The first-dose datetime on the dosing form is the reference time point. */data doses; set odm; where FormOID='FO.EX' and ItemOID='IT.EX.EXSTDTC'; length VSRFTDTC $1024; VSRFTDTC=Value; keep StudyOID SubjectKey VSRFTDTC; run;proc sql; create table joined as select a.*,b.VSDTC,c.VSTESTCD,c.UNIT,d.RFSTDTC,e.VSRFTDTC from odm a inner join dates b on a.StudyOID=b.StudyOID and a.SubjectKey=b.SubjectKey and a.StudyEventOID=b.StudyEventOID and a.StudyEventRepeatKey=b.StudyEventRepeatKey and a.FormOID=b.FormOID and a.FormRepeatKey=b.FormRepeatKey inner join vs_mapping c on a.ItemOID=c.ItemOID left join dm d on a.StudyOID=d.STUDYID and a.SubjectKey=d.USUBJID left join doses e on a.StudyOID=e.StudyOID and a.SubjectKey=e.SubjectKey; quit;data prepared; set joined; length DOMAIN $2 STUDYID USUBJID VISIT VSTPT VSELTM VSTPTREF VSORRES VSORRESU VSSTRESU $1024; DOMAIN='VS'; VSTPTREF='FIRST DOSE'; STUDYID=StudyOID; USUBJID=SubjectKey; VISIT='DAY 1'; VSTPT=''; VSELTM=''; VSTPTNUM=.;if FormOID='FO.VS_PREDOSE' then do; VSTPT='PRE-DOSE'; VSTPTNUM=1; VSELTM='-PT15M'; end;if FormOID='FO.VS_30MIN' then do; VSTPT='30 MIN POST-DOSE'; VSTPTNUM=2; VSELTM='PT30M'; end;if FormOID='FO.VS_1H' then do; VSTPT='1 H POST-DOSE'; VSTPTNUM=3; VSELTM='PT1H'; end;if FormOID='FO.VS_4H' then do; VSTPT='4 H POST-DOSE'; VSTPTNUM=4; VSELTM='PT4H'; end;VSORRES=Value; VSORRESU=UNIT; VSSTRESU=UNIT; VSSTRESN=input(Value,best32.); VSDY=.; if lengthn(VSDTC)>=10 and lengthn(RFSTDTC)>=10 then do; VSDY=input(substr(VSDTC,1,10),yymmdd10.)-input(substr(RFSTDTC,1,10),yymmdd10.); if VSDY>=0 then VSDY+1; end;TESTORD=3; if VSTESTCD='PULSE' then TESTORD=1; if VSTESTCD='SYSBP' then TESTORD=2; run;proc sort data=prepared; by STUDYID USUBJID VSTPTNUM TESTORD; run;data result; set prepared; by STUDYID USUBJID; retain VSSEQ; if first.USUBJID then VSSEQ=0; VSSEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, VSSEQ, VISIT, VSTPT, VSTPTNUM, VSELTM, VSTPTREF, VSRFTDTC, VSTESTCD, VSORRES, VSORRESU, VSSTRESN, VSSTRESU, VSDTC, VSDY from result;quit;proc export data=final outfile="/app/output/vs.csv" dbms=csv replace; run;
yamaa