-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.html
1435 lines (1346 loc) · 58.5 KB
/
index.html
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="ja">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-162141832-1"></script>
<script>
window.dataLayer = window.dataLayer || []
function gtag(){dataLayer.push(arguments)}
gtag('js', new Date())
gtag('config', 'UA-162141832-1')
</script>
<meta charset="utf-8">
<title>COVID-19 Japan - 新型コロナウイルス対策ダッシュボード #StopCOVID19JP</title>
<meta name="keywords" content="新型コロナウイルス,新型コロナ対策,ダッシュボーボード,dashboard,COVID-19 Japan,COVID-19,病床数,対策病床数,オープンデータ,opendata,open data,一日一創,福野泰介,Taisuke Fukuno,jig.jp">
<meta property="og:title" content="COVID-19 Japan 新型コロナウイルス対策ダッシュボード #StopCOVID19JP">
<meta property="og:description" content="日本の新型コロナ対策病床数と現在患者数を都道府県別にすばやく表示、厚生労働省と各自治体から提供されるオープンデータ使用 #StopCOVID19JP">
<meta name="theme-color" content="#AD232F">
<meta name="msapplication-TileColor" content="#AD232F">
<link rel="icon" type="image/png" href="covid19japan-icon.png">
<link rel="apple-touch-icon" href="covid19japan-leargeicon.png">
<meta name="msapplication-square310x310logo" content="covid19japan-leargeicon.png">
<meta name="twitter:card" content="summary_large_image">
<meta property="og:image" content="https://www.stopcovid19.jp/ogp/covid19japan_ogp_20230511085506.png">
<meta name="twitter:image" content="https://www.stopcovid19.jp/ogp/covid19japan_ogp_20230511085506.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="format-detection" content="telephone=no">
<link href="https://fonts.googleapis.com/css2?family=Overpass:wght@700&display=swap" rel="stylesheet">
<style>
body {
--main-color: #AD232F;
color: black;
font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
word-wrap: break-word;
margin: 0;
font-size: 1vmax;
}
a {
color: #555 !important;
}
header {
background-color: var(--main-color);
color: white;
}
h1 {
text-align: center;
margin: 0;
padding: .3em;
font-size: 8vmin;
x-font-family: 'Overpass', sans-serif;
}
.trendarrow {
position: relative;
top: .15em;
margin-left: .2em;
width: 1em;
}
.subtitle {
text-align: center;
margin: 0 0 .5em 0;
padding: .3em;
font-size: 3vmin;
}
#cmap {
display: inline-block;
vertical-align: top;
}
#summary {
display: inline-block;
vertical-align: middle;
max-width: 40vw;
margin-top: 0.3vw;
margin-right: 2vw;
margin-left: 2vw;
}
.summarygrid {
display: inline-grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(7);
grid-gap: 0;
grid-template-areas:
"a c"
"b d"
"e g"
"f h"
"i j"
"k k";
margin-bottom: 0.5vh;
font-size: 1.2vw;
}
.sga { grid-area: a; }
.sgb { grid-area: b; }
.sgc { grid-area: c; }
.sgd { grid-area: d; }
.sge { grid-area: e; }
.sgf { grid-area: f; }
.sgg { grid-area: g; }
.sgh { grid-area: h; }
.sgi { grid-area: i; }
.sgj { grid-area: j; }
.sgk { grid-area: k; }
.summarygrid > div {
border: .3vw solid var(--main-color);
margin: 0 -.3vw -.3vw 0;
padding: .1vh .5vw;
}
.sga, .sgc, .sge, .sgg {
}
.sgb, .sgd, .sgf, .sgh {
background-color: var(--main-color);
color: white;
font-size: 260%;
}
.sgi, .sgj {
}
.sgk {
}
.fontsmaller {
font-size: 60%;
}
#summarytable {
display: inline-block;
margin-left: auto;
margin-right: auto;
border-collapse: collapse;
margin-bottom: 0.1vh;
}
#summarytable td, #summarytable th {
border: .3vw solid var(--main-color);
padding: .2vh .5vw;
width: 20vw;
font-size: 1.3vw;
text-align: center;
}
#summarytable td {
background-color: var(--main-color);
color: white;
font-size: 4.0vw;
}
#summarydesc {
margin-bottom: 1em;
}
.summaryvent {
font-size: 70%;
}
#ventsrc {
font-size: 60%;
font-weight: normal;
}
#lastupdatebox {
}
.bedformula {
font-size: 110%;
font-weight: bold;
margin-bottom: .3em;
}
#beddescription {
font-size: 100%;
margin: .2em 0 .5em 0;
}
#bedtypes {
margin: .1em 0 .5em 0;
}
.content {
position: relative;
text-align: center;
}
.description {
margin: 1em;
}
.relateddata {
margin: 1em;
text-align: center;
}
.prefname {
font-size: 120%;
}
.npatients {
font-weight: bold;
}
.nbed {
font-size: 80%;
}
.pcr {
font-size: 64%;
}
.jpalllabel {
font-size: 125%;
}
.pcrsum {
font-size: 45%;
}
#datasrc {
x-font-size: 80%;
}
/* japan map */
#japan {
display: inline-block;
width: 100%;
position: relative;
}
#jp0 {
border-collapse: separate;
border-spacing: .4vw;
margin: auto;
}
#jp0 td {
font-size: 1.0vw;
width: 6vw;
height: 4em;
vertical-align: middle;
text-align: center;
x-border-radius: .5vw;
x-padding: vmin 0vw;
border: .25vmin solid #333;
cursor: pointer;
}
#detail {
display: none;
position: fixed;
z-index: 2;
background-color: white;
border: 4px solid black;
left: 0vw;
top: 0vh;
x-top: 23vh;
width: 100vw;
max-width: 95vh;
max-height: 100vh;
overflow-y: auto;
padding: 1vh 1vw;
box-sizing: border-box;
text-align: center;
}
#detailc {
display: inline-block;
}
#detailtitle {
font-size: 3.5vmin;
text-align: center;
margin: .5vmin;
}
#detaildesc {
font-size: 1.8vmin;
text-align: center;
margin: .5vmin;
}
#detaildesc .sum {
font-size: 2.8vmin;
}
#detailvent {
font-size: 1.8vmin;
text-align: center;
margin: 0.5vmin;
}
#chart {
width: 100%;
vertical-align: middle;
}
#detailbtns {
text-align: center;
margin: 2vmin;
}
#detailbtns > button {
margin: 1vmin;
font-size: 2.5vmin;
padding: 1vmin;
}
.areamap_title {
font-size: 140%;
margin-top: 1em;
margin-bottom: .3em;
}
.areamap {
border: 1px solid #333;
margin: .5em;
}
.areamap > span {
display: flex;
align-items: center;
justify-content: center;
padding: .2vmax .2vmax;
x-border: .1vmax solid #333;
x-margin: .2vmax;
}
@keyframes fadein {
0% { opacity: 0 }
100% { opacity: 1 }
}
@keyframes fadeout {
0% { opacity: 1 }
100% { opacity: 0 }
}
/* aspect */
@media (max-aspect-ratio: 3/4) {
body {
font-size: 1.3vmax;
}
#jp0 td {
font-size: 2.2vw;
width: 13.0vw;
}
#summary {
max-width: 100vw;
}
.summarygrid {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(5);
grid-gap: 0px;
grid-template-areas:
"a c e g"
"b d f h"
"i i j j"
"k k k k";
font-size: 1.9vw;
}
.sgb, .sgd, .sgf, .sgh {
font-size: 250%;
}
}
/* min font-size */
/*
@media (max-width: 640px) {
body {
font-size: 2vmax; calc(16px + ((1vw - 6.4px)*3.571));
}
}
*/
.pr {
margin-top: 1em;
text-align: center;
}
#pr {
text-align: center;
margin: 1em;
font-size: 160%;
}
#pr2 {
display: inline-block;
margin: 1vw;
border: 1px solid;
padding: .3vw 2vw;
}
#pr3, #pr5 {
display: inline-block;
text-align: center;
margin: 1vw;
x-width: 50vw;
}
#pr3 img, #pr3 picture {
width: 30vw;
}
#pr4 {
display: inline-block;
margin: 1vw;
}
#pr4 iframe {
display: inline-block;
width: 30vw;
height: 6.8vw;
border: #ddd solid 1px;
box-sizing: border-box;
padding-top: .5vw;
}
#pr5 img {
width: 30vw;
}
@media (max-width: 480px) {
#pr3 img, #pr5 img {
width: 90vw;
}
#pr4 iframe {
width: 90vw;
height: 19.2vw;
}
}
.lang {
text-align: center;
margin: .5em;
}
/* share */
#share {
text-align: center;
padding-bottom: 3em;
}
#share > * {
vertical-align: bottom;
}
#fb-share-button {
display: inline-block;
margin: .5em;
}
/* credit */
.credit {
margin: 2vw 0 1vw 0;
text-align: center;
}
/* media */
#media {
text-align: center;
margin-bottom: 2em;
}
#qrcode {
width: 140px;
}
/* debug */
#debug {
text-align: left;
}
</style>
<script src="fukuno.js"></script>
<script defer src='Chart.bundle.min.js' xsrc="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
<!--<script defer src='html2canvas.min.js'></script>-->
<script src='translation.js'></script>
<script>"use strict";
const getLang = function() {
const hash = document.location.hash
if (hash.indexOf('en') >= 0) {
return "en"
}
if (hash.indexOf('ja') >= 0) {
return "ja"
}
const lang = (window.navigator.languages && window.navigator.languages[0]) || window.navigator.language || window.navigator.userLanguage || window.navigator.browserLanguage
return lang
}
const tx = function(s) {
let lang = getLang()
if (lang.match('ja'))
return s
lang = 'en'
// return s
for (const ja in TX) {
for (;;) {
const n = s.indexOf(ja)
if (n < 0)
break
s = s.substring(0, n) + TX[ja][lang] + s.substring(n + ja.length)
}
}
const txarray = function(s, ar, aren) {
for (let i = 0; i < ar.length; i++) {
const s2 = ar[i]
for (;;) {
const n = s.indexOf(s2)
if (n < 0)
break
s = s.substring(0, n) + aren[i] + s.substring(n + s2.length)
}
}
return s
}
s = txarray(s, PREF, PREF_EN)
s = txarray(s, PREF_S, PREF_EN)
return s
}
const translate = function() {
document.title = tx(document.title)
//document.body.innerHTML = tx(document.body.innerHTML)
contents.innerHTML = tx(contents.innerHTML)
credit.innerHTML = tx(credit.innerHTML)
if (getLang() == 'en') {
document.getElementsByTagName('html')[0].setAttribute('lang', 'en')
/*
for (const css of document.styleSheets.cssRules) {
console.log(css)
}
*/
}
}
const lazyLoading = function() {
const iframes = document.getElementsByTagName('iframe')
for (const f of iframes) {
if (f.getAttribute('data-src')) {
f.setAttribute('src', f.getAttribute('data-src'))
}
}
}
const link = function(url, name) {
return `<a href="${cutQuery(url)}">${name}</a>`
}
const fetchJSON = async function(url) {
return await (await fetch(url)).json()
}
const fetchCSV = async function(url) {
const csv = await (await fetch(url)).text()
const data = decodeCSV(csv)
return csv2json(data)
}
const makeURL = function(path) {
//const base = 'http://localhost:8003/api/'
const base = 'data/'
return base + path + "?" + new Date().getTime() // ignore cache
}
const cutQuery = function(url) {
const n = url.lastIndexOf('?')
if (n >= 0)
return url.substring(0, n)
return url
}
const calcRatio = function(cnt, base) {
if (base == 0 || isNaN(cnt) || isNaN(base))
return "-"
const n = cnt / base * 100
return fixfloat(n, n >= 100 ? 0 : 1)
}
const parseTime = function(s) {
return new Date(s).getTime()
}
const main = async function() {
translate()
get("japan").innerHTML += makeJapanHTML()
const url = makeURL('covid19japan.json')
const json_mhlw = await fetchJSON(url)
for (const p of json_mhlw.area) {
p.lastUpdate = json_mhlw.lastUpdate
p.url_opendata = json_mhlw.srcurl_pdf
}
//console.log(json_mhlw)
const url_trend = makeURL('covid19japan-trend.json')
const json_trend = await fetchJSON(url_trend)
for (const p of json_mhlw.area) {
p.trend = json_trend.find(i => i.name === p.name)
}
//console.log(json_mhlw)
let json = json_mhlw
const url_bed = makeURL('bedforinfection_summary.json')
const json_bed = await fetchJSON(url_bed)
//console.log("json_bed", json_bed)
/*
const url_bedc = makeURL('bedforinfection_current.json')
const json_bedc = await fetchJSON(url_bedc)
console.log(json_bedc)
for (let i = 0; i < json_bedc.length; i++) {
const cbed = json_bedc[i]
for (let j = 0; j < json_bed.area.length; j++) {
const a = json_bed.area[j]
if (a.name_ja == cbed['自治体名']) {
const n = parseInt(cbed['新型コロナウイルス対策感染症病床数'])
a.sumc = n
a.sumc_src = cbed
}
json.area[j].bed = a
}
}
*/
const url_bedc = makeURL("covid19japan_beds/latest.json");
// list.push(['都道府県番号', '都道府県名', 'PCR検査陽性者数', '入院者数', '入院患者受入確保病床', '入院患者受入確保想定病床数', 'うち重症者数', '重症患者受入確保病床数', '重症患者受入確保想定病床数', '宿泊療養者数', '宿泊施設受入可能室数', '自宅療養者数', '社会福祉施設等療養者数', '確認中の人数', '更新日', '出典']);
const json_bedc = await fetchJSON(url_bedc)
console.log("json_bedc", json_bedc)
for (let i = 0; i < json_bedc.length; i++) {
const cbed = json_bedc[i]
for (let j = 0; j < json_bed.area.length; j++) {
const a = json_bed.area[j]
if (a.name_ja == cbed['都道府県名']) {
const n1 = parseInt(cbed['入院患者受入確保病床']);
const n2 = parseInt(cbed['宿泊施設受入可能室数']);
a.sumc = n1 + n2;
a.sumc_src = {
出典: cbed['出典'],
発表日: cbed['更新日'],
備考: '医療機関' + n1 + '床+宿泊施設' + n2 + '室'
};
}
json.area[j].bed = a;
}
}
const chkbed = [ bedt, bed1, bed2, bedk, beds ]
const namebed = [ 'sumt', 'sum1', 'sum2', 'sumk', 'sums' ]
const getBedCount = function(json) {
if (usebednow.checked && json.sumc) {
return json.sumc
}
let cnt = 0
for (let i = 0; i < chkbed.length; i++) {
const chk = chkbed[i]
if (chk.checked) {
cnt += json[namebed[i]]
}
}
return cnt
}
const url_vent = makeURL('ventilator-20200306.csv')
const json_vent = await fetchCSV(url_vent)
//console.log(json_vent)
for (let i = 0; i < json.area.length; i++) {
json.area[i].vent = json_vent[i]
}
json.vent = json_vent[47]
const showSummary = async function(json, json_bed) {
const sum = { ncurrentpatients: 0, nexits: 0, ndeaths: 0, npatients: 0 }
for (let i = 0; i < json.area.length; i++) {
for (const n in sum) {
const s = json.area[i][n]
sum[n] += s != parseInt(s) ? 0 : parseInt(s)
}
}
for (const n in sum) {
json[n] = sum[n]
}
if (window.usepatientspeek && usepatientspeek.checked) {
json.nexits = "-"
json.ndeaths = "-"
}
let sumbed = 0
for (let i = 0; i < json_bed.area.length; i++) {
sumbed += getBedCount(json_bed.area[i])
}
json_bed.total.useratio = calcRatio(json.ncurrentpatients, sumbed)
json_bed.total.sumc = sumbed
const data = [ json, json_bed.total ]
const show = [ [ 'ncurrentpatients', 'nexits', 'ndeaths', 'npatients', 'lastUpdate' ], [ 'useratio', 'sumc' ] ]
for (let i = 0; i < data.length; i++) {
const d = data[i]
for (const name of show[i]) {
const div = document.getElementById(name)
if (div) {
let n = d[name]
if (parseInt(n) === n && n >= 1000)
n = addComma(n)
div.textContent = n
}
}
}
const v = json.vent
const pi = parseInt
ventce.textContent = addComma(v['総CE(名)'])
ventvent.textContent = addComma(pi(v['人工呼吸器取扱(台)']) + pi(v['マスク専用人工呼吸器取扱(台)']))
ventecmo.textContent = addComma(v['ECMO装置取扱(台)'])
const srcurl = 'https://www.ja-ces.or.jp/info-ce/%e4%ba%ba%e5%b7%a5%e5%91%bc%e5%90%b8%e5%99%a8%e3%81%8a%e3%82%88%e3%81%b3ecmo%e8%a3%85%e7%bd%ae%e3%81%ae%e5%8f%96%e6%89%b1%e5%8f%b0%e6%95%b0%e7%ad%89%e3%81%ab%e9%96%a2%e3%81%99%e3%82%8b%e7%b7%8a/'
ventsrc.innerHTML = tx(`2020年2月回答 出典 <a href=${srcurl}>一般社団法人 日本呼吸療法医学会 公益社団法人 日本臨床工学技士会</a>`)
}
/*
const json_now = JSON.parse(JSON.stringify(json))
const url_tokyo = 'https://raw.githubusercontent.com/tokyo-metropolitan-gov/covid19/master/data/data.json'
const json_tokyo = await (await fetch(url_tokyo)).json()
console.log('tokyo', json_tokyo)
const tokyo = json_now.area[PREF.indexOf('東京都')]
tokyo.npatients = json_tokyo.main_summary.children[0].value
tokyo.ncurrentpatients = json_tokyo.main_summary.children[0].children[0].value
tokyo.nexits = json_tokyo.main_summary.children[0].children[1].value
tokyo.ndeaths = json_tokyo.main_summary.children[0].children[2].value
json_now.lastUpdateNow = json_tokyo.lastUpdate.replace(/\//g, '-')
*/
const json_now = JSON.parse(JSON.stringify(json))
const fastprefs = []
{
const url_fast = makeURL('covid19japan-fast.json')
const json_fast = await (await fetch(url_fast)).json()
console.log('fast', json_fast)
for (const json of json_fast) {
const pref = json_now.area[PREF_EN.indexOf(json.name)]
for (const name in json) {
pref[name] = json[name]
}
// if nbeds exists
if (pref.nbeds) {
//console.log('nbeds', pref)
const bed = json_bed.area.find(a => a.name === pref.name)
bed.sumc = pref.nbeds
bed.sumc_src = { 出典: pref.src_url, 発表日: pref.lastUpdate }
// for Chart .. 整理が必要
pref.bed.sumc = pref.nbeds
pref.bed.sumc_src = { 出典: pref.src_url, 発表日: pref.lastUpdate }
}
if (!json_now.lastUpdateNow || parseTime(json_now.lastUpdateNow) < parseTime(pref.lastUpdate)) {
json_now.lastUpdateNow = pref.lastUpdate
}
//console.log(pref) //
fastprefs.push(shortenPref(pref.name_jp))
}
}
// 病床数データ日付
const set = new Set();
console.log({json_now})
json_now.area.forEach(d => set.add(d.bed.sumc_src.発表日));
lastUpdateBed.textContent = Array.from(set.keys()).join(", ");
// ピーク時
const json_peek = JSON.parse(JSON.stringify(json))
{
const url_peek = makeURL('jmari_med_or_jp/patients_peek.csv')
const scsv = await (await fetch(url_peek)).text()
const json_p = csv2json(decodeCSV(scsv))
//console.log('peek', json_p)
const sum = function(d, ar) {
let n = 0
for (const name of ar) {
n += parseInt(d[name].trim())
}
return n
}
const date = '2020-04-03'
for (let i = 0; i < json_p.length; i++) {
const a = json_peek.area[i]
a.npatients = parseInt(json_p[i]['発症者'].trim())
a.ncurrentpatients1 = parseInt(json_p[i]['入院患者'].trim())
a.ncurrentpatients2 = parseInt(json_p[i]['重症患者'].trim())
a.nicus = sum(json_p[i], [ "ICU", "HCU", "SCU" ])
a.nexits = ""
a.ndeaths = ""
a.lastUpdate = date
}
json_peek.lastUpdateNow = date
//console.log(json_peek)
}
const update = function() {
if (window.usepatientspeek && usepatientspeek.checked) {
for (let i = 0; i < json_peek.area.length; i++) {
const a = json_peek.area[i]
a.ncurrentpatients = usepatientspeekh.checked ? a.ncurrentpatients2 : a.ncurrentpatients1
}
json = json_peek
labelcurrent.textContent = tx(usepatientspeekh.checked ? 'ピーク時予測重症患者数' : 'ピーク時予測患者数')
} else {
if (window.usepatientspeekh) {
usepatientspeekh.checked = false
}
json = usepatientsnow.checked ? json_now : json_mhlw
labelcurrent.textContent = tx('現在患者数')
}
if (json.lastUpdateNow) {
lastUpdateNow.textContent = tx(' (速報 ' + json.lastUpdateNow + ")")
}
lastUpdateNow.style.display = usepatientsnow.checked ? "inline" : "none"
showSummary(json, json_bed)
showPrefs(json, json_bed, getBedCount)
}
update()
for (const chk of chkbed) {
chk.onclick = update
}
usebednow.onclick = update
usepatientsnow.onclick = update
if (window.usepatientspeek) {
usepatientspeek.onclick = update
usepatientspeekh.onclick = function() {
if (usepatientspeekh.checked) {
usepatientspeek.checked = true
}
update()
}
}
const makeCSVURL = function(url) {
url = cutQuery(url)
return url.substring(0, url.length - 4) + 'csv'
}
const url_csv = makeCSVURL(url)
//description.innerHTML = tx('新型コロナウイルス感染症(国内事例) 現在患者数 / 対策病床数(累積陽性者/累積退院者/累積死者数)')
datasrc.innerHTML = tx('データ出典<br>現在患者数(速報): ' + link('https://docs.google.com/spreadsheets/d/1SPqnO0yLn8ubax96sDJZVDcjAH8QT1suLCIgroPGVHY/edit#gid=0', fastprefs.length + '都道府県発表 新型コロナウイルス患者数オープンデータ(' + fastprefs.join("/") + ')') + '→' + link("https://www.stopcovid19.jp/data/covid19japan-fast.csv", "CSV") + "/" + link("https://www.stopcovid19.jp/data/covid19japan-fast.json", "JSON") + "<br>現在患者数(日次更新、ベース): " + link(json.srcurl_web, '厚生労働省「各都道府県の検査陽性者の状況」') + link(json.srcurl_pdf, 'PDF') + " → " + link(url_csv, 'CSV') + '/' + link(url, 'JSON')) + '/' + link('tableview.html', 'APP') + " / " + link("https://www.mhlw.go.jp/stf/covid-19/open-data.html", "厚労省オープンデータ");
//datasrc.innerHTML += tx("<br>対策病床数: " + link('https://docs.google.com/spreadsheets/d/1u0Ul8TgJDqoZMnqFrILyXzTHvuHMht1El7wDZeVrpp8/edit#gid=0', '都道府県発表 新型コロナウイルス対策病床数オープンデータ') + " & " + link('https://www.mhlw.go.jp/bunya/kenkou/kekkaku-kansenshou15/02-02.html', '厚生労働省「感染症指定医療機関の指定状況」') + " → " + link(url_bed, "JSON") + "/" + link('https://code4sabae.github.io/bedforinfection/', 'APP'))
datasrc.innerHTML += tx("<br>対策病床数(週次更新): " + link("https://www.mhlw.go.jp/stf/seisakunitsuite/newpage_00023.html", "療養状況等及び入院患者受入病床数等に関する調査について|厚生労働省") + " → " + link("https://www.stopcovid19.jp/data/covid19japan_beds/latest.csv", "CSV") + "/" + link("https://www.stopcovid19.jp/data/covid19japan_beds/latest.json", "JSON") + "/" + link("./mhlw-beds.html", "APP"));
datasrc.innerHTML += tx("<br>救急搬送困難事案数(週次更新): " + link("https://www.fdma.go.jp/disaster/coronavirus/post-1.html", "新型コロナウイルス感染症に伴う救急搬送困難事案に係る状況調査について(救急企画室) | 新型コロナウイルス感染症関連 | 総務省消防庁") + " → " + link("https://github.com/code4fukui/fdma_go_jp/blob/main/README.md", "CSV") + "/" + link("https://code4fukui.github.io/fdma_go_jp/pref.html", "APP"));
const url_link = makeURL('covid19pref.json')
const json_link = await fetchJSON(url_link)
//const url_cio = makeURL('covid19cio.json')
//const json_cio = await fetchJSON(url_cio)
//console.log(json_cio)
showAreas(json_link, url_link, json, json_bed.total, getBedCount)
//description.textContent = json.description
//datasrc.innerHTML += tx("<br><a href=http://square.umin.ac.jp/jrcm/index.html>一般社団法人 日本呼吸療法医学会</a> <a href=https://www.ja-ces.or.jp/>公益社団法人 日本臨床工学技士会</a>")
lazyLoading()
/*
capture.onclick = async function() {
window.scrollTo(0, 0)
const canvas = await html2canvas(tocapture)
downloadImage('covid19japan.png', canvas.toDataURL())
}
*/
// hash
for (let i = 0; i < PREF_EN.length; i++) {
const pref = PREF_EN[i];
if (document.location.hash.indexOf(pref) >= 0) {
const div = get("jp" + (i + 1));
showChart(div);
break;
}
}
}
document.addEventListener("DOMContentLoaded", main)
const downloadImage = function(fn, data) {
const a = create('a')
a.href = data
a.download = fn
a.click()
}
const showChart = async function(data) {
//console.log('showChart', data.data)
console.log("show", data.data);
const npatients_c = data.data.ncurrentpatients
const nbed = data.getBedCount()
if (detail.chart) {
detail.chart.destroy()
}
detail.chart = new Chart(chart, {
type: 'pie',
data: {
labels: [ tx("現在患者数(" + npatients_c + ")"), tx("想定病床残数(" + (nbed - npatients_c) + ")") ],
datasets: [{
backgroundColor: [ 'red', '#ccc' ],
data: [ npatients_c, nbed - npatients_c < 0 ? 0 : nbed - npatients_c ],
}]
}
})
detailtitle.innerHTML = tx((data.data.name_jp ? data.data.name_jp : "全国") + ' 現在患者数/対策病床数 ' + calcRatio(npatients_c, nbed) + "%");
const voice = (data.data.name_jp ? data.data.name_jp : "全国") + "の現在患者数は、" + npatients_c + "人、対策病床数は" + nbed + "、その割合は" + calcRatio(npatients_c, nbed) + "%です";
detaildesc.innerHTML = "<span class=sum>" + tx(`累積陽性者: ${addComma(data.data.npatients)}人 累積退院者: ${addComma(data.data.nexits)}人<br> 累積死者: ${addComma(data.data.ndeaths)}人 対策病床数: ${addComma(nbed)}床`) + "</span>";
if (data.data.src_url) {
detaildesc.innerHTML += tx(`<br>現在患者数 出典: <a href=${data.data.url_opendata}>${data.data.name_jp} 新型コロナウイルス患者数オープンデータ</a>(更新日: ${data.data.lastUpdate})`)
} else {
detaildesc.innerHTML += tx(`<br>現在患者数 出典: <a href=${data.data.url_opendata}>厚生労働省 新型コロナウイルス感染症 各都道府県の検査陽性者の状況</a>(更新日: ${data.data.lastUpdate})`)
}
detaildesc.innerHTML += tx(`<br><a href=http://www.jibika.or.jp/members/information/info_corona.html>一般社団法人 日本耳鼻咽喉科学会</a>定義における`)
if (npatients_c < 10) {
detaildesc.innerHTML += tx(`ローリスク地域(現在患者数 ${npatients_c}名 < 10名)`)
} else {
detaildesc.innerHTML += tx(`ハイリスク地域(現在患者数 ${npatients_c}名 >= 10名)`)
}
//console.log(data.data)
const bed = data.data.bed
if (bed && bed.sumc_src) {
//console.log(bed.sumc_src)
detaildesc.innerHTML += tx(`<br>対策病床数`);
if (bed.sumc_src['備考']) {
detaildesc.innerHTML += tx(` ${bed.sumc_src['備考']}`)
}
detaildesc.innerHTML += tx(` 出典: <a href="https://www.mhlw.go.jp/stf/seisakunitsuite/newpage_00023.html" xhref="${bed.sumc_src['出典']}">新型コロナウイルス対策病床数オープンデータ</a>(発表日: ${bed.sumc_src['発表日']})`)
}
const v = data.data.vent
const pi = parseInt
detailvent.innerHTML = tx(`<br>(参考) 臨床工学技士:${addComma(v['総CE(名)'])}人 マスク専用含む人工呼吸器取扱:${addComma(pi(v['人工呼吸器取扱(台)']) + pi(v['マスク専用人工呼吸器取扱(台)']))}台 ECMO装置取扱:${addComma(v['ECMO装置取扱(台)'])}台`)
//detailvent.innerHTML += "<br>※総人工呼吸器取扱 = 人工呼吸器取扱 + マスク専用人工呼吸器取扱<br>データ出典:<a href=https://www.ja-ces.or.jp/info-ce/%e4%ba%ba%e5%b7%a5%e5%91%bc%e5%90%b8%e5%99%a8%e3%81%8a%e3%82%88%e3%81%b3ecmo%e8%a3%85%e7%bd%ae%e3%81%ae%e5%8f%96%e6%89%b1%e5%8f%b0%e6%95%b0%e7%ad%89%e3%81%ab%e9%96%a2%e3%81%99%e3%82%8b%e7%b7%8a/>人工呼吸器およびECMO装置の取扱台数等に関する緊急調査の結果について | 公益社団法人 日本臨床工学技士会</a><br>出典(<a href=https://www.ja-ces.or.jp/>一般社団法人 日本呼吸療法医学会 公益社団法人 日本臨床工学技士会</a>)"
const srcurl = 'https://www.ja-ces.or.jp/info-ce/%e4%ba%ba%e5%b7%a5%e5%91%bc%e5%90%b8%e5%99%a8%e3%81%8a%e3%82%88%e3%81%b3ecmo%e8%a3%85%e7%bd%ae%e3%81%ae%e5%8f%96%e6%89%b1%e5%8f%b0%e6%95%b0%e7%ad%89%e3%81%ab%e9%96%a2%e3%81%99%e3%82%8b%e7%b7%8a/'
detailvent.innerHTML += tx(`<br>2020年2月回答 出典: <a href=${srcurl}>一般社団法人 日本呼吸療法医学会 公益社団法人 日本臨床工学技士会</a>`)
detail.style.display = "block"
detail.style.animation = "fadein .2s ease 0s 1 normal"
/*detail.onclick = */btnclose2.onclick = btnclose.onclick = function() {
detail.style.animation = "fadeout .2s ease 0s 1 normal"
setTimeout(function() {
detail.style.display = "none"
}, 150)
};
if (data.appurl) {
btnapp.style.display = "inline"
btnapp.onclick = function(e) {
window.open(data.appurl)
e.stopPropagation()
}
} else {
btnapp.style.display = "none"
}
btnweb.onclick = function(e) {
window.open(data.url)
e.stopPropagation()
}
// 推移
detail_graph.innerHTML = "";
showAreaMapGraph(detail_graph, data.data.name);
// 東京
detail_areamap.innerHTML = ''
if (data.data.name == 'Tokyo') {
await showAreaMapTokyo()
}
// hash
{
const pref = data.data.name;
const hash = document.location.hash;
if (hash.indexOf('en') >= 0) {
document.location.hash = pref + ",en";
} else {
document.location.hash = pref;
}
}
// 読み上げ
btnsay.style.cursor = "pointer";
btnsay.onclick = async () => {
globalThis.voiceOver = globalThis.voiceOver || (await import("./voiceOver.js")).voiceOver;
voiceOver(voice);
};
}
// 推移グラフ
const showAreaMapGraph = async (parent, pref) => {
if (!pref) {
return;
}
const fn = `data/covid19japan/pref/${pref}.csv`;
const json = await fetchCSV(fn);
//console.log(fn, json);
const date = [];
const data1 = [];
const data2 = [];
const data_c = [];
const data_d = [];
let bkis = null;
for (const d of json) {
date.push(d.date);
data_c.push(d.ncurrentpatients);
data_d.push(d.ndeaths);
if (d.ninspections === undefined) {
data2.push(0);
} else {
const n = parseInt(d.ninspections);
if (bkis === null) {
data2.push(n);
} else {
data2.push(n - bkis);
}
bkis = n;
}
}
const config = {
data: {
labels: date,
datasets: [
{ type: "line", label: tx("入院治療を要する者"), data: data_c, borderColor: 'rgb(80, 80, 205)', fill: false, lineTension: 0, yAxisID: "yr" },
//{ type: "line", label: "PCR 検査陽性者数", data: data1, borderColor: 'rgb(255, 99, 132)', fill: false, lineTension: 0, yAxisID: "yl" },
// { type: "line", label: "死亡者数", data: data_dd, borderColor: 'rgb(10, 10, 12)', fill: false, lineTension: 0, yAxisID: "yl" },
{ type: "line", label: tx("累計死亡者数"), data: data_d, borderColor: 'rgb(10, 10, 12)', fill: false, lineTension: 0, yAxisID: "yl" },
//{ type: "bar", label: "PCR 検査実施件数", hidden: false /*true*/, data: data2, backgroundColor: 'rgb(99, 255, 132)', fill: false, lineTension: 0, yAxisID: "yr" }
]
},
options: {
scales: {
xAxes: [{ scaleLabel: { display: false, labelString: "日付" } }],
yAxes: [
{ id: "yr", position: "right", scaleLabel: { display: true, labelString: /*"PCR 検査実施件数・*/ tx("入院治療を要する者") }, ticks: { beginAtZero: true } },
{ id: "yl", position: "left", scaleLabel: { display: true, labelString: tx("PCR検査陽性者数・累計死亡者数") }, ticks: { beginAtZero: true } },
],
},
legend: { display: true }
}
};
parent.style.display = "block";
parent.style.marginBottom = ".5em";
const chart = document.createElement("canvas");
chart.width = 600;
chart.height = 350;
new Chart.Chart(chart, config);
parent.appendChild(chart);
};
// 東京マップ
const TOKYO_CITY_MAP = `奥多摩町 青梅市 武蔵村山市 東村山市 清瀬市 板橋区 北区 足立区
日の出町 瑞穂町 立川市 東大和市 東久留米市 練馬区 文京区 荒川区
あきる野市 羽村市 国分寺市 小平市 西東京市 中野区 千代田区 台東区
檜原村 福生市 国立市 小金井市 武蔵野市 豊島区 中央区 墨田区
- 昭島市 府中市 三鷹市 杉並区 新宿区 港区 葛飾区
- 日野市 多摩市 調布市 世田谷区 渋谷区 品川区 江戸川区
新島村 八王子市 町田市 稲城市 狛江市 目黒区 大田区 江東区
利島村 大島町 神津島村 御蔵島村 三宅村 青ヶ島村 八丈町 小笠原村`
const makeGrids = function(stab) {
const area = []
let maxc = 0
const lines = stab.split('\n')
for (let a of lines) {