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 { Consult } from '../models/patientModels';
import { environment } from '../../environments/environment';
import * as _ from 'lodash';
export function processEncounterSummary(data: Consult[], dataType: string) {
let xdata: Consult = {};
// if we're in a development environment, manually filter results, returning the first match
// of selected vital type...
if (environment.sessionServices.appEnv === 'development') {
const encounterType = dataType.replace(/^(lastIn|lastOut)patient\./, '');
const sortedData = _.orderBy(data, ['encounterStartDateTime'], ['desc']);
for (let i = 0; i < sortedData.length; i++) {
if ( sortedData[i].encounterType && sortedData[i].encounterType.match(new RegExp(encounterType, 'i'))) {
xdata = JSON.parse(JSON.stringify(sortedData[i]));
break;
}
}
} else {
if (data.length > 0) { xdata = JSON.parse(JSON.stringify(data[0])); }
}
return xdata;
}