Skip to content

Feature request: SDTM input (EX to PKNCAdose)#517

Open
Gero1999 wants to merge 9 commits intohumanpred:mainfrom
Gero1999:516-sdtm-input
Open

Feature request: SDTM input (EX to PKNCAdose)#517
Gero1999 wants to merge 9 commits intohumanpred:mainfrom
Gero1999:516-sdtm-input

Conversation

@Gero1999
Copy link
Copy Markdown
Contributor

@Gero1999 Gero1999 commented Mar 16, 2026

Closes #516

This PR introduces ex_to_PKNCAdose to convert SDTM EX (Exposure) domain data into a PKNCAdose object, along with shared SDTM helpers and unit tests.

Key changes

ex_to_PKNCAdose

  • Parses ISO 8601 date-times (EXSTDTC, EXENDTC, EXRFTDTC) with mixed precision
  • Derives EXDUR from EXENDTC - EXSTDTC when not pre-existing
  • Derives EXELTM from EXSTDTC - EXRFTDTC when not pre-existing; parses ISO 8601 duration strings (e.g. "PT2H") to numeric hours when character
  • Derives AFRLT (actual time from reference) as hours from first dose per subject
  • Derives NFRLT (nominal time from reference) as (EXRFTDTC + EXELTM) - min(EXRFTDTC) per dose grouping (EXTRT + USUBJID), used as time.nominal in the PKNCAdose object
  • Maps CDISC routes to PKNCA "intravascular" / "extravascular"
  • All time-related columns (EXDUR, EXELTM, EXRFTDTC, EXROUTE, EXDOSU) are optional — the function adapts to what's available

Shared internal helpers (extracted as top-level @keywords internal)

  • std_dtc_to_rdate — ISO 8601 date-time parsing with mixed precision
  • parse_iso8601_duration — ISO 8601 duration to numeric hours (supports negative values)
  • route_cdisc_to_pknca — CDISC route mapping

NFRLT derivation

When both EXRFTDTC and EXELTM are present, NFRLT is derived per dose grouping as a continuous nominal time axis. When either is absent, NFRLT is not derived and time.nominal is omitted from the PKNCAdose object.

Tests

  • Helper functions: std_dtc_to_rdate, parse_iso8601_duration, route_cdisc_to_pknca
  • ex_to_PKNCAdose: basic object creation, oral/IV duration, route mapping, relative time, mixed precision, EXELTM derivation, pre-existing EXDUR/EXELTM, minimal datasets
  • NFRLT: numeric EXELTM, ISO 8601 EXELTM, time.nominal assignment, absent EXRFTDTC fallback, per-treatment-group derivation

Gero1999 and others added 6 commits March 16, 2026 14:16
This script simulates a Phase I dose-escalation study with various parameters for drug exposure. It creates a data frame for the SDTM EX domain, detailing subjects, treatments, doses, and timing.
Add tests for ex_to_PKNCAdose function covering various scenarios including handling of oral doses, IV infusions, duration calculations, and optional columns.
@Gero1999 Gero1999 marked this pull request as ready for review March 16, 2026 16:52
Extract std_dtc_to_rdate, parse_iso8601_duration, and
route_cdisc_to_pknca as top-level internal helpers.

Parse EXELTM from ISO 8601 duration to numeric hours when character.
Derive NFRLT = (EXRFTDTC + EXELTM) - min(EXRFTDTC) per dose grouping
and use it as time.nominal in PKNCAdose instead of raw EXELTM.

Co-authored-by: Ona <no-reply@ona.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: SDTM input functions

1 participant