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 { Injectable, OnDestroy } from '@angular/core';
import deepDiff from 'return-deep-diff';
import { Subject } from 'rxjs/Subject';

@Injectable()
export class BillingInfoService {


differences = new Subject();
firstClaimObject;
secondClaimObject;

constructor() { }


getInstance(instance) {
const myNewInstance = Object.assign({}, instance);
myNewInstance.billingInfoService = null;
if (myNewInstance && !myNewInstance.isDetail && myNewInstance.viewType === 'quick') {
if (this.firstClaimObject) {
this.secondClaimObject = myNewInstance;
} else {
this.firstClaimObject = myNewInstance;
}

if (this.secondClaimObject) {
this.compareServiceLine();
}

}
const first = this.firstClaimObject;
const second = this.secondClaimObject;
// console.log('first', first, 'second', second);
}

retrievedButtonClicked() {
this.firstClaimObject = null;
this.secondClaimObject = null;
}
clearCompareInstance() {
this.secondClaimObject = null;
}

compareServiceLine() {

const servLinesDiffs = [];

const servLines1 = this.firstClaimObject.serviceLinesTableInfoRows;
const servLines2 = this.secondClaimObject.serviceLinesTableInfoRows;

const dx1 = this.firstClaimObject.dx;
const dx2 = this.secondClaimObject.dx;
const dxDiffs = deepDiff(dx2, dx1);

const eCodes1 = this.firstClaimObject.eCodes;
const eCodes2 = this.secondClaimObject.eCodes;
const eCodesDiffs = deepDiff(eCodes1, eCodes2);

const px1 = this.firstClaimObject.px;
const px2 = this.secondClaimObject.px;
const pxDiffs = deepDiff(px1, px2);

let drugDiffs;

const billingMiscDiffs = deepDiff(this.firstClaimObject.billingMiscellanous, this.secondClaimObject.billingMiscellanous);

// matches service lines from each object by lineNumber and find the differences.
servLines1.map((o1, index) => {
servLines2.map((o2) => {
if (o1.lineNumber === o2.lineNumber) {
const diffs = deepDiff(o1, o2);
if (o1.listOfDrugLines && o2.listOfDrugLines) {
drugDiffs = deepDiff(o1.listOfDrugLines, o2.listOfDrugLines);
}
// since the compared service lines from each object have the same 'lineNumber', the deepdiff software
// will remove the 'lineNumber' property. We add it back here so we retain a reference to what line
// we are working with.
if (diffs) {
diffs['lineNumber'] = o1.lineNumber;
servLinesDiffs.push(diffs);
}

}
});
});

if (JSON.stringify(servLinesDiffs) === '{}') {

}

this.differences.next([servLinesDiffs, dxDiffs, eCodesDiffs, pxDiffs, billingMiscDiffs, drugDiffs]);
}




// destroyClaim(isRight, detail) {
// if (this.secondClaimObject) {
// this.secondClaimObject = null;
// this.firstClaimObject = null;
// }
// }
}