MarkRowsIfPrrTooHigh
This commit is contained in:
@@ -27,14 +27,14 @@ class PdfCreator {
|
|||||||
static #getWorstDrugsSection({ selectElement, table }, valueName) {
|
static #getWorstDrugsSection({ selectElement, table }, valueName) {
|
||||||
return [
|
return [
|
||||||
PdfCreator.#getHeading(`Worst ${valueName} for "${PdfCreator.#getSelection(selectElement)}"`),
|
PdfCreator.#getHeading(`Worst ${valueName} for "${PdfCreator.#getSelection(selectElement)}"`),
|
||||||
PdfCreator.#getTable(table)
|
PdfCreator.#getTable(table, true)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static #getStrongestSymptomsSection({ selectElement, table }) {
|
static #getStrongestSymptomsSection({ selectElement, table }) {
|
||||||
return [
|
return [
|
||||||
PdfCreator.#getHeading(`Strongest Symptoms for "${PdfCreator.#getSelection(selectElement)}"`),
|
PdfCreator.#getHeading(`Strongest Symptoms for "${PdfCreator.#getSelection(selectElement)}"`),
|
||||||
PdfCreator.#getTable(table)
|
PdfCreator.#getTable(table, false)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,17 +52,14 @@ class PdfCreator {
|
|||||||
return selectElement.select2('data')[0].text;
|
return selectElement.select2('data')[0].text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FK-TODO: add red background to some rows
|
static #getTable(table, shallMarkRowsIfPrrTooHigh) {
|
||||||
static #getTable(table) {
|
|
||||||
const headers = PdfCreator.#getTableHeaders(table);
|
|
||||||
const rows = table.rows({ search: 'applied' }).data().toArray();
|
|
||||||
return {
|
return {
|
||||||
layout: 'lightHorizontalLines',
|
layout: 'lightHorizontalLines',
|
||||||
table: {
|
table: {
|
||||||
headerRows: 1,
|
headerRows: 1,
|
||||||
body: [
|
body: [
|
||||||
headers,
|
PdfCreator.#getTableHeaders(table),
|
||||||
...rows
|
...PdfCreator.#getMarkedRows(table, shallMarkRowsIfPrrTooHigh)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -78,4 +75,42 @@ class PdfCreator {
|
|||||||
}))
|
}))
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static #getMarkedRows(table, shallMarkRowsIfPrrTooHigh) {
|
||||||
|
const rows = PdfCreator.#getRows(table);
|
||||||
|
return shallMarkRowsIfPrrTooHigh ?
|
||||||
|
PdfCreator.#markRowsIfPrrTooHigh(rows) :
|
||||||
|
rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
static #getRows(table) {
|
||||||
|
return table
|
||||||
|
.rows({ search: 'applied' })
|
||||||
|
.data()
|
||||||
|
.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
static #markRowsIfPrrTooHigh(rows) {
|
||||||
|
return rows.map(PdfCreator.#markRowIfPrrTooHigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static #markRowIfPrrTooHigh(row) {
|
||||||
|
const prr = row[1];
|
||||||
|
return [
|
||||||
|
PdfCreator.#markValueIfPrrTooHigh({ value: row[0], prr: prr }),
|
||||||
|
PdfCreator.#markValueIfPrrTooHigh({ value: row[1], prr: prr })
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
static #markValueIfPrrTooHigh({ value, prr }) {
|
||||||
|
return prr >= 2.0 ? PdfCreator.#markValue(value) : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static #markValue(value) {
|
||||||
|
return {
|
||||||
|
text: value,
|
||||||
|
fillColor: '#FF0000',
|
||||||
|
fillOpacity: 0.1,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user