Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Commit ed6ddb1

Browse files
committed
Restructure CSV
This ensures we continue to have separate metrics for: - initialDosesCumulative* - finalDosesCumulative* …and… - onlyPartiallyVaccinated* - atLeastPartiallyVaccinated* - fullyVaccinated* Issue: #35
1 parent 32dc400 commit ed6ddb1

File tree

7 files changed

+2345
-2278
lines changed

7 files changed

+2345
-2278
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Usually, the spreadsheets containing the statistics for day `X` are published on
2424

2525
### Partially vs. fully vaccinated
2626

27-
There’s been [some confusion](https://github.com/mathiasbynens/covid-19-vaccinations-germany/issues/27#issuecomment-829299315) about what “partial” vaccination means. Given that there are multiple potentially interesting metrics that RKI does not report directly, we derive and expose the following additional columns:
27+
There’s been [some](https://github.com/mathiasbynens/covid-19-vaccinations-germany/issues/27#issuecomment-829299315) [confusion](https://github.com/mathiasbynens/covid-19-vaccinations-germany/issues/35#issuecomment-856290243) about what “partial” vaccination means. Given that there are multiple potentially interesting metrics that RKI does not report directly, we derive and expose the following additional columns:
2828

2929
- `onlyPartiallyVaccinatedCumulative`: the number of people who are partially vaccinated but still need a second shot. (They received exactly 1 dose of Pfizer/BioNTech, Moderna, Oxford/AstraZeneca, and still need a second dose to become fully vaccinated.)
3030
- `onlyPartiallyVaccinatedPercent`

build-chart.js

+54-20
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ let maxCount = 0;
5252
let oldestDate = '9001-12-31';
5353
let latestDate = '1970-01-01';
5454
let latestPubDate = '1970-01-01';
55-
for (const {date, pubDate, state, atLeastPartiallyVaccinatedCumulative, atLeastPartiallyVaccinatedPercent, atLeastPartiallyVaccinatedCumulativeBioNTech, atLeastPartiallyVaccinatedCumulativeModerna, atLeastPartiallyVaccinatedCumulativeAstraZeneca, fullyVaccinatedCumulative, fullyVaccinatedPercent, fullyVaccinatedCumulativeBioNTech, fullyVaccinatedCumulativeModerna, fullyVaccinatedCumulativeAstraZeneca, fullyVaccinatedCumulativeJohnsonAndJohnson, totalDosesCumulative} of records) {
55+
for (const {date, pubDate, state, onlyPartiallyVaccinatedCumulative, onlyPartiallyVaccinatedPercent, atLeastPartiallyVaccinatedCumulative, atLeastPartiallyVaccinatedPercent, fullyVaccinatedCumulative, fullyVaccinatedPercent, totalDosesCumulative, initialDosesCumulative, finalDosesCumulative, initialDosesPercent, finalDosesPercent, initialDosesCumulativeBioNTech, finalDosesCumulativeBioNTech, initialDosesCumulativeModerna, finalDosesCumulativeModerna, initialDosesCumulativeAstraZeneca, finalDosesCumulativeAstraZeneca, finalDosesCumulativeJohnsonAndJohnson} of records) {
5656
if (state !== BUNDESWEHR) states.add(state);
57+
const countInitialDoses = Number(initialDosesCumulative);
58+
const countFinalDoses = Number(finalDosesCumulative);
5759
const countTotal = Number(totalDosesCumulative);
60+
const countBioNTech = Number(initialDosesCumulativeBioNTech) + Number(finalDosesCumulativeBioNTech);
61+
const countModerna = Number(initialDosesCumulativeModerna) + Number(finalDosesCumulativeModerna);
62+
const countAstraZeneca = Number(initialDosesCumulativeAstraZeneca) + Number(finalDosesCumulativeAstraZeneca);
63+
const countJohnsonAndJohnson = Number(finalDosesCumulativeJohnsonAndJohnson);
5864
if (countTotal > maxCount) {
5965
maxCount = countTotal;
6066
}
@@ -74,17 +80,18 @@ for (const {date, pubDate, state, atLeastPartiallyVaccinatedCumulative, atLeastP
7480
}
7581
map.get(date).set(state, {
7682
cumulativeTotal: countTotal,
77-
cumulativeFinal: Number(fullyVaccinatedCumulative),
78-
// TODO: This might be wrong, depending on whether `atLeastPartiallyVaccinatedCumulative*` includes people who received a second dose as well.
79-
cumulativeTotalBioNTech: Number(atLeastPartiallyVaccinatedCumulativeBioNTech) + Number(fullyVaccinatedCumulativeBioNTech),
80-
cumulativeTotalModerna: Number(atLeastPartiallyVaccinatedCumulativeModerna) + Number(fullyVaccinatedCumulativeModerna),
81-
cumulativeTotalAstraZeneca: Number(atLeastPartiallyVaccinatedCumulativeAstraZeneca) + Number(fullyVaccinatedCumulativeAstraZeneca),
82-
cumulativeTotalJohnsonAndJohnson: Number(fullyVaccinatedCumulativeJohnsonAndJohnson),
83+
cumulativeInitial: countInitialDoses,
84+
cumulativeFinal: countFinalDoses,
85+
cumulativeTotalBioNTech: countBioNTech,
86+
cumulativeTotalModerna: countModerna,
87+
cumulativeTotalAstraZeneca: countAstraZeneca,
88+
cumulativeTotalJohnsonAndJohnson: countJohnsonAndJohnson,
89+
onlyPartiallyVaccinatedCumulative: Number(onlyPartiallyVaccinatedCumulative),
90+
onlyPartiallyVaccinatedPercent: Number(onlyPartiallyVaccinatedPercent),
8391
atLeastPartiallyVaccinatedCumulative: Number(atLeastPartiallyVaccinatedCumulative),
8492
atLeastPartiallyVaccinatedPercent: Number(atLeastPartiallyVaccinatedPercent),
8593
fullyVaccinatedCumulative: Number(fullyVaccinatedCumulative),
8694
fullyVaccinatedPercent: Number(fullyVaccinatedPercent),
87-
// TODO: This now possibly includes 2nd doses, since it’s atLeastPartiallyVaccinatedPercent. Rename.
8895
percentInitialDose: percentInitialDose,
8996
percentFinalDose: percentFinalDose,
9097
});
@@ -139,6 +146,17 @@ const percentFormatter = new Intl.NumberFormat('en', {
139146
minimumFractionDigits: 2,
140147
maximumFractionDigits: 2,
141148
});
149+
function percentOnlyPartiallyVaccinated(state) {
150+
if (state) {
151+
const latestEntries = sortedMap.get(latestDate);
152+
const latestStateEntries = latestEntries.get(state);
153+
const percent = latestStateEntries.onlyPartiallyVaccinatedPercent;
154+
return percentFormatter.format(percent);
155+
}
156+
const percent = nationalCumulativeOnlyPartiallyVaccinated /
157+
POPULATION_GERMANY * 100;
158+
return percentFormatter.format(percent);
159+
}
142160
function percentAtLeastPartiallyVaccinated(state) {
143161
if (state) {
144162
const latestEntries = sortedMap.get(latestDate);
@@ -166,6 +184,12 @@ const intFormatter = new Intl.NumberFormat('en', {
166184
minimumFractionDigits: 0,
167185
maximumFractionDigits: 0,
168186
});
187+
function onlyPartiallyVaccinated(state) {
188+
const current = state ?
189+
map.get(latestDate).get(state).onlyPartiallyVaccinatedCumulative :
190+
nationalCumulativeOnlyPartiallyVaccinated;
191+
return intFormatter.format(current);
192+
}
169193
function atLeastPartiallyVaccinated(state) {
170194
const current = state ?
171195
map.get(latestDate).get(state).atLeastPartiallyVaccinatedCumulative :
@@ -264,6 +288,7 @@ function sevenDayAverageDosesAsPercentage(state) {
264288
}
265289

266290
let nationalCumulativeTotal = 0;
291+
let nationalCumulativeOnlyPartiallyVaccinated = 0;
267292
let nationalCumulativeAtLeastPartiallyVaccinated = 0;
268293
let nationalCumulativeFullyVaccinated = 0;
269294
let nationalCumulativeTotalInitialDose = 0;
@@ -284,28 +309,36 @@ function generateNationalData() {
284309
];
285310

286311
const countsTotal = [];
312+
const countsInitialDose = [];
287313
const countsFinalDose = [];
288314
const countsAvailable = [];
289315
for (const [date, entry] of sortedMap) {
316+
let onlyPartiallyVaccinated = 0;
290317
let atLeastPartiallyVaccinated = 0;
291318
let fullyVaccinated = 0;
292319
let totalDoses = 0;
320+
let initialDoses = 0;
293321
let finalDoses = 0;
294322
let availableDoses = 0;
295323
for (const data of entry.values()) {
324+
onlyPartiallyVaccinated += data.onlyPartiallyVaccinatedCumulative;
296325
atLeastPartiallyVaccinated += data.atLeastPartiallyVaccinatedCumulative;
297326
fullyVaccinated += data.fullyVaccinatedCumulative;
298327
totalDoses += data.cumulativeTotal;
328+
initialDoses += data.cumulativeInitial;
299329
finalDoses += data.cumulativeFinal;
300330
availableDoses = cumulativeDeliveryMap.get(date).get('Total');
301331
}
302332
if (date === latestDate) {
333+
nationalCumulativeOnlyPartiallyVaccinated = onlyPartiallyVaccinated;
303334
nationalCumulativeAtLeastPartiallyVaccinated = atLeastPartiallyVaccinated;
304335
nationalCumulativeFullyVaccinated = fullyVaccinated;
305336
nationalCumulativeTotal = totalDoses;
337+
nationalCumulativeTotalInitialDose = initialDoses;
306338
nationalCumulativeTotalFinalDose = finalDoses;
307339
}
308340
countsTotal.push(totalDoses);
341+
countsInitialDose.push(initialDoses);
309342
countsFinalDose.push(finalDoses);
310343
countsAvailable.push(availableDoses);
311344
}
@@ -320,12 +353,11 @@ function generateNationalData() {
320353
chartType: 'line',
321354
values: countsTotal,
322355
},
323-
// TODO: Replace with atLeastPartiallyVaccinatedCumulative?
324-
// {
325-
// name: 'Initial doses',
326-
// chartType: 'line',
327-
// values: countsInitialDose,
328-
// },
356+
{
357+
name: 'Initial doses',
358+
chartType: 'line',
359+
values: countsInitialDose,
360+
},
329361
{
330362
name: 'Final doses',
331363
chartType: 'line',
@@ -657,14 +689,14 @@ function generateStateData(desiredState) {
657689
];
658690

659691
const countsTotal = [];
660-
const countsAtLeastPartiallyVaccinated = [];
661-
const countsFullyVaccinated = [];
692+
const countsInitialDose = [];
693+
const countsFinalDose = [];
662694
const countsAvailable = [];
663695
for (const [date, entry] of sortedMap) {
664696
const data = entry.get(desiredState);
665697
countsTotal.push(data.cumulativeTotal);
666-
countsAtLeastPartiallyVaccinated.push(data.atLeastPartiallyVaccinatedCumulative);
667-
countsFullyVaccinated.push(data.cumulativeFinal);
698+
countsInitialDose.push(data.cumulativeInitial);
699+
countsFinalDose.push(data.cumulativeFinal);
668700
const availableDoses = cumulativeDeliveryMap.get(date).get(desiredState);
669701
countsAvailable.push(availableDoses);
670702
}
@@ -682,12 +714,12 @@ function generateStateData(desiredState) {
682714
{
683715
name: 'Initial doses',
684716
chartType: 'line',
685-
values: countsAtLeastPartiallyVaccinated,
717+
values: countsInitialDose,
686718
},
687719
{
688720
name: 'Final doses',
689721
chartType: 'line',
690-
values: countsFullyVaccinated,
722+
values: countsFinalDose,
691723
},
692724
);
693725

@@ -752,8 +784,10 @@ const createHtml = template(HTML_TEMPLATE, {
752784
dataAnomalyWarning,
753785
isDeliveryDataDefinitelyOutdated,
754786
population,
787+
percentOnlyPartiallyVaccinated,
755788
percentAtLeastPartiallyVaccinated,
756789
percentFullyVaccinated,
790+
onlyPartiallyVaccinated,
757791
atLeastPartiallyVaccinated,
758792
fullyVaccinated,
759793
sevenDayAverageDoses,

0 commit comments

Comments
 (0)