Newer
Older
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
### Information quality tab
##################
### Data objects
##################
INFOQ_plot_tab <- reactive({
date1 <- as.Date(paste0(input$INFOQdates[1],"-01-01"))
date2 <- as.Date(paste0(input$INFOQdates[2],"-12-31"))
consultation_har_filter(JSON_cons_har,
source = input$INFOQcountry,
new_attack = input$INFOQnew_attack,
diagn = input$INFOQdiagn,
sex = input$INFOQsex
) %>%
filter(consultation_date >= date1 & consultation_date <= date2) %>%
mutate(year = lubridate::year(consultation_date)) %>%
select(residence_place,
infection_place,
id_center,
patient_age,
patient_sex,
diagnosis_result,
new_attack,
active_diagnosis,
source,
year
) %>%
group_by(source, year) %>%
dplyr::summarise(
count = n(),
residence_place = mean(is.na(residence_place))*100,
infection_place = mean(is.na(infection_place))*100,
center = mean(is.na(id_center))*100,
patient_age = mean(is.na(patient_age))*100,
sex = mean(is.na(patient_sex))*100,
diagnosis_result = mean(is.na(diagnosis_result))*100,
new_attack = mean(is.na(new_attack))*100,
active_diagnosis = mean(is.na(active_diagnosis))*100
)
})
INFOQ_plot_tab_fg <- reactive({
INFOQ_plot_tab() %>% filter(source == "FR-GF")
})
INFOQ_plot_tab_br <- reactive({
INFOQ_plot_tab() %>% filter(source == "BR")
})
INFOQ_tab <- reactive({
date1 <- as.Date(paste0(input$INFOQdates[1],"-01-01"))
date2 <- as.Date(paste0(input$INFOQdates[2],"-12-31"))
if(input$INFOQtype == "residence_area"){
consultation_har_filter(JSON_cons_har,
source = input$INFOQcountry,
new_attack = input$INFOQnew_attack,
diagn = input$INFOQdiagn,
sex = input$INFOQsex
) %>%
filter(consultation_date >= date1 & consultation_date <= date2) %>%
select(residence_place,
infection_place,
id_center,
patient_age,
patient_sex,
diagnosis_result,
new_attack,
active_diagnosis
) %>%
group_by(residence_place) %>%
dplyr::summarise(
count = n(),
infection_place = percent(mean(is.na(infection_place)), format = "d"),
center = percent(mean(is.na(id_center)), format = "d"),
patient_age = percent(mean(is.na(patient_age)), format = "d"),
sex = percent(mean(is.na(patient_sex)), format = "d"),
diagnosis_result = percent(mean(is.na(diagnosis_result)), format = "d"),
new_attack = percent(mean(is.na(new_attack)), format = "d"),
active_diagnosis = percent(mean(is.na(active_diagnosis)), format = "d")
) %>%
inner_join(JSON_area_har, by = c("residence_place" = "id"))
} else if(input$INFOQtype == "center"){
consultation_har_filter(JSON_cons_har,
source = input$INFOQcountry,
new_attack = input$INFOQnew_attack,
diagn = input$INFOQdiagn,
sex = input$INFOQsex
) %>%
filter(consultation_date >= date1 & consultation_date <= date2) %>%
select(id_center,
residence_place,
infection_place,
patient_age,
patient_sex,
diagnosis_result,
new_attack,
active_diagnosis
) %>%
group_by(id_center) %>%
dplyr::summarise(
count = n(),
residence_place = percent(mean(is.na(residence_place)), format = "d"),
infection_place = percent(mean(is.na(infection_place)), format = "d"),
patient_age = percent(mean(is.na(patient_age)), format = "d"),
sex = percent(mean(is.na(patient_sex)), format = "d"),
diagnosis_result = percent(mean(is.na(diagnosis_result)), format = "d"),
new_attack = percent(mean(is.na(new_attack)), format = "d"),
active_diagnosis = percent(mean(is.na(active_diagnosis)), format = "d")
) %>%
inner_join(JSON_healthcenter_har, by = c("id_center" = "id_center"))
} else if(input$INFOQtype == "infection_place"){
consultation_har_filter(JSON_cons_har,
source = input$INFOQcountry,
new_attack = input$INFOQnew_attack,
diagn = input$INFOQdiagn,
sex = input$INFOQsex
) %>%
filter(consultation_date >= date1 & consultation_date <= date2) %>%
select(infection_place,
residence_place,
id_center,
patient_age,
patient_sex,
diagnosis_result,
new_attack,
active_diagnosis
) %>%
group_by(infection_place) %>%
dplyr::summarise(
count = n(),
residence_place = percent(mean(is.na(residence_place)), format = "d"),
center = percent(mean(is.na(id_center)), format = "d"),
patient_age = percent(mean(is.na(patient_age)), format = "d"),
sex = percent(mean(is.na(patient_sex)), format = "d"),
diagnosis_result = percent(mean(is.na(diagnosis_result)), format = "d"),
new_attack = percent(mean(is.na(new_attack)), format = "d"),
active_diagnosis = percent(mean(is.na(active_diagnosis)), format = "d")
) %>%
inner_join(JSON_area_har, by = c("infection_place" = "id"))
}
})
##################
### Plot
##################
output$INFOQ_plot_sex <- renderPlotly({
p <- plot_ly(data = INFOQ_plot_tab_fg(), x = ~year, y = ~sex, type = 'scatter', mode = 'lines', name = tr("FG")) %>%
add_trace(data = INFOQ_plot_tab_br(), x = ~year, y = ~sex, type = 'scatter', mode = 'lines', name = tr("BR")) %>%
layout(xaxis = list(title = tr("year")), yaxis = list(title = "%", range = c(0,100)))
p
})
output$INFOQ_plot_residence_area <- renderPlotly({
p <- plot_ly(data = INFOQ_plot_tab_fg(), x = ~year, y = ~residence_place, type = 'scatter', mode = 'lines', name = tr("FG")) %>%
add_trace(data = INFOQ_plot_tab_br(), x = ~year, y = ~residence_place, type = 'scatter', mode = 'lines', name = tr("BR")) %>%
layout(xaxis = list(title = tr("year")), yaxis = list(title = "%", range = c(0,100)))
p
})
output$INFOQ_plot_infection_place <- renderPlotly({
p <- plot_ly(data = INFOQ_plot_tab_fg(), x = ~year, y = ~infection_place, type = 'scatter', mode = 'lines', name = tr("FG")) %>%
add_trace(data = INFOQ_plot_tab_br(), x = ~year, y = ~infection_place, type = 'scatter', mode = 'lines', name = tr("BR")) %>%
layout(xaxis = list(title = tr("year")), yaxis = list(title = "%", range = c(0,100)))
p
})
output$INFOQ_plot_center <- renderPlotly({
p <- plot_ly(data = INFOQ_plot_tab_fg(), x = ~year, y = ~center, type = 'scatter', mode = 'lines', name = tr("FG")) %>%
add_trace(data = INFOQ_plot_tab_br(), x = ~year, y = ~center, type = 'scatter', mode = 'lines', name = tr("BR")) %>%
layout(xaxis = list(title = tr("year")), yaxis = list(title = "%", range = c(0,100)))
p
})
##################
### Table
##################
output$INFOQ_ftable <- renderDataTable({
if(input$INFOQtype == "residence_area"){
INFOQ_tab() %>%
plyr::arrange(-count) %>%
select(
name,
count,
source,
center,
infection_place,
patient_age,
sex,
diagnosis_result,
new_attack,
active_diagnosis
) %>%
mutate(source = ifelse(source == "BR", tr("BR"), tr("FG"))) %>%
formattable(., list(
center = color_tile("transparent", "orange"),
infection_place = color_tile("transparent", "orange"),
patient_age = color_tile("transparent", "orange"),
sex = color_tile("transparent", "orange"),
diagnosis_result = color_tile("transparent", "orange"),
new_attack = color_tile("transparent", "orange"),
active_diagnosis = color_tile("transparent", "orange")
)) %>%
as.datatable(., colnames = c(
tr("name"),
tr("cases"),
tr("country"),
tr("center"),
tr("infection_place"),
tr("age"),
tr("sex"),
tr("diagnosis_result"),
tr("new_attack"),
tr("active_search_leg")
),
extensions = 'Buttons', options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
)
)
} else if(input$INFOQtype == "center"){
INFOQ_tab() %>%
plyr::arrange(-count) %>%
select(
name,
count,
source,
residence_place,
infection_place,
patient_age,
sex,
diagnosis_result,
new_attack,
active_diagnosis
) %>%
mutate(source = ifelse(source == "BR", tr("BR"), tr("FG"))) %>%
formattable(., list(
residence_place = color_tile("transparent", "orange"),
infection_place = color_tile("transparent", "orange"),
patient_age = color_tile("transparent", "orange"),
sex = color_tile("transparent", "orange"),
diagnosis_result = color_tile("transparent", "orange"),
new_attack = color_tile("transparent", "orange"),
active_diagnosis = color_tile("transparent", "orange")
)) %>%
as.datatable(., colnames = c(
tr("name"),
tr("cases"),
tr("country"),
tr("residence_area"),
tr("infection_place"),
tr("age"),
tr("sex"),
tr("diagnosis_result"),
tr("new_attack"),
tr("active_search_leg")
),
extensions = 'Buttons', options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
)
)
} else if(input$INFOQtype == "infection_place"){
INFOQ_tab() %>%
plyr::arrange(-count) %>%
select(
name,
count,
source,
residence_place,
center,
patient_age,
sex,
diagnosis_result,
new_attack,
active_diagnosis
) %>%
mutate(source = ifelse(source == "BR", tr("BR"), tr("FG"))) %>%
formattable(., list(
residence_place = color_tile("transparent", "orange"),
center = color_tile("transparent", "orange"),
patient_age = color_tile("transparent", "orange"),
sex = color_tile("transparent", "orange"),
diagnosis_result = color_tile("transparent", "orange"),
new_attack = color_tile("transparent", "orange"),
active_diagnosis = color_tile("transparent", "orange")
)) %>%
as.datatable(., colnames = c(
tr("name"),
tr("cases"),
tr("country"),
tr("residence_area"),
tr("center"),
tr("age"),
tr("sex"),
tr("diagnosis_result"),
tr("new_attack"),
tr("active_search_leg")
),
extensions = 'Buttons', options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
)
)
}
},
server = FALSE
)