readding batch code table

This commit is contained in:
frankknoll
2023-04-24 09:02:04 +02:00
parent 59e10f986e
commit 8d196c6ef4
8 changed files with 9326 additions and 9102 deletions

View File

@@ -0,0 +1,79 @@
class BatchCodeTableInitializer {
#batchCodeTableElement;
constructor(batchCodeTableElement) {
this.#batchCodeTableElement = batchCodeTableElement;
}
initialize() {
const clazz = this;
this.#batchCodeTableElement.DataTable(
{
ajax: 'data/batchCodeTables/Global.json',
initComplete: function (settings) {
batchCodeTable = settings.oInstance.api();
const columnSearch = new ColumnSearch(batchCodeTable.column(clazz.#getColumnIndex('Company')));
columnSearch.columnContentUpdated();
},
language:
{
searchPlaceholder: "Enter Batch Code"
},
searching: true,
search:
{
return: true
},
processing: true,
deferRender: true,
order: [[this.#getColumnIndex('Adverse Reaction Reports'), "desc"]],
columnDefs:
[
{
searchable: false,
targets: [
this.#getColumnIndex('Adverse Reaction Reports'),
this.#getColumnIndex('Deaths'),
this.#getColumnIndex('Disabilities'),
this.#getColumnIndex('Life Threatening Illnesses'),
this.#getColumnIndex('Severe reports'),
this.#getColumnIndex('Lethality')
]
},
{
orderable: false,
targets: [this.#getColumnIndex('Batch'), this.#getColumnIndex('Company')]
},
{
render: (data, type, row) => {
const numberInPercent = parseFloat(data);
return !isNaN(numberInPercent) ? numberInPercent.toFixed(2) + " %" : '';
},
targets: [this.#getColumnIndex('Severe reports'), this.#getColumnIndex('Lethality')]
}
]
});
}
#getColumnIndex(columnName) {
switch (columnName) {
case 'Batch':
return 0;
case 'Adverse Reaction Reports':
return 1;
case 'Deaths':
return 2;
case 'Disabilities':
return 3;
case 'Life Threatening Illnesses':
return 4;
case 'Company':
return 5;
case 'Severe reports':
return 6;
case 'Lethality':
return 7;
}
}
}

35
docs/ColumnSearch.js Normal file
View File

@@ -0,0 +1,35 @@
// adapted from https://datatables.net/examples/api/multi_filter_select.html
class ColumnSearch {
#column;
#select;
constructor(column) {
this.#column = column;
const clazz = this;
$('<br/>').appendTo($(this.#column.header()));
this.#select = $('<select></select>')
.appendTo($(this.#column.header()))
.on(
'change',
function () {
const val = $.fn.dataTable.util.escapeRegex($(this).val());
clazz.#column
.search(val ? '^' + val + '$' : '', true, false)
.draw();
});
}
columnContentUpdated() {
this.#select.empty();
this.#select.append('<option value=""></option>');
const clazz = this;
this.#column
.data()
.unique()
.sort()
.each(function (d, _) {
clazz.#select.append('<option value="' + d + '">' + d + '</option>');
});
}
}

9112
docs/HowBadIsMyBatch.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,7 @@
.dataTables_filter {
display: none;
}
.chartWithSlider {
display: flex;
flex-wrap: nowrap;

File diff suppressed because it is too large Load Diff

76
docs/batchCodes.html Normal file
View File

@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Batch Codes of Coronavirus 2019 Vaccines</title>
<!-- Google tag (gtag.js) -->
<script async="" src="https://www.googletagmanager.com/gtag/js?id=G-ERHYDH4P64"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-ERHYDH4P64');
</script>
<link href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<link href="batchCodeTable.css" rel="stylesheet" type="text/css" />
<link href="forkMeOnGitHub.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous"
integrity="sha512-T5Bneq9hePRO8JR0S/0lQ7gdW+ceLThvC80UjwkMRz+8q+4DARVZ4dqKoyENC7FcYresjfJ6ubaOgIE35irf4w=="
referrerpolicy="no-referrer"
src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.5.1/nouislider.min.js"></script>
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.5.1/nouislider.css"
integrity="sha512-MKxcSu/LDtbIYHBNAWUQwfB3iVoG9xeMCm32QV5hZ/9lFaQZJVaXfz9aFa0IZExWzCpm7OWvp9zq9gVip/nLMg=="
referrerpolicy="no-referrer" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script charset="utf8" src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.2.0/dist/chart.umd.min.js"></script>
<script src="./Utils.js"></script>
<script src="./UIUtils.js"></script>
<script src="./ColumnSearch.js"></script>
<script src="./BatchCodeTableInitializer.js"></script>
<script>
$(document).ready(function () {
const batchCodeTableInitializer = new BatchCodeTableInitializer($('#batchCodeTable'));
batchCodeTableInitializer.initialize();
});
</script>
</head>
<body>
<h1>Batch Codes of Coronavirus 2019 Vaccines</h1>
<table class="display" id="batchCodeTable">
<thead>
<tr>
<th>Batch</th>
<th>Adverse Reaction Reports</th>
<th>Deaths</th>
<th>Disabilities</th>
<th>Life Threatening Illnesses</th>
<th>Company</th>
<th>Severe reports</th>
<th>Lethality</th>
</tr>
</thead>
</table>
<footer>
<dl>
<dt>Data Source:</dt>
<dd><a href="https://vaers.hhs.gov/data/datasets.html" target="_blank">Vaccine Adverse Event Reporting System
(VAERS)</a></dd>
<dt>Last updated:</dt>
<dd id="last_updated">April 21, 2023</dd>
</dl>
<span id="forkongithub"><a href="https://github.com/KnollFrank/HowBadIsMyBatch" target="_blank">Fork me on
GitHub</a></span>
<div class="clearfix"></div>
</footer>
<template id="template-canvas">
<canvas></canvas>
</template>
</body>
</html>

View File

@@ -8,7 +8,7 @@ from DateProvider import DateProvider
def updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile):
batchcodeOptions = getBatchcodeOptions(getBatchcodes(batchCodeTable.sort_values(by = 'Adverse Reaction Reports', ascending = False)))
_saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile)
_saveLastUpdatedBatchCodeTable(
saveLastUpdatedBatchCodeTable(
DateProvider().getLastUpdatedDataSource(),
batchCodeTableHtmlFile)
@@ -22,7 +22,7 @@ def _saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile):
options=batchcodeOptions),
'lxml'))
def _saveLastUpdatedBatchCodeTable(lastUpdated, batchCodeTableHtmlFile):
def saveLastUpdatedBatchCodeTable(lastUpdated, batchCodeTableHtmlFile):
def setLastUpdated(soup):
soup.find(id="last_updated").string.replace_with(
lastUpdated.strftime(DateProvider.DATE_FORMAT))

View File

@@ -13,11 +13,12 @@
"pd.set_option('display.max_columns', None)\n",
"\n",
"import os\n",
"from IOUtils import IOUtils\n",
"from VAERSFileDownloader import updateVAERSFiles\n",
"from datetime import datetime\n",
"from DateProvider import DateProvider\n",
"from InternationalVaersCovid19Provider import getInternationalVaersCovid19, get_international_VAERSVAX_VAERSSYMPTOMS_Covid19\n",
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile\n",
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile, saveLastUpdatedBatchCodeTable\n",
"from BatchCodeTablePersister import createGlobalBatchCodeTable\n",
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n",
@@ -126,6 +127,19 @@
"batchCodeTable"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8e81ffc",
"metadata": {},
"outputs": [],
"source": [
"IOUtils.saveDataFrameAsJson(batchCodeTable, '../docs/data/batchCodeTables/Global.json')\n",
"saveLastUpdatedBatchCodeTable(\n",
" DateProvider().getLastUpdatedDataSource(),\n",
" batchCodeTableHtmlFile=\"../docs/batchCodes.html\")"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -133,7 +147,7 @@
"metadata": {},
"outputs": [],
"source": [
"updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile=\"../docs/batchCodeTable.html\")"
"updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile=\"../docs/HowBadIsMyBatch.html\")"
]
},
{