displaying PrrByVaccineTable
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
||||
class BatchCodeSelectInitializer {
|
||||
|
||||
static initialize({batchCodeSelectElement, batchCodeDetailsElement}) {
|
||||
const batchCodeDetailsView = new BatchCodeDetailsView(batchCodeDetailsElement);
|
||||
batchCodeSelectElement.select2({ minimumInputLength: 4 });
|
||||
batchCodeSelectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const batchcode = event.params.data.id;
|
||||
batchCodeDetailsView.displayBatchCodeDetails(batchcode);
|
||||
GoogleAnalytics.click_batchcode(batchcode);
|
||||
});
|
||||
batchCodeSelectElement.select2('open');
|
||||
}
|
||||
}
|
||||
22
docs/SymptomsCausedByVaccines/js/PageInitializer.js
Normal file
22
docs/SymptomsCausedByVaccines/js/PageInitializer.js
Normal file
@@ -0,0 +1,22 @@
|
||||
class PageInitializer {
|
||||
|
||||
static initializePage({ symptomSelectElement, prrByVaccineTableElement }) {
|
||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement);
|
||||
PageInitializer.#initializeSymptomSelectElement(
|
||||
{
|
||||
symptomSelectElement: symptomSelectElement,
|
||||
onSymptomSelected: symptom => prrByVaccineTableView.displayPrrByVaccineTable4Symptom(symptom)
|
||||
});
|
||||
}
|
||||
|
||||
static #initializeSymptomSelectElement({ symptomSelectElement, onSymptomSelected }) {
|
||||
symptomSelectElement.select2({ minimumInputLength: 4 });
|
||||
symptomSelectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const symptom = event.params.data.id;
|
||||
onSymptomSelected(symptom);
|
||||
});
|
||||
symptomSelectElement.select2('open');
|
||||
}
|
||||
}
|
||||
6
docs/SymptomsCausedByVaccines/js/PrrByVaccineProvider.js
Normal file
6
docs/SymptomsCausedByVaccines/js/PrrByVaccineProvider.js
Normal file
@@ -0,0 +1,6 @@
|
||||
class PrrByVaccineProvider {
|
||||
|
||||
static getPrrByVaccine(symptom) {
|
||||
return fetch(`../data/ProportionalReportingRatios/${symptom}.json`).then(response => response.json());
|
||||
}
|
||||
}
|
||||
72
docs/SymptomsCausedByVaccines/js/PrrByVaccineTable.js
Normal file
72
docs/SymptomsCausedByVaccines/js/PrrByVaccineTable.js
Normal file
@@ -0,0 +1,72 @@
|
||||
class PrrByVaccineTable {
|
||||
|
||||
#tableElement;
|
||||
#table;
|
||||
#sumPrrs;
|
||||
|
||||
constructor(tableElement) {
|
||||
this.#tableElement = tableElement;
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.#table = this.#createEmptyTable();
|
||||
}
|
||||
|
||||
display(prrByVaccine) {
|
||||
const vaccine_prr_pairs = Object.entries(prrByVaccine);
|
||||
this.#setTableRows(vaccine_prr_pairs);
|
||||
}
|
||||
|
||||
#createEmptyTable() {
|
||||
return this.#tableElement.DataTable(
|
||||
{
|
||||
search:
|
||||
{
|
||||
return: false
|
||||
},
|
||||
processing: true,
|
||||
deferRender: true,
|
||||
order: [[this.#getColumnIndex('Proportional Reporting Ratio'), "desc"]],
|
||||
columnDefs:
|
||||
[
|
||||
{
|
||||
searchable: false,
|
||||
targets: [this.#getColumnIndex('Proportional Reporting Ratio')]
|
||||
},
|
||||
{
|
||||
render: prr =>
|
||||
NumberWithBarElementFactory
|
||||
.createNumberWithBarElement(
|
||||
{
|
||||
number: prr,
|
||||
barLenInPercent: prr / this.#sumPrrs * 100
|
||||
})
|
||||
.outerHTML,
|
||||
targets: [this.#getColumnIndex('Proportional Reporting Ratio')]
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
#getColumnIndex(columnName) {
|
||||
switch (columnName) {
|
||||
case 'Vaccine':
|
||||
return 0;
|
||||
case 'Proportional Reporting Ratio':
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#setTableRows(vaccine_prr_pairs) {
|
||||
this.#sumPrrs = this.#getSumPrrs(vaccine_prr_pairs);
|
||||
this.#table
|
||||
.clear()
|
||||
.rows.add(vaccine_prr_pairs)
|
||||
.draw();
|
||||
}
|
||||
|
||||
#getSumPrrs(vaccine_prr_pairs) {
|
||||
const prrs = vaccine_prr_pairs.map(vaccine_prr_pair => vaccine_prr_pair[1])
|
||||
return Utils.sum(prrs);
|
||||
}
|
||||
}
|
||||
15
docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js
Normal file
15
docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js
Normal file
@@ -0,0 +1,15 @@
|
||||
class PrrByVaccineTableView {
|
||||
|
||||
#prrByVaccineTable;
|
||||
|
||||
constructor(prrByVaccineTableElement) {
|
||||
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
|
||||
this.#prrByVaccineTable.initialize();
|
||||
}
|
||||
|
||||
displayPrrByVaccineTable4Symptom(symptom) {
|
||||
PrrByVaccineProvider
|
||||
.getPrrByVaccine(symptom)
|
||||
.then(prrByVaccine => this.#prrByVaccineTable.display(prrByVaccine));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user