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