Skip to content

Commit 2104e7a

Browse files
author
Andrey L
committed
replacement public version of sheets with special chars
1 parent b51d074 commit 2104e7a

1 file changed

Lines changed: 52 additions & 7 deletions

File tree

app/services/sheets/public-row-transform.js

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,18 @@ export default function publicRownTrasnform(sheet) {
6666
const parts = [];
6767

6868
const severeInfo = [
69-
_get(cell('Severe Calculated'), 'v'),
70-
_get(cell('Critical only'), 'v'),
71-
_get(cell('Severe Adjusted'), 'v'),
69+
// if Critical Only == “Y” --> put a double cross at the beginning of the Severe column
70+
_get(cell('Critical only'), 'v', '')
71+
.replace(/^Y$/i, '‡')
72+
,
73+
// if Severe Adjusted == “Not Adjusted” --> put a double S at the beginning of the Severe column
74+
_get(cell('Severe Adjusted'), 'v', '')
75+
.replace(/^Not Adjusted$/i, '§')
76+
,
77+
// if “Severe Calculated” == “Calculated” --> put a single cross at the beginning the Severe column
78+
_get(cell('Severe Calculated'), 'v', '')
79+
.replace(/^Calculated$/i, '†')
80+
,
7281
_get(cell('Severe'), 'v')
7382
].filter(v => !isEmpty(v)).join(' ').trim();
7483

@@ -91,9 +100,21 @@ export default function publicRownTrasnform(sheet) {
91100
parts.push(`p=${pValue}`);
92101
}
93102

103+
const severeSignificant = _get(cell('Severe Significant'), 'v', '')
104+
.toLowerCase();
105+
106+
let bgColor = null;
107+
108+
if (severeSignificant === 'significant') {
109+
bgColor = 'red';
110+
} else if (severeSignificant === 'not significant') {
111+
bgColor = 'green';
112+
}
113+
94114
return {
95115
v: parts.join(', ').trim(),
96116
t: 'string',
117+
bgColor,
97118
severeInfo,
98119
severeRange,
99120
pValue,
@@ -106,9 +127,21 @@ export default function publicRownTrasnform(sheet) {
106127
const parts = [];
107128

108129
const fatalityInfo = [
109-
_get(cell('Fatality Calculated'), 'v'),
110-
_get(cell('Discharged vs. death?'), 'v'),
111-
_get(cell('Fatality Adjusted'), 'v'),
130+
// if Fatality Adjusted == “Not Adjusted” --> put a double S at the beginning of the Fatality column
131+
_get(cell('Fatality Adjusted'), 'v', '')
132+
.replace(/^Not Adjusted$/i, '§')
133+
,
134+
// if “Fatality Calculated” == “Calcluated” --> put a single cross at the beginning of the Fatality column
135+
_get(cell('Fatality Calculated'), 'v', '')
136+
.replace(/^Calcluated$/i, '†')
137+
,
138+
// if “Discharged vs. death?” == “Y” --> put a little square at the beginning of the Fatality column
139+
(
140+
_get(cell('Discharged vs. death?'), 'v', '') ||
141+
_get(cell('Discharge vs. death?'), 'v', '')
142+
)
143+
.replace(/^Y$/i, '□')
144+
,
112145
_get(cell('Fatality'), 'v')
113146
].filter(v => !isEmpty(v)).join(' ').trim();
114147

@@ -131,10 +164,22 @@ export default function publicRownTrasnform(sheet) {
131164
parts.push(`p=${pValue}`);
132165
}
133166

167+
const fatalitySignificant = _get(cell('Fatality Significant'), 'v', '')
168+
.toLowerCase();
169+
170+
let bgColor = null;
171+
172+
if (fatalitySignificant === 'significant') {
173+
bgColor = 'red';
174+
} else if (fatalitySignificant === 'not significant') {
175+
bgColor = 'green';
176+
}
177+
134178
return {
135179
v: parts.join(', ').trim(),
136180
t: 'string',
137181
_id: null,
182+
bgColor,
138183
fatalityInfo,
139184
fatalityRange,
140185
pValue
@@ -175,5 +220,5 @@ export default function publicRownTrasnform(sheet) {
175220
}
176221

177222
function isEmpty(v) {
178-
return v === undefined || v === null || v === '';
223+
return v === undefined || v === null || v === '' || v === 'N';
179224
}

0 commit comments

Comments
 (0)