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 { Component, OnInit, ViewChild, ElementRef, ChangeDetectorRef, OnDestroy } from '@angular/core';
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
import { PrimarySearchModel, AdvancedSearchModel, LookupResponseModel } from './rfai-search277.model';
import { atLeastOne } from '../../shared/validators';
import { RfaiSearch277Service } from './rfai-search277.service';
import { AuthenticationService } from '../../auth/auth.service';
import { TableColumnModel, TableSettings, PaginationSettings } from '../../shared/table';
import { AppSettingsService } from '../../shared/app-settings/app-settings.service';
import { MenuModel } from '../../shared/menu/menu.component.model';
@Component({
selector: 'app-rfai-search277',
templateUrl: './rfai-search277.component.html',
styleUrls: [
'./../rfai-submission/rfai-submission.component.scss',
'./rfai-search277.component.scss'
],
})
export class RfaiSearch277Component implements OnInit, OnDestroy {
subscription: Subscription = new Subscription();
// table setup
tableColumns: TableColumnModel[] = [
new TableColumnModel('Submission ID', 'submissionId'),
new TableColumnModel('PDI / Claim ID', 'pdiClaimId'),
new TableColumnModel('Billing Provider Name', 'providerName'),
new TableColumnModel('Status', 'status'),
// new TableColumnModel('Provider NPI', 'providerNpi'),
// new TableColumnModel('Provider TIN', 'providerTin'),
new TableColumnModel('Patient Name', 'patientName'),
new TableColumnModel('Date Submitted', 'datesubmitted'),
new TableColumnModel('Required Response Date', 'requiredResponseDate')
];
tableSettings: TableSettings = new TableSettings();
paginationSettings: PaginationSettings = new PaginationSettings();
// end of table setup
title = '277 RFAI Search';
menu: MenuModel;
primaryForm: FormGroup;
advancedForm: FormGroup;
primaryModel: PrimarySearchModel = new PrimarySearchModel();
advancedModel: AdvancedSearchModel = new AdvancedSearchModel();
typeOfSearch = 'P';
dateRangeError = false;
errorMsg = '';
errorStatus = false;
successStatus = false;
successMsg = '';
row = {};
searchResults: LookupResponseModel[];
showResults = false;
lookupPermissions;
disableSearch = false;
disableViewSubmission = false;
loading = true;
@ViewChild('primaryRadioButton')
primaryRadioButton: ElementRef = new ElementRef('');
@ViewChild('advancedRadioButton')
advancedRadioButton: ElementRef = new ElementRef('');
constructor(
private fb: FormBuilder,
private rfaiSearch277Service: RfaiSearch277Service,
private router: Router,
private authenticationService: AuthenticationService,
private appSettingsService: AppSettingsService,
private changeDetectorRef: ChangeDetectorRef
) {}
ngOnInit() {
this.appSettingsService
.getMenu('ARS_MENU')
.subscribe(menu => (this.menu = menu));
this.getUserData();
this.formInit();
this.showPrimary();
this.primaryRadioButton.nativeElement.focus = true;
// table Settings
this.tableSettings.rowNumberDisplay = false;
this.tableSettings.checkBoxesShow = false;
this.tableSettings.buttonShow = false;
this.tableSettings.linkColumn = false;
this.tableSettings.imgColumn = true;
this.tableSettings.imageUrls = [
'../../assets/images/ic_text_clipboard_blue_24px.svg'
];
this.tableSettings.imageColumnNames = ['View'];
this.tableSettings.imgTitle = (row: any, idx: number) =>
`${this.tableSettings.imageColumnNames[idx]} submission ${
row.submissionId
}`;
}
getUserData() {
const permissionLookup = this.authenticationService.getDecodedUserInfo()
.permissions.lookup;
if (permissionLookup) {
this.lookupPermissions = permissionLookup;
this.disableSearch = !this.lookupPermissions['search'];
this.disableViewSubmission = !this.lookupPermissions['viewSubmission'];
}
}
// Initialize form and set up the Validations
formInit() {
this.primaryForm = this.fb.group({
primarySearchParam: [this.primaryModel.number, Validators.required]
});
this.advancedForm = this.fb.group(
{
pdiClaimId: [this.advancedModel.number, [Validators.pattern('[0-9]*')]],
billingProvider: [this.advancedModel.providerName],
providerNpi: [
this.advancedModel.providerNpi,
[Validators.pattern('[0-9]{10}')]
],
providerTin: [
this.advancedModel.providerTin,
[Validators.pattern('[0-9]{9}')]
],
patientLastname: [this.advancedModel.patientLastName],
patientFirstName: [this.advancedModel.patientfirstName],
patientIdentifier: [
this.advancedModel.patientIdentifier,
[Validators.pattern('[0-9]*')]
],
patientcontrolNumber: [
this.advancedModel.patientControlNumber,
[Validators.pattern('[0-9]*')]
],
medicalRecordNumber: [
this.advancedModel.medicalRecordNumber,
[Validators.pattern('[0-9]*')]
],
serviceStartDate: [
'',
[
Validators.pattern(
'(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d'
)
]
],
serviceEndDate: [
'',
[
Validators.pattern(
'(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d'
)
]
]
},
{ validator: atLeastOne(Validators.required) }
);
}
primarySearch() {
// this.primaryModel.number = +this.primaryModel.number;
// update table settings
this.primaryModel.pageSize = this.paginationSettings.pageSize;
this.primaryModel.pageNumber = this.paginationSettings.currentPage;
this.primaryModel.descending = this.paginationSettings.descending;
this.primaryModel.sortColumn = this.paginationSettings.sortColumn;
this.subscription.add(
this.rfaiSearch277Service.quickSearch(this.primaryModel).subscribe(
data => {
this.searchResults = data.response;
this.showResults = true;
this.errorStatus = false;
this.errorMsg = '';
this.paginationSettings = {
currentPage: data.pageNumber,
pageSize: data.pageSize,
totalPages: Math.ceil(data.totalNumberOfResults / data.pageSize),
totalResults: data.totalNumberOfResults,
sortColumn: data.sortColumn,
descending: this.primaryModel.descending
};
this.loading = false;
},
error => {
this.paginationSettings = new PaginationSettings();
this.errorStatus = true;
this.errorMsg = error.error.message;
this.searchResults = [];
this.showResults = false;
this.loading = false;
}
)
);
}
clearPrimary() {
this.primaryForm.reset();
this.typeOfSearch = 'A';
this.primaryModel = new PrimarySearchModel();
this.paginationSettings = new PaginationSettings();
this.showResults = false;
this.errorStatus = false;
this.errorMsg = '';
}
clearAdvancedForm() {
this.advancedForm.reset();
this.dateRangeError = false;
this.typeOfSearch = 'P';
this.advancedModel = new AdvancedSearchModel();
this.paginationSettings = new PaginationSettings();
this.showResults = false;
this.errorStatus = false;
this.errorMsg = '';
// this.formInit();
}
advancedSearch() {
// this.advancedModel.number = +this.advancedModel.number;
this.advancedModel.serviceStartDate = this.advancedForm.get('serviceStartDate').value;
this.advancedModel.serviceEndDate = this.advancedForm.get('serviceEndDate').value;
// update table settings
this.advancedModel.pageSize = this.paginationSettings.pageSize;
this.advancedModel.pageNumber = this.paginationSettings.currentPage;
this.advancedModel.descending = this.paginationSettings.descending;
this.advancedModel.sortColumn = this.paginationSettings.sortColumn;
this.subscription.add(
this.rfaiSearch277Service.advancedSearch(this.advancedModel).subscribe(
data => {
this.searchResults = data.response;
this.showResults = true;
this.errorStatus = false;
this.errorMsg = '';
// service to setup table (obsolete, removed)
// this.tableService.setData([this.tableColumns, this.searchResults]);
this.paginationSettings = {
currentPage: data.pageNumber,
pageSize: data.pageSize,
totalPages: Math.ceil(data.totalNumberOfResults / data.pageSize),
totalResults: data.totalNumberOfResults,
sortColumn: data.sortColumn,
descending: this.advancedModel.descending
};
this.loading = false;
},
error => {
this.errorStatus = true;
this.errorMsg = error.error.message;
this.searchResults = [];
this.showResults = false;
this.loading = false;
}
)
);
}
// validate the date range between the two date fields. fromDate should be less than toDate.
datesValidator() {
if (this.advancedForm.get('serviceStartDate').value.length === 10 && this.advancedForm.get('serviceEndDate').value.length === 10
) {
const fromDate = new Date(this.advancedForm.get('serviceStartDate').value);
const toDate = new Date(this.advancedForm.get('serviceEndDate').value);
if (toDate.valueOf() < fromDate.valueOf()) {
this.dateRangeError = true;
this.advancedForm.get('serviceStartDate').setValue('');
this.advancedForm.get('serviceEndDate').setValue('');
this.changeDetectorRef.detectChanges();
} else {
this.dateRangeError = false;
}
}
}
validateDates() {
this.subscription.add(this.advancedForm.controls['serviceEndDate'].valueChanges.subscribe(v => {
if (this.advancedForm.get('serviceStartDate').valid &&
this.advancedForm.get('serviceEndDate').value &&
this.advancedForm.get('serviceEndDate').value.length === 10 &&
this.advancedForm.get('serviceStartDate').value &&
this.advancedForm.get('serviceStartDate').value.length === 10
) {
this.datesValidator();
}
}));
this.subscription.add(this.advancedForm.controls['serviceStartDate'].valueChanges.subscribe(v => {
if (this.advancedForm.get('serviceStartDate').valid && this.advancedForm.get('serviceEndDate').valid &&
this.advancedForm.get('serviceEndDate').value &&
this.advancedForm.get('serviceEndDate').value.length === 10 &&
this.advancedForm.get('serviceStartDate').value &&
this.advancedForm.get('serviceStartDate').value.length === 10
) {
this.datesValidator();
}
}));
}
// Methods to toggle Display between Quick Search and Advanced Search.
// Using display instead of ngIf as calendar not functioning when ngIf is used.
showAdvanced() {
// this.primaryDiv.nativeElement.style.display = 'none';
// this.advancedDiv.nativeElement.style.display = 'block';
this.clearPrimary();
this.searchResults = [];
this.showResults = false;
this.errorStatus = false;
this.errorMsg = '';
}
showPrimary() {
// this.advancedDiv.nativeElement.style.display = 'none';
// this.primaryDiv.nativeElement.style.display = 'block';
this.clearAdvancedForm();
this.searchResults = [];
this.showResults = false;
this.errorStatus = false;
this.errorMsg = '';
}
updateTable() {
if (this.typeOfSearch === 'P') {
this.primarySearch();
} else {
this.advancedSearch();
}
}
viewSubmissionDetails(event) {
const row = event.data;
// const idx = event.index; // not used
this.setSubmissionId(row.submissionId);
this.router.navigate(['/viewSubmission']);
}
setSubmissionId(id) {
this.rfaiSearch277Service.setSubmissionId(id);
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}