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 { AuthenticationService } from '../../auth/auth.service';
import { Component, OnInit, ViewChild, OnDestroy, Input, AfterViewInit, ChangeDetectorRef } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Search275Service } from './search275.service';
import { Search275Model } from './search275.component.model';
import { TableColumnModel, TableSettings, PaginationSettings } from '../../shared/table';
import { AttachmentViewerComponent } from '../../shared/attachment-viewer/attachment-viewer.component';
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';
// Use a name that suggests actual syntax: mm/dd/20yy or mm/dd/19yy
const date_MM_DD_19YYor20YY = /^(0[1-9]|1[012])[/](0[1-9]|[12]\d|3[01])[/](19|20)\d\d$/; // ^anchors$ match only entire string
// for mm: /(0[1-9]|1[012])/ is short for /(01|02|03|04|05|06|07|08|09|10|11|12)/
// for dd: /(0[1-9]|[12]\d|3[01])/ is short for
// /(01|02|03|04|05|06|07|08|09)|(10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29)|(30|31))/
// /a[/]b/ matches 'a/b' but /a/b/ is a syntax error: like regex '/a/' followed by 'b/'
// Use a logical name that conveys intended usage
const date_Service = date_MM_DD_19YYor20YY;
@Component({
selector: 'app-search275',
templateUrl: './search275.component.html',
styleUrls: ['./search275.component.scss'],
})
export class Search275Component implements OnInit, AfterViewInit, OnDestroy {
userRoles;
userInfo;
menu: MenuModel;
permissions: any;
isAdmin = false;
constructor(
private fb: FormBuilder,
private search275Service: Search275Service,
private attachmentService: AttachmentViewerService,
private authenticationService: AuthenticationService,
private appSettingsService: AppSettingsService,
private changeDetectorRef: ChangeDetectorRef
) {}
@ViewChild(AttachmentViewerComponent)
attachmentViewerComponent;
@Input()
tabIdx = '0';
tableColumns: TableColumnModel[] = [
new TableColumnModel('VA Attch. Ctrl. #', 'attachIdLx'),
new TableColumnModel('Prov. Attch. ID', 'attachCtrNumber'),
new TableColumnModel('Patient Name', 'patientName'),
new TableColumnModel('Patient ID', 'patientIdentifier'),
new TableColumnModel('Patient Ctrl. #', 'patientCtrNumber'),
new TableColumnModel('Provider Name', 'providerName'),
new TableColumnModel('Provider NPI', 'providerNpi'),
new TableColumnModel('Payer Ctrl.', 'payerControlNumber'),
new TableColumnModel('Claim ID', 'externalClaimId'),
new TableColumnModel('Svc. Start Date', 'claimServiceStartDate'),
new TableColumnModel('Rpt. Type', 'reportTypeCode'),
new TableColumnModel('Status', 'status'),
// new TableColumnModel('Med. Record', 'medicalRecordNumber', 'right', 'right') // Right alignment for numeric column
new TableColumnModel('Med. Record', 'medicalRecordNumber', 'left', 'left') // Not really a number, it is a string of digits
// new TableColumnModel('Attch. Type', 'attachType'),
// new TableColumnModel('View', '')
];
tableSettings: TableSettings = new TableSettings();
paginationSettings: PaginationSettings = new PaginationSettings();
errorStatus = false;
errorMsg = '';
successStatus = false;
successMsg = '';
showResults = false;
requestModel: Search275Model = new Search275Model();
loading = true;
searchSubscription: Subscription = new Subscription();
subscription: Subscription = new Subscription();
reportCodes = [
'All ',
'03 Report Justifying Treatment Beyond Utilization Guidelines',
'04 Drugs Administered',
'05 Treatment Diagnosis',
'06 Initial Assessment',
'07 Functional Goals',
'08 Plan of Treatment',
'09 Progress Report',
'10 Continued Treatment',
'11 Chemical Analysis',
'13 Certified Test Report',
'15 Justification for Admission',
'21 Recovery Plan',
'A3 Allergies/Sensitivities Document',
'A4 Autopsy Report',
'AM Ambulance Certification',
'AS Admission Summary',
'B2 Prescription',
'B3 Physician Order',
'B4 Referral Form',
'BR Benchmark Testing Results',
'BS Baseline',
'BT Blanket Test Results',
'CB Chiropractic Justification',
'CK Consent Form(s)',
'CT Certification',
'D2 Drug Profile Document',
'DA Dental Models',
'DB Durable Medical Equipment Prescription',
'DG Diagnostic Report',
'DJ Discharge Monitoring Report',
'DS Discharge Summary',
'EB Explanation of Benefits (Coordination of Benefits or Medicare Secondary Payer)',
'HC Health Certificate',
'HR Health Clinic Records',
'I5 Immunization Record',
'IR State School Immunization Records',
'LA Laboratory Results',
'M1 Medical Record Attachment',
'MT Models',
'NN Nursing Notes',
'OB Operative Note',
'OC Oxygen Content Averaging Report',
'OD Orders and Treatments Document',
'OE Objective Physical Examination (including vital signs) Document',
'OX Oxygen Therapy Certification',
'OZ Support Data for Claim',
'P4 Pathology Report',
'P5 Patient Medical History Document',
'PE Parenteral or Enteral Certification',
'PN Physical Therapy Notes',
'PO Prosthetics or Orthotic Certification',
'PQ Paramedical Results',
'PY Physician\u2019s Report', // ’ character is Unicode \u2019
'PZ Physical Therapy Certification',
'RB Radiology Films',
'RR Radiology Reports',
'RT Report of Tests and Analysis Report',
'RX Renewable Oxygen Content Averaging Report',
'SG Symptoms'
];
searchResults: Search275Model[];
form: FormGroup;
statuses = ['Active', 'Inactive'];
dateRangeError = false;
// test data list
selectedAttachmentId: {};
fileList: string[] = [];
selectedAttachment: string = null;
displayAttachmentViewer = false;
title = 'Attachments Retrieval \u00A0\u00A0|\u00A0\u00A0 275 Search';
ngOnInit() {
this.formInit();
this.getUserData();
this.tableInit();
this.appSettingsService
.getMenu('ARS_MENU')
.subscribe(menu => (this.menu = menu));
}
ngAfterViewInit() {
this.subscription.add(this.form.controls['claimServiceEndDate'].valueChanges.subscribe(v => {
if (this.form.get('claimServiceStartDate').valid &&
this.form.get('claimServiceEndDate').value &&
this.form.get('claimServiceEndDate').value.length === 10 &&
this.form.get('claimServiceStartDate').value &&
this.form.get('claimServiceStartDate').value.length === 10
) {
this.datesValidator();
}
}));
this.subscription.add(this.form.controls['claimServiceStartDate'].valueChanges.subscribe(v => {
if (this.form.get('claimServiceStartDate').valid &&
this.form.get('claimServiceEndDate').valid &&
this.form.get('claimServiceEndDate').value &&
this.form.get('claimServiceEndDate').value.length === 10 &&
this.form.get('claimServiceStartDate').value &&
this.form.get('claimServiceStartDate').value.length === 10
) {
this.datesValidator();
}
}));
}
formInit() {
this.form = this.fb.group(
{
attachIdLx: [
this.requestModel.attachIdLx,
Validators.pattern(/^(\d+\.\d{1,3})?$/)
],
attachCtrNumber: [this.requestModel.attachCtrNumber],
// claimId: [this.requestModel.claimId, Validators.pattern('\\d*')], // 'test' => !valid string patterns are automatically anchored
// claimId: [this.requestModel.claimId, Validators.pattern(/\d*/)], // 'test' => valid (it should not!)
claimId: [this.requestModel.claimId, Validators.pattern(/^\d*$/)], // We must anchor (i.e., /^...$/) our regex to match the entire form element
status: this.requestModel.status,
patientLastName: this.requestModel.patientLastName,
patientFirstName: this.requestModel.patientFirstName,
patientCtrNumber: [this.requestModel.patientCtrNumber],
patientIdentifier: [
this.requestModel.patientIdentifier,
Validators.pattern(/^\d*$/)
],
providerName: this.requestModel.providerName,
providerNpi: [
this.requestModel.providerNpi,
Validators.pattern(/^\d*$/)
],
medicalRecordNumber: [
this.requestModel.medicalRecordNumber
// Validators.pattern(/^\d*$/)
],
payerControlNumber: [this.requestModel.payerControlNumber],
reportTypeCode: this.requestModel.reportTypeCode,
claimServiceStartDate: [
'',
[Validators.pattern(date_Service)]
],
claimServiceEndDate: [
'',
[Validators.pattern(date_Service)]
]
}
// { validator: atLeastOne(Validators.required) }
);
}
tableInit() {
// Initializes the search results table
this.tableSettings.buttonShow = false; // not used
this.tableSettings.buttonNames = [' ']; // doesn't hurt anything
this.tableSettings.imgColumn = false; // not used
this.tableSettings.imageColumnNames = [' ']; // doesn't hurt anything
// extShow is used instead of Buttons Or Images or Counters.
this.tableSettings.extShow = true; // test code
this.tableSettings.extCol = 'View';
this.tableSettings.extSrc = row => this.iconAttachType(row); // this.iconAttachType; fails to find this.attachType_toUrl()
// There used to be multiple attachments listed for an attachment ID, but now we separate them by using attachIdLx
// But we still return an array for pathAddress. Well, no: It's undefined!
// this.tableSettings.extTitle = (row) => `${this.tableSettings.extCol} attachment ${row.pathAddress[0]}`; // not used any more
this.tableSettings.extTitle = row =>
`${this.tableSettings.extCol} attachment ${row.attachIdLx}`;
// added to accommodate digits on the attachment images.
this.tableSettings.imgCounterView = false; // not used
// this.tableSettings.imageUrls = [
// '../../assets/images/ic_attachCount_blue_24.svg'
// ];
}
// getUserData() {
// if (sessionStorage.getItem('additionalInformationPermissions')) {
// this.additionalInfoPermissions = JSON.parse(
// sessionStorage.getItem('additionalInformationPermissions')
// );
// this.disablePopulateInfo = !this.additionalInfoPermissions[
// 'populateInfo'
// ];
// this.disableSubmitInfo = !this.additionalInfoPermissions['submitInfo'];
// }
// this.roles = JSON.parse(sessionStorage.getItem('userRoles'));
// }
resetForm(): void {
this.form.reset();
this.requestModel = new Search275Model();
this.form.get('reportTypeCode').setValue(this.requestModel.reportTypeCode);
this.form.get('status').setValue(this.requestModel.status);
this.form.updateValueAndValidity();
this.showResults = false;
this.errorStatus = false;
this.errorMsg = '';
this.successStatus = false;
this.successMsg = '';
this.dateRangeError = false;
}
search(): void {
this.showResults = true;
this.paginationSettings = new PaginationSettings();
this.fetchData();
}
fetchData(): void {
this.loading = true;
this.requestModel.pageSize = this.paginationSettings.pageSize;
this.requestModel.pageNumber = this.paginationSettings.currentPage;
this.requestModel.descending = this.paginationSettings.descending;
this.requestModel.sortColumn = this.paginationSettings.sortColumn;
this.requestModel.claimServiceStartDate = this.form.get('claimServiceStartDate').value;
this.requestModel.claimServiceEndDate = this.form.get('claimServiceEndDate').value;
this.searchSubscription.add(this.search275Service
.search(this.requestModel)
.subscribe(
data => {
this.searchResults = data.response;
this.loading = false;
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.requestModel.descending
};
},
error => {
this.paginationSettings = new PaginationSettings();
this.errorStatus = true;
this.errorMsg = 'Error in processing search request.';
this.searchResults = [];
this.showResults = false;
this.loading = false;
}
));
}
updateTable() {
this.fetchData();
}
onArchive(evt) {
if (evt) {
this.successMsg = 'Attachment successfully deactivated.';
this.successStatus = evt;
this.updateTable();
} else {
this.errorMsg = 'Failed to deactivate attachment.';
this.errorStatus = true;
}
}
reActivate(evt) {
if (evt) {
this.successMsg = 'Attachment successfully reactivated.';
this.successStatus = evt;
this.updateTable();
} else {
this.errorMsg = 'Failed to reactivate attachment.';
this.errorStatus = true;
}
}
imgClicked(event: any) {}
// validate the date range between the two date fields. fromDate should be less than toDate.
datesValidator(): void {
this.dateRangeError = false;
if (
this.form.get('claimServiceStartDate').value.length === 10 &&
this.form.get('claimServiceEndDate').value.length === 10
) {
const fromDate = new Date(this.form.get('claimServiceStartDate').value);
const toDate = new Date(this.form.get('claimServiceEndDate').value);
if (toDate.valueOf() < fromDate.valueOf()) {
this.dateRangeError = true;
this.form.get('claimServiceStartDate').setValue('');
this.form.get('claimServiceEndDate').setValue('');
this.changeDetectorRef.detectChanges();
} else {
this.dateRangeError = false;
}
}
}
getUserData() {
this.userInfo = this.authenticationService.getDecodedUserInfo();
this.userRoles = this.userInfo.userRoles;
this.permissions = this.userInfo.permissions;
this.isAdmin = this.userRoles.some(data => data === 'ARS_ADMIN');
}
onDisplayAttachmentViewer(row) {
this.attachmentService.setAttachmentViewerState(true);
this.tabIdx = '-1';
this.successStatus = false;
this.errorStatus = false;
this.selectedAttachmentId = {
attachmentId: row.attachId,
attachIdLx: row.attachIdLx,
status: row.status
};
this.fileList = row.pathAddress; // in html: <app-attachment-viewer [attachmentList]="fileList">
// if (this.fileList.length > 1) {
// this.selectedAttachment = this.fileList.filter(attachment => attachment.endsWith('XML'))[0]
// } else {
// this.selectedAttachment = this.fileList[0];
// }
// this.attachmentViewerComponent.fileExtension = this.selectedAttachment
// .split('.')
// .pop()
// .toUpperCase();
if (row.status === 'Active' || this.isAdmin) {
this.showResults = false;
this.displayAttachmentViewer = true;
}
}
onAttachmentViewerClose(attachmentOption) {
this.showResults = true;
this.tabIdx = '0';
this.displayAttachmentViewer = attachmentOption.open;
this.attachmentService.setAttachmentViewerState(false);
if (attachmentOption.updateTable) {
this.updateTable();
}
}
ngOnDestroy() {
this.searchSubscription.unsubscribe();
this.subscription.unsubscribe();
}
iconAttachType(row: any): string {
if (row === null) {
return null;
} // pass on the pain
const atype = row['attachType'];
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(attachType: string): string {
if (typeof attachType !== 'string') {
attachType = '';
}
const ext = attachType.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';
}
}
}