AlertaDengue / AlertaDengue/AlertTools

Improve sql queries : case aggregation

未关闭
#11 10 条评论 0 个 reaction 已指派 4 人 已被 @luabida 认领 在 GitHub 查看
help wanted
主要语言
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 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。