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 {
AfterViewInit,
Component,
ElementRef,
Inject,
OnDestroy,
OnInit,
ViewChild
} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AppSettingsService } from './../../shared/app-settings/app-settings.service';
import { AttachmentViewerService } from '../../shared/attachment-viewer/attachment-viewer.service';
import { AuthenticationService } from '../../auth/auth.service';
import { BillingInfoComponent } from '../ewv-components/billing-info/billing-info.component';
import { BillingInfoService } from './../ewv-components/billing-info/billing-info.service';
import { DOCUMENT } from '@angular/platform-browser';
import { EwvHighlightService } from './ewv-highlight.service';
import { EwvViewerService } from './ewv-viewer.service';
import { MenuModel } from '../../shared/menu/menu.component.model';
import { MessageModel } from '../pdf-reference/pdf-reference.model';
import { PdfReferenceService } from '../pdf-reference/pdf-reference.service';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
import { WindowRefService } from '../../window-ref.service';
@Component({
selector: 'app-ewv-viewer',
templateUrl: './ewv-viewer.component.html',
styleUrls: ['./ewv-viewer.component.scss']
})
export class EwvViewerComponent implements OnInit, AfterViewInit, OnDestroy {
// 0 Institutional, 1 Professional, 2 Dental
@ViewChild('pdfTest')
pdfLink = new ElementRef('');
@ViewChild(BillingInfoComponent)
billingInfoComponent;
pdfReferencesFocused: boolean;
hotKeysFocused: boolean;
form: FormGroup;
pageSelector = 'content';
pdiSearchParam; // TODO: Confirm number or string
collapseState = true;
data;
programIndicator: string;
programIndicator2: string;
tabType = 'c';
ewvMsg = 'The requested PDI was not found.';
show = true;
noDataToCompare = false;
isSplitView: boolean;
isSplitSubscription = new Subscription();
containerClassWidth = 1284;
uploadModalClosed = true;
isSplitActive = false;
errorStatus = false;
errorMsg = '';
successStatus = false;
successMsg = '';
compareData;
loadedRight = false;
archiveSuccessMsg = '';
archiveErrorMsg = '';
archiveSuccessStatus = false;
archiveErrorStatus = false;
uploadModalErrorMsg = '';
uploadModalErrorStatus = false;
loadingSpinnerClosed = true;
ewvMenu: MenuModel;
compareClicked: boolean;
leftPdiNumber;
rightPdiNumber;
userInfo;
hasAttachment = false;
hasAttachment2 = false;
hasP2E = false;
hasP2E2 = false;
tabIdx = '0';
constructor(
private ewvViewerService: EwvViewerService,
private ewvHighlightService: EwvHighlightService,
private router: Router,
private fb: FormBuilder /* , private ewvElement: ElementRef */,
private _window: WindowRefService,
@Inject(DOCUMENT) private document,
public attachmentService: AttachmentViewerService,
private pdfReferenceService: PdfReferenceService,
private authenticationService: AuthenticationService,
private appSettingsService: AppSettingsService,
private billingInfoService: BillingInfoService
) {}
ngOnInit() {
this.openloadingSpinnerModal();
this.userInfo = this.authenticationService.getDecodedUserInfo();
if (this.getPdiNumber()) {
this.onSearch(this.getPdiNumber(), false);
} else {
this.router.navigate(['ewvSearch']);
}
this.getStyle();
this.formInit();
this.isSplitSubscription = this.ewvViewerService.isSplitView.subscribe(
data => (this.isSplitView = data)
);
}
ngAfterViewInit() {
setTimeout(() => {
this.setMenu();
});
// Below Timeout is needed, to give enough time for the various
// GUI components to show up on the screen before closing the
// Spinner Modal. Timeout not needed.
// if (!this.loadingSpinnerClosed) {
// setTimeout(() => {
// this.closeloadingSpinnerModal();
// }, 10000);
// }
}
setMenu() {
this.appSettingsService
.getMenu('EWV_MENU')
.subscribe(menu => (this.ewvMenu = menu));
this.pdfReferenceService.populatePdfReferenceMenu().subscribe(data => {
this.ewvMenu.dropDownGroups[1].dropdowns = data;
});
}
getStyle() {
switch (this.pageSelector) {
case (this.pageSelector = 'INSTITUTIONAL'):
return 'inst';
case (this.pageSelector = 'PROFESSIONAL'):
return 'prof';
case (this.pageSelector = 'DENTAL'):
return 'dent';
default:
return 'inst';
}
}
focusMenuBarElements(element): void {
switch (element) {
case 'hotKeys':
this.pdfReferencesFocused = false;
this.hotKeysFocused = true;
break;
case 'pdfElem':
this.pdfReferencesFocused = true;
this.hotKeysFocused = false;
break;
case 'find':
this.hotKeysFocused = false;
this.pdfReferencesFocused = false;
break;
default:
this.hotKeysFocused = false;
this.pdfReferencesFocused = false;
}
this.document.onclick = () => {
this.pdfReferencesFocused = false;
this.hotKeysFocused = false;
};
}
clickElementOnEnter(event) {
event.srcElement.firstElementChild.click();
}
collapseFunctions(state) {
// Collapse Functionality Collapsing
this.collapseState = state;
// Collapse Functionality Not Collapsing
}
collapseAll() {
this.ewvViewerService.setCollapseState(false);
}
expandAll() {
this.ewvViewerService.setCollapseState(true);
}
print() {
this._window.nativeWindow.print();
}
scrollToTop() {
this._window.nativeWindow.scrollTo({ top: 0, behavior: 'smooth' });
}
onRetrieve(pdiNumber) {
this.switchView('single');
// this.ewvHighlightService.clearBothClaims();
// this.billingInfoService.retrievedButtonClicked();
this.onSearch(pdiNumber);
// this.billingInfoComponent.updateInstance();
// switchView('single'); onSearch(); clearHighlightService('second')
}
onClear() {
this.switchView('single');
// this.billingInfoService.clearCompareInstance();
// this.ewvHighlightService.clearSecondClaimObject();
this.onSearch(this.leftPdiNumber);
// this.billingInfoComponent.updateInstance();
}
// switchView('single'); onSearch(leftPdiNumber); clearHighlightService('both')
onSearch(searchParam, fromEwvViewer?) {
if (searchParam) {
this.resetMsgs();
this.openloadingSpinnerModal();
this.scrollToTop();
this.ewvViewerService.searchClaim(searchParam).subscribe(
data => {
if (data && data.patientHeaderInfo) {
if (this.isSplitView) {
this.hasP2E2 = false;
this.hasAttachment2 = false;
this.ewvViewerService.setClaimData2(data);
this.ewvViewerService.setPdi2(searchParam);
this.rightPdiNumber = searchParam;
this.isSplitActive = true;
this.compareData = data;
this.loadedRight = true;
this.containerClassWidth = 1701;
this.checkIfClaimIsOriginalOrCurrent(searchParam, true);
this.ewvViewerService.getAttachments2().subscribe(
info => {
if (info && info['pdiRelatedResponse']) {
this.hasAttachment2 = true;
}
},
err => console.log('error from attachment2', err)
);
} else {
// checked.
this.hasP2E = false;
this.hasAttachment = false;
this.ewvViewerService.setClaimData(data);
this.ewvViewerService.setPdi(searchParam);
this.leftPdiNumber = searchParam;
this.containerClassWidth = 1284;
this.data = data;
this.pageSelector = data.patientHeaderInfo.claimType;
this.getStyle();
this.checkIfClaimIsOriginalOrCurrent(searchParam, false);
this.ewvViewerService
.getAttachments()
.subscribe(attachmentData => {
if (
attachmentData &&
attachmentData['pdiRelatedResponse']
) {
this.hasAttachment = true;
}
});
}
// this.loading = false;
for (const claimOhi of data.ohiInfo.claimOhiList) {
if (claimOhi.claimOhiHeaderBean.subscriberPayerId === 'P2E') {
this.isSplitView ? (this.hasP2E2 = true) : (this.hasP2E = true);
break;
}
}
this.closeloadingSpinnerModal();
this.show = true;
this.expandAll();
this.tabType = 'q';
} else {
if (this.isSplitView) {
this.ewvMsg = 'Failed to Compare';
if (data && data['message']) {
this.ewvMsg = this.ewvMsg + ', ' + data['message'];
// When PDI is not found switching the view from split to single and changing back the container width
this.ewvViewerService.isSplitView.next(false);
this.containerClassWidth = 1284;
}
this.scrollToTop();
this.noDataToCompare = true;
} else {
this.show = false;
this.noDataToCompare = true;
if (data && data['message']) {
this.ewvMsg = data['message'];
} else {
this.ewvMsg = 'The requested PDI was not found';
}
this.scrollToTop();
}
// this.loading = false;
}
if (fromEwvViewer) {
this.closeloadingSpinnerModal();
}
},
error => {
this.errorMsg = 'Error occured while searching the PDI';
this.errorStatus = true;
this.closeloadingSpinnerModal();
}
);
}
}
// clearHighlightService(claim) {
// if (claim === 'first') {
// this.ewvHighlightService.clearFirstClaimObject();
// } else if (claim === 'second') {
// this.ewvHighlightService.clearSecondClaimObject();
// } else if (claim === 'both') {
// this.ewvHighlightService.clearBothClaims();
// }
// }
resetMsgs() {
this.successStatus = false;
this.errorStatus = false;
this.successMsg = '';
this.errorMsg = '';
this.archiveErrorMsg = '';
this.archiveSuccessMsg = '';
this.archiveSuccessStatus = false;
this.archiveErrorStatus = false;
this.ewvMsg = '';
this.show = true;
this.noDataToCompare = false;
}
getPdiNumber() {
this.leftPdiNumber = this.ewvViewerService.getPdi();
// this.ewvHighlightService.leftClaimPdiNumber = this.leftPdiNumber;
return this.leftPdiNumber;
}
// Pdi Number for the second claim, to compare
getPdiNumber2() {
this.rightPdiNumber = this.ewvViewerService.getPdi2();
this.ewvHighlightService.rightClaimPdiNumber = this.rightPdiNumber;
this.ewvHighlightService.checkIfBothPdiNumbersSame();
// console.log('get pdi 2', this.rightPdiNumber);
// console.log('get pdi 2 SERV', this.ewvHighlightService.rightClaimPdiNumber);
return this.rightPdiNumber;
}
formInit() {
this.form = this.fb.group({
pdiSearchParam: [
this.pdiSearchParam,
Validators.compose([
Validators.required,
Validators.pattern('[0-9]*'),
Validators.minLength(15)
])
]
});
}
onViewChange(value) {
this.tabType = value;
}
switchView(view) {
this.ewvViewerService.switchView(view);
this.isSplitActive = false;
this.loadedRight = false;
if (view === 'split') {
if (this.pdiSearchParam !== '' && this.form.valid) {
this.onSearch(this.pdiSearchParam, true);
}
} else if (view === 'single') {
this.containerClassWidth = 1284;
}
}
checkIfClaimIsOriginalOrCurrent(pdi: number, isRight?: boolean): void {
if (!isRight) {
if (!!this.data.patientHeaderInfo.linkedPdis) {
if (
this.leftPdiNumber ===
this.data.patientHeaderInfo.linkedPdis.originalPdi
) {
this.programIndicator = 'Original';
} else if (
this.leftPdiNumber ===
this.data.patientHeaderInfo.linkedPdis.currentPdi
) {
this.programIndicator = 'Current';
} else {
this.programIndicator = '';
}
} else {
this.programIndicator = '';
}
} else if (!!this.compareData.patientHeaderInfo.linkedPdis) {
if (
this.rightPdiNumber ===
this.compareData.patientHeaderInfo.linkedPdis.originalPdi
) {
this.programIndicator2 = 'Original';
} else if (
this.rightPdiNumber ===
this.compareData.patientHeaderInfo.linkedPdis.currentPdi
) {
this.programIndicator2 = 'Current';
} else {
this.programIndicator2 = '';
}
} else {
this.programIndicator2 = '';
}
// const eighthAndNinthDigits = pdi
// .toString()
// .split('')
// .splice(7, 2)
// .join('');
// if (eighthAndNinthDigits === '91' || eighthAndNinthDigits === '92') {
// isRight
// ? (this.programIndicator2 = 'Original')
// : (this.programIndicator = 'Original');
// } else if (eighthAndNinthDigits === '90' || eighthAndNinthDigits === '97') {
// isRight
// ? (this.programIndicator2 = 'Current')
// : (this.programIndicator = 'Current');
// } else {
// isRight ? (this.programIndicator2 = '') : (this.programIndicator = '');
// }
}
onUploadSuccess(uploadMsg: MessageModel) {
this.successMsg = uploadMsg.msg;
this.successStatus = uploadMsg.status;
}
onUploadError(uploadMsg: MessageModel) {
this.errorMsg = uploadMsg.msg;
this.errorStatus = uploadMsg.status;
}
onArchiveSuccess(archiveMsg: MessageModel) {
this.archiveSuccessMsg = archiveMsg.msg;
this.archiveSuccessStatus = archiveMsg.status;
}
onArchiveError(archiveMsg: MessageModel) {
this.archiveErrorMsg = archiveMsg.msg;
this.archiveErrorStatus = archiveMsg.status;
}
closeloadingSpinnerModal() {
this.loadingSpinnerClosed = true;
// Enables Tabbing by setting the tabindex to 0
this.tabIdx = '0';
}
openloadingSpinnerModal() {
this.loadingSpinnerClosed = false;
// Disables Tabbing by setting the tabindex to -1
this.tabIdx = '-1';
}
getPdfFile(guid: number) {
this.ewvViewerService.getPdfFile(guid).subscribe(data => {
const fileName = data.headers.get('Content-Disposition');
const pdfBlob = new Blob([data.blob()], { type: 'application/pdf' });
const pdfURL = this._window.nativeWindow.URL.createObjectURL(pdfBlob);
if (
this._window.nativeWindow.navigator &&
this._window.nativeWindow.navigator.msSaveOrOpenBlob
) {
this._window.nativeWindow.navigator.msSaveOrOpenBlob(pdfBlob, fileName);
return;
}
this._window.nativeWindow.open(pdfURL);
});
}
notify(evt) {
if (evt.guid) {
this.getPdfFile(evt.guid);
}
}
// method to autoCompare by clicking on tooltip pdiNumber;
// autoCompare(pdi) {
// if (pdi && pdi.length > 14) {
// console.log('pdi ', pdi);
// this.form.get('pdiSearchParam').setValue(pdi);
// this.switchView('split');
// } else {
// return;
// }
// }
autoCompare() {
if (!this.isSplitView) {
if (
this.leftPdiNumber ===
this.data.patientHeaderInfo.linkedPdis['originalPdi']
) {
this.form
.get('pdiSearchParam')
.setValue(this.data.patientHeaderInfo.linkedPdis['currentPdi']);
this.form.markAsDirty();
this.switchView('split');
} else {
this.form
.get('pdiSearchParam')
.setValue(this.data.patientHeaderInfo.linkedPdis['originalPdi']);
this.form.markAsDirty();
this.switchView('split');
}
} else {
return;
}
}
ngOnDestroy() {
this.isSplitSubscription.unsubscribe();
}
// affectBothAccordions() {
// console.log('both');
// console.log(this.ohiInfoComponents);
// this.ohiInfoComponents.forEach((component) => {
// if (component.accordionId.indexOf('2')) {
// console.log('2 was clicked');
// component.collapseState = component.collapseState ? false : true;
// } else if (component.accordionId.indexOf('1')) {
// console.log('1 was clicked');
// component.collapseState = component.collapseState ? false : true;
// }
// });
// }
}