-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shiny_Test_1.R
94 lines (75 loc) · 2.36 KB
/
Shiny_Test_1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#1. Install Packages-----
#install.packages("jsonlite")
#install.packages("yaml")
#install.packages("shiny")
#install.packages("shinyWidgets")
#install.packages("DT")
#install.packages("tibble")
#install.packages("dplyr")
#2. Library R Packages -----
library(shiny)
library(shinyWidgets)
library(jsonlite)
library(yaml)
library(tibble)
library(dplyr)
config <- yaml.load_file("config.yaml")
filenames <- list.files(paste0(getwd(),config$path), pattern = "*.json", full.names = TRUE)
json_files_list_all <- lapply(filenames, fromJSONfile <- function(x) rjson::fromJSON(file = x))
#error and general omitted bcs of missing counts
target_names <- c('Condition','Medication','MedicationAdministration','MedicationStatment','Procedure','Specimen')
#### Problems with inserting the col-names "Diagnostics" -> not displayed when executing the script----
get_diagnostics <- function(df, lable) {
results_list <- list()
for(l in lable) {
df_chunk <- df$validation[[l]]$issues
r <- do.call(rbind, as.list(lapply(df_chunk, get_text_count <- function(x) { cbind(x$diagnostics, x$count) } )))
r <- tibble(r)
colnames(r) <- c( paste("diagnostics_",l), "counts")
results_list <- append(results_list, r)
}
return(results_list)
}
get_diagnostics_from_list <- function(ldf, lable) {
r <- (lapply(ldf, call_diagnostics_with_lable <- function(x) {get_diagnostics(x,lable)} ))
return(r)
}
diagnistics_counts_list_all <- get_diagnostics_from_list(json_files_list_all, target_names)
# Umbenennen der Spalten
df3 <- diagnistics_counts_list_all[[1]]
df4 <- df3[[2]]
colnames(df4) <- c("Errorcode", "Häufigkeit")
####
ui <- fluidPage(
tags$head(
tags$style(HTML("
.error-box {
background-color: #c2e6c2;
border: 1px solid #a3c2a3;
border-radius: 5px;
padding: 15px;
margin-bottom: 10px;
color: #333;
}
body {
background-color: #edf4ff;
}
"))
),
fluidRow(
column(
width = 4,
style = "overflow-y: auto;",
lapply(1:nrow(df4), function(i) {
div(
class = "error-box",
tags$h4(paste0("Fehler-Meldung ", i)),
tags$h5(style = "margin-top: 0;", "Fehlercode: ", df4[i, "Errorcode"]),
tags$h5("Häufigkeit: ", df4[i, "Häufigkeit"])
)
})
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)