combining batch code tables of all companies

This commit is contained in:
frankknoll
2022-02-12 21:06:49 +01:00
parent e7ae087108
commit 732c273095
7 changed files with 24 additions and 105 deletions

View File

@@ -4,7 +4,7 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>batch codes</title> <title>Batch codes</title>
<!-- FK-TODO: keine externen Links --> <!-- FK-TODO: keine externen Links -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.css"> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="batchCodeTable.css"> <link rel="stylesheet" type="text/css" href="batchCodeTable.css">
@@ -15,31 +15,13 @@
<script type="text/javascript" charset="utf8" <script type="text/javascript" charset="utf8"
src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script> src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
<script> <script>
function getSearchParams() { function loadBatchCodeTable() {
const searchParams = new URLSearchParams(window.location.search);
return {
company: searchParams.get('company'),
companyName: searchParams.get('companyName'),
title: searchParams.get('title')
};
}
function replaceCssClassesWithStrs({ title, companyName }) {
replaceCssClassWithStr(".title", title);
replaceCssClassWithStr(".companyName", companyName);
}
function replaceCssClassWithStr(cssClass, str) {
document.querySelectorAll(cssClass).forEach(element => element.textContent = str);
}
function loadBatchCodeTable(file, searchPlaceholder) {
$('#batchCodeTable').DataTable( $('#batchCodeTable').DataTable(
{ {
ajax: file, ajax: "data/batchCodeTable.json",
language: language:
{ {
searchPlaceholder: searchPlaceholder searchPlaceholder: "Enter Batch Code"
}, },
search: search:
{ {
@@ -52,26 +34,23 @@
[ [
{ {
searchable: false, searchable: false,
targets: [1, 2, 3, 4] targets: [1, 2, 3, 4, 5]
} }
] ]
}); });
} }
$(document).ready(function () { $(document).ready(function () {
const { company, companyName, title } = getSearchParams(); loadBatchCodeTable();
document.title = title;
replaceCssClassesWithStrs({ title, companyName });
loadBatchCodeTable("data/" + company + ".json", "Enter " + companyName + " Batch Code");
}); });
</script> </script>
</head> </head>
<body> <body>
<span id="forkongithub"><a href="https://github.com/KnollFrank/HowBadIsMyBatch">Fork me on GitHub</a></span> <span id="forkongithub"><a href="https://github.com/KnollFrank/HowBadIsMyBatch">Fork me on GitHub</a></span>
<h1 class="title"></h1> <h1>Batch codes</h1>
<p> <p>
<b>Check out your <span class="companyName"></span> batch code </b>&emsp;<font size="-2">(last updated 11th February <b>Check out your batch code </b>&emsp;<font size="-2">(last updated 11th February
2022)</font> 2022)</font>
<table class="display" id="batchCodeTable"> <table class="display" id="batchCodeTable">
<thead> <thead>
@@ -81,6 +60,7 @@
<th>DEATHS</th> <th>DEATHS</th>
<th>DISABILITIES</th> <th>DISABILITIES</th>
<th>LIFE THREATENING ILLNESSES</th> <th>LIFE THREATENING ILLNESSES</th>
<th>COMPANY</th>
</tr> </tr>
</thead> </thead>
</table> </table>

1
data/batchCodeTable.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,23 +1,11 @@
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="utf-8">
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="refresh" content="0; url=batchCodeTable.html" />
<title>How Bad is My Batch</title>
<link rel="stylesheet" type="text/css" href="forkMeOnGitHub.css">
</head> </head>
<body> <body>
<span id="forkongithub"><a href="https://github.com/KnollFrank/HowBadIsMyBatch">Fork me on GitHub</a></span>
<h1>How Bad is My Batch</h1>
<p>
<ul>
<li><a href="batchCodeTable.html?company=moderna&companyName=Moderna&title=Moderna">Moderna</a></li>
<li><a href="batchCodeTable.html?company=pfizer&companyName=Pfizer&title=Pfizer">Pfizer</a></li>
<li><a href="batchCodeTable.html?company=janssen&companyName=Janssen&title=Janssen">Janssen</a></li>
</ul>
</p>
</body> </body>
</html> </html>

View File

@@ -228,10 +228,10 @@
"class BatchCodeTableFactory:\n", "class BatchCodeTableFactory:\n",
"\n", "\n",
" @staticmethod\n", " @staticmethod\n",
" def createBatchCodeTable(dataFrame : pd.DataFrame, manufacturer, dose):\n", " def createBatchCodeTable(dataFrame : pd.DataFrame, dose):\n",
" dataFrame = DataFrameFilter().filterByCovid19(dataFrame)\n", " dataFrame = DataFrameFilter().filterByCovid19(dataFrame)\n",
" dataFrame = DataFrameFilter().filterBy(dataFrame, manufacturer = manufacturer, dose = dose)\n", " dataFrame = DataFrameFilter().filterBy(dataFrame, dose = dose)\n",
" return BatchCodeTableFactory._createSummationTableByVAX_LOT(dataFrame)[['ADRs', 'DEATHS', 'DISABILITIES', 'LIFE THREATENING ILLNESSES']]\n", " return BatchCodeTableFactory._createSummationTableByVAX_LOT(dataFrame)[['ADRs', 'DEATHS', 'DISABILITIES', 'LIFE THREATENING ILLNESSES', 'COMPANY']]\n",
"\n", "\n",
" # create table from https://www.howbadismybatch.com/combined.html\n", " # create table from https://www.howbadismybatch.com/combined.html\n",
" @staticmethod\n", " @staticmethod\n",
@@ -740,17 +740,17 @@
" dtypes = {'VAX_DOSE_SERIES': \"string\"})\n", " dtypes = {'VAX_DOSE_SERIES': \"string\"})\n",
" }\n", " }\n",
" ])\n", " ])\n",
" self._test_createBatchCodeTable(dataFrame, \"MODERNA\", '1')\n", " self._test_createBatchCodeTable(dataFrame, '1')\n",
"\n", "\n",
" def test_createBatchCodeTable(self):\n", " def test_createBatchCodeTable(self):\n",
" dataFrame = VaersDescr2DataFrameConverter.createDataFrameFromDescrs(\n", " dataFrame = VaersDescr2DataFrameConverter.createDataFrameFromDescrs(\n",
" VaersDescrReader(dataDir = \"test/VAERS\").readAllVaersDescrs())\n", " VaersDescrReader(dataDir = \"test/VAERS\").readAllVaersDescrs())\n",
" DataFrameNormalizer.normalize(dataFrame)\n", " DataFrameNormalizer.normalize(dataFrame)\n",
" self._test_createBatchCodeTable(dataFrame, \"MODERNA\", '1')\n", " self._test_createBatchCodeTable(dataFrame, '1')\n",
"\n", "\n",
" def _test_createBatchCodeTable(self, dataFrame, manufacturer, dose):\n", " def _test_createBatchCodeTable(self, dataFrame, dose):\n",
" # When\n", " # When\n",
" batchCodeTable = BatchCodeTableFactory.createBatchCodeTable(dataFrame, manufacturer, dose)\n", " batchCodeTable = BatchCodeTableFactory.createBatchCodeTable(dataFrame, dose)\n",
"\n", "\n",
" # Then\n", " # Then\n",
" batchCodeTableExpected = pd.DataFrame(\n", " batchCodeTableExpected = pd.DataFrame(\n",
@@ -758,7 +758,8 @@
" 'ADRs': [2, 1],\n", " 'ADRs': [2, 1],\n",
" 'DEATHS': [0, 1],\n", " 'DEATHS': [0, 1],\n",
" 'DISABILITIES': [2, 0],\n", " 'DISABILITIES': [2, 0],\n",
" 'LIFE THREATENING ILLNESSES': [0, 0]\n", " 'LIFE THREATENING ILLNESSES': [0, 0],\n",
" 'COMPANY': ['MODERNA', 'MODERNA']\n",
" },\n", " },\n",
" index = pd.Index(['025L20A', '037K20A'], name = 'VAX_LOT'))\n", " index = pd.Index(['025L20A', '037K20A'], name = 'VAX_LOT'))\n",
" assert_frame_equal(batchCodeTable, batchCodeTableExpected, check_dtype = False)\n" " assert_frame_equal(batchCodeTable, batchCodeTableExpected, check_dtype = False)\n"
@@ -961,8 +962,8 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"def saveBatchCodeTable(vaers, manufacturer, file):\n", "def saveBatchCodeTable(vaers, file):\n",
" batchCodeTable = BatchCodeTableFactory.createBatchCodeTable(vaers, manufacturer = manufacturer, dose = '1')\n", " batchCodeTable = BatchCodeTableFactory.createBatchCodeTable(vaers, dose = '1')\n",
" display(batchCodeTable)\n", " display(batchCodeTable)\n",
" IOUtils.saveDataFrame(batchCodeTable, file)" " IOUtils.saveDataFrame(batchCodeTable, file)"
] ]
@@ -997,22 +998,12 @@
"internationalVaers = getInternationalVaers()" "internationalVaers = getInternationalVaers()"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "f74475e8",
"metadata": {},
"outputs": [],
"source": [
"internationalVaers"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "987a04d1", "id": "987a04d1",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### Moderna batch codes" "### Batch codes"
] ]
}, },
{ {
@@ -1023,45 +1014,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# https://www.howbadismybatch.com/moderna.html\n", "# https://www.howbadismybatch.com/moderna.html\n",
"saveBatchCodeTable(internationalVaers, \"MODERNA\", \"../data/moderna\")" "saveBatchCodeTable(internationalVaers, \"../data/batchCodeTable\")"
]
},
{
"cell_type": "markdown",
"id": "29dd4daa",
"metadata": {},
"source": [
"### Pfizer batch codes"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6121e2b3",
"metadata": {},
"outputs": [],
"source": [
"# https://www.howbadismybatch.com/pfizer.html\n",
"saveBatchCodeTable(internationalVaers, \"PFIZER\\BIONTECH\", \"../data/pfizer\")"
]
},
{
"cell_type": "markdown",
"id": "7e83a551",
"metadata": {},
"source": [
"### Janssen batch codes"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a64eef5",
"metadata": {},
"outputs": [],
"source": [
"# https://www.howbadismybatch.com/janssen.html\n",
"saveBatchCodeTable(internationalVaers, \"JANSSEN\", \"../data/janssen\")"
] ]
}, },
{ {