Skip to content

fix: support basic SDTM domains (dm/ex/pc) in reformat_data_sdtm_to_modeling#6

Merged
roninsightrx merged 3 commits intomainfrom
reformat-modeling-doses
Apr 3, 2026
Merged

fix: support basic SDTM domains (dm/ex/pc) in reformat_data_sdtm_to_modeling#6
roninsightrx merged 3 commits intomainfrom
reformat-modeling-doses

Conversation

@roninsightrx
Copy link
Copy Markdown
Contributor

Summary

  • Derives ADSL from DM when ADSL is not provided, so users with only basic SDTM domains (dm, ex, pc) can create modeling datasets
  • Makes VS and LB domains optional for covariate derivation (WT defaults to NA when VS missing)
  • Builds param_lookup dynamically from actual PCTESTCD values instead of hardcoding DRUGX
  • Fixes ignore_seconds_flag compatibility with admiral 1.4.0+ (default changed from FALSE to TRUE)
  • Fixes invalid !!!adsl_vars splice inside c() in keep_source_vars
  • Adds 33 tests for all SDTM reformatting paths

Test plan

  • Tested with real SDTM data (CDISC pilot: dm + ex + pc only)
  • Tested with explicit ADSL — produces identical results
  • Full test suite passes (258/258, 0 failures)
  • Verified compatibility with admiral 1.4.1

🤖 Generated with Claude Code

…odeling

The function previously required adsl, vs, and lb domains but many users
only have basic SDTM domains. This change:

- Derives ADSL from DM when ADSL is not provided (RFXSTDTC → TRTSDT/TRTSDTM,
  ARM/ACTARM → TRT01P/TRT01A)
- Makes EX→ADSL merge conditional (matching existing PC pattern)
- Makes VS and LB domains optional for covariate derivation
- Builds param_lookup dynamically from actual PCTESTCD values instead of
  hardcoding DRUGX
- Fixes invalid !!!adsl_vars splice in keep_source_vars
- Sets ignore_seconds_flag=FALSE for admiral 1.4.0+ compatibility
- Adds 33 tests covering all SDTM reformatting paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends reformat_data_sdtm_to_modeling() to support generating modeling (NONMEM-style) datasets from “basic” SDTM inputs (DM/EX/PC), including deriving ADSL when not provided, and adds comprehensive test coverage for the SDTM reformatting paths.

Changes:

  • Derive ADSL from DM when ADSL is absent; make VS/LB optional for covariate derivations (ensuring WT exists even without VS).
  • Build param_lookup dynamically from observed PCTESTCD values rather than hardcoding a specific analyte.
  • Add an extensive testthat suite for SDTM → modeling reformatting behaviors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
R/reformat_data_sdtm_to_modeling.R Adds ADSL-from-DM derivation, dynamic param_lookup, optional VS/LB handling, and minor output-shaping adjustments.
tests/testthat/test-reformat_data_sdtm_to_modeling.R Adds a full set of unit tests covering basic SDTM inputs and key dataset invariants (EVID/MDV/TIME/covariates).
DESCRIPTION Bumps development version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

roninsightrx and others added 2 commits April 2, 2026 21:17
Tests cover default na="." replacement, na=NA pass-through,
na=NULL (skip conversion), and custom na=-99. Updates existing
tests to account for new default NA→"." conversion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@roninsightrx roninsightrx merged commit 61befbb into main Apr 3, 2026
3 checks passed
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.

2 participants