Skip to content

Commit

Permalink
modify null reason field
Browse files Browse the repository at this point in the history
so if it is about a numeric field, it will take any text placed in that field.
  • Loading branch information
Damion Dooley committed Sep 4, 2021
1 parent 21d8280 commit 6e37f85
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions template/canada_covid19/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ var exportVirusSeq_Portal = (baseName, hot, data, xlsx, fileType) => {
// Otherwise apply source (many to one) to target field transform:
var value = getMappedField(headerName, inputRow, sources, sourceFields, sourceFieldNameMap, ':', 'VirusSeq_Portal');

const numeric_datatypes = new Set(['xs:nonNegativeInteger', 'xs:decimal']);

// Some columns have an extra ' null reason' field for demultiplexing null value into.
if (ExportHeaders.has(headerName + ' null reason')) {
//headerName = source field name in this format case.
Expand All @@ -102,12 +104,21 @@ var exportVirusSeq_Portal = (baseName, hot, data, xlsx, fileType) => {
skip = true;
}
// Small gesture towards normalization: correct case
else if (nullOptionsMap.has(value.toLowerCase())) {
else
if (nullOptionsMap.has(value.toLowerCase())) {
value = nullOptionsMap.get(value.toLowerCase());
outputRow.push('');
skip = true;
}

else
// If a numeric field has text in it then push that over
// to null reason field. This is occuring at data export
// stage, after validation so text is assumed to be
// intentional
if (numeric_datatypes.has(field.datatype) && isNaN(Number(value)) ) {
outputRow.push('');
skip = true;
}
}
else
alert ('Template configuration error: "'+ headerName + '" has misnamed source field.');
Expand Down

0 comments on commit 6e37f85

Please sign in to comment.