2021-11-01 14:38:23 +01:00
|
|
|
# WELCOME TO RadaR
|
|
|
|
|
|
|
|
#RadaR is licensed under the GNU General Public License (GPL) v2.0 (https://github.com/ceefluz/radar/blob/master/LICENSE)
|
|
|
|
|
|
|
|
# LIST OF REQUIRED PACKAGES -----------------------------------------------
|
|
|
|
library(shiny)
|
|
|
|
library(shinydashboard)
|
|
|
|
library(shinydashboardPlus)
|
|
|
|
library(dashboardthemes)
|
|
|
|
library(shinyWidgets)
|
|
|
|
library(shinycssloaders)
|
|
|
|
library(shinyjs)
|
|
|
|
library(DT)
|
|
|
|
library(tidyverse)
|
|
|
|
library(ggtext)
|
|
|
|
library(AMR)
|
|
|
|
library(cleaner)
|
|
|
|
library(scales)
|
|
|
|
library(ggiraph)
|
|
|
|
|
2023-02-07 16:49:16 +01:00
|
|
|
source('interfaces.R')
|
2021-11-16 12:21:55 +01:00
|
|
|
|
|
|
|
trsns <- read_tsv("translations.txt", lazy = FALSE)
|
|
|
|
# to do: make system settings dependent
|
|
|
|
trnslt <- function(english, new_lang = "nl", file = trsns) {
|
|
|
|
if (english %in% trsns[, 1, drop = TRUE]) {
|
|
|
|
trsns[match(english, trsns[, 1, drop = TRUE]), new_lang, drop = TRUE]
|
|
|
|
} else {
|
|
|
|
english
|
|
|
|
}
|
|
|
|
}
|
2021-11-01 14:38:23 +01:00
|
|
|
|
2023-02-07 16:49:16 +01:00
|
|
|
pathogens <- read_csv("data/grouping microorganisms.csv")
|
|
|
|
|
|
|
|
# created by calling createAbMapping()
|
|
|
|
tAntibiotics = readxl::read_xlsx('data/ab_mapping.xlsx') %>%
|
|
|
|
select(Mnemonic, Naam, `EARS-Net.Mnemonic`, `EARS-Net.Name`)
|
|
|
|
|
|
|
|
# radar_data <- readGlimsArchive(ymdStartDate = ymdStartDate,
|
|
|
|
# ymdEndDate = ymdEndDate,
|
|
|
|
# readPreprocessed = T)
|
2023-03-06 13:51:19 +01:00
|
|
|
radar_data <- readGlimsFinalResults() %>%
|
|
|
|
mutate_if(is.rsi, as.sir)
|
2023-02-07 16:49:16 +01:00
|
|
|
|
|
|
|
if (!'CRO' %in% colnames(radar_data))
|
|
|
|
radar_data <- radar_data %>% add_column('CRO' = '')
|
|
|
|
|
|
|
|
if (!'OXA' %in% colnames(radar_data))
|
|
|
|
radar_data <- radar_data %>% add_column('OXA' = '')
|
|
|
|
|
|
|
|
specialties <- read_csv("data/specialties.csv", lazy = FALSE)
|
|
|
|
|
|
|
|
specialties <- specialties %>%
|
2021-11-01 14:38:23 +01:00
|
|
|
mutate(specialty_shiny = if_else(specialty != "Outpatients", paste0(specialty, " (", str_replace_all(specialism, ";", ", "), ")"), "Outpatients"),
|
|
|
|
department = if_else(is.na(department), "NO DEPARTMENT GIVEN", department))
|
2023-02-07 16:49:16 +01:00
|
|
|
|
2021-11-01 14:38:23 +01:00
|
|
|
specialties <- separate_rows(specialties, specialism, sep = ";")
|
|
|
|
|
|
|
|
specialties <- separate_rows(specialties, department, sep = ";")
|
|
|
|
|
|
|
|
|
|
|
|
radar_data <- radar_data %>%
|
|
|
|
left_join(specialties) %>%
|
|
|
|
mutate(specialty = if_else(is.na(specialty), "NO SPECIALTY GIVEN", specialty),
|
|
|
|
specialty_shiny = if_else(is.na(specialty_shiny), "NO SPECIALTY GIVEN", specialty_shiny),
|
|
|
|
name = mo_name(mo),
|
2021-11-16 12:21:55 +01:00
|
|
|
FLC = OXA) %>%
|
2021-11-01 14:38:23 +01:00
|
|
|
left_join(pathogens)
|
|
|
|
|
2023-02-07 16:49:16 +01:00
|
|
|
lab_ab <- c("CFCC", "CFCL", "CFOC", "CFSC", "CFTC", "COCL", "GEHI", "QUDA")
|
2021-11-01 14:38:23 +01:00
|
|
|
|
|
|
|
radar_data <- radar_data %>%
|
2023-02-07 16:49:16 +01:00
|
|
|
select_at(vars(!contains(lab_ab))) %>%
|
2021-11-01 14:38:23 +01:00
|
|
|
rename_if(is.rsi, function(x) ifelse(is.na(suppressWarnings(as.ab(x))),
|
|
|
|
x,
|
|
|
|
suppressWarnings(as.ab(x)))) %>%
|
|
|
|
mutate(group_all = 1) # dummy variable to disable grouping
|
|
|
|
|
|
|
|
radar_data <- radar_data %>%
|
|
|
|
mutate(CRO = if_else(is.na(CRO) & !is.na(CTX), CTX, CRO))
|
|
|
|
|
2021-11-16 12:21:55 +01:00
|
|
|
suppressMessages(
|
|
|
|
radar_data_first <- radar_data %>%
|
|
|
|
filter_first_isolate(col_patient_id = "patientid", episode_days = 365, info = FALSE) %>%
|
|
|
|
mutate(mo = as.mo(mo, Becker = TRUE))
|
|
|
|
)
|
2021-11-01 14:38:23 +01:00
|
|
|
|
2021-11-16 12:21:55 +01:00
|
|
|
intrinsic_info <- AMR::intrinsic_resistant %>%
|
2023-03-06 13:51:19 +01:00
|
|
|
mutate(#mo = as.mo(microorganism),
|
2021-11-01 14:38:23 +01:00
|
|
|
intrinsic_r = TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
download_box <- function(exportname, plot) {
|
|
|
|
downloadHandler(
|
|
|
|
filename = function() {
|
|
|
|
paste(exportname, Sys.Date(), ".png", sep = "")
|
|
|
|
},
|
|
|
|
content = function(file) {
|
|
|
|
ggsave(file, plot = plot, device = "png", width = 8)
|
|
|
|
}
|
|
|
|
)
|
2021-11-16 12:21:55 +01:00
|
|
|
}
|