← Previous: AE Explorer Next: AE Timelines Workflow →

This example runs the AE Explorer report through the same workr YAML workflow that a tester or downstream package can execute directly: inst/workflow/3_reports/ae_explorer.yaml. The YAML stores meta$widgetSettings, calls safetyCharts::init_aeExplorer(), then saves the initialized widget as a standalone HTML report with gsm.safety::RenderSafetyChartsWidget().

workflow_path <- system.file(
  "workflow", "3_reports", "ae_explorer.yaml",
  package = "gsm.safety"
)
if (!nzchar(workflow_path)) {
  workflow_path <- file.path("inst", "workflow", "3_reports", "ae_explorer.yaml")
}

lWorkflow <- yaml::read_yaml(workflow_path)
lData <- gsm.safety::MakeExampleData()

The workflow YAML is the report contract. It maps GSM workflow data into the safetyCharts AE Explorer shape, initializes the widget with safetyCharts::init_aeExplorer(), and writes the rendered HTML report with the generic renderer.

Workflow YAML
meta:
  Type: Report
  ID: ae_explorer
  Output: html
  Name: AE Explorer Report
  Description: AE Explorer report scaffold for SafetyGraphics-style adverse event review
  ParentIssue: 10
  domains:
    dm: Mapped_SUBJ
    aes: Mapped_AE
  widgetName: aeExplorer
  widgetSettings:
    dm:
      id_col: subjid
      treatment_col: sex
    aes:
      id_col: subjid
      term_col: mdrpt_nsv
      bodsys_col: mdrsoc_nsv
  optionalFilters:
    seriousness: aeser
    severity: aetoxgr
    relationship: aerel
  knownGaps:
    aeout: No current Mapped_AE outcome field identified.
spec:
  Mapped_SUBJ:
    _all:
      required: true
    subjid:
      type: character
    sex:
      type: character
      required: false
  Mapped_AE:
    _all:
      required: true
    subjid:
      type: character
    mdrpt_nsv:
      type: character
    mdrsoc_nsv:
      type: character
    aeser:
      type: character
      required: false
    aetoxgr:
      type: integer
      required: false
    aerel:
      type: character
      required: false
steps:
  - output: AeExplorerData
    name: list
    params:
      dm: Mapped_SUBJ
      aes: Mapped_AE
  - output: InitializedAeExplorer
    name: safetyCharts::init_aeExplorer
    params:
      data: AeExplorerData
      settings: widgetSettings
  - output: strOutputDir
    name: getwd
  - output: Report
    name: gsm.safety::RenderSafetyChartsWidget
    params:
      lInitialized: InitializedAeExplorer
      strWidgetName: widgetName
      strOutputDir: strOutputDir
      strOutputFile: ID

Run the workflow with the example mapped data:

lReport <- workr::RunWorkflow(
  lWorkflow = lWorkflow,
  lData = lData,
  bReturnResult = TRUE
)
#> [INFO] Initializing `Report_ae_explorer` Workflow
#> [INFO] Checking data against spec
#> [INFO] Workflow Step 1 of 4: `list`
#> [INFO] Evaluating 2 parameter(s) for `list`
#> [INFO] dm = Mapped_SUBJ: Passing lData$Mapped_SUBJ.
#> [INFO] aes = Mapped_AE: Passing lData$Mapped_AE.
#> [INFO] Calling `list`
#> [INFO] list of length 2 saved as `lData$AeExplorerData`.
#> [INFO] Workflow Step 2 of 4: `safetyCharts::init_aeExplorer`
#> [INFO] Evaluating 2 parameter(s) for `safetyCharts::init_aeExplorer`
#> [INFO] data = AeExplorerData: Passing lData$AeExplorerData.
#> [INFO] settings = widgetSettings: Passing lMeta$widgetSettings.
#> [INFO] Calling `safetyCharts::init_aeExplorer`
#> [INFO] list of length 2 saved as `lData$InitializedAeExplorer`.
#> [INFO] Workflow Step 3 of 4: `getwd`
#> [INFO] Evaluating 0 parameter(s) for `getwd`
#> [INFO] Calling `getwd`
#> [INFO] character of length 1 saved as `lData$strOutputDir`.
#> [INFO] Workflow Step 4 of 4: `gsm.safety::RenderSafetyChartsWidget`
#> [INFO] Evaluating 4 parameter(s) for `gsm.safety::RenderSafetyChartsWidget`
#> [INFO] lInitialized = InitializedAeExplorer: Passing lData$InitializedAeExplorer.
#> [INFO] strWidgetName = widgetName: Passing lMeta$widgetName.
#> [INFO] strOutputDir = strOutputDir: Passing lData$strOutputDir.
#> [INFO] strOutputFile = ID: Passing lMeta$ID.
#> [INFO] Calling `gsm.safety::RenderSafetyChartsWidget`
#> [INFO] list of length 3 saved as `lData$Report`.
#> [INFO] Returning results from final step: list of length 3`.
#> [INFO] Completed `Report_ae_explorer` Workflow

lReport$path
#> [1] "/home/runner/work/gsm.safety/gsm.safety/pkgdown/menus/examples/ae_explorer.html"