AlertaDengue / AlertaDengue/AlertTools
Improve sql queries : case aggregation
- 主要语言
- R
- 星标
- 1
- 派生
- 0
- 平均合并
- 11 天 23 分钟
- 30 天内合并 PR
- 1
描述
# Problem
Currently, line list of cases are queried and then aggregated. In order to include group_by in the sql query, we need to
compute the epiweek.
# Why do that
To optimize consultation, this is also useful for the webpage
# current code (AlertTools::getCases.R)
```R
comando <- paste("SELECT * from \"Municipio\".\"Notificacao\" WHERE dt_digita <= '",lastday,
"' AND dt_digita >= '",firstday, "' AND municipio_geocodigo IN (", sqlcity,
") AND cid10_codigo IN(", sqlcid,")", sep="")
dd <- dbGetQuery(datasource,comando)
dd$se_sin_pri <- epiweek(as.Date(dd$dt_sin_pri, format = "%Y-%m-%d"))
dd <- dd %>%
mutate(ano_sinpri = epiyear(dt_sin_pri),
SE = ano_sinpri*100+se_sin_pri)
casos <- dd %>%
group_by(municipio_geocodigo, SE) %>%
summarise(
casos = length(classi_fin),
cas_prov = sum(classi_fin != 5, na.rm = TRUE),
cas_lab = sum(classi_fin != 5 & criterio == 1 , na.rm = TRUE))
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。