Improved lab report edge case parsing
This commit is contained in:
parent
0712eccf15
commit
976276e2e0
@ -52,14 +52,17 @@ function lab_parse1default(data) {
|
||||
if(x.comment) x.comment.push(line.substring(12));
|
||||
else x.comment = [line.substring(12)];
|
||||
} else console.log('DANGLING:', line);
|
||||
} else if(m = line.match(/^\b(?<name>.*?)\s{2,}(?<value>.*?)(?: (?<flag>L\*|L|H\*|H))?\s+(?:(?<unit>.{10}) (?<range>.{16}) \[(?<site>\d+)\])?$/)) {
|
||||
} else if(m = line.match(/^\b(?<name>.*?)\s{2,}(?<value>.*?)(?: (?<flag>L\*|L|H\*|H))?\s+(?:(?<unit>.{10}) (?<range>.*?)(?: \[(?<site>\d+)\])?)?$/)) {
|
||||
if((m.groups.range) && (m.groups.range.startsWith('Ref: '))) m.groups.range = m.groups.range.substring(5);
|
||||
results.push(x = m.groups);
|
||||
if((x.value === '') && (m = x.name.match(/^(?<name>.*?)(?<value>(?:[\d\.]+|positive|negative|reactive|test not performed))$/i))) {
|
||||
if((x.value === '') && (m = x.name.match(/^(?<name>.*?)(?<value>(?:[\d\.]+|positive|negative|reactive|not detected|collected - specimen in lab|test not performed))$/i))) {
|
||||
x.name = m.groups.name;
|
||||
x.value = m.groups.value;
|
||||
}
|
||||
for(var k in x) if(x[k]) x[k] = x[k] ? x[k].replace(/^\s+|\s+$/g, '') : undefined;
|
||||
} else if(m = line.match(/^\b(?<name>.*?) (?<value>(?:[\d\.]+|positive|negative|reactive|not detected|collected - specimen in lab|test not performed))\s*$/i)) {
|
||||
results.push(x = m.groups);
|
||||
for(var k in x) if(x[k]) x[k] = x[k] ? x[k].replace(/^\s+|\s+$/g, '') : undefined;
|
||||
} else if(line.startsWith(' [')) {
|
||||
if(results.length > 0) results[results.length - 1].site = line.split('[')[1].split(']')[0]
|
||||
else console.log('DANGLING:', line);
|
||||
@ -71,6 +74,13 @@ function lab_parse1default(data) {
|
||||
x.site = line.split('[')[1].split(']')[0];
|
||||
} else x.range = line.replace(/^\s+|\s+$/g, '');
|
||||
} else console.log('DANGLING:', line);
|
||||
} else if(m = line.match(/^\s{40}\b(?:(?<unit>.{10}) (?<range>.*?)(?: \[(?<site>\d+)\])?)?$/)) {
|
||||
if(results.length > 0) {
|
||||
x = results[results.length - 1];
|
||||
if(m.groups.unit) x.unit = m.groups.unit.replace(/^\s+|\s+$/g, '');
|
||||
if(m.groups.range) x.range = m.groups.range.replace(/^\s+|\s+$/g, '');
|
||||
if(m.groups.site) x.site = m.groups.site.replace(/^\s+|\s+$/g, '');
|
||||
} else console.log('DANGLING:', line, m.groups);
|
||||
} else console.log('INVALID:', line);
|
||||
}
|
||||
for(var i = results.length - 1; i >= 0; --i) {
|
||||
|
Loading…
Reference in New Issue
Block a user