refactoring

This commit is contained in:
frankknoll
2023-10-15 14:55:10 +02:00
parent ae425cf723
commit d3589104ea
2 changed files with 15 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ class PrrByVaccineTable {
#tableElement;
#table;
#sumPrrs;
#prrByVaccine;
constructor(tableElement) {
this.#tableElement = tableElement;
@@ -13,10 +14,23 @@ class PrrByVaccineTable {
}
display(prrByVaccine) {
this.#prrByVaccine = prrByVaccine;
const vaccine_prr_pairs = Object.entries(prrByVaccine);
this.#setTableRows(vaccine_prr_pairs);
}
getDisplayedTableAsCsv(heading) {
return PrrByKey2CsvConverter.convertPrrByKey2Csv(
{
heading: heading,
columns: {
keyColumn: 'Vaccine',
prrColumn: 'Proportional Reporting Ratio'
},
prrByKey: this.#prrByVaccine
});
}
#createEmptyTable() {
return this.#tableElement.DataTable(
{

View File

@@ -35,17 +35,7 @@ class PrrByVaccineTableView {
UIUtils.downloadUrlAsFilename(
window.URL.createObjectURL(
new Blob(
[
PrrByKey2CsvConverter.convertPrrByKey2Csv(
{
heading: '# Symptom: ' + this.#symptom,
columns: {
keyColumn: 'Vaccine',
prrColumn: 'Proportional Reporting Ratio'
},
prrByKey: this.#prrByVaccine
})
],
[this.#prrByVaccineTable.getDisplayedTableAsCsv('# Symptom: ' + this.#symptom)],
{ type: 'text/csv' })),
this.#symptom
);