Create a static shiny app

In this vignette we show the basis to create shiny apps. To do so we will use the mock results provided by the package:

library(OmopViewer)
omopViewerResults
#> # A tibble: 39,264 × 13
#>    result_id cdm_name            group_name group_level strata_name strata_level
#>        <int> <chr>               <chr>      <chr>       <chr>       <chr>       
#>  1         1 synthea-covid19-20… overall    overall     overall     overall     
#>  2         1 synthea-covid19-20… overall    overall     overall     overall     
#>  3         1 synthea-covid19-20… overall    overall     overall     overall     
#>  4         1 synthea-covid19-20… overall    overall     overall     overall     
#>  5         1 synthea-covid19-20… overall    overall     overall     overall     
#>  6         1 synthea-covid19-20… overall    overall     overall     overall     
#>  7         1 synthea-covid19-20… overall    overall     overall     overall     
#>  8         1 synthea-covid19-20… overall    overall     overall     overall     
#>  9         1 synthea-covid19-20… overall    overall     overall     overall     
#> 10         1 synthea-covid19-20… overall    overall     overall     overall     
#> # ℹ 39,254 more rows
#> # ℹ 7 more variables: variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>
summary(omopViewerResults)
#> A summarised_result object with 39264 rows, 95 different result_id, 1 different
#> cdm names, and 44 settings.
#> CDM names: synthea-covid19-200k.
#> Settings: result_type, package_name, package_version, group, strata,
#> additional, min_cell_count, analysis, analysis_censor_cohort_name,
#> analysis_complete_database_intervals, analysis_full_contribution,
#> analysis_outcome_washout, analysis_repeated_events, analysis_type, censor_date,
#> cohort_definition_id, cohort_table_name, denominator_age_group, …, type, and
#> unknown_indication_table.

Let’s use a subset of the default result data set:

result <- omopViewerResults |>
  omopgenerics::filterSettings(
    result_type %in% c("summarise_omop_snapshot", "summarise_characteristics", "incidence")
  )

Using the default parameters you only have to provide a directory and a object.

exportStaticApp(result = result, directory = tempdir())
#> ℹ Processing data
#> ✔ Data processed: 3 panels idenfied: `summarise_omop_snapshot`,
#>   `summarise_characteristics`, and `incidence`.
#> ℹ Creating shiny from provided data
#> `analysis`, `analysis_full_contribution`, `analysis_type`, `censor_date`,
#> `cohort_definition_id`, `cohort_table_name`, `gap_era`, `incident`,
#> `index_date`, `indication_cohort_name`, `interval`, `mutually_exclusive`,
#> `overlap_by`, `prior_drug_observation`, `prior_use_washout`,
#> `restrict_incident`, `restrict_to_first_discontinuation`,
#> `restrict_to_first_entry`, …, `type`, and `unknown_indication_table` eliminated
#> from settings as all elements are NA.
#> ✔ Shiny created in:
#>   /var/folders/pl/k11lm9710hlgl02nvzx4z9wr0000gp/T//RtmpRMcqhi/shiny

The panels that will be created are defined by the panelDetails argument. By default, a tab is created by each result_type of the result object. The default tab getPanel("default") is used if no tab is defined for that result_type in omopViewerPanels. Let’s see the default panelDetails:

panelDetails <- panelDetailsFromResult(result)
panelDetails
#> $summarise_omop_snapshot
#> Snapshot (OmopViewer panel)
#> • icon: clipboard-list
#> • data: result_type: <summarise_omop_snapshot>
#> • filters: 1 filters + 1 automatic filters
#> • content: Tidy (DT); Table Snapshot (gt)
#> 
#> $summarise_characteristics
#> Cohort Characteristics (OmopViewer panel)
#> • icon: users-gear
#> • data: result_type: <summarise_characteristics>
#> • filters: 1 filters + 4 automatic filters
#> • content: Tidy (DT); Table Characteristics (gt); Plot Characteristics (plot)
#> 
#> $incidence
#> Incidence (OmopViewer panel)
#> • icon: chart-line
#> • data: result_type: <incidence>
#> • filters: 1 filters + 6 automatic filters
#> • content: Tidy (DT); Table Incidence (gt); Plot Incidence (plot)