Improved measurement parsing
This commit is contained in:
parent
5d2a8f464f
commit
18d6b6f19c
@ -49,13 +49,14 @@
|
||||
|
||||
function vitals_normalize(rs) {
|
||||
return rs.map(function(x) {
|
||||
var comment = x.comment && x.comment.replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ');
|
||||
var res = {
|
||||
time: x.datetime,
|
||||
name: x.name,
|
||||
unit: x.unit,
|
||||
value: x.value,
|
||||
flag: x.flag,
|
||||
comment: x.user
|
||||
comment: comment ? x.user + ' • ' + comment : x.user
|
||||
};
|
||||
return vitals_mapping[x.name] ? Object.assign(res, vitals_mapping[x.name]) : res;
|
||||
});
|
||||
|
@ -195,20 +195,36 @@ export function measurement_parse(data) {
|
||||
res.name = row.substring(idx + 3, idx = row.indexOf(': ', idx));
|
||||
value = row.substring(idx + 4, idx = row.indexOf(' _', idx));
|
||||
res.user = row.substring(idx + 2);
|
||||
m = value.match(/^(?:(.*?)(?: (\S+))?)(\*)?(?: \((?:(.*?)(?: (\S+))?)\))?\s*$/);
|
||||
res.value = m[4] ? m[4] : m[1];
|
||||
res.unit = m[4] ? m[5] : m[2];
|
||||
res.flag = m[3];
|
||||
res.value_american = m[4] ? m[1] : m[4];
|
||||
res.unit_american = m[4] ? m[2] : m[5];
|
||||
if(res.value.charAt(res.value.length - 1) == '%') {
|
||||
res.unit = '%';
|
||||
res.value = res.value.substring(0, res.value.length - 1);
|
||||
if(m = value.match(/(?:^(?<value>[\d\.\/%]+)(?: (?<unit>\w+) \((?<value2>[\d\.\/%]+) (?<unit2>\w+)\))?(?<flag>\*)? (?: (?<comment>.*))?$)|(?:^(?<value3>[\d\.\/%]+)(?<flag3>\*)?\s*(?<comment3>.*)$)/)) {
|
||||
if(m.groups.value2) {
|
||||
res.value = m.groups.value2;
|
||||
res.unit = m.groups.unit2;
|
||||
res.value_american = m.groups.value;
|
||||
res.unit_american = m.groups.unit;
|
||||
res.flag = m.groups.flag;
|
||||
res.comment = m.groups.comment;
|
||||
} else if(m.groups.value) {
|
||||
res.value = m.groups.value;
|
||||
res.unit = m.groups.unit;
|
||||
res.flag = m.groups.flag;
|
||||
res.comment = m.groups.comment;
|
||||
} else if(m.groups.value3) {
|
||||
res.value = m.groups.value3;
|
||||
res.flag = m.groups.flag3;
|
||||
res.comment = m.groups.comment3;
|
||||
} else res.comment = value;
|
||||
if(res.comment) res.comment = res.comment.replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ');
|
||||
}
|
||||
if(res.name == 'B/P') {
|
||||
var bpsplit = res.value.split('/');
|
||||
extras.push({...res, name: 'SBP', range: '90 - 120', unit: 'mmHg', value: bpsplit[0] });
|
||||
extras.push({...res, name: 'DBP', range: '60 - 80', unit: 'mmHg', value: bpsplit[1] });
|
||||
if(res.value) {
|
||||
if(res.value.charAt(res.value.length - 1) == '%') {
|
||||
res.unit = '%';
|
||||
res.value = res.value.substring(0, res.value.length - 1);
|
||||
}
|
||||
if(res.name == 'B/P') {
|
||||
var bpsplit = res.value.split('/');
|
||||
extras.push({...res, name: 'SBP', range: '90 - 120', unit: 'mmHg', value: bpsplit[0] });
|
||||
extras.push({...res, name: 'DBP', range: '60 - 80', unit: 'mmHg', value: bpsplit[1] });
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user