From f066966f2061c09c6375948f69d271fab9c68c23 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Sun, 15 Oct 2023 14:22:46 +0200 Subject: [PATCH] addin heading to convertPrrByKey2Csv() method --- .../js/PrrByKey2CsvConverter.js | 21 ++++++++++++------- .../js/PrrByVaccineTableView.js | 9 +++++--- .../PrrByKey2CsvConverterTest.js | 13 ++++++++---- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/docs/SymptomsCausedByVaccines/js/PrrByKey2CsvConverter.js b/docs/SymptomsCausedByVaccines/js/PrrByKey2CsvConverter.js index 49f037fac17..65272b118b4 100644 --- a/docs/SymptomsCausedByVaccines/js/PrrByKey2CsvConverter.js +++ b/docs/SymptomsCausedByVaccines/js/PrrByKey2CsvConverter.js @@ -1,12 +1,19 @@ class PrrByKey2CsvConverter { - static convertPrrByKey2Csv({ prrByKey, keyColumn, prrColumn }) { - return PrrByKey2CsvConverter.#convert2Csv( - { - prrByKey: PrrByKey2CsvConverter.#quoteKeys(prrByKey), - keyColumn: PrrByKey2CsvConverter.#quote(keyColumn), - prrColumn: PrrByKey2CsvConverter.#quote(prrColumn) - }); + static convertPrrByKey2Csv( + { + heading, + columns: { keyColumn, prrColumn }, + prrByKey + } + ) { + return heading + '\n\n' + + PrrByKey2CsvConverter.#convert2Csv( + { + prrByKey: PrrByKey2CsvConverter.#quoteKeys(prrByKey), + keyColumn: PrrByKey2CsvConverter.#quote(keyColumn), + prrColumn: PrrByKey2CsvConverter.#quote(prrColumn) + }); } static #quoteKeys(prrByKey) { diff --git a/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js b/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js index 263a7e7c7dc..6f377b1253c 100644 --- a/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js +++ b/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js @@ -38,9 +38,12 @@ class PrrByVaccineTableView { [ PrrByKey2CsvConverter.convertPrrByKey2Csv( { - prrByKey: this.#prrByVaccine, - keyColumn: 'Vaccine', - prrColumn: 'Proportional Reporting Ratio' + heading: '# Symptom: ' + this.#symptom, + columns: { + keyColumn: 'Vaccine', + prrColumn: 'Proportional Reporting Ratio' + }, + prrByKey: this.#prrByVaccine }) ], { type: 'text/csv' })), diff --git a/test/SymptomsCausedByVaccines/PrrByKey2CsvConverterTest.js b/test/SymptomsCausedByVaccines/PrrByKey2CsvConverterTest.js index 1319018f62c..6963ec45eed 100644 --- a/test/SymptomsCausedByVaccines/PrrByKey2CsvConverterTest.js +++ b/test/SymptomsCausedByVaccines/PrrByKey2CsvConverterTest.js @@ -10,14 +10,19 @@ QUnit.module('PrrByKey2CsvConverterTest', function () { // When const csv = PrrByKey2CsvConverter.convertPrrByKey2Csv( { - prrByKey: prrByKey, - keyColumn: 'Vaccine', - prrColumn: 'Proportional Reporting Ratio' + heading: '# Symptom: Acute hepatitis C', + columns: { + keyColumn: 'Vaccine', + prrColumn: 'Proportional Reporting Ratio' + }, + prrByKey: prrByKey }); // Then const csvExpected = - `"Vaccine","Proportional Reporting Ratio" + `# Symptom: Acute hepatitis C + +"Vaccine","Proportional Reporting Ratio" "MM,R",26.17432376240791 "VARCEL",10.549534724816644`; assert.equal(csv, csvExpected);