Skip to contents

Reads dataset files from a directory, validates them, optionally converts format, generates Define-XML, and produces validation reports and a manifest with SHA-256 checksums.

Data files are copied as-is when the input and output formats are the same (no re-encoding). Format conversion (e.g. JSON → XPT) re-reads and writes.

Usage

submit(
  path,
  output = path,
  spec = NULL,
  config = NULL,
  rules = "all",
  standard = NULL,
  version = NULL,
  define = TRUE,
  report = TRUE,
  manifest = TRUE,
  format = "xpt",
  output_format = format,
  xpt_version = 5L,
  ct_path = NULL
)

Arguments

path

Character. Path to a directory containing dataset files.

output

Character. Output directory where submission artifacts are written. Defaults to path (eCTD convention: define.xml lives alongside the data files). Override when the input directory is read-only.

spec

A herald_spec object, a path to a spec file (.xlsx, .xml, .json), or NULL.

config

Optional. A herald-rules submission config identifier string (e.g., "fda-sdtm-ig-3.3", "pmda-adam-ig-1.1"). Takes precedence over rules. When NULL, auto-selected from standard + version (defaults to FDA authority) if a matching bundled config exists.

rules

Character shortcut ("fda", "pmda", "core", "all"), or a list of herald_rule objects. Defaults to "all" so that full conformance checking runs on every submission when no config is auto-selected. Ignored when config is provided. Set to NULL to run spec checks only.

standard

Character. CDISC standard: "sdtmig", "adamig", or "sendig". When spec is provided, read from the standard column of the dataset sheet. When no spec is given this parameter is required for anchor auto-detection.

version

Character. Standard version, e.g. "3.4".

define

Logical. Generate Define-XML and define.html? Requires spec and the xml2 package. Default TRUE.

report

Logical. Generate validation reports (HTML + XLSX)? Default TRUE.

manifest

Logical. Generate manifest.json with SHA-256 checksums? Default TRUE.

format

Input file format: "xpt" (default) or "json".

output_format

Output data file format. Default is the same as format. Set to "xpt" or "json" to convert.

xpt_version

Integer. XPT transport version for output: 5L (default, FDA submission standard) or 8L (extended names/labels). Only used when output_format = "xpt".

ct_path

Optional character. Path to a custom controlled terminology file (.xlsx or .csv, NCI EVS column layout) applied to this submission only. For session-wide CT use register_ct().

Value

A herald_submission object (invisibly) with paths and validation results.

See also

validate() for conformance only, write_xpt() for XPT only, write_define_xml() for Define-XML only, read_spec() for spec input.

Examples

spec <- herald_spec(
  ds_spec = data.frame(dataset = "DM", label = "Demographics",
                       stringsAsFactors = FALSE),
  var_spec = data.frame(
    dataset = "DM", variable = c("STUDYID", "AGE"),
    label = c("Study ID", "Age"), data_type = c("text", "integer"),
    length = c("12", "8"), stringsAsFactors = FALSE
  )
)
dm <- data.frame(STUDYID = "S1", AGE = 65L, stringsAsFactors = FALSE)

dir <- tempfile()
dir.create(dir)
write_xpt(dm, file.path(dir, "dm.xpt"), dataset = "DM")
result <- submit(dir, spec = spec, rules = NULL, define = FALSE, report = FALSE,
                 manifest = FALSE)
result$validation
#> 
#> ── herald validation ──
#> 
#> Datasets checked: 1
#>  Spec checks only -- no conformance rules evaluated
#> Findings: 0 reject, 0 high, 3 medium, 0 low
unlink(dir, recursive = TRUE)