-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_snapshots.R
224 lines (154 loc) · 9.42 KB
/
get_snapshots.R
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
# library(desurvdata)
source("survstat_webservice.R")
library(data.table)
library(XML)
library(dplyr)
library(ISOweek)
require(RCurl)
require(stringi)
today <- Sys.Date()
time_of_last_update <- function(message = FALSE){
available_versions <- getHierarchyMembers("SurvStat", "English", "Data status as published in")
current <- available_versions$Caption[1]
cat("Data status to be displayed:", current, "- returning as date. \n")
current <- as.Date(substr(current, 10, 19))
return(current)
}
time_of_last_update(message = TRUE)
# dis <- get_diseases()
# define years to load. Note: For some pathogens we can only start in 2024
years <- year(Sys.Date()) - 0:2
years_short <- years[years >= 2024]
years <- as.character(years)
years_short <- as.character(years_short)
########## COVID-19
try({
dir.create("covid19")
dat_covid_age <- get_weekly_timeseries(disease = "COVID-19", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_covid_age, file = paste0("covid19/covid19-age-", today, ".csv"), row.names = FALSE)
dat_covid_states <- get_weekly_timeseries(disease = "COVID-19", years = years,
region_level = "State")
write.csv(dat_covid_states, file = paste0("covid19/covid19-states-", today, ".csv"), row.names = FALSE)
})
########## RSV
try({
dir.create("RSV_Infection")
dat_rsv_age <- get_weekly_timeseries(disease = "RSV (Meldepflicht gemäß IfSG)", years = years_short,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_rsv_age, file = paste0("RSV_Infection/RSV_Infection-age-", today, ".csv"), row.names = FALSE)
dat_rsv_states <- get_weekly_timeseries(disease = "RSV (Meldepflicht gemäß IfSG)", years = years_short,
region_level = "State")
write.csv(dat_rsv_states, file = paste0("RSV_Infection/RSV_Infection-states-", today, ".csv"), row.names = FALSE)
})
########## Seasonal influenza
try({
dir.create("Seasonal_Influenza")
dat_influenza_age <- get_weekly_timeseries(disease = "Influenza, saisonal", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_influenza_age, file = paste0("Seasonal_Influenza/Seasonal_Influenza-age-", today, ".csv"), row.names = FALSE)
dat_influenza_states <- get_weekly_timeseries(disease = "Influenza, saisonal", years = years,
region_level = "State")
write.csv(dat_influenza_states, file = paste0("Seasonal_Influenza/Seasonal_Influenza-states-", today, ".csv"), row.names = FALSE)
})
########## Pneumococcal disease
try({
dir.create("Pneumococcal_Disease")
dat_pneumococcal_age <- get_weekly_timeseries(disease = "Pneumokokken (Meldepflicht gemäß IfSG)", years = years_short,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_pneumococcal_age, file = paste0("Pneumococcal_Disease/Pneumococcal_Disease-age-", today, ".csv"), row.names = FALSE)
dat_pneumococcal_states <- get_weekly_timeseries(disease = "Pneumokokken (Meldepflicht gemäß IfSG)", years = years_short,
region_level = "State")
write.csv(dat_pneumococcal_states, file = paste0("Pneumococcal_Disease/Pneumococcal_Disease-states-", today, ".csv"), row.names = FALSE)
})
########## Norovirus
try({
dir.create("Noroviral_Gastroenteritis")
dat_noro_age <- get_weekly_timeseries(disease = "Noroviral gastroenteritis", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_noro_age, file = paste0("Noroviral_Gastroenteritis/Noroviral_Gastroenteritis-age-", today, ".csv"), row.names = FALSE)
dat_noro_states <- get_weekly_timeseries(disease = "Noroviral gastroenteritis", years = years,
region_level = "State")
write.csv(dat_noro_states, file = paste0("Noroviral_Gastroenteritis/Noroviral_Gastroenteritis-states-", today, ".csv"), row.names = FALSE)
})
########## Rotavirus
try({
dir.create("Rotavirus_Gastroenteritis")
dat_rota_age <- get_weekly_timeseries(disease = "Rotavirus gastroenteritis", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_rota_age, file = paste0("Rotavirus_Gastroenteritis/Rotavirus_Gastroenteritis-age-", today, ".csv"), row.names = FALSE)
dat_rota_states <- get_weekly_timeseries(disease = "Rotavirus gastroenteritis", years = years,
region_level = "State")
write.csv(dat_rota_states, file = paste0("Rotavirus_Gastroenteritis/Rotavirus_Gastroenteritis-states-", today, ".csv"), row.names = FALSE)
})
########## Listeriosis
try({
dir.create("Listeriosis")
dat_listeriosis_age <- get_weekly_timeseries(disease = "Listeriosis", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_listeriosis_age, file = paste0("Listeriosis/Listeriosis-age-", today, ".csv"), row.names = FALSE)
dat_listeriosis_states <- get_weekly_timeseries(disease = "Listeriosis", years = years,
region_level = "State")
write.csv(dat_listeriosis_states, file = paste0("Listeriosis/Listeriosis-states-", today, ".csv"), row.names = FALSE)
})
########## Salmonellosis
try({
dir.create("Salmonellosis")
dat_salmonellosis_age <- get_weekly_timeseries(disease = "Salmonellosis", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_salmonellosis_age, file = paste0("Salmonellosis/Salmonellosis-age-", today, ".csv"), row.names = FALSE)
dat_salmonellosis_states <- get_weekly_timeseries(disease = "Salmonellosis", years = years,
region_level = "State")
write.csv(dat_salmonellosis_states, file = paste0("Salmonellosis/Salmonellosis-states-", today, ".csv"), row.names = FALSE)
})
########## Campylobacteriosis
try({
dir.create("Campylobacteriosis")
dat_campylobacteriosis_age <- get_weekly_timeseries(disease = "Campylobacteriosis", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_campylobacteriosis_age, file = paste0("Campylobacteriosis/Campylobacteriosis-age-", today, ".csv"), row.names = FALSE)
dat_campylobacteriosis_states <- get_weekly_timeseries(disease = "Campylobacteriosis", years = years,
region_level = "State")
write.csv(dat_campylobacteriosis_states, file = paste0("Campylobacteriosis/Campylobacteriosis-states-", today, ".csv"), row.names = FALSE)
})
########## Meningococcal disease
try({
dir.create("Meningococcal_Disease")
dat_meningococcal_age <- get_weekly_timeseries(disease = "Meningococcal disease, invasive", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_meningococcal_age, file = paste0("Meningococcal_Disease/Meningococcal_Disease-age-", today, ".csv"), row.names = FALSE)
dat_meningococcal_states <- get_weekly_timeseries(disease = "Meningococcal disease, invasive", years = years,
region_level = "State")
write.csv(dat_meningococcal_states, file = paste0("Meningococcal_Disease/Meningococcal_Disease-states-", today, ".csv"), row.names = FALSE)
})
########## Lyme disease
try({
dir.create("Lyme_Disease")
dat_lyme_age <- get_weekly_timeseries(disease = "Lyme disease", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_lyme_age, file = paste0("Lyme_Disease/Lyme_Disease-age-", today, ".csv"), row.names = FALSE)
dat_lyme_states <- get_weekly_timeseries(disease = "Lyme disease", years = years,
region_level = "State")
write.csv(dat_lyme_states, file = paste0("Lyme_Disease/Lyme_Disease-states-", today, ".csv"), row.names = FALSE)
})
########## TBE
# dir.create("Tick-borne_encephalitis")
#
#
# dat_tbe_age <- get_weekly_timeseries(disease = "Tick-borne encephalitis (TBE)", years = years,
# region_level = "Age stratification: 1 year intervals")
# write.csv(dat_tbe_age, file = paste0("Tick-borne_encephalitis/Tick-borne_encephalitis-age-", today, ".csv"), row.names = FALSE)
#
# dat_tbe_states <- get_weekly_timeseries(disease = "Tick-borne encephalitis (TBE)", years = years,
# region_level = "State")
# write.csv(dat_tbe_states, file = paste0("Tick-borne_encephalitis/Tick-borne_encephalitis-states-", today, ".csv"), row.names = FALSE)
########## Legionnaires disease
try({
dir.create("Legionnaires_Disease")
dat_legionnaires_age <- get_weekly_timeseries(disease = "Legionnaires' disease", years = years,
region_level = "Age stratification: 1 year intervals")
write.csv(dat_legionnaires_age, file = paste0("Legionnaires_Disease/Legionnaires_Disease-age-", today, ".csv"), row.names = FALSE)
dat_legionnaires_states <- get_weekly_timeseries(disease = "Legionnaires' disease", years = years,
region_level = "State")
write.csv(dat_legionnaires_states, file = paste0("Legionnaires_Disease/Legionnaires_Disease-states-", today, ".csv"), row.names = FALSE)
})