adding global batch code table
This commit is contained in:
1
docs/data/Global.json
Normal file
1
docs/data/Global.json
Normal file
File diff suppressed because one or more lines are too long
@@ -68,7 +68,7 @@
|
||||
}
|
||||
|
||||
function displayCountry(country, batchCodeTable) {
|
||||
document.querySelector('.heading').textContent = `Batch Codes for ${country}`;
|
||||
document.querySelector('.heading').textContent = country == 'Global' ? 'Global Batch Codes' : `Batch Codes for ${country}`;
|
||||
batchCodeTable.ajax.url(`data/${country}.json`).load();
|
||||
selectInput();
|
||||
}
|
||||
@@ -79,10 +79,9 @@
|
||||
'change',
|
||||
event => {
|
||||
const country = event.target.value;
|
||||
if (country != 'Select country ...') {
|
||||
displayCountry(country, batchCodeTable);
|
||||
}
|
||||
});
|
||||
displayCountry('Global', batchCodeTable)
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
@@ -93,7 +92,7 @@
|
||||
<p>
|
||||
<label>Select country:
|
||||
<select id="countrySelect" name="country">
|
||||
<option value="Select country ...">Select country ...</option>
|
||||
<option value="Global" selected>Global</option>
|
||||
<option value="Afghanistan">Afghanistan</option>
|
||||
<option value="Albania">Albania</option>
|
||||
<option value="Algeria">Algeria</option>
|
||||
|
||||
@@ -421,6 +421,9 @@
|
||||
" def createBatchCodeTableByCountry(self, country):\n",
|
||||
" return self.batchCodeTableByCountryFactory.createBatchCodeTableByCountry(country)\n",
|
||||
"\n",
|
||||
" def createGlobalBatchCodeTable(self):\n",
|
||||
" return self.createBatchCodeTableByCountry(None)\n",
|
||||
"\n",
|
||||
" def _createInternationalLotTable(self):\n",
|
||||
" return SummationTableFactory.createSummationTableHavingSevereReportsColumn(self.dataFrame.groupby(self.dataFrame['COUNTRY']))\n"
|
||||
]
|
||||
@@ -453,9 +456,14 @@
|
||||
" ]]\n",
|
||||
" return batchCodeTable.sort_values(by = 'Severe reports', ascending = False)\n",
|
||||
"\n",
|
||||
" # FK-TODO: refactor\n",
|
||||
" def _createBatchCodeTableByCountry(self, country):\n",
|
||||
" if country is None:\n",
|
||||
" return SummationTableFactory.createSummationTableHavingSevereReportsColumn(self.dataFrame.groupby('VAX_LOT'))\n",
|
||||
"\n",
|
||||
" if self.countryBatchCodeTable is None:\n",
|
||||
" self.countryBatchCodeTable = self._getCountryBatchCodeTable()\n",
|
||||
" \n",
|
||||
" return self._getCountry(self.countryBatchCodeTable, country)\n",
|
||||
"\n",
|
||||
" def _getCountryBatchCodeTable(self):\n",
|
||||
@@ -1192,6 +1200,42 @@
|
||||
" name = 'VAX_LOT')),\n",
|
||||
" check_dtype = False)\n",
|
||||
"\n",
|
||||
" def test_createGlobalBatchCodeTable(self):\n",
|
||||
" # Given\n",
|
||||
" dataFrame = TestHelper.createDataFrame(\n",
|
||||
" columns = ['DIED', 'L_THREAT', 'DISABLE', 'VAX_TYPE', 'VAX_MANU', 'VAX_LOT', 'VAX_DOSE_SERIES', 'SPLTTYPE', 'HOSPITAL', 'ER_VISIT', 'COUNTRY'],\n",
|
||||
" data = [ [1, 0, 0, 'COVID19', 'PFIZER\\BIONTECH', '016M20A', '2', 'GBPFIZER INC2020486806', 0, 0, 'United Kingdom'],\n",
|
||||
" [0, 0, 0, 'COVID19', 'MODERNA', '030L20A', '1', 'FRMODERNATX, INC.MOD20224', 0, 0, 'France'],\n",
|
||||
" [1, 1, 1, 'COVID19', 'MODERNA', '030L20B', '1', 'FRMODERNATX, INC.MOD20224', 0, 0, 'France'],\n",
|
||||
" [0, 1, 1, 'COVID19', 'MODERNA', '030L20B', '1', 'FRMODERNATX, INC.MOD20224', 0, 0, 'France']],\n",
|
||||
" index = [\n",
|
||||
" \"1048786\",\n",
|
||||
" \"1048786\",\n",
|
||||
" \"4711\",\n",
|
||||
" \"0815\"])\n",
|
||||
" dataFrame = SevereColumnAdder.addSevereColumn(dataFrame)\n",
|
||||
" internationalLotTableFactory = InternationalLotTableFactory(dataFrame)\n",
|
||||
" \n",
|
||||
" # When\n",
|
||||
" batchCodeTable = internationalLotTableFactory.createGlobalBatchCodeTable()\n",
|
||||
"\n",
|
||||
" # Then\n",
|
||||
" assert_frame_equal(\n",
|
||||
" batchCodeTable,\n",
|
||||
" TestHelper.createDataFrame(\n",
|
||||
" columns = ['Adverse Reaction Reports', 'Deaths', 'Disabilities', 'Life Threatening Illnesses', 'Company', 'Severe reports', 'Lethality'],\n",
|
||||
" data = [ [1, 1, 0, 0, 'PFIZER\\BIONTECH', 1/1 * 100, 1/1 * 100],\n",
|
||||
" [2, 1, 2, 2, 'MODERNA', 2/2 * 100, 1/2 * 100],\n",
|
||||
" [1, 0, 0, 0, 'MODERNA', 0/1 * 100, 0/1 * 100]],\n",
|
||||
" index = pd.Index(\n",
|
||||
" [\n",
|
||||
" '016M20A',\n",
|
||||
" '030L20B',\n",
|
||||
" '030L20A'\n",
|
||||
" ],\n",
|
||||
" name = 'VAX_LOT')),\n",
|
||||
" check_dtype = False)\n",
|
||||
"\n",
|
||||
" def test_createBatchCodeTableByNonExistingCountry(self):\n",
|
||||
" # Given\n",
|
||||
" dataFrame = TestHelper.createDataFrame(\n",
|
||||
@@ -1464,8 +1508,8 @@
|
||||
" IOUtils.saveDataFrame(batchCodeTable, '../docs/data/' + country)\n",
|
||||
" display(country + \":\", batchCodeTable)\n",
|
||||
"\n",
|
||||
"def createAndSaveAndDisplayBatchCodeTablesByCountry(nonDomesticVaers, countries, minADRsForLethality = None):\n",
|
||||
" internationalLotTableFactory = InternationalLotTableFactory(nonDomesticVaers)\n",
|
||||
"def createAndSaveAndDisplayBatchCodeTablesByCountry(vaers, countries, minADRsForLethality = None):\n",
|
||||
" internationalLotTableFactory = InternationalLotTableFactory(vaers)\n",
|
||||
" for country in countries:\n",
|
||||
" createAndSaveAndDisplayBatchCodeTableByCountry(internationalLotTableFactory, country, minADRsForLethality)"
|
||||
]
|
||||
@@ -1518,6 +1562,33 @@
|
||||
" minADRsForLethality = 100)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "106c0d91",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"internationalLotTableFactory = InternationalLotTableFactory(internationalVaers)\n",
|
||||
"globalBatchCodeTable = internationalLotTableFactory.createGlobalBatchCodeTable()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e75bd993",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # FK-TODO: DRY with createAndSaveAndDisplayBatchCodeTableByCountry()\n",
|
||||
" minADRsForLethality = 100\n",
|
||||
" globalBatchCodeTable.index.set_names(\"Batch\", inplace = True)\n",
|
||||
" if minADRsForLethality is not None:\n",
|
||||
" globalBatchCodeTable.loc[globalBatchCodeTable['Adverse Reaction Reports'] < minADRsForLethality, ['Severe reports', 'Lethality']] = [np.nan, np.nan]\n",
|
||||
" IOUtils.saveDataFrame(globalBatchCodeTable, '../docs/data/Global')\n",
|
||||
" display('Global' + \":\", globalBatchCodeTable)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ba02139d",
|
||||
|
||||
Reference in New Issue
Block a user