From 3bd09aaf09b2a675891a16abd0260c1372282b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=BAria=20Mercad=C3=A9-Besora?= <61558739+nmercadeb@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:50:32 +0100 Subject: [PATCH 1/3] Update shinyDiagnostics.R --- R/shinyDiagnostics.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/shinyDiagnostics.R b/R/shinyDiagnostics.R index cff1b38..5993d9a 100644 --- a/R/shinyDiagnostics.R +++ b/R/shinyDiagnostics.R @@ -14,6 +14,11 @@ shinyDiagnostics <- function(result, rlang::check_installed("omopViewer") result |> - omopViewer::exportStaticApp(directory = directory) - + omopViewer::exportStaticApp( + directory = directory, + background = c( + "header" = "phenotypeR diagnostics", + "body" = "This Shiny App contains results generated by the (phenotypeR)[https://ohdsi.github.io/phenotypeR/] package (version {as.character(utils::packageVersion('CohortCharacteristics'))}) to support the assessment of cohorts in the OMOP CDM." |> glue::glue() + ) + ) } From 4c340a1479c1429e5a5c4cae9eeb6683989380a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=BAria=20Mercad=C3=A9-Besora?= <61558739+nmercadeb@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:44:03 +0100 Subject: [PATCH 2/3] add phenotypeR background --- R/shinyDiagnostics.R | 73 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/R/shinyDiagnostics.R b/R/shinyDiagnostics.R index 5993d9a..da1ed6c 100644 --- a/R/shinyDiagnostics.R +++ b/R/shinyDiagnostics.R @@ -16,9 +16,74 @@ shinyDiagnostics <- function(result, result |> omopViewer::exportStaticApp( directory = directory, - background = c( - "header" = "phenotypeR diagnostics", - "body" = "This Shiny App contains results generated by the (phenotypeR)[https://ohdsi.github.io/phenotypeR/] package (version {as.character(utils::packageVersion('CohortCharacteristics'))}) to support the assessment of cohorts in the OMOP CDM." |> glue::glue() - ) + background = getBackground(result) ) } + +getBackground <- function(results) { + + cohorts <- result |> + visOmopResults::filterSettings(table_name == "my_cohort") |> + dplyr::distinct(.data$group_name, .data$group_level) |> + visOmopResults::splitGroup() + + if ("cohort_name" %in% colnames(cohorts)) { + cohorts <- c( + "title" = "**Cohorts**", + "body" = "The diagnostic results cover the following cohorts: {paste0(unique(cohorts$cohort_name), collapse = ', ')}" |> glue::glue() + ) + } else { + cohorts <- character() + } + + codelists <- result |> + visOmopResults::filterSettings(result_type == "cohort_code_use") |> + dplyr::distinct(.data$group_name, .data$group_level) |> + visOmopResults::splitGroup() + + if ("codelist_name" %in% colnames(codelists)) { + codelists <- c( + "title" = "**Codelists**", + "body" = "Diagnostics have been generated for these codelists: {paste0(unique(codelists$codelist_name), collapse = ', ')}" |> glue::glue() + ) + } else { + codelists <- character() + } + + databases <- result |> + dplyr::filter(!is.na(.data$cdm_name)) |> + dplyr::pull("cdm_name") |> + unique() + + if (length(databases) > 0) { + databases <- c( + "title" = "**Databases**", + "body" = "The results are based on data from the following databases: {paste0(databases, collapse = ', ')}" |> glue::glue() + ) + } else { + databases <- character() + } + + resTypes <- settings(result) |> + dplyr::filter(!is.na(.data$result_type)) |> + dplyr::pull("result_type") |> + unique() + + if (length(resTypes) > 0) { + resTypes <- c( + "title" = "**Results**", + "body" = "The following results are available: {paste0(resTypes, collapse = ', ')}" |> glue::glue() + ) + } else { + resTypes <- character() + } + + c( + "header" = "phenotypeR Diagnostics", + cohorts, + codelists, + databases, + resTypes, + "footer" = "This Shiny App presents results generated using the [phenotypeR](https://ohdsi.github.io/phenotypeR/) package (version {as.character(utils::packageVersion('phenotypeR'))})." |> glue::glue() + ) +} From d4293d42f6639895bb4f38ea4f3ac3537e180c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=BAria=20Mercad=C3=A9-Besora?= <61558739+nmercadeb@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:51:12 +0100 Subject: [PATCH 3/3] notes --- DESCRIPTION | 3 ++- R/shinyDiagnostics.R | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b3f8298..90f4aae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,7 +47,8 @@ Imports: rlang, shiny, vctrs, - visOmopResults + visOmopResults, + glue URL: https://oxford-pharmacoepi.github.io/phenotypeR/ VignetteBuilder: knitr Remotes: diff --git a/R/shinyDiagnostics.R b/R/shinyDiagnostics.R index da1ed6c..c24bba9 100644 --- a/R/shinyDiagnostics.R +++ b/R/shinyDiagnostics.R @@ -20,10 +20,10 @@ shinyDiagnostics <- function(result, ) } -getBackground <- function(results) { +getBackground <- function(result) { cohorts <- result |> - visOmopResults::filterSettings(table_name == "my_cohort") |> + visOmopResults::filterSettings(.data$table_name == "my_cohort") |> dplyr::distinct(.data$group_name, .data$group_level) |> visOmopResults::splitGroup() @@ -37,7 +37,7 @@ getBackground <- function(results) { } codelists <- result |> - visOmopResults::filterSettings(result_type == "cohort_code_use") |> + visOmopResults::filterSettings(.data$result_type == "cohort_code_use") |> dplyr::distinct(.data$group_name, .data$group_level) |> visOmopResults::splitGroup()