Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { Allergy } from '../models/patientModels';
import * as _ from 'lodash';
export function processAllergyData(data: Allergy[]) {
const xdata = JSON.parse(JSON.stringify(data));
xdata.forEach((itm, idx) => {
// create an allergy-level severity property
itm.severity = { value: 0, key: 'N/A' };
// sort reactions by date descending & move highest severity into allergy.severity
if (itm.reactions) {
itm.reactions.forEach((reaction) => {
if (reaction.severity && reaction.severity.value > itm.severity.value) {
itm.severity.key = reaction.severity.key;
itm.severity.value = reaction.severity.value;
}
});
itm.reactions = _.orderBy(itm.reactions, ['onset'], ['desc']);
} else {
itm.reactions = [];
}
// sort comments by signatureDate descending
if (itm.comments) {
itm.comments.sort((a, b) => {
// empties go to the back of the line...
if (!a.signature || !a.signature.signDate) {
return 1;
} else if (!b.signature || !b.signature.signDate) {
return -1;
} else if (new Date(a.signature.signDate) > new Date(b.signature.signDate)) {
return -1;
} else {
return 1;
}
});
}
// set up the verification string
itm.verificationString = '';
const rtn = (itm.verified) ? itm.verified : 'Non-Verified';
if (RegExp('NO', 'i').test(rtn) || RegExp('N', 'i').test(rtn)) {
itm.verificationString = 'Non-Verified';
} else if (RegExp('YES', 'i').test(rtn) || RegExp('Y', 'i').test(rtn)) {
if (itm.verifierSig != null && itm.verifierSig.signator != null) {
itm.verificationString = 'Verified by ' + itm.verifierSig.signator + ' ('
+ itm.verifierSig.blockTitle + ') at ' + new Date(itm.verifierSig.signDate).toLocaleString('en-US',
{ hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }).replace(',', '');
} else {
itm.verificationString = 'Auto-Verified by ' + itm.originatorSig.signator + ' ('
+ itm.originatorSig.blockTitle + ') at ' + new Date(itm.verifierSig.signDate).toLocaleString('en-US',
{ hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }).replace(',', '');
}
}
});
xdata.sort((a, b) => {
if (a.gmrAllergy > b.gmrAllergy) {
return 1;
} else {
return -1;
}
});
return xdata;
}