refactoring
This commit is contained in:
@@ -10,8 +10,8 @@ class PageInitializer {
|
|||||||
PageInitializer.#initializeSelectElement(
|
PageInitializer.#initializeSelectElement(
|
||||||
{
|
{
|
||||||
selectElement: symptomSelectElement,
|
selectElement: symptomSelectElement,
|
||||||
onValueSelected: symptom => prrByVaccineTableView.displayPrrByVaccineTable4Symptom(symptom),
|
onValueSelected: (id, text) => prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text),
|
||||||
minimumInputLength: 4
|
minimumInputLength: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class PageInitializer {
|
|||||||
PageInitializer.#initializeSelectElement(
|
PageInitializer.#initializeSelectElement(
|
||||||
{
|
{
|
||||||
selectElement: vaccineSelectElement,
|
selectElement: vaccineSelectElement,
|
||||||
onValueSelected: vaccine => prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(vaccine),
|
onValueSelected: (id, text) => prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id ,text),
|
||||||
minimumInputLength: 0
|
minimumInputLength: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -30,8 +30,9 @@ class PageInitializer {
|
|||||||
selectElement.on(
|
selectElement.on(
|
||||||
'select2:select',
|
'select2:select',
|
||||||
function (event) {
|
function (event) {
|
||||||
const value = event.params.data.id;
|
const id = event.params.data.id;
|
||||||
onValueSelected(value);
|
const text = event.params.data.text;
|
||||||
|
onValueSelected(id, text);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class PrrByKeyTableView {
|
|||||||
|
|
||||||
#prrByKeyTable;
|
#prrByKeyTable;
|
||||||
#downloadPrrByKeyTableButton;
|
#downloadPrrByKeyTableButton;
|
||||||
#value;
|
#text;
|
||||||
#valueName;
|
#valueName;
|
||||||
#prrByKeyProvider;
|
#prrByKeyProvider;
|
||||||
|
|
||||||
@@ -14,11 +14,11 @@ class PrrByKeyTableView {
|
|||||||
this.#prrByKeyProvider = prrByKeyProvider;
|
this.#prrByKeyProvider = prrByKeyProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayPrrByKeyTable4Value(value) {
|
displayPrrByKeyTable4Value(id, text) {
|
||||||
UIUtils.disableButton(this.#downloadPrrByKeyTableButton);
|
UIUtils.disableButton(this.#downloadPrrByKeyTableButton);
|
||||||
this.#prrByKeyProvider(value)
|
this.#prrByKeyProvider(id)
|
||||||
.then(prrByKey => {
|
.then(prrByKey => {
|
||||||
this.#value = value;
|
this.#text = text;
|
||||||
this.#prrByKeyTable.display(prrByKey);
|
this.#prrByKeyTable.display(prrByKey);
|
||||||
UIUtils.enableButton(this.#downloadPrrByKeyTableButton);
|
UIUtils.enableButton(this.#downloadPrrByKeyTableButton);
|
||||||
});
|
});
|
||||||
@@ -36,9 +36,8 @@ class PrrByKeyTableView {
|
|||||||
UIUtils.downloadUrlAsFilename(
|
UIUtils.downloadUrlAsFilename(
|
||||||
window.URL.createObjectURL(
|
window.URL.createObjectURL(
|
||||||
new Blob(
|
new Blob(
|
||||||
[this.#prrByKeyTable.getDisplayedTableAsCsv(`# ${this.#valueName}: ${this.#value}`)],
|
[this.#prrByKeyTable.getDisplayedTableAsCsv(`# ${this.#valueName}: ${this.#text}`)],
|
||||||
{ type: 'text/csv' })),
|
{ type: 'text/csv' })),
|
||||||
this.#value
|
this.#text);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ class PrrBySymptomTableView {
|
|||||||
PrrByVaccineProvider.getPrrBySymptom);
|
PrrByVaccineProvider.getPrrBySymptom);
|
||||||
}
|
}
|
||||||
|
|
||||||
displayPrrBySymptomTable4Vaccine(vaccine) {
|
displayPrrBySymptomTable4Vaccine(id, text) {
|
||||||
this.#delegate.displayPrrByKeyTable4Value(vaccine);
|
this.#delegate.displayPrrByKeyTable4Value(id, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
#createPrrBySymptomTable(tableElement) {
|
#createPrrBySymptomTable(tableElement) {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ class PrrByVaccineTableView {
|
|||||||
PrrByVaccineProvider.getPrrByVaccine);
|
PrrByVaccineProvider.getPrrByVaccine);
|
||||||
}
|
}
|
||||||
|
|
||||||
displayPrrByVaccineTable4Symptom(symptom) {
|
displayPrrByVaccineTable4Symptom(id, text) {
|
||||||
this.#delegate.displayPrrByKeyTable4Value(symptom);
|
this.#delegate.displayPrrByKeyTable4Value(id, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
#createPrrByVaccineTable(tableElement) {
|
#createPrrByVaccineTable(tableElement) {
|
||||||
|
|||||||
@@ -467,93 +467,81 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "4ad05656",
|
"id": "f38924ec",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"prrByVaccineAndSymptom = pd.read_csv(\n",
|
"def saveProportionalReportingRatios4PrrByVaccineBySymptomWithoutZeroPrrs(prrByVaccineAndSymptom, webAppBaseDir):\n",
|
||||||
" 'data/prrByDrugAndSymptom-EudraVigilance.csv',\n",
|
" prrByVaccineBySymptom = PrrSeriesFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
||||||
" index_col = 'DRUG')\n",
|
"\n",
|
||||||
"prrByVaccineAndSymptom"
|
" prrByVaccineBySymptomWithoutZeroPrrs = PrrSeriesTransformer.filterByNonZeroPrrs(prrByVaccineBySymptom)\n",
|
||||||
|
" del prrByVaccineBySymptom\n",
|
||||||
|
" gc.collect()\n",
|
||||||
|
"\n",
|
||||||
|
" filenameBySymptom = saveProportionalReportingRatios(\n",
|
||||||
|
" prrByVaccineBySymptomWithoutZeroPrrs,\n",
|
||||||
|
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/symptoms'))\n",
|
||||||
|
"\n",
|
||||||
|
" del prrByVaccineBySymptomWithoutZeroPrrs\n",
|
||||||
|
" gc.collect()\n",
|
||||||
|
" return filenameBySymptom"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "7aed1621",
|
"id": "e1237c0b",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"prrByVaccineAndSymptom = DataFrameFilter.withoutZeroRowsAndZeroColumns(prrByVaccineAndSymptom)\n",
|
"def saveProportionalReportingRatios4PrrBySymptomByVaccineWithHighPrrs(prrByVaccineAndSymptom, webAppBaseDir):\n",
|
||||||
"prrByVaccineAndSymptom"
|
" prrBySymptomByVaccine = PrrSeriesFactory.getPrrBySymptomByVaccine(prrByVaccineAndSymptom)\n",
|
||||||
|
" prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)\n",
|
||||||
|
" del prrBySymptomByVaccine\n",
|
||||||
|
" gc.collect()\n",
|
||||||
|
"\n",
|
||||||
|
" filenameByDrug = saveProportionalReportingRatios(\n",
|
||||||
|
" prrBySymptomByVaccineWithHighPrrs,\n",
|
||||||
|
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/vaccines'))\n",
|
||||||
|
"\n",
|
||||||
|
" del prrBySymptomByVaccineWithHighPrrs\n",
|
||||||
|
" gc.collect()\n",
|
||||||
|
" return filenameByDrug"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "b41b60c7",
|
"id": "64ccf3c9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByDrugs'"
|
"def saveProportionalReportingRatiosAndUpdateHtmlFile(prrByVaccineAndSymptom, webAppBaseDir):\n",
|
||||||
|
" prrByVaccineAndSymptom = DataFrameFilter.withoutZeroRowsAndZeroColumns(prrByVaccineAndSymptom)\n",
|
||||||
|
" filenameBySymptom = saveProportionalReportingRatios4PrrByVaccineBySymptomWithoutZeroPrrs(prrByVaccineAndSymptom, webAppBaseDir)\n",
|
||||||
|
" filenameByDrug = saveProportionalReportingRatios4PrrBySymptomByVaccineWithHighPrrs(prrByVaccineAndSymptom, webAppBaseDir)\n",
|
||||||
|
" updateHtmlFile(\n",
|
||||||
|
" symptomsDescr = {\n",
|
||||||
|
" 'symptoms': list(prrByVaccineAndSymptom.columns),\n",
|
||||||
|
" 'filenameBySymptom': filenameBySymptom },\n",
|
||||||
|
" vaccinesDescr = {\n",
|
||||||
|
" 'vaccines': list(prrByVaccineAndSymptom.index),\n",
|
||||||
|
" 'filenameByDrug': filenameByDrug },\n",
|
||||||
|
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "26f72e75",
|
"id": "3db1a115",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"prrByVaccineBySymptom = PrrSeriesFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
"saveProportionalReportingRatiosAndUpdateHtmlFile(\n",
|
||||||
"\n",
|
" prrByVaccineAndSymptom = pd.read_csv(\n",
|
||||||
"prrByVaccineBySymptomWithoutZeroPrrs = PrrSeriesTransformer.filterByNonZeroPrrs(prrByVaccineBySymptom)\n",
|
" 'data/prrByDrugAndSymptom-EudraVigilance-10.csv',\n",
|
||||||
"del prrByVaccineBySymptom\n",
|
" index_col = 'DRUG'),\n",
|
||||||
"gc.collect()\n",
|
" webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByDrugs')"
|
||||||
"\n",
|
|
||||||
"filenameBySymptom = saveProportionalReportingRatios(\n",
|
|
||||||
" prrByVaccineBySymptomWithoutZeroPrrs,\n",
|
|
||||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/symptoms'))\n",
|
|
||||||
"\n",
|
|
||||||
"del prrByVaccineBySymptomWithoutZeroPrrs\n",
|
|
||||||
"gc.collect()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "5bfdcbdd",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"prrBySymptomByVaccine = PrrSeriesFactory.getPrrBySymptomByVaccine(prrByVaccineAndSymptom)\n",
|
|
||||||
"prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)\n",
|
|
||||||
"del prrBySymptomByVaccine\n",
|
|
||||||
"gc.collect()\n",
|
|
||||||
"\n",
|
|
||||||
"filenameByDrug = saveProportionalReportingRatios(\n",
|
|
||||||
" prrBySymptomByVaccineWithHighPrrs,\n",
|
|
||||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/vaccines'))\n",
|
|
||||||
"\n",
|
|
||||||
"del prrBySymptomByVaccineWithHighPrrs\n",
|
|
||||||
"gc.collect()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "cc97b8d4",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"updateHtmlFile(\n",
|
|
||||||
" symptomsDescr = {\n",
|
|
||||||
" 'symptoms': list(prrByVaccineAndSymptom.columns),\n",
|
|
||||||
" 'filenameBySymptom': filenameBySymptom },\n",
|
|
||||||
" vaccinesDescr = {\n",
|
|
||||||
" 'vaccines': list(prrByVaccineAndSymptom.index),\n",
|
|
||||||
" 'filenameByDrug': filenameByDrug },\n",
|
|
||||||
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -567,22 +555,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "5cd9935f",
|
"id": "0974c307",
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"from SymptomsCausedByVaccines.DataFrameFilter import DataFrameFilter\n",
|
|
||||||
"from SymptomsCausedByVaccines.HtmlUpdater import updateHtmlFile, updateHtmlFile4SymptomsCausedByCOVIDLots\n",
|
|
||||||
"from SymptomsCausedByVaccines.PrrSeriesFactory import PrrSeriesFactory\n",
|
|
||||||
"from SymptomsCausedByVaccines.PrrSeriesTransformer import PrrSeriesTransformer\n",
|
|
||||||
"from SymptomsCausedByVaccines.ProportionalReportingRatiosPersister import saveProportionalReportingRatios\n",
|
|
||||||
"import os\n",
|
|
||||||
"import pandas as pd"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -597,101 +570,13 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"id": "dfa98cd9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"prrByVaccineAndSymptom = DataFrameFilter.withoutZeroRowsAndZeroColumns(prrByVaccineAndSymptom)\n",
|
"saveProportionalReportingRatiosAndUpdateHtmlFile(\n",
|
||||||
"prrByVaccineAndSymptom"
|
" prrByVaccineAndSymptom = prrByVaccineAndSymptom,\n",
|
||||||
]
|
" webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByVaccines')"
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "640868c7",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"prrByVaccineBySymptom = PrrSeriesFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
|
||||||
"prrByVaccineBySymptom"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "0f247c64",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"prrBySymptomByVaccine = PrrSeriesFactory.getPrrBySymptomByVaccine(prrByVaccineAndSymptom)\n",
|
|
||||||
"prrBySymptomByVaccine"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "760ac423",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"prrByVaccineBySymptomWithoutZeroPrrs = PrrSeriesTransformer.filterByNonZeroPrrs(prrByVaccineBySymptom)\n",
|
|
||||||
"prrByVaccineBySymptomWithoutZeroPrrs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "f07203e4",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)\n",
|
|
||||||
"prrBySymptomByVaccineWithHighPrrs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByVaccines'"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "0b40071c",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"saveProportionalReportingRatios(\n",
|
|
||||||
" prrByVaccineBySymptomWithoutZeroPrrs,\n",
|
|
||||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/symptoms'))"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "fac4b34f",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"saveProportionalReportingRatios(\n",
|
|
||||||
" prrBySymptomByVaccineWithHighPrrs,\n",
|
|
||||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/vaccines'))"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "803dfbef",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"updateHtmlFile(\n",
|
|
||||||
" symptoms = list(prrByVaccineAndSymptom.columns),\n",
|
|
||||||
" vaccines = list(prrByVaccineAndSymptom.index),\n",
|
|
||||||
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user