← Previous: AE Explorer Workflow Next: Hep Explorer Workflow →

This example runs the AE Timelines report through a workr YAML workflow: inst/workflow/3_reports/ae_timelines.yaml. The YAML stores the widget settings, calls safetyCharts::init_aeTimelines(), then writes the rendered HTML report with gsm.safety::RenderSafetyChartsWidget().

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

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

The workflow YAML is the report contract:

Workflow YAML
meta:
  Type: Report
  ID: ae_timelines
  Output: html
  Name: AE Timelines Report
  Description: AE Timelines report scaffold for SafetyGraphics-style adverse event chronology review
  ParentIssue: 17
  domains:
    aes: Mapped_AE
  widgetName: aeTimelines
  widgetSettings:
    id_col: subjid
    stdy_col: aestdy
    endy_col: aeendy
    seq_col: aeseq
    term_col: mdrpt_nsv
    serious_col: aeser
    severity_col: aesev
spec:
  Mapped_AE:
    _all:
      required: true
    subjid:
      type: character
    aestdy:
      type: integer
    aeendy:
      type: integer
    aeseq:
      type: integer
    mdrpt_nsv:
      type: character
    aeser:
      type: character
      required: false
    aesev:
      type: character
      required: false
steps:
  - output: InitializedAeTimelines
    name: safetyCharts::init_aeTimelines
    params:
      data: Mapped_AE
      settings: widgetSettings
  - output: strOutputDir
    name: getwd
  - output: Report
    name: gsm.safety::RenderSafetyChartsWidget
    params:
      lInitialized: InitializedAeTimelines
      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_timelines` Workflow
#> [INFO] Checking data against spec
#> [INFO] Workflow Step 1 of 3: `safetyCharts::init_aeTimelines`
#> [INFO] Evaluating 2 parameter(s) for `safetyCharts::init_aeTimelines`
#> [INFO] data = Mapped_AE: Passing lData$Mapped_AE.
#> [INFO] settings = widgetSettings: Passing lMeta$widgetSettings.
#> [INFO] Calling `safetyCharts::init_aeTimelines`
#> [INFO] list of length 2 saved as `lData$InitializedAeTimelines`.
#> [INFO] Workflow Step 2 of 3: `getwd`
#> [INFO] Evaluating 0 parameter(s) for `getwd`
#> [INFO] Calling `getwd`
#> [INFO] character of length 1 saved as `lData$strOutputDir`.
#> [INFO] Workflow Step 3 of 3: `gsm.safety::RenderSafetyChartsWidget`
#> [INFO] Evaluating 4 parameter(s) for `gsm.safety::RenderSafetyChartsWidget`
#> [INFO] lInitialized = InitializedAeTimelines: Passing lData$InitializedAeTimelines.
#> [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_timelines` Workflow

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