From 8d196c6ef4ecbed57546b102fa4a8dc9da4e8d1d Mon Sep 17 00:00:00 2001 From: frankknoll Date: Mon, 24 Apr 2023 09:02:04 +0200 Subject: [PATCH] readding batch code table --- docs/BatchCodeTableInitializer.js | 79 + docs/ColumnSearch.js | 35 + docs/HowBadIsMyBatch.html | 9112 +++++++++++++++++++++++++++++ docs/batchCodeTable.css | 4 + docs/batchCodeTable.html | 9100 +--------------------------- docs/batchCodes.html | 76 + src/BatchCodeTableHtmlUpdater.py | 4 +- src/HowBadIsMyBatch.ipynb | 18 +- 8 files changed, 9326 insertions(+), 9102 deletions(-) create mode 100644 docs/BatchCodeTableInitializer.js create mode 100644 docs/ColumnSearch.js create mode 100644 docs/HowBadIsMyBatch.html create mode 100644 docs/batchCodes.html diff --git a/docs/BatchCodeTableInitializer.js b/docs/BatchCodeTableInitializer.js new file mode 100644 index 00000000000..af8a850019d --- /dev/null +++ b/docs/BatchCodeTableInitializer.js @@ -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; + } + } +} diff --git a/docs/ColumnSearch.js b/docs/ColumnSearch.js new file mode 100644 index 00000000000..bafe737a09b --- /dev/null +++ b/docs/ColumnSearch.js @@ -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; + $('
').appendTo($(this.#column.header())); + this.#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(''); + const clazz = this; + this.#column + .data() + .unique() + .sort() + .each(function (d, _) { + clazz.#select.append(''); + }); + } +} \ No newline at end of file diff --git a/docs/HowBadIsMyBatch.html b/docs/HowBadIsMyBatch.html new file mode 100644 index 00000000000..bcac1f22a74 --- /dev/null +++ b/docs/HowBadIsMyBatch.html @@ -0,0 +1,9112 @@ + + + + + + + + + + How Bad is My Batch + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+
+
+
+

How Bad is My Batch

+
+
+
+

+ + + or view a table of all batch codes + +

+
+
+
+
+

Outcomes of Adverse Events

+
+
+
+ +
+
+
+
+
+
+

Frequencies of Reported Symptoms

+
+
+
+ + + + + + + +
SymptomFrequency
+
+
+
+
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/batchCodeTable.css b/docs/batchCodeTable.css index 85c45a3fe41..fdcb1bd14c6 100644 --- a/docs/batchCodeTable.css +++ b/docs/batchCodeTable.css @@ -1,3 +1,7 @@ +.dataTables_filter { + display: none; +} + .chartWithSlider { display: flex; flex-wrap: nowrap; diff --git a/docs/batchCodeTable.html b/docs/batchCodeTable.html index eb082bbbf39..739d6857427 100644 --- a/docs/batchCodeTable.html +++ b/docs/batchCodeTable.html @@ -2,9106 +2,10 @@ - - - - - - Batch Codes of Coronavirus 2019 Vaccines - - - - - - - - - - - - - - - - - - - - - + - -
-
- -
-
- - -
-
-
-
-

Batch Codes of Coronavirus 2019 Vaccines

-
-
-
-

- - -

-
-
-
-
-

Outcomes of Adverse Events

-
-
-
- -
-
-
-
-
-
-

Frequencies of Reported Symptoms

-
-
-
- - - - - - - -
SymptomFrequency
-
-
-
-
-
-
-
-
- - - -
- - - - - - - - - - - - - - + \ No newline at end of file diff --git a/docs/batchCodes.html b/docs/batchCodes.html new file mode 100644 index 00000000000..fc2823bcc01 --- /dev/null +++ b/docs/batchCodes.html @@ -0,0 +1,76 @@ + + + + + + + Batch Codes of Coronavirus 2019 Vaccines + + + + + + + + + + + + + + + + + + + +

Batch Codes of Coronavirus 2019 Vaccines

+ + + + + + + + + + + + + +
BatchAdverse Reaction ReportsDeathsDisabilitiesLife Threatening IllnessesCompanySevere reportsLethality
+ + + + + \ No newline at end of file diff --git a/src/BatchCodeTableHtmlUpdater.py b/src/BatchCodeTableHtmlUpdater.py index b01f2177f1b..7e115ca6235 100644 --- a/src/BatchCodeTableHtmlUpdater.py +++ b/src/BatchCodeTableHtmlUpdater.py @@ -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)) diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index 939616b2973..f3f01f57974 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -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\")" ] }, {