6
6
# '
7
7
# ' A specific UF or a vector of UFs can be informed using the following abbreviations: "AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO".
8
8
# '
9
- # ' The following systems are implemented: "SIH-RD", "SIH-RJ", "SIH-SP", "SIH-ER", "SIM-DO", "SIM-DOFET", "SIM-DOEXT", "SIM-DOINF", "SIM-DOMAT", "SINASC", "CNES-LT", "CNES-ST", "CNES-DC", "CNES-EQ", "CNES-SR", "CNES-HB", "CNES-PF", "CNES-EP", "CNES-RC", "CNES-IN", "CNES-EE", "CNES-EF", "CNES-GM", "SIA-AB", "SIA-ABO", "SIA-ACF", "SIA-AD", "SIA-AN", "SIA-AM", "SIA-AQ", "SIA-AR", "SIA-ATD", "SIA-PA", "SIA-PS", "SIA-SAD", "SINAN-DENGUE-FINAL", "SINAN-DENGUE-PRELIMINAR", "SINAN-CHIKUNGUNYA-FINAL", "SINAN-CHIKUNGUNYA-PRELIMINAR", "SINAN-ZIKA-FINAL", "SINAN-ZIKA-PRELIMINAR".
9
+ # ' The following systems are implemented: "SIH-RD", "SIH-RJ", "SIH-SP", "SIH-ER", "SIM-DO", "SIM-DOFET", "SIM-DOEXT", "SIM-DOINF", "SIM-DOMAT", "SINASC", "CNES-LT", "CNES-ST", "CNES-DC", "CNES-EQ", "CNES-SR", "CNES-HB", "CNES-PF", "CNES-EP", "CNES-RC", "CNES-IN", "CNES-EE", "CNES-EF", "CNES-GM", "SIA-AB", "SIA-ABO", "SIA-ACF", "SIA-AD", "SIA-AN", "SIA-AM", "SIA-AQ", "SIA-AR", "SIA-ATD", "SIA-PA", "SIA-PS", "SIA-SAD", "SINAN-DENGUE-FINAL", "SINAN-DENGUE-PRELIMINAR", "SINAN-CHIKUNGUNYA-FINAL", "SINAN-CHIKUNGUNYA-PRELIMINAR", "SINAN-ZIKA-FINAL", "SINAN-ZIKA-PRELIMINAR", "SINAN-MALARIA-FINAL", "SINAN-MALARIA-PRELIMINAR" .
10
10
# '
11
11
# ' @param year_start,year_end numeric. Start and end year of files in the format yyyy.
12
12
# ' @param month_start,month_end Numeric. Start and end month in the format mm. Those parameters are only used with the healh information systems SIH, CNES and SIA. There parameter are ignored if the information health system is SIM or SINASC.
@@ -45,15 +45,15 @@ fetch_datasus <- function(year_start, month_start, year_end, month_end, uf="all"
45
45
sisSINASC <- c(" SINASC" )
46
46
sisCNES <- c(" CNES-LT" , " CNES-ST" , " CNES-DC" , " CNES-EQ" , " CNES-SR" , " CNES-HB" ," CNES-PF" ," CNES-EP" ," CNES-RC" ," CNES-IN" ," CNES-EE" ," CNES-EF" ," CNES-GM" )
47
47
sisSIA <- c(" SIA-AB" , " SIA-ABO" , " SIA-ACF" , " SIA-AD" , " SIA-AN" , " SIA-AM" , " SIA-AQ" , " SIA-AR" , " SIA-ATD" , " SIA-PA" , " SIA-PS" , " SIA-SAD" )
48
- sisSINAN <- c(" SINAN-DENGUE-FINAL" , " SINAN-DENGUE-PRELIMINAR" , " SINAN-CHIKUNGUNYA-FINAL" , " SINAN-CHIKUNGUNYA-PRELIMINAR" , " SINAN-ZIKA-FINAL" , " SINAN-ZIKA-PRELIMINAR" )
48
+ sisSINAN <- c(" SINAN-DENGUE-FINAL" , " SINAN-DENGUE-PRELIMINAR" , " SINAN-CHIKUNGUNYA-FINAL" , " SINAN-CHIKUNGUNYA-PRELIMINAR" , " SINAN-ZIKA-FINAL" , " SINAN-ZIKA-PRELIMINAR" , " SINAN-MALARIA-FINAL " , " SINAN-MALARIA-PRELIMINAR " )
49
49
available_information_system <- c(sisSIH , sisSIM , sisSINASC , sisCNES , sisSIA , sisSINAN )
50
50
if (! (information_system %in% available_information_system )) stop(" Health informaton system unknown." )
51
51
52
52
# Create dates for verification
53
53
if (substr(information_system ,1 ,3 ) == " SIH" | substr(information_system ,1 ,4 ) == " CNES" | substr(information_system ,1 ,3 ) == " SIA" ){
54
54
date_start <- as.Date(paste0(year_start ," -" ,formatC(month_start , width = 2 , format = " d" , flag = " 0" )," -" ," 01" ))
55
55
date_end <- as.Date(paste0(year_end ," -" ,formatC(month_end , width = 2 , format = " d" , flag = " 0" )," -" ," 01" ))
56
- } else if (substr(information_system ,1 ,3 ) == " SIM" | information_system == " SINASC" | information_system == " SINAN-DENGUE-FINAL" | information_system == " SINAN-DENGUE-PRELIMINAR" | information_system == " SINAN-CHIKUNGUNYA-FINAL" | information_system == " SINAN-CHIKUNGUNYA-PRELIMINAR" | information_system == " SINAN-ZIKA-FINAL" | information_system == " SINAN-ZIKA-PRELIMINAR" ){
56
+ } else if (substr(information_system ,1 ,3 ) == " SIM" | information_system == " SINASC" | information_system == " SINAN-DENGUE-FINAL" | information_system == " SINAN-DENGUE-PRELIMINAR" | information_system == " SINAN-CHIKUNGUNYA-FINAL" | information_system == " SINAN-CHIKUNGUNYA-PRELIMINAR" | information_system == " SINAN-ZIKA-FINAL" | information_system == " SINAN-ZIKA-PRELIMINAR" | information_system == " SINAN-MALARIA-FINAL " | information_system == " SINAN-MALARIA-PRELIMINAR " ){
57
57
date_start <- as.Date(paste0(year_start ," -01-01" ))
58
58
date_end <- as.Date(paste0(year_end ," -01-01" ))
59
59
}
@@ -68,7 +68,7 @@ fetch_datasus <- function(year_start, month_start, year_end, month_end, uf="all"
68
68
} else if (substr(information_system ,1 ,3 ) == " SIM" | information_system == " SINASC" ){
69
69
dates <- seq(date_start , date_end , by = " year" )
70
70
dates <- lubridate :: year(dates )
71
- } else if (information_system == " SINAN-DENGUE-FINAL" | information_system == " SINAN-DENGUE-PRELIMINAR" | information_system == " SINAN-CHIKUNGUNYA-FINAL" | information_system == " SINAN-CHIKUNGUNYA-PRELIMINAR" | information_system == " SINAN-ZIKA-FINAL" | information_system == " SINAN-ZIKA-PRELIMINAR" ){
71
+ } else if (information_system == " SINAN-DENGUE-FINAL" | information_system == " SINAN-DENGUE-PRELIMINAR" | information_system == " SINAN-CHIKUNGUNYA-FINAL" | information_system == " SINAN-CHIKUNGUNYA-PRELIMINAR" | information_system == " SINAN-ZIKA-FINAL" | information_system == " SINAN-ZIKA-PRELIMINAR" | information_system == " SINAN-MALARIA-FINAL " | information_system == " SINAN-MALARIA-PRELIMINAR " ){
72
72
dates <- seq(date_start , date_end , by = " year" )
73
73
dates <- lubridate :: year(dates )
74
74
dates <- substr(dates , 3 , 4 )
@@ -223,6 +223,12 @@ fetch_datasus <- function(year_start, month_start, year_end, month_end, uf="all"
223
223
} else if (information_system == " SINAN-ZIKA-PRELIMINAR" ){
224
224
url <- " ftp://ftp.datasus.gov.br/dissemin/publicos/SINAN/DADOS/PRELIM/"
225
225
files_list <- paste0(url ," ZIKA" , file_extension )
226
+ } else if (information_system == " SINAN-MALARIA-FINAL" ){
227
+ url <- " ftp://ftp.datasus.gov.br/dissemin/publicos/SINAN/DADOS/FINAIS/"
228
+ files_list <- paste0(url ," MALA" , file_extension )
229
+ } else if (information_system == " SINAN-MALARIA-PRELIMINAR" ){
230
+ url <- " ftp://ftp.datasus.gov.br/dissemin/publicos/SINAN/DADOS/PRELIM/"
231
+ files_list <- paste0(url ," MALA" , file_extension )
226
232
}
227
233
228
234
# Dowload files
@@ -244,7 +250,7 @@ fetch_datasus <- function(year_start, month_start, year_end, month_end, uf="all"
244
250
245
251
# Merge files
246
252
if (nrow(partial ) > 0 ){
247
- if (! all(vars %in% names(partial ))) stop(" One or more variables names are unknow . Typo?" )
253
+ if (! all(vars %in% names(partial ))) stop(" One or more variables names are unknown . Typo?" )
248
254
if (is.null(vars )){
249
255
data <- dplyr :: bind_rows(data , partial )
250
256
} else {
0 commit comments