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
### Brazil tab
##################
### Data objects
##################
# Positive incidence
BR_sub <- reactive({
date1 <- as.Date(paste0(input$BRdates[1],"-01-01"))
date2 <- as.Date(paste0(input$BRdates[2],"-12-31"))
br_df %>%
sivep_filter_notif(plasm = "Any", minAge = 0, maxAge = 100) %>%
filter(DT_NOTIF >= date1 & DT_NOTIF <= date2)
})
# Tabulate
BR_tab_pos_incidence <- reactive({
sub <- sivep_filter_notif(BR_sub(), type = "AP")
as.data.frame(incidence(sub$DT_NOTIF, interval = 30))
})
BR_tab_pregnant <- reactive({
sub <- sivep_filter_notif(BR_sub(), preg = "Pregnant")
as.data.frame(incidence(sub$DT_NOTIF, interval = 30))
})
BR_tab_falci <- reactive({
sub <- sivep_filter_notif(BR_sub(), plasm = "Falci_assoc")
as.data.frame(incidence(sub$DT_NOTIF, interval = 30))
})
BR_tab_non_falci <- reactive({
sub <- sivep_filter_notif(BR_sub(), plasm = "Non_falci")
as.data.frame(incidence(sub$DT_NOTIF, interval = 30))
})
BR_tab_imported_cases <- reactive({
sub <- subset(BR_sub(), PAIS_INF != "Brasil")
as.data.frame(incidence(sub$DT_NOTIF, interval = 30))
})
BR_tab_lvc <- reactive({
BR_sub() %>%
select(DT_NOTIF, ID_LVC) %>%
mutate(month = floor_date(DT_NOTIF, "month"), pos = if_else(ID_LVC == "Yes", "Yes", "No")) %>%
select(month, pos) %>%
group_by(month, pos) %>%
dplyr::summarise(count=n()) %>%
spread(pos, count) %>%
replace_na(list(Yes = 0, No = 0)) %>%
mutate(prop = Yes/(No+Yes)*100) %>%
select(month, prop)%>%
as.data.frame()
})
BR_tab_symptons <- reactive({
BR_sub() %>%
select(DT_NOTIF, SINTOMAS, RES_EXAM) %>%
mutate(month = floor_date(DT_NOTIF, "month"), pos = if_else(SINTOMAS == "Without symptons" & RES_EXAM != "Negative", "Yes", "No")) %>%
select(month, pos) %>%
group_by(month, pos) %>%
dplyr::summarise(count=n()) %>%
spread(pos, count) %>%
replace_na(list(Yes = 0, No = 0)) %>%
mutate(prop = Yes/(No+Yes)*100) %>%
select(month, prop)%>%
as.data.frame()
})
BR_tab_active_search <- reactive({
BR_sub() %>%
select(DT_NOTIF, TIPO_LAM) %>%
mutate(month = floor_date(DT_NOTIF, "month"), pos = if_else(TIPO_LAM == "Active search", "Yes", "No")) %>%
select(month, pos) %>%
group_by(month, pos) %>%
dplyr::summarise(count=n()) %>%
spread(pos, count) %>%
replace_na(list(Yes = 0, No = 0)) %>%
mutate(prop = Yes/(No+Yes)*100) %>%
select(month, prop)%>%
as.data.frame()
})
BR_tab_passive_search <- reactive({
BR_sub() %>%
select(DT_NOTIF, TIPO_LAM) %>%
mutate(month = floor_date(DT_NOTIF, "month"), pos = if_else(TIPO_LAM == "Passive search", "Yes", "No")) %>%
select(month, pos) %>%
group_by(month, pos) %>%
dplyr::summarise(count=n()) %>%
spread(pos, count) %>%
replace_na(list(Yes = 0, No = 0)) %>%
mutate(prop = Yes/(No+Yes)*100) %>%
select(month, prop)%>%
as.data.frame()
})
BR_tab_imported_cases_prop <- reactive({
BR_sub() %>%
select(DT_NOTIF, PAIS_INF) %>%
mutate(month = floor_date(DT_NOTIF, "month"), pos = if_else(PAIS_INF != "Brasil", "Yes", "No")) %>%
select(month, pos) %>%
group_by(month, pos) %>%
dplyr::summarise(count=n()) %>%
spread(pos, count) %>%
replace_na(list(Yes = 0, No = 0)) %>%
mutate(prop = Yes/(No+Yes)*100) %>%
select(month, prop)%>%
as.data.frame()
})
BR_tab_age <- reactive({
BR_sub() %>%
select(ID_PACIE, ID_DIMEA) %>%
mutate(ID_PACIE_ADJ = ifelse((ID_DIMEA == "Days" | ID_DIMEA == "Months"), 0, ID_PACIE))
})
BR_tab_sex_prop <- reactive({
BR_sub() %>%
select(SEXO) %>%
filter(SEXO == "Male" | SEXO == "Female") %>%
droplevels() %>%
count(SEXO)
})
BR_tab_symptons_prop <- reactive({
BR_sub() %>%
select(SINTOMAS) %>%
count(SINTOMAS)
})
BR_tab_occupation_prop <- reactive({
BR_sub() %>%
select(COD_OCUP) %>%
count(COD_OCUP)
})
BR_tab_crosses_prop <- reactive({
BR_sub() %>%
select(QTD_CRUZ) %>%
count(QTD_CRUZ)
})
BR_tab_imported_uf <- reactive({
BR_sub() %>%
select(UF_INFEC) %>%
filter(UF_INFEC != "Amapá") %>%
count(UF_INFEC)
})
BR_tab_imported_country <- reactive({
BR_sub() %>%
select(PAIS_INF) %>%
filter(PAIS_INF != "Brasil") %>%
count(PAIS_INF)
})
##################
### Plots
##################
# Count positive cases
output$BR_count_incidence <- renderValueBox({
valueBox(
paste0(sum(BR_tab_pos_incidence()$counts), tr("cases2")), tr("positive_cases"), color = "purple"
)
})
# Count pregnant cases
output$BR_count_pregnant <- renderValueBox({
valueBox(
paste0(sum(BR_tab_pregnant()$counts), tr("cases2")), tr("pregnant_cases"), color = "purple"
)
})
# Count imported cases
output$BR_count_imported <- renderValueBox({
valueBox(
paste0(sum(BR_tab_imported_cases()$counts), tr("cases2")), tr("imported_cases"), color = "purple"
)
})
# Plot incidences
output$BR_plot_incidence <- renderPlotly({
plot_ly(data = BR_tab_pos_incidence(), x = ~dates, y = ~counts, type = 'scatter', mode = 'lines', name = tr("positive_cases_leg")) %>%
add_trace(data = BR_tab_pregnant(), x = ~dates, y = ~counts, type = 'scatter', mode = 'lines', name = tr("pregnant_cases_leg")) %>%
add_trace(data = BR_tab_falci(), x = ~dates, y = ~counts, type = 'scatter', mode = 'lines', name = tr("falciparum_assoc_leg")) %>%
add_trace(data = BR_tab_non_falci(), x = ~dates, y = ~counts, type = 'scatter', mode = 'lines', name = tr("non_falciparum_leg")) %>%
add_trace(data = BR_tab_imported_cases(), x = ~dates, y = ~counts, type = 'scatter', mode = 'lines', name = tr("imported_cases_leg")) %>%
layout(xaxis = list(title = tr("date")), yaxis = list(title = tr("cases")))
})
# Plot proportions
output$BR_plot_proportions <- renderPlotly({
plot_ly(data = BR_tab_lvc(), x = ~month, y = ~prop, type = 'scatter', mode = 'lines', name = tr("lvc_leg")) %>%
add_trace(data = BR_tab_symptons(), x = ~month, y = ~prop, type = 'scatter', mode = 'lines', name = tr("asymptomatic_cases_leg")) %>%
add_trace(data = BR_tab_active_search(), x = ~month, y = ~prop, type = 'scatter', mode = 'lines', name = tr("active_search_leg")) %>%
add_trace(data = BR_tab_passive_search(), x = ~month, y = ~prop, type = 'scatter', mode = 'lines', name = tr("passive_search_leg")) %>%
add_trace(data = BR_tab_imported_cases_prop(), x = ~month, y = ~prop, type = 'scatter', mode = 'lines', name = tr("imported_cases_leg")) %>%
layout(xaxis = list(title = tr("date")), yaxis = list(title = tr("percentage")))
})
# Plot age (histogram)
output$BR_plot_age <- renderPlotly({
plot_ly(data = BR_tab_age(), x = ~ID_PACIE_ADJ, type = "histogram") %>%
layout(xaxis = list(title = tr("age"), domain = c(0,100)), yaxis = list(title = tr("cases")))
})
# Plot sex
output$BR_plot_sex <- renderPlotly({
plot_ly(data = BR_tab_sex_prop(), labels = ~SEXO, values = ~n) %>%
add_pie(hole = 0.6) %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
# Plot symptons
output$BR_plot_symptons <- renderPlotly({
plot_ly(data = BR_tab_symptons_prop(), labels = ~SINTOMAS, values = ~n) %>%
add_pie(hole = 0.6) %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
# Plot occupation
output$BR_plot_occupation <- renderPlotly({
plot_ly(data = BR_tab_occupation_prop(), labels = ~COD_OCUP, values = ~n) %>%
add_pie(hole = 0.6) %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
# Plot crosses
output$BR_plot_crosses <- renderPlotly({
plot_ly(data = BR_tab_crosses_prop(), labels = ~QTD_CRUZ, values = ~n, sort = FALSE) %>%
add_pie(hole = 0.6) %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
# Plot imported cases by state
output$BR_plot_imported_uf <- renderPlotly({
plot_ly(data = BR_tab_imported_uf(), labels = ~UF_INFEC, values = ~n) %>%
add_pie(hole = 0.6) %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
# Plot imported cases by country
output$BR_plot_imported_country <- renderPlotly({
plot_ly(data = BR_tab_imported_country(), labels = ~PAIS_INF, values = ~n) %>%
add_pie(hole = 0.6) %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})