-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
453 lines (416 loc) · 13.1 KB
/
Copy pathindex.html
File metadata and controls
453 lines (416 loc) · 13.1 KB
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
<html>
<head>
<meta charset="utf-8"/>
<title>都道府県別 感染症病床数(カラム地図7x7、厚生労働省データ)</title>
<meta property="og:title" content="都道府県別 感染症病床数"/>
<meta property="og:description" content="感染病床を持つ医療機関と病床数を都道府県別にすばやく表示、厚生労働省のオープンデータ使用"/>
<link rel="apple-touch-icon" href="bedforinfection_icon.png"/>
<meta name="twitter:card" content="summary_large_image"/>
<meta property="og:image" content="https://code4sabae.github.io/bedforinfection/bedforinfection.png"/>
<meta name="twitter:image" content="https://code4sabae.github.io/bedforinfection/bedforinfection.png"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no"/>
<script src="https://fukuno.jig.jp/fukuno.js"></script>
<script>"use strict"
const link = function(url, name) {
return `<a href="${url}">${name}</a>`
}
window.onload = async function() {
get("japan").innerHTML += makeJapanHTML()
//const url = 'https://app.sabae.cc/api/bedforinfection.json'
const url = 'data/bedforinfection.json'
const json = await (await fetch(url)).json()
console.log(json)
init(json)
description.textContent = json.description
datasrc.innerHTML = 'データ出典:' + link(json.srcurl, '感染症指定医療機関の指定状況(平成31年4月1日現在)|厚生労働省') + " → " + link(url, 'JSON')
const show = [ 'sumi', 'sumt', 'sum1', 'sum2', 'sumk', 'sums' ]
for (const name of show) {
const c = document.getElementById(name)
if (c)
c.textContent = addComma(json.summary.total[name])
else
console.log(name)
}
lastUpdate.textContent = json.lastUpdate
}
const calcRatio = function(cnt, base) {
if (isNaN(cnt) || isNaN(base))
return "-"
return fixfloat(cnt / base * 100, 1) + "%"
}
const makeTableFromJSON = function(json, header) {
const s = []
s.push("<table>")
if (!header) {
header = []
for (const d of json) {
for (const name in d) {
if (header.indexOf(name) == -1) {
header.push(name)
}
}
}
}
s.push('<tr>')
for (let i = 0; i < header.length; i++) {
const name = header[i]
s.push(`<th>${name}</th>`)
}
s.push('</tr>')
const sum = []
for (let i = 0; i < header.length; i++)
sum[i] = 0
sum[1] = [] // 病院名
for (const d of json) {
s.push('<tr>')
for (let i = 0; i < header.length; i++) {
const name = header[i]
let val = d[name]
if (val === undefined) {
val = "-"
}
s.push(`<td>${val}</td>`)
if (val != "" && parseInt(val) == val) {
sum[i] += parseInt(val)
}
if (i == 1 && sum[1].indexOf(val) == -1) {
sum[1].push(val)
}
}
s.push('</tr>')
}
s.push('<tr>')
s.push('<td>合計</td>')
sum[1] = sum[1].length
for (let i = 1; i < sum.length; i++) {
let val = sum[i]
//if (val == 0 || header[i] == 'No.')
if (val == 0)
val = ""
s.push(`<td>${val}</th>`)
}
s.push("</table>")
return s.join("")
}
const HEADER_BED_ALL = [ '種別', '病院名', '所在地', 'No.', '病床数', '感染症病床', '結核病床(稼働病床)', '一般病床又は精神病床' ]
const HEADER_BED = [ '種別', '病院名', '病床数', '感染症病床', '結核病床(稼働病床)', '一般病床又は精神病床' ]
const init = function(data) {
// dump(data);
const area = data.summary.area
let max = 0
for (let i = 0; i < area.length; i++) {
if (area[i].sumi > max)
max = area[i].sumi
}
let sum = 0
for (let i = 1; i <= 47; i++) {
const c = get("jp" + i)
c.num = i - 1
const a = area[i - 1]
sum += a.sumi
const r = a.sumi / max
c.innerHTML += `<br>${addComma(a.sumi)}床<div class=pcr>(${addComma(a.sumt)}, ${addComma(a.sum1)}, ${addComma(a.sum2)}, ${addComma(a.sumk)})</div>`
const off = .05
// 224FC4
c.style.background = `rgba(${0x22}, ${0x4f}, ${0xfc},` + ((r + off) / (1 - off)) + ")"
c.style.color = r < .5 ? "black" : "white"
c.onclick = function() {
const pref = PREF[this.num]
const hosp = data.hospitals
const res = []
for (const name in hosp) {
for (const d of hosp[name]) {
if (d['所在地'] == pref) {
d['種別'] = name
res.push(d)
}
}
}
//dump(res)
tbl.innerHTML = makeTableFromJSON(res, HEADER_BED)
}
}
const t = data.summary.total
jpall.innerHTML = `全国<br>${addComma(t.sumi)}床` // <div class=pcrsum>(特定${addComma(t.sumt)} 一種${addComma(t.sum1)} 二種${addComma(t.sum2)} 結核${addComma(t.sumk)})</div>`
//jpall.style.fontSize = "150%"
jpall.style.background = 'var(--main-color)'
jpall.style.color = 'white'
jpall.onclick = function() {
//dump(data.summary.total)
//dump(null)
//tbl.innerHTML = ''
const hosp = data.hospitals
const res = []
for (const name in hosp) {
for (const d of hosp[name]) {
d['種別'] = name
res.push(d)
}
}
tbl.innerHTML = makeTableFromJSON(res, HEADER_BED_ALL)
}
}
// --
var PREF = [ "北海道", "青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県", "茨城県", "栃木県", "群馬県", "埼玉県", "千葉県", "東京都", "神奈川県", "新潟県", "富山県", "石川県", "福井県", "山梨県", "長野県", "岐阜県", "静岡県", "愛知県", "三重県", "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", "鳥取県", "島根県", "岡山県", "広島県", "山口県", "徳島県", "香川県", "愛媛県", "高知県", "福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県", "沖縄県" ];
// from CC0 カラム地図
// https://hackmd.io/7m2A33zJSWq6DA9lYbvtpQ
/*
const JAPAN = `
山口 島根 鳥取 石川 新潟 青森 北海道
広島 岡山 兵庫 福井 富山 秋田 岩手
長崎 大阪 京都 長野 山形 宮城
佐賀 福岡 滋賀 山梨 群馬 福島
熊本 宮崎 大分 三重 静岡 埼玉 栃木
鹿児島 愛媛 香川 奈良 岐阜 東京 茨城
沖縄 高知 徳島 和歌山 愛知 神奈川 千葉`
*/
/*
const JAPAN = `
山口 島根 鳥取 石川 新潟 青森 北海道
広島 岡山 兵庫 福井 富山 秋田 岩手
長崎 福岡 大阪 京都 長野 山形 宮城
佐賀 宮崎 滋賀 日本 山梨 群馬 福島
熊本 大分 奈良 日本 静岡 埼玉 栃木
鹿児島 愛媛 香川 三重 岐阜 東京 茨城
沖縄 高知 徳島 和歌山 愛知 神奈川 千葉`
*/
/*
const JAPAN = `
日本 日本 鳥取 石川 新潟 青森 北海道
山口 島根 兵庫 福井 富山 秋田 岩手
長崎 岡山 大阪 京都 長野 山形 宮城
佐賀 福岡 広島 滋賀 山梨 群馬 福島
熊本 宮崎 大分 三重 静岡 埼玉 栃木
鹿児島 愛媛 香川 奈良 岐阜 東京 茨城
沖縄 高知 徳島 和歌山 愛知 神奈川 千葉`
*/
const JAPAN = `
日本 日本 鳥取 石川 富山 青森 北海道
山口 島根 岡山 福井 新潟 秋田 岩手
長崎 福岡 広島 滋賀 長野 山形 宮城
佐賀 大分 兵庫 京都 山梨 群馬 福島
熊本 宮崎 大阪 奈良 岐阜 埼玉 栃木
鹿児島 愛媛 香川 和歌山 静岡 東京 茨城
沖縄 高知 徳島 三重 愛知 神奈川 千葉`
const PREF_S = [ '北海道', '青森', '岩手', '宮城', '秋田', '山形', '福島', '茨城', '栃木', '群馬', '埼玉', '千葉', '東京', '神奈川', '新潟', '富山', '石川', '福井', '山梨', '長野', '岐阜', '静岡', '愛知', '三重', '滋賀', '京都', '大阪', '兵庫', '奈良', '和歌山', '鳥取', '島根', '岡山', '広島', '山口', '徳島', '香川', '愛媛', '高知', '福岡', '佐賀', '長崎', '熊本', '大分', '宮崎', '鹿児島', '沖縄' ]
const makeJapanHTML = function() {
let japan = []
const japans = JAPAN.trim().split('\n')
for (let j of japans) {
japan.push(j.split('\t'))
}
let s = []
s.push('<table id=jp0>')
let flg = false
for (let jpn of japan) {
s.push('<tr>')
for (let pref of jpn) {
const n = PREF_S.indexOf(pref)
if (n < 0) {
if (!flg) {
s.push('<td class=pref id=jpall colspan=2>' + pref + '</td>')
flg = true
}
} else {
s.push('<td class=pref id=jp' + (n + 1) + '>' + pref + '</td>')
}
}
s.push('</tr>')
}
s.push('</table>')
return s.join('')
}
</script>
<style>
body {
font-family: sans-serif;
margin: 0;
word-wrap: break-word;
--main-color: #224FC4;
text-align: center;
}
h1 {
background-color: var(--main-color);
color: white;
text-align: center;
margin: 0;
padding: .3em;
font-size: 8vmin;
}
.subtitle {
background-color: var(--main-color);
color: white;
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: 50vw;
margin-top: 1vw;
margin-right: 2vw;
margin-left: 2vw;
}
#summarytable {
display: inline-block;
margin-left: auto;
margin-right: auto;
border-collapse: collapse;
margin-bottom: 0.5vh;
}
#summarytable td, th {
border: .3vw solid var(--main-color);
padding: .2vh .5vw;
width: 5vw;
font-size: 1.7vw;
text-align: center;
}
#summarytable td {
background-color: var(--main-color);
color: white;
font-size: 2vw;
}
#summarytable .sumi {
color: black;
background-color: white;
font-size: 3vw;
}
#summarydesc {
font-size: 80%;
margin-bottom: 1em;
}
#lastupdatebox {
margin-left: 1em;
}
#tbl table {
border-collapse: collapse;
display: inline-block;
margin-bottom: .5vw;
}
#tbl td {
border: 1px solid black;
padding: .2vw .4vw;
font-size: 1.8vw;
text-align: left;
}
#tbl td:nth-child(3), #tbl td:nth-child(4), #tbl td:nth-child(5), #tbl td:nth-child(6) {
text-align: right;
}
#tbl th {
border: 1px solid black;
padding: .2vw .4vw;
}
.content {
position: relative;
text-align: center;
}
#description {
margin: 1em;
font-size: 70%;
}
.pcr {
font-size: 65%;
}
.pcrsum {
font-size: 35%;
}
a {
color: gray !important;
}
#debug {
text-align: left;
font-size: 80%;
padding: .5em;
margin: 1em;
border: 1px solid black;
}
#datasrc {
font-size: 80%;
}
#link {
margin: 1em;
font-size: 90%;
}
#link img {
width: 80vw;
max-width: 300px;
}
#pr {
display: inline-block;
margin: 1vw;
border: 1px solid;
padding: .3vw 2vw;
}
/* credit */
.credit {
margin: 20px;
text-align: center;
font-size: 80%;
}
/* japan */
#japan {
display: inline-block;
width: 100%;
position: relative;
}
#jp0 {
border-spacing: .4vw;
border-collapse: separate;
margin: auto;
}
#jp0 td {
font-size: 1.4vw;
width: 6vw;
vertical-align: middle;
text-align: center;
x-border-radius: .5vw;
x-padding: vmin 0vw;
border: .25vmin solid #333;
cursor: pointer;
}
@media (max-aspect-ratio: 3/4) {
#jp0 td {
font-size: 2.5vw;
width: 12.0vw;
}
}
</style>
</head>
<body>
<h1 id=title>都道府県別 感染症病床数</h1>
<div class=subtitle>(平成31年4月1日現在)</div>
<div class="content">
<div id=summary>
<table id=summarytable>
<tr><th colspan=5 class=sumi>感染症病床数 <span id=sumi></span></th></tr>
<tr><th>特定</th><th>一種</th><th>二種</th><th>結核</th><th>一般</th></tr>
<tr><td id=sumt></td><td id=sum1></td><td id=sum2></td><td id=sumk></td><td id=sums></td></tr>
</table>
<div id=summarydesc>※ 感染症病床 = 特定 + 一種 + 二種(感染症病床)</div>
<div id=lastupdatebox>更新日時: <span id=lastUpdate></span></div>
</div>
<div id=cmap>
<div id="japan"></div>
</div>
<div id="description"></div>
<div id='tbl'></div>
<div id='datasrc'></div>
</div>
<!--<div id='pr'>自治体、医療機関の方へ<br><a href=https://fukuno.jig.jp/2799>新型コロナウイルス対策の感染病床のデータ提供お願いします</a></div>-->
<div id="link"><a href=https://www.stopcovid19.jp/><img alt="COVID-19 JAPAN" src="covid19japan.png"/></a></div>
<div class="credit">
APP: CC BY <a href=https://fukuno.jig.jp/2794>福野泰介 - 厚生労働省提供 都道府県別 感染症病床数を<a href=https://app.sabae.cc/api/bedforinfection.json>JSON-API</a>化して公開</a> <a href="https://twitter.com/search?q=%23StopCOVID19JP">#StopCOVID19JP</a> (<a href=https://github.com/code4sabae/bedforinfection>src on GitHub</a>)<br>
DATA: CC BY 「<a href=https://www.mhlw.go.jp/bunya/kenkou/kekkaku-kansenshou15/02-02.html>感染症指定医療機関の指定状況(平成31年4月1日現在)|厚生労働省</a>」公開データをJSON-APIに加工して使用 (<a href=https://github.com/code4sabae/app_sabae_cc>src on GitHub</a>)<br>
DATA: CC BY 「<a href=http://www.hospital.or.jp/shibu_kaiin/member.cgi>日本病院会|都道府県別会員一覧インデックス</a>」公開データのリンク追加 → <a href=data/hospitals-japan.csv>CSV</a> / <a href=data/hospitals-japan.sjis.csv>CSV for Excel</a> / <a href=data/hospitals-japan.json>JSON</a> (<a href=https://github.com/code4sabae/bedforinfection>src on GitHub</a>)<br>
LAYOUT: CC0 <a href=https://hackmd.io/7m2A33zJSWq6DA9lYbvtpQ>カラム地図</a> (<a href=https://github.com/tabularmaps/hq>カラム地図 / TabularMaps on Github</a> / <a href=https://fukuno.jig.jp/2434>7x7都道府県</a>)<br>
<img id=qrcode><script>addEventListener("load", () => qrcode.src = "https://chart.apis.google.com/chart?chs=140x140&cht=qr&chl=" + encodeURIComponent(document.location))</script><br>
</div>
</body>
</html>