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 { Subscription } from 'rxjs/Subscription';
import { Component, OnInit, OnDestroy, ChangeDetectorRef, AfterViewInit } from '@angular/core';
import { ArsReportsRequestModel, ARSReportResponse, ResponseModel, PayerModel } from './ars-reports.model';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ArsReportsService } from './ars-reports.service';
import { TableColumnModel, TableSettings, PaginationSettings } from '../../shared/table';
import { AttachmentViewerService } from '../../shared/attachment-viewer/attachment-viewer.service';
import { AppSettingsService } from './../../shared/app-settings/app-settings.service';
import { MenuModel } from './../../shared/menu/menu.component.model';

@Component({
selector: 'app-ars-reports',
templateUrl: './ars-reports.component.html',
styleUrls: ['./ars-reports.component.scss']
})

export class ArsReportsComponent implements OnInit, OnDestroy, AfterViewInit {
title = 'ARS Reporting';
menu: MenuModel;
arsReportsRequestModel: ArsReportsRequestModel = new ArsReportsRequestModel();
subscription: Subscription = new Subscription();
form: FormGroup;
searchResults: ResponseModel[];
response: ARSReportResponse;
showResults = false;
dateRangeError = false;
errorMsg = '';
errorStatus = false;
loading = true;
displayMatUnMat = '';
showStorageWarning = false;
arsStorageClicked = false;
weeksUntillFull: number;
payers: PayerModel[] = [];
warningMsg = '';
displayAttachmentViewer = false;
successMsg = '';
successStatus = false;
selectedAttachKey: { attachIdLx: string }; // app-view-attachment [attachKey]
selectedAttachment: string = null; // app-view-attachment [selectedAttachment]
tabIdx = '0';
tableColumns: TableColumnModel[] = [
new TableColumnModel('VA Attch. Ctrl. #', 'attachIdLx'),
// new TableColumnModel('Facility', 'facility'),
new TableColumnModel('Provider', 'providerName'),
new TableColumnModel('Prov. ZIP', 'providerZip'),
new TableColumnModel('Prov. NPI', 'providerNpi'),
new TableColumnModel('Patient Name', 'patientName'),
new TableColumnModel('Patient ID', 'patientIdentifierNumber'),
// new TableColumnModel('Pat. DOB', 'patientIdentifierNumber'),
new TableColumnModel('Patient Ctrl.', 'patientControlNumber'),
new TableColumnModel('Svc. Start', 'claimServiceStartDate'),
new TableColumnModel('Svc. End', 'claimServiceEndDate'),
new TableColumnModel('Prov. Attch. ID', 'attachmentControlNumber'),
// new TableColumnModel('Report', 'attachmentControlNumber'),
new TableColumnModel('Status', 'status'),
new TableColumnModel('Date Rec.', 'dateReceived')
// new TableColumnModel('Attachment', 'attachmentType')
];
tableSettings: TableSettings = new TableSettings();
paginationSettings: PaginationSettings = new PaginationSettings();
constructor(
private fb: FormBuilder,
private arsReportsService: ArsReportsService,
private attachmentService: AttachmentViewerService,
private appSettingsService: AppSettingsService,
private changeDetectorRef: ChangeDetectorRef
) {}

ngOnInit() {
this.appSettingsService
.getMenu('ARS_MENU')
.subscribe(menu => (this.menu = menu));
this.formInit();
this.tableSettings.extShow = true; // test code
this.tableSettings.extCol = 'View';
this.tableSettings.extTitle = row =>
`${this.tableSettings.extCol} attachment ${row.attachIdLx}`;
this.tableSettings.extSrc = row => this.iconAttachType(row);
this.arsReportsService.getPayerInfo().subscribe(
data => {
this.payers = data;
},
error => {
console.log('error getting payer info from ars reports', error);
}
);
this.setDefaultDate();
}
ngAfterViewInit() {
this.subscription.add(this.form.controls['endDate'].valueChanges.subscribe(v => {
if (this.form.get('startDate').valid &&
this.form.get('endDate').value &&
this.form.get('endDate').value.length === 10 &&
this.form.get('startDate').value &&
this.form.get('startDate').value.length === 10
) {
this.datesValidator();
}
}));
this.subscription.add(this.form.controls['startDate'].valueChanges.subscribe(v => {
if (this.form.get('startDate').valid &&
this.form.get('endDate').valid &&
this.form.get('endDate').value &&
this.form.get('endDate').value.length === 10 &&
this.form.get('startDate').value &&
this.form.get('startDate').value.length === 10
) {
this.datesValidator();
}
}));
}

setDefaultDate() {
const temp = new Date();
// let currentDate = '';
const month =
(temp.getMonth() >= 9 ? '' : '0') + (temp.getMonth() + 1).toString();
const day = (temp.getDate() > 9 ? '' : '0') + temp.getDate().toString();
const year = temp.getFullYear().toString();
// currentDate = month + '/' + day + '/' + year;
this.form.get('startDate').setValue('');
this.form.get('endDate').setValue('');
// this.arsReportsRequestModel.startDate = currentDate;
// this.arsReportsRequestModel.endDate = currentDate;
}
formInit() {
this.form = this.fb.group({
payerID: [
this.arsReportsRequestModel.payerId,
Validators.compose([
Validators.required
// Validators.minLength(2),
// Validators.pattern('[0-9]*')
])
],
typeOf275: this.arsReportsRequestModel.typeOf275,
typeOfReport: this.arsReportsRequestModel.typeOfReport,
// last24Hours: this.arsReportsRequestModel.last24Hours,
startDate: [
'',
[
Validators.required,
Validators.pattern(
'(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d'
)
]
],
endDate: [
'',
[
Validators.required,
Validators.pattern(
'(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d'
)
]
],
typeOfDate: this.arsReportsRequestModel.receivedDateRequested
});
}

// assignStartValue() {
// this.form.get('startDate').setValue(this.startDate.nativeElement.value);
// }
// assignEndValue() {
// this.form.get('endDate').setValue(this.endDate.nativeElement.value);
// }
onGenerate() {
this.loading = true;
this.searchResults = [];
if (
(this.arsReportsRequestModel.typeOfReport === 'matched' ||
this.arsReportsRequestModel.typeOfReport === 'all') &&
this.tableColumns[1].property !== 'externalClaimId'
) {
this.tableColumns.splice(
1,
0,
new TableColumnModel('Claim ID', 'externalClaimId')
);
this.tableColumns.splice(2, 0, new TableColumnModel('Fac.', 'facility'));
this.tableColumns.splice(
8,
0,
new TableColumnModel('Patient DOB', 'patientDob')
);
this.tableColumns.splice(
13,
0,
new TableColumnModel('Rpt. Type', 'reportCode')
);
}
if (
this.arsReportsRequestModel.typeOfReport === 'unmatched' &&
this.tableColumns[1].property === 'externalClaimId'
) {
this.tableColumns.splice(13, 1);
this.tableColumns.splice(8, 1);
this.tableColumns.splice(2, 1);
this.tableColumns.splice(1, 1);
}

this.arsReportsRequestModel.startDate = this.form.get('startDate').value;
this.arsReportsRequestModel.endDate = this.form.get('endDate').value;
this.paginationSettings = new PaginationSettings();
this.arsReportsRequestModel.pageSize = this.paginationSettings.pageSize;
this.arsReportsRequestModel.pageNumber = this.paginationSettings.currentPage;
this.arsReportsRequestModel.descending = this.paginationSettings.descending;
this.arsReportsRequestModel.sortColumn = this.paginationSettings.sortColumn;

// subscribing to generate reports
this.fetchData();
}
fetchData() {
const generateSubscription = this.arsReportsService
.generateReportRange(this.arsReportsRequestModel)
.subscribe(
data => {
if (data['errorCode']) {
this.paginationSettings = new PaginationSettings();
this.errorStatus = true;
this.errorMsg = 'Error in Generating Report.';
this.searchResults = [];
this.showResults = false;
} else {
this.response = data;
this.searchResults = this.response.response;
if (this.arsReportsRequestModel.typeOfReport === 'matched') {
this.displayMatUnMat = 'Matched';
} else if (
this.arsReportsRequestModel.typeOfReport === 'unmatched'
) {
this.displayMatUnMat = 'Unmatched';
} else {
this.displayMatUnMat = 'Matched & Unmatched';
}
this.showResults = true;
this.errorStatus = false;
this.errorMsg = '';
this.loading = false;
this.paginationSettings = {
currentPage: this.response.pageNumber,
pageSize: this.response.pageSize,
totalPages: Math.ceil(
this.response.totalNumberOfResults / this.response.pageSize
),
totalResults: this.response.totalNumberOfResults,
sortColumn: this.response.sortColumn,
descending: this.arsReportsRequestModel.descending
};
}
},
err => {
this.searchResults = [];
this.loading = false;
this.errorMsg = 'Error Occured while generating the report';
this.errorStatus = true;
console.log('ars-reports.component ', err);
}
);
this.subscription.add(generateSubscription);
this.tableSettings.linkColumn = true;
this.showResults = true;
}
resetAttachReports() {
this.arsReportsRequestModel = new ArsReportsRequestModel();
this.showResults = false;
this.errorStatus = false;
this.errorMsg = '';
this.dateRangeError = false;
this.displayMatUnMat = 'Matched';
// this.formInit();

this.form.reset(
Object.assign({}, new ArsReportsRequestModel(), { payerID: '' })
);
this.form.get('typeOfDate').setValue(true);
this.setDefaultDate();
}

datesValidator() {
if (this.form.get('startDate').value.length === 10 && this.form.get('endDate').value.length === 10) {
const fromDate = new Date(this.form.get('startDate').value);
const toDate = new Date(this.form.get('endDate').value);
if (toDate.valueOf() < fromDate.valueOf()) {
this.dateRangeError = true;
this.form.get('startDate').setValue('');
this.form.get('endDate').setValue('');
this.changeDetectorRef.detectChanges();
} else {
this.dateRangeError = false;
}
}
}
updateTable() {
this.arsReportsRequestModel.pageSize = this.paginationSettings.pageSize;
this.arsReportsRequestModel.pageNumber = this.paginationSettings.currentPage;
this.arsReportsRequestModel.descending = this.paginationSettings.descending;
this.arsReportsRequestModel.sortColumn = this.paginationSettings.sortColumn;
this.fetchData();
}
print() {}

export() {}

resetArsStorage() {
this.arsStorageClicked = false;
}

ngOnDestroy() {
this.subscription.unsubscribe();
}
receiveWeeksUntilFull(event) {
this.weeksUntillFull = event;
if (+this.weeksUntillFull <= 25) {
this.showStorageWarning = true;
this.warningMsg = `WARNING! Available Attachment Storage will reach 0 in
${this.weeksUntillFull} weeks.`;
} else {
this.showStorageWarning = false;
}
}

iconAttachType(row: any): string {
if (row === null) {
return null;
} // pass on the pain
const atype = row['attachmentType'];
if (row.status === 'Inactive') {
return '../../../assets/images/ic_doc_achive_icon_24.svg';
}
return this.attachType_toUrl(atype);
}

// attachType_toUrl is a method specific for the attachmentViewerComponent.
attachType_toUrl(attachmentType: string): string {
if (typeof attachmentType !== 'string') {
attachmentType = '';
}
const ext = attachmentType.toUpperCase();
switch (ext) {
case 'XML':
return '../../../assets/images/ic_XML_icon_24.svg';
case 'PDF':
return '../../../assets/images/ic_PDF_icon_24.svg';
case 'PNG':
return '../../../assets/images/ic_PNG_icon_24.svg';
case 'TIFF':
return '../../../assets/images/ic_TIFF_icon_24.svg';
case 'TIF':
return '../../../assets/images/ic_TIFF_icon_24.svg';
case 'TXT':
return '../../../assets/images/ic_TXT_icon_24.svg';
case 'DOC':
return '../../../assets/images/ic_DOC_icon_24.svg';
case 'DCM':
return '../../../assets/images/ic_DCM_icon_24.svg';
case 'JPG':
return '../../../assets/images/ic_JPG_icon_24.svg';
case 'GIF':
return '../../../assets/images/ic_GIF_icon_24.svg';
case 'RTF':
return '../../../assets/images/ic_RTF_icon_24.svg';
case 'HTML':
return '../../../assets/images/ic_HTML_icon_24.svg';
case 'BMP':
return '../../../assets/images/ic_BMP_icon_24.svg';
default:
return '../../../assets/images/ic_attachCount_blue_24.svg';
}
}

onDisplayAttachmentViewer(row) {
this.attachmentService.setAttachmentViewerState(true);
this.tabIdx = '-1';
this.selectedAttachKey = {
attachIdLx: row.attachIdLx
};
this.showResults = false;
this.displayAttachmentViewer = true;
}

onAttachmentViewerClose(attachmentOption) {
this.tabIdx = '0';
this.showResults = true;
this.displayAttachmentViewer = attachmentOption.open;
this.attachmentService.setAttachmentViewerState(false);
if (attachmentOption.updateTable) {
this.updateTable();
}
}

onArchive(evt) {
if (evt) {
this.successMsg = 'Successfully Archived';
this.successStatus = evt;
this.updateTable();
} else {
this.errorMsg = 'Failed to archive';
this.errorStatus = true;
}
}
}