This example runs the Safety Outlier Explorer report through a
workr YAML workflow:
inst/workflow/3_reports/safety_outlier_explorer.yaml. The
YAML stores the widget settings, initializes the widget when a
safetyCharts init_* helper is available, and writes the
rendered HTML report with
gsm.safety::RenderSafetyChartsWidget().
workflow_path <- system.file(
"workflow", "3_reports", "safety_outlier_explorer.yaml",
package = "gsm.safety"
)
if (!nzchar(workflow_path)) {
workflow_path <- file.path("inst", "workflow", "3_reports", "safety_outlier_explorer.yaml")
}
lWorkflow <- yaml::read_yaml(workflow_path)
lData <- gsm.safety::MakeExampleData()
The workflow YAML is the report contract:
meta:
Type: Report
ID: safety_outlier_explorer
Output: html
Name: Safety Outlier Explorer Report
Description: Safety Outlier Explorer report scaffold for SafetyCharts lab review
ParentIssue: 23
domains:
dm: Mapped_SUBJ
labs: Mapped_LB
widgetName: safetyOutlierExplorer
widgetSettings:
dm:
id_col: subjid
age_col: age
sex_col: sex
race_col: race
labs:
id_col: subjid
visit_col: visit
visitn_col: visitn
studyday_col: studyday
measure_col: measure
value_col: value
normal_col_low: normal_low
normal_col_high: normal_high
group_by: sex
group_cols:
- value_col: sex
label: Sex
spec:
Mapped_SUBJ:
_all:
required: true
subjid:
type: character
age:
type: integer
required: false
sex:
type: character
required: false
race:
type: character
required: false
Mapped_LB:
_all:
required: true
subjid:
type: character
visit:
type: character
visitn:
type: integer
studyday:
type: integer
measure:
type: character
value:
type: numeric
unit:
type: character
required: false
normal_low:
type: numeric
required: false
normal_high:
type: numeric
required: false
baseline_flag:
type: character
required: false
steps:
- output: WidgetData
name: list
params:
dm: Mapped_SUBJ
labs: Mapped_LB
- output: InitializedWidget
name: safetyCharts::init_safetyOutlierExplorer
params:
data: WidgetData
settings: widgetSettings
- output: strOutputDir
name: getwd
- output: Report
name: gsm.safety::RenderSafetyChartsWidget
params:
lInitialized: InitializedWidget
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_safety_outlier_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] labs = Mapped_LB: Passing lData$Mapped_LB.
#> [INFO] Calling `list`
#> [INFO] list of length 2 saved as `lData$WidgetData`.
#> [INFO] Workflow Step 2 of 4: `safetyCharts::init_safetyOutlierExplorer`
#> [INFO] Evaluating 2 parameter(s) for `safetyCharts::init_safetyOutlierExplorer`
#> [INFO] data = WidgetData: Passing lData$WidgetData.
#> [INFO] settings = widgetSettings: Passing lMeta$widgetSettings.
#> [INFO] Calling `safetyCharts::init_safetyOutlierExplorer`
#> [INFO] list of length 2 saved as `lData$InitializedWidget`.
#> [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 = InitializedWidget: Passing lData$InitializedWidget.
#> [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_safety_outlier_explorer` Workflow
lReport$path
#> [1] "/home/runner/work/gsm.safety/gsm.safety/pkgdown/menus/examples/safety_outlier_explorer.html"