diff --git a/docs/VaccineDistributionByZipcode.html b/docs/VaccineDistributionByZipcode.html new file mode 100644 index 00000000000..b44c854abb3 --- /dev/null +++ b/docs/VaccineDistributionByZipcode.html @@ -0,0 +1,50 @@ + + + +
+ + +| PROVIDER_NAME | +ZIPCODE_SHP | +LOT_NUMBER | +DOSES_SHIPPED | +
|---|
Data Sources: + Vaccine Adverse Event Reporting System + (VAERS) and + Vaccine Distribution by Zipcode +
+ + + \ No newline at end of file diff --git a/docs/VaccineDistributionByZipcodeTableInitializer.js b/docs/VaccineDistributionByZipcodeTableInitializer.js new file mode 100644 index 00000000000..a2f5a1c1307 --- /dev/null +++ b/docs/VaccineDistributionByZipcodeTableInitializer.js @@ -0,0 +1,81 @@ +class VaccineDistributionByZipcodeTableInitializer { + + #tableElement; + #table; + + constructor({ tableElement }) { + this.#tableElement = tableElement; + } + + initialize() { + this.#table = this.#createEmptyTable(); + this.#loadDataIntoTable(); + } + + #createEmptyTable() { + return this.#tableElement.DataTable( + { + language: + { + searchPlaceholder: "Enter Batch Code" + }, + search: + { + return: false + }, + processing: true, + deferRender: true, + columnDefs: + [ + { + searchable: false, + targets: [this.#getColumnIndex('DOSES_SHIPPED')] + }, + { + searchable: true, + targets: [ + this.#getColumnIndex('PROVIDER_NAME'), + this.#getColumnIndex('ZIPCODE_SHP'), + this.#getColumnIndex('LOT_NUMBER'), + ] + }, + ] + }); + } + + #getColumnIndex(columnName) { + switch (columnName) { + case 'PROVIDER_NAME': + return 0; + case 'ZIPCODE_SHP': + return 1; + case 'LOT_NUMBER': + return 2; + case 'DOSES_SHIPPED': + return 3; + } + } + + #loadDataIntoTable() { + // FK-TODO: show "Loading.." message or spinning wheel. + fetch('data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.json') + .then(response => response.json()) + .then(json => { + this.#setTableRows(json.data); + this.#selectInput(); + }); + } + + #setTableRows(rows) { + this.#table + .clear() + .rows.add(rows) + .draw(); + } + + #selectInput() { + const input = document.querySelector(".dataTables_filter input"); + input.focus(); + input.select(); + } +} diff --git a/src/BatchCodeTablePersister.py b/src/BatchCodeTablePersister.py index f89aeffdb8b..f3e51ea3506 100644 --- a/src/BatchCodeTablePersister.py +++ b/src/BatchCodeTablePersister.py @@ -42,9 +42,9 @@ def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, count 'Severe reports', 'Lethality' ]] - IOUtils.saveDataFrame( + IOUtils.saveDataFrameAsJson( batchCodeTable, - '../docs/data/batchCodeTables/' + country) + '../docs/data/batchCodeTables/' + country + '.json') onCountryProcessed(country) diff --git a/src/IOUtils.py b/src/IOUtils.py index f864ffbcdc1..d58cbe18221 100644 --- a/src/IOUtils.py +++ b/src/IOUtils.py @@ -3,22 +3,16 @@ import json class IOUtils: - @staticmethod - def saveDataFrame(dataFrame, file): - # IOUtils.saveDataFrameAsExcelFile(dataFrame, file) - # IOUtils.saveDataFrameAsHtml(dataFrame, file) - IOUtils.saveDataFrameAsJson(dataFrame, file) - @staticmethod def saveDataFrameAsExcelFile(dataFrame, file): IOUtils.ensurePath(file) - dataFrame.to_excel(file + '.xlsx') + dataFrame.to_excel(file) @staticmethod def saveDataFrameAsHtml(dataFrame, file): IOUtils.ensurePath(file) dataFrame.to_html( - file + '.html', + file, index = False, table_id = 'batchCodeTable', classes = 'display', @@ -29,7 +23,7 @@ class IOUtils: def saveDataFrameAsJson(dataFrame, file): IOUtils.ensurePath(file) dataFrame.to_json( - file + '.json', + file, orient = "split", index = False) diff --git a/src/VaccineDistributionByZipcode.ipynb b/src/VaccineDistributionByZipcode.ipynb new file mode 100644 index 00000000000..fe850d8088e --- /dev/null +++ b/src/VaccineDistributionByZipcode.ipynb @@ -0,0 +1,103 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "\n", + "vaccineDistributionByZipcode = pd.read_excel('tmp/Amended-22-01962-Pfizer-2022-0426-pulled-2022-0823_edited.xlsx')\n", + "vaccineDistributionByZipcode" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "len(vaccineDistributionByZipcode['PROVIDER_NAME'].unique())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "len(vaccineDistributionByZipcode['ZIPCODE_SHP'].unique())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vaccineDistributionByZipcode['AWARDEE'].unique()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vaccineDistributionByZipcode['STATE_SHP'].unique()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vaccineDistributionByZipcode[vaccineDistributionByZipcode['ZIPCODE_SHP'] == '37801']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from IOUtils import IOUtils\n", + "\n", + "IOUtils.saveDataFrameAsJson(vaccineDistributionByZipcode, '../docs/data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.json')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "IOUtils.saveDataFrameAsHtml(vaccineDistributionByZipcode, '../docs/data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.html')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "howbadismybatch-venv-kernel", + "language": "python", + "name": "howbadismybatch-venv-kernel" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}