-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
335 lines (232 loc) · 9.66 KB
/
index.Rmd
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
---
params:
cache: FALSE
export: FALSE
need_privacy: TRUE
force_update: FALSE
q_overall_completed: "Completed"
q_overall_type: "Proportion"
q_hosp_completed: "Completed"
q_hosp_type: "Proportion"
q_miss_center: ""
q_err_center: ""
d_gender_completed: "Completed only"
title: "TIPNet inter-dynamical report"
author: "La Rete Italiana delle Unità di Terapia Intensiva Pediatrica (**TIPNet**) fa parte della Società Italiana di Anestesia e Terapia Intensiva Pediatrica e Neonatale (**SARNePI**).
</br>
\\ \\ \\ \\ Questo report è stato sviluppato in collaborazione con l'Unità di Biostatistica, Epidemiologia e Sanità Pubblica (**UBEP**) --- Università di Padova"
biblio-style: apalike
link-citations: yes
bibliography:
- inst/bib/bibliography.bib
- inst/bib/packages.bib
output:
bookdown::html_document2:
toc: true
toc_float: true
toc_depth: 2
df_print: paged
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
# This is run only once both to the render and server side, and it
# is the very first chunk of code that will be run
options(
knitr.duplicate.label = 'allow',
width = 144
)
httr::config(ssl_verifypeer = FALSE) |>
httr::set_config(override = FALSE)
knitr::opts_chunk$set(
comment = "",
cache = FALSE,
echo = FALSE,
message = FALSE,
warning = FALSE,
width = 150, # output size
out.width = "100%", # part of output covered
fig.width = 11, # set size creation-time
dpi = 192 # set output resolution (impact weight)
)
all_attached <- paste0("package:", names(sessionInfo()$otherPkgs))
attempt::attempt(suppressWarnings(invisible(lapply(
all_attached, detach, character.only = TRUE, unload = TRUE
))), silent = TRUE)
library(tidyverse)
library(lubridate)
library(plotly)
library(shiny)
library(glue)
library(here)
library(DT)
library(fs)
if (getOption("tipnet.dev", FALSE)) {
rstudioapi::documentSaveAll()
roxygen2::roxygenise()
devtools::load_all(quiet = TRUE)
cat("!!!!!!! dev !!!!!!!")
} else {
devtools::load_all(quiet = TRUE)
# library(tipnet.report)
cat("!!!!!!! prod !!!!!!")
}
last_file <- file.path(data_path(), "tipnet.rds")
is_to_update <- !fs::file_exists(last_file) ||
(
getOption("tipnet.auto_update", TRUE) &&
is_expired(last_file, getOption("tipnet.max_days_update"))
)
if (
getOption("tipnet.force_update") || is_to_update
) {
usethis::ui_todo("Updating TIPNet from REDCap...")
np <- params[["need_privacy"]]
db_update_from_server(use_city = np)
usethis::ui_done("TIPNet db updated.")
}
last_data_date <- as.Date(file.info(last_file)$mtime)
set.seed(1)
```
```{r data, include=FALSE, cache=params$cache, cache.extra=last_data_date}
# This run only once bot in the render and server side
# cache.extra option in the knitr tags here above needs to speed up
# normal computation and running time (render side) as the data are not
# changed. Note that server-side data are loaded from the render-side
# if included in the chunk named "data" (like this is), hence setting
# cache.extra provide a further speed up.
tipnet <- read_rds(last_file)
tipnet_meta <- path(data_path(), "tipnet_meta.rds") %>%
read_rds()
iwalk(generate_main_data(), ~assign(.y, .x, pos = 1))
```
<!-- ```{r server-start, include = FALSE} -->
<!-- # this run only once on the server session when it starts (after -->
<!-- # setup and data chunks) -->
<!-- ``` -->
**Last report update**: `r as.Date(file.info('index.Rmd')$mtime)` --- **Last data update**: `r last_data_date`
# Colophon {-}
<style>
div.blue { background-color:#e6f0ff; border-radius: 5px; padding: 20px;}
</style>
<div class = "blue">
**Network coordinator**: Andrea Wolfler (Division of Anesthesia, Children’s Hospital G Gaslini – Genova) and Angela Amigoni (Pediatric Intensive Care Unit, University Hospital – Padova)
**In collaboration with**: Unit of Biostatistics, Epidemiology and Public Helath ([UBEP](https://www.unipd-ubep.it/)), [Department of Cardiac, Toracic, Vascular sciences and Public Health](https://www.dctv.unipd.it/) -- [University of Padova](https://www.unipd.it/) --- Interuniversity Consortium
- Dario Gregori (head of UBEP)
- Corrado Lanera, Giorgia Stoppa (Laboratory of Artificial Intelligence for Medical Sciences)
- Giulia Lorenzoni, Honoria Ocagli (Laboratory of Clinical Epidemiology)
- Rosanna Comoretto (Laboratory for Health Service Research)
- Matteo Martinato, Laura Nasato (Service for Clinical Trials and Biometrics)
**Steering Committee TIPNET (SCT)**: Angela Amigoni, Andrea Wolfler, Maria Cristina Mondardini, Dario Gregori, Matteo Martinato, Francesca Izzo, Marco Piastra, Paolo Biban, Rosanna Comoretto)
**IT Project Managers**: Dario Gregori, Corrado Lanera
**TIPNet study group** - participating center:
- Pediatric and Neonatal Intensive Care Unit, Children’s Hospital G Gaslini, Genova
- Division of Anesthesia and Intensive Care, Children’s Hospital Sant’Antonio e Biagio e Cesare Arrigo, Alessandria
- Department of Pediatrics, Ospedale Maggiore della Carità, Novara
- Division of Anesthesia and Intensive Care, Children’s Hospital V Buzzi, Milan
- Division of Pediatric Anesthesia and Intensive Care, Fondazione IRCCS Ca Granda, Ospedale Maggiore Policlinico, Milan
- Department of Neonatal and Paediatric Intensive Care, Azienda Ospedaliera Universitaria Integrata, Verona
- Department of Woman’s and Child’s Health, Pediatric ICU, University Hospital, Padova
- Division of Anesthesia and Intensive Care, Institute for Maternal and Child health, IRCCS Burlo Garofolo, Trieste
- Department of Pediatric Anesthesia and Intensive Care, Ospedale Sant’Orsola Malpighi, Bologna
- Division of Anesthesia and Intensive Care, Children’s Hospital Meyer, Firenze
- Department of Anesthesia and Intensive Care, Children’s Hospital Salesi, Ancona
- Division of Anesthesia and Intensive Care, Children’s Hospital Santobono-Pausillipon, Napoli
- Division of Anesthesia and Intensive Care, Children’s Hospital G Di Cristina, Palermo
- Division of Anesthesia and Intensive Care Ospedale Garibaldi – Nesima, Catania
- Department of Pediatrics Ospedale Policlinico –Universitario G Martino, Messina
</div>
```{r}
yearRangeUI("year_range", last_data_date)
```
```{r, context="server"}
data_ranged <- yearRange("year_range")
```
```{r, child = "005-quality.Rmd"}
```
```{r, child = "010-descriptives.Rmd"}
```
```{r, child = "020-origin.Rmd"}
```
```{r, child = "030-ccc.Rmd"}
```
```{r, child = "035-focus.Rmd"}
```
```{r, child = "050-los.Rmd"}
```
<!-- ```{r, results='asis', eval=!params$export} -->
<!-- cat("# Download current report {-}") -->
<!-- ``` -->
<!-- ```{r, eval=!params$export} -->
<!-- actionButton("generate", "Generate Report", icon = icon("file")) -->
<!-- ``` -->
<!-- </br> -->
<!-- ```{r, eval=!params$export} -->
<!-- shiny::downloadLink("report", "Download report", icon = icon("file")) -->
<!-- ``` -->
<!-- ```{r, context="server", eval=!params$export} -->
<!-- report_path <- reactiveValues(filepath = NULL) -->
<!-- observeEvent(input$generate, { -->
<!-- progress <- shiny::Progress$new() -->
<!-- # Make sure it closes when we exit this reactive, even if there's an error -->
<!-- on.exit(progress$close()) -->
<!-- progress$set( -->
<!-- message = "Gathering data to build the report.", -->
<!-- value = 0 -->
<!-- ) -->
<!-- static_dir <- "static" -->
<!-- if (fs::dir_exists(static_dir)) fs::dir_delete(static_dir) -->
<!-- dir <- normalizePath(fs::dir_create(static_dir)) -->
<!-- list.files( -->
<!-- pattern = "\\.Rmd$|inst", -->
<!-- all.files = TRUE, -->
<!-- include.dirs = TRUE -->
<!-- ) %>% -->
<!-- stringr::str_subset("^index\\.Rmd$", negate = TRUE) %>% -->
<!-- file.copy(dir, recursive = TRUE, copy.date = TRUE) -->
<!-- report_raw <- file.path(dir, "index.Rmd") -->
<!-- report_out <- file.path(dir, "report.html") -->
<!-- read_lines("index.Rmd") %>% -->
<!-- str_remove("^runtime: shiny_prerendered$") %>% -->
<!-- str_remove("\\.tabset \\.tabset-fade \\.tabset-pills") %>% -->
<!-- write_lines(report_raw) -->
<!-- # Set up parameters to pass to Rmd document -->
<!-- params <- list( -->
<!-- export = TRUE, -->
<!-- q_overall_completed = input[[NS("q_overall", "completed")]], -->
<!-- q_overall_type = input[[NS("q_overall", "type")]], -->
<!-- q_hosp_completed = input[[NS("q_hosp", "completed")]], -->
<!-- q_hosp_type = input[[NS("q_hosp", "type")]], -->
<!-- q_miss_center = input[[NS("q_miss", "center")]], -->
<!-- q_err_center = input[[NS("q_err", "center")]], -->
<!-- d_gender_completed = input[[NS("d_gender", "completed")]] -->
<!-- ) -->
<!-- progress$inc(amount = 0.4, -->
<!-- message = "Building the report", -->
<!-- detail = "This may take a while..." -->
<!-- ) -->
<!-- withr::local_options(list(tipnet.dev = FALSE)) -->
<!-- rmarkdown::render(report_raw, -->
<!-- output_file = report_out, -->
<!-- params = params, -->
<!-- envir = new.env(parent = globalenv()) -->
<!-- ) -->
<!-- progress$set(value = 1, -->
<!-- message = "Report build", -->
<!-- detail = "Click the download link to download it. -->
<!-- This window will disappear in 10 seconds." -->
<!-- ) -->
<!-- Sys.sleep(10) -->
<!-- report_path$filepath <- report_out -->
<!-- }) -->
<!-- output$report <- downloadHandler( -->
<!-- filename = paste0(today(), "_tipnet-report.html"), -->
<!-- content = function(file) file.copy(report_path$filepath, file) -->
<!-- ) -->
<!-- ``` -->
<!-- cat("# References {-}") -->
```{r include=FALSE}
# automatically create a bib database for R packages
knitr::write_bib(c(
.packages(), 'bookdown', 'knitr', 'rmarkdown'
), 'inst/bib/packages.bib')
```