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 { RfaiSubmissionComponent } from './rfai-submission.component';
import { RfaiSubmissionService } from './rfai-submission.service';
import { FormBuilder, FormArray } from '@angular/forms';
import { RequestCodesComponent } from './request-codes/request-codes.component';
import { AppSettingsService } from './../../shared/app-settings/app-settings.service';
import { AuthenticationService } from '../../auth/auth.service';
import { PDIInfoModel, LineModel, RfaiInfoModel } from './rfai-submission.model';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { CodeModel, PayerModel } from './../rfai-admin/rfai-admin.model';

describe('RfaiSubmissionComponent', () => {
let rfaiSubmissionService: RfaiSubmissionService;
let authenticationService: AuthenticationService;
let component: RfaiSubmissionComponent;
let fb: FormBuilder;
let healthCareClaimStatusCodes: CodeModel[];
let loincCodes: CodeModel[];
let loincCodeModifiers: CodeModel[];
let additionalInfoPermissions: any;
let roles: string[];
let requestCodesComponent: RequestCodesComponent;
let codeListTemp;
let linesFormArrayTemp;
let appSettingsService: AppSettingsService;
let payers: PayerModel[];

beforeEach(() => {
healthCareClaimStatusCodes = [
{
cd: 'HEALTH_CODE_1',
stcCd: 'HEALTH_STC_CODE_1',
stcCdDesc: 'HEALTH_STC_CODE_DESC_1',
flag: false,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'HEALTH_CODE_2',
stcCd: 'HEALTH_STC_CODE_2',
stcCdDesc: 'HEALTH_STC_CODE_DESC_2',
flag: false,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'HEALTH_CODE_3',
stcCd: 'HEALTH_STC_CODE_3',
stcCdDesc: 'HEALTH_STC_CODE_DESC_3',
flag: true,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'HEALTH_CODE_4',
stcCd: 'HEALTH_STC_CODE_4',
stcCdDesc: 'HEALTH_STC_CODE_DESC_4',
flag: true,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
}
];

loincCodes = [
{
cd: 'LOINC_CODE_1',
stcCd: 'LOINC_STC_CODE_1',
stcCdDesc: 'LOINC_STC_CODE_DESC_1',
flag: false,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'LOINC_CODE_2',
stcCd: 'LOINC_STC_CODE_2',
stcCdDesc: 'LOINC_STC_CODE_DESC_2',
flag: false,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'LOINC_CODE_3',
stcCd: 'LOINC_STC_CODE_3',
stcCdDesc: 'LOINC_STC_CODE_DESC_3',
flag: true,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'LOINC_CODE_4',
stcCd: 'LOINC_STC_CODE_4',
stcCdDesc: 'LOINC_STC_CODE_DESC_4',
flag: true,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
}
];

loincCodeModifiers = [
{
cd: 'LOINC_MOD_CODE_1',
stcCd: 'LOINC_MOD_STC_CODE_1',
stcCdDesc: 'LOINC_MOD_STC_CODE_DESC_1',
flag: false,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'LOINC_MOD_CODE_2',
stcCd: 'LOINC_MOD_STC_CODE_2',
stcCdDesc: 'LOINC_MOD_STC_CODE_DESC_2',
flag: false,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'Claim',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'LOINC_MOD_CODE_3',
stcCd: 'LOINC_MOD_STC_CODE_3',
stcCdDesc: 'LOINC_MOD_STC_CODE_DESC_3',
flag: true,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'line',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
cd: 'LOINC_MOD_CODE_4',
stcCd: 'LOINC_MOD_STC_CODE_4',
stcCdDesc: 'LOINC_MOD_STC_CODE_DESC_4',
flag: true,
editedOrNewFlag: false,
startDate: '',
endDate: '',
archive: false,
level: 'both',
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
}
];
payers = [
{
payerIndex: '1',
payerIdentifier: 'Payer_1',
payerIdentifierDesc: 'Payer_Desc_1',
archive: false,
editedOrNewFlag: false,
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
payerIndex: '2',
payerIdentifier: 'Payer_2',
payerIdentifierDesc: 'Payer_Desc_2',
archive: false,
editedOrNewFlag: true,
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
payerIndex: '3',
payerIdentifier: 'Payer_3',
payerIdentifierDesc: 'Payer_Desc_3',
archive: true,
editedOrNewFlag: false,
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
},
{
payerIndex: '4',
payerIdentifier: 'Payer_4',
payerIdentifierDesc: 'Payer_Desc_4',
archive: true,
editedOrNewFlag: true,
archiveImg: '../../assets/images/ic_archive_red_24.svg',
editTableImg: '../../assets/images/ic_edit_table_blue_24.svg'
}
];

roles = ['ADMIN'];

additionalInfoPermissions = {
populateInfo: false,
submitInfo: false
};

// sessionStorage.setItem('additionalInformationPermissions', JSON.stringify(additionalInfoPermissions));
// sessionStorage.setItem('userRoles', JSON.stringify(roles));

rfaiSubmissionService = new RfaiSubmissionService(null);
fb = new FormBuilder();
authenticationService = new AuthenticationService(null, null, null, null);
appSettingsService = new AppSettingsService(authenticationService, null);
component = new RfaiSubmissionComponent(
fb,
rfaiSubmissionService,
authenticationService,
appSettingsService,
null
);
requestCodesComponent = new RequestCodesComponent(fb);
requestCodesComponent.formInit();
component.autoCodes = requestCodesComponent;
component.manualCodes = requestCodesComponent;
codeListTemp = requestCodesComponent.codeList.controls;
linesFormArrayTemp = {
controls: [
{
controls: {
chargeAmount: {
value: ''
},
modifiers: {
value: ''
},
procedureCode: {
value: ''
},
revenueCode: {
value: ''
},
lineServiceFrom: {
value: ''
},
serviceLine: {
value: ''
},
lineServiceTo: {
value: ''
}
}
}
]
};
component.populatedInfo = { nativeElement: { style: { display: '' } } };
component.linesDiv = { nativeElement: { style: { display: '' } } };
});

it('component should have been created', () => {
expect(component).toBeTruthy();
});

it('test ngOnInit method', () => {
spyOn(authenticationService, 'getDecodedToken').and.callFake(() => {
return {
userInfo: {
userRoles: ['ADMIN'],
permissions: {
additionalInformation: {
populatedInfo: true
}
}
}
};
});
spyOn(authenticationService, 'getDecodedUserInfo').and.callFake(() => {
const userInfo = {};
return {
userInfo: {},
userRoles: ['ADMIN'],
permissions: {
additionalInformation: {
populatedInfo: true
}
}
};
});
const hccs = spyOn(rfaiSubmissionService, 'getHccscCodes').and.callFake(
() => {
return Observable.create((observer: Observer<string>) =>
observer.next('data')
);
}
);

const loincCode = spyOn(
rfaiSubmissionService,
'getLoincCodes'
).and.callFake(() => {
return Observable.create((observer: Observer<string>) =>
observer.next('data')
);
});

const lioncCodeModifier = spyOn(
rfaiSubmissionService,
'getLoincCodeModifiers'
).and.callFake(() => {
return Observable.create((observer: Observer<string>) =>
observer.next('data')
);
});

const payersT = spyOn(rfaiSubmissionService, 'getPayers').and.callFake(
() => {
return Observable.create((observer: Observer<string>) =>
observer.next('data')
);
}
);

component.ngOnInit();

const formSpy = spyOn(component, 'formInit');
expect(component.manualForm).toBeTruthy();
});

it('test getCodes method', () => {
const loincCodesCombine = [
{
claimList: loincCodes,
lineList: loincCodes
}
];
spyOn(rfaiSubmissionService, 'getHccscCodes').and.callFake(() => {
return new Observable(observer =>
observer.next(healthCareClaimStatusCodes)
);
});

spyOn(rfaiSubmissionService, 'getLoincCodes').and.callFake(() => {
return new Observable(observer => observer.next(loincCodesCombine));
});

spyOn(rfaiSubmissionService, 'getLoincCodeModifiers').and.callFake(() => {
return new Observable(observer => observer.next(loincCodeModifiers));
});

spyOn(rfaiSubmissionService, 'getPayers').and.callFake(() => {
return new Observable(observer => observer.next(payers));
});

expect(component.healthCareClaimStatusCodes).toEqual([]);
expect(component.loincCodesLineLevel).toEqual([]);
expect(component.loincCodesClaimLevel).toEqual([]);
expect(component.loincCodeModifiers).toEqual([]);
expect(component.payers).toEqual([]);

component.getCodes();

expect(rfaiSubmissionService.getHccscCodes).toHaveBeenCalled();
expect(rfaiSubmissionService.getLoincCodes).toHaveBeenCalled();
expect(rfaiSubmissionService.getLoincCodeModifiers).toHaveBeenCalled();
expect(rfaiSubmissionService.getPayers).toHaveBeenCalled();

expect(component.healthCareClaimStatusCodes).toEqual(
healthCareClaimStatusCodes
);
expect(component.loincCodesClaimLevel).toEqual(loincCodes);
expect(component.loincCodesLineLevel).toEqual(loincCodes);
expect(component.loincCodeModifiers).toEqual(loincCodeModifiers);
expect(component.payers).toEqual(payers);
});

it('test formInit method for autoFillform to have falsy value and valid value', () => {
component.formInit();

component.autoFillform.get('claimId').setValue('');
expect(component.autoFillform.get('claimId').invalid).toBeTruthy();

component.autoFillform.get('claimId').setValue(2356);
expect(component.autoFillform.get('claimId').valid).toBeTruthy();
});

it('test formInit method: should pass truthy values into validators, form should be valid', () => {
component.formInit();

component.autoFillform.get('claimId').setValue('1234');
expect(component.autoFillform.valid).toBeTruthy();
component.prepopulateForm
.get('contactInfo')
.setValue('cindy.lauper@gmail.com');
component.prepopulateForm
.get('responseDueDateAutoCalendar')
.get('responseDueDateAuto')
.setValue('08/28/2019');

expect(component.prepopulateForm.valid).toBeTruthy();

component.manualForm.get('contactInfo').setValue('cindy.lauper@gmail.com');
component.manualForm
.get('responseDueDateManual')
.setValue('11/17/2018');
component.manualForm.get('payerID').setValue(78954678);
component.manualForm.get('payerClaimControlNumber').setValue('637589004');
component.manualForm.get('billingProvider').setValue('value');
component.manualForm.get('providerNpi').setValue(1234567890);
component.manualForm.get('billingProviderTIN').setValue(546478987);
component.manualForm.get('lastName').setValue('Lauper');
component.manualForm.get('firstName').setValue('Cindy');
component.manualForm.get('patientID').setValue(63838495409);
component.manualForm.get('patientControlNumber').setValue(73849859);
component.manualForm.get('informationReceiver').setValue('value');
component.manualForm.get('billType').setValue('value');
component.manualForm.get('clearingHouseID').setValue(73834949);
component.manualForm.get('medicalRecordNumber').setValue(63738494);
component.manualForm.get('level').setValue('C');
component.manualForm
.get('serviceFromDate')
.setValue('01/01/2018');
component.manualForm
.get('serviceToDate')
.setValue('11/17/2018');
expect(component.manualForm.valid).toBeFalsy();

component.manualForm.get('level').setValue('L');
component.manualForm
.get('linesFormArray')
.get('0')
.get('serviceLine')
.setValue(12);
component.manualForm
.get('linesFormArray')
.get('0')
.get('lineServiceFrom')
.setValue('01/01/2018');
component.manualForm
.get('linesFormArray')
.get('0')
.get('lineServiceTo')
.setValue('01/01/2019');
component.manualForm
.get('linesFormArray')
.get('0')
.get('revenueCode')
.setValue(123);
component.manualForm
.get('linesFormArray')
.get('0')
.get('procedureCode')
.setValue(1234);
component.manualForm
.get('linesFormArray')
.get('0')
.get('modifiers')
.setValue(12345);
component.manualForm
.get('linesFormArray')
.get('0')
.get('chargeAmount')
.setValue(123456);
expect(component.manualForm.valid).toBeFalsy();
});

it('test onSubmitPrepopulated method', () => {
spyOn(component, 'submitData');
component.formInit();
component.prepopulatedInfo.rfaiLineItemResponse = <LineModel[]>[
{
serviceLineId: 1,
serviceFrom: '01/02/2000',
serviceTo: '01/02/2001',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: true
},
{
serviceLineId: 2,
serviceFrom: '01/02/2001',
serviceTo: '01/02/2003',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: false
},
{
serviceLineId: 3,
serviceFrom: '01/02/2002',
serviceTo: '01/02/2004',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: true
},
{
serviceLineId: 4,
serviceFrom: '01/02/2004',
serviceTo: '01/02/2005',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: false
}
];

expect(component.prepopulatedInfo.responseDate).toEqual('');
expect(component.autoFormModel.claimId).toEqual(undefined);

component.prepopulateForm
.get('responseDueDateAutoCalendar')
.get('responseDueDateAuto')
.setValue('08/28/2018');

const rfaiInfoModel = Object.assign(
{},
component.autoFormModel,
component.prepopulatedInfo,
component.prepopulatedInfo.rfaiLineItemResponse.filter(
line => line.selected
)
);
rfaiInfoModel.claimId = null;

component.onSubmitPrepopulated();

expect(component.submitData).toHaveBeenCalled();
// expect(component.submitData).toHaveBeenCalledWith(rfaiInfoModel, codeListTemp);

expect(component.prepopulatedInfo.responseDate).toEqual('08/28/2018');
});

it('test onSubmitManual method: pdfInfoModel.level is not equl to "C"', () => {
component.pdiInfoModel.payerId = payers[0].payerIdentifier;
component.payers = payers;
component.pdiInfoModel.level = 'L';
component.linesFormArray = linesFormArrayTemp;
component.formInit();
expect(component.pdiInfoModel.serviceFromDate).toEqual('');
expect(component.pdiInfoModel.serviceToDate).toEqual('');
expect(component.pdiInfoModel.rfaiLineItemResponse).toEqual([]);

expect(component.pdiInfoModel.responseDate).toEqual('');

component.manualForm
.get('responseDueDateManual')
.setValue('11/17/2018');

component.lines = <LineModel[]>[
{
serviceLineId: 1,
serviceFrom: '01/02/2000',
serviceTo: '01/02/2001',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: true
},
{
serviceLineId: 2,
serviceFrom: '01/02/2001',
serviceTo: '01/02/2003',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: false
},
{
serviceLineId: 3,
serviceFrom: '01/02/2002',
serviceTo: '01/02/2004',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: true
},
{
serviceLineId: 4,
serviceFrom: '01/02/2004',
serviceTo: '01/02/2005',
revenueCode: '12',
procedureCode: '123',
modifiers: '1234',
chargeAmount: 12345,
selected: false
}
];

spyOn(component, 'submitData');

component.onSubmitManual();

expect(component.submitData).toHaveBeenCalled();

expect(component.pdiInfoModel.responseDate).toEqual('11/17/2018');
});

it('test submitData method', () => {
const rfaiInfoModel: RfaiInfoModel = new RfaiInfoModel();
const returnedData = { error: true };
spyOn(rfaiSubmissionService, 'submitRfai').and.callFake(() => {
return new Observable(observer => {
observer.error(returnedData);
});
});
expect(component.successMsg).toEqual('');
expect(component.errorMsg).toEqual('');
expect(component.successStatus).toEqual(false);
expect(component.errorStatus).toEqual(false);
component.submitData(rfaiInfoModel, codeListTemp);
expect(rfaiSubmissionService.submitRfai).toHaveBeenCalled();
expect(component.successMsg).toEqual('');
expect(component.errorMsg).toEqual(
'An error occurred during 277 RFAI submission.'
);
expect(component.successStatus).toEqual(false);
expect(component.errorStatus).toEqual(true);
});

it('test resetCommon method', () => {
expect(component.lines).toEqual([]);

component.errorStatus = true;
component.successStatus = true;
component.errorMsg = '';
component.successMsg = '';
component.pdiInfoModel.level = '';

spyOn(component, 'formInit');

component.resetCommon();

expect(component.lines.length).toEqual(1);
expect(component.errorStatus).toEqual(false);
expect(component.successStatus).toEqual(false);
expect(component.errorMsg).toEqual('');
expect(component.successMsg).toEqual('');
expect(component.pdiInfoModel.level).toEqual('C');

expect(component.formInit).toHaveBeenCalled();
});

it('test onResetPrepopulated method', () => {
component.populateClicked = true;
component.autoFormModel = null;
spyOn(component, 'resetCommon');

component.onResetPrepopulated();

expect(component.resetCommon).toHaveBeenCalled();
expect(component.populateClicked).toEqual(true);
expect(component.autoFormModel).toBeDefined();
expect(component.autoFormModel).not.toBeNull();
});

it('test onResetManual method', () => {
spyOn(component, 'resetCommon');

component.onResetManual();

expect(component.resetCommon).toHaveBeenCalled();
expect(component.manualFormModel).not.toBeNull();
expect(component.manualFormModel).toBeDefined();
expect(component.linesDiv.nativeElement.style.display).toEqual('none');
});

it('test toggleLines method: check for claim or line level', () => {
component.pdiInfoModel.level = 'C';
component.toggleLines();
expect(component.linesDiv.nativeElement.style.display).toEqual('none');
component.pdiInfoModel.level = 'L';
component.toggleLines();
expect(component.linesDiv.nativeElement.style.display).toEqual('block');
});

it('test checkPending method', () => {
spyOn(component, 'checkPending');

component.checkPending(12, true);

expect(component.checkPending).toHaveBeenCalled();
});

it('test checkPending method', () => {
const pendingSubmission = true;

spyOn(rfaiSubmissionService, 'checkPending').and.callFake(() => {
return new Observable(observer => {
observer.next(pendingSubmission);
});
});

component.checkPending(12, true);

expect(rfaiSubmissionService.checkPending).toHaveBeenCalled();
});

it('test openWarningModal method', () => {
component.openWarningModal();

expect(component.warningModalClosed).toBe(false);
});

it('test closeWarningModal method', () => {
component.closeWarningModal();

expect(component.warningModalClosed).toBe(true);
});

it('test cancel method', () => {
spyOn(component, 'closeWarningModal');

component.cancel();
expect(component.closeWarningModal).toHaveBeenCalled();

spyOn(component, 'onResetPrepopulated');
component.populateClicked = true;
component.cancel();
expect(component.onResetPrepopulated).toHaveBeenCalled();
spyOn(component, 'onResetManual');
component.populateClicked = false;
component.cancel();
expect(component.onResetManual).toHaveBeenCalled();
});

it('test populateInfo method', () => {
const returnedData = {
error: {
error: {
message: 'error'
}
}
};
component.formInit();
spyOn(component, 'checkPending');
const populateInfoSpy = spyOn(
rfaiSubmissionService,
'populateInfo'
).and.callFake(() => {
return new Observable(observer => {
observer.next(new PDIInfoModel());
});
});
component.populateInfo();

expect(component.populateClicked).toBe(false);
expect(
component.prepopulateForm
.get('responseDueDateAutoCalendar')
.get('responseDueDateAuto').value
).toBe('');
expect(component.errorStatus).toBe(false);
expect(component.errorMsg).toBe('');
expect(component.checkPending).toHaveBeenCalled();
expect(rfaiSubmissionService.populateInfo).toHaveBeenCalled();
expect(component.populatedInfo.nativeElement.style.display).toBe('none');
expect(component.errorStatus).toBe(false);
expect(component.errorMsg).toBe('');

populateInfoSpy.and.callFake(() => {
return new Observable(observer => {
observer.error(returnedData);
});
});
component.populateInfo();
expect(component.populatedInfo.nativeElement.style.display).toBe('none');
expect(component.errorStatus).toBe(false);
expect(component.prepopulatedInfo).toBeDefined(new PDIInfoModel());
});

it('test ngOnDestroy method', () => {
component.ngOnDestroy();

expect(component.resetChild).toBe(false);
});
});