Skip to content

Commit

Permalink
Feature/mhv medical records/util unit testing coverage (#33606)
Browse files Browse the repository at this point in the history
  • Loading branch information
acrollet authored Dec 17, 2024
1 parent 6214ea4 commit 1eddab1
Show file tree
Hide file tree
Showing 7 changed files with 1,051 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
import { expect } from 'chai';
import { generateBlueButtonData } from '../../../util/pdfHelpers/blueButton';
import {
NONE_RECORDED,
recordType,
blueButtonRecordTypes,
labTypes,
loincCodes,
medicationTypes,
vitalTypes,
} from '../../../util/constants';

describe('generateBlueButtonData', () => {
it('should return an empty array when no records are provided', () => {
const result = generateBlueButtonData({}, []);
expect(result).to.be.an('array');
expect(result.length).to.equal(11);
});

it('should generate data for labs and tests', () => {
const labsAndTests = [
{
name: 'Test 1',
type: labTypes.CHEM_HEM,
results: [{ name: 'Test result 1', result: 'Test result 1' }],
},
{
name: 'Test 2',
type: labTypes.MICROBIOLOGY,
results: [
{
name: 'Test result 2',
result: 'Test result 2',
labType: 'Test lab type',
},
],
},
{
name: 'Test 3',
type: labTypes.PATHOLOGY,
results: [{ name: 'Test result 3', result: 'Test result 3' }],
},
{
name: 'Test 4',
type: labTypes.EKG,
results: [{ name: 'Test result 4', result: 'Test result 4' }],
},
{
name: 'Test 5',
type: labTypes.RADIOLOGY,
results: [{ name: 'Test result 5', result: 'Test result 5' }],
},
];
const result = generateBlueButtonData({ labsAndTests }, ['labTests']);
expect(result).to.be.an('array').that.is.not.empty;
const labsAndTestsSection = result.find(
section => section.type === recordType.LABS_AND_TESTS,
);
expect(labsAndTestsSection).to.exist;
expect(labsAndTestsSection.records).to.have.lengthOf(5);
expect(labsAndTestsSection.records[0].title).to.equal('Test 1');
expect(
labsAndTestsSection.records[0].results.items[0].items[0].value,
).to.equal('Test result 1');
});

it('should generate data for care summaries and notes', () => {
const notes = [
{ name: 'Note 1', type: loincCodes.DISCHARGE_SUMMARY },
{ name: 'Note 2', type: loincCodes.PHYSICIAN_PROCEDURE_NOTE },
{ name: 'Note 2', type: loincCodes.CONSULT_RESULT },
];
const result = generateBlueButtonData({ notes }, ['careSummaries']);
expect(result).to.be.an('array').that.is.not.empty;
const notesSection = result.find(
section => section.type === recordType.CARE_SUMMARIES_AND_NOTES,
);
expect(notesSection).to.exist;
expect(notesSection.records).to.have.lengthOf(3);
expect(notesSection.records[0].title).to.equal('Note 1');
});

it('should generate data for vaccines', () => {
const vaccines = [
{ name: 'Vaccine 1', date: '2021-01-01' },
{ name: 'Vaccine 2', date: '2021-01-01' },
];
const result = generateBlueButtonData({ vaccines }, ['vaccines']);
expect(result).to.be.an('array').that.is.not.empty;
const vaccinesSection = result.find(
section => section.type === recordType.VACCINES,
);
expect(vaccinesSection).to.exist;
expect(vaccinesSection.records.results.items).to.have.lengthOf(2);
expect(vaccinesSection.records.results.items[0].items[0].value).to.equal(
'2021-01-01',
);
});

it('should generate data for allergies', () => {
const allergies = [
{ name: 'Allergy 1' },
{ name: 'Allergy 2', isOracleHealthData: true },
];
const result = generateBlueButtonData({ allergies }, ['allergies']);
expect(result).to.be.an('array').that.is.not.empty;
const allergiesSection = result.find(
section => section.type === recordType.ALLERGIES,
);
expect(allergiesSection).to.exist;
expect(allergiesSection.records.results.items).to.have.lengthOf(2);
expect(allergiesSection.records.results.items[0].header).to.equal(
'Allergy 1',
);
});

it('should generate data for health conditions', () => {
const conditions = [{ name: 'Condition 1' }, { name: 'Condition 2' }];
const result = generateBlueButtonData({ conditions }, ['conditions']);
expect(result).to.be.an('array').that.is.not.empty;
const conditionsSection = result.find(
section => section.title === 'Health conditions',
);
expect(conditionsSection).to.exist;
expect(conditionsSection.records).to.have.lengthOf(2);
expect(conditionsSection.records[0].title).to.equal('Condition 1');
});

it('should generate data for vitals', () => {
const vitals = [
{
name: 'Vital 1',
type: vitalTypes.HEIGHT,
date: '2021-01-01',
measurement: '72',
location: 'Test location',
notes: 'Test notes',
},
{
name: 'Vital 2',
type: vitalTypes.PAIN_SEVERITY,
date: '2021-01-01',
measurement: '5',
location: 'Pittsburgh VAMC',
},
];
const result = generateBlueButtonData({ vitals }, ['vitals']);
expect(result).to.be.an('array').that.is.not.empty;
const vitalsSection = result.find(
section => section.type === recordType.VITALS,
);
expect(vitalsSection).to.exist;
expect(vitalsSection.records).to.have.lengthOf(2);
expect(vitalsSection.records[0].results.items[0].header).to.equal(
'2021-01-01',
);
expect(vitalsSection.records[0].results.items[0].items[0].value).to.equal(
'72',
);
});

it('should generate data for medications', () => {
const medications = [
{
prescriptionName: 'Medication 1',
status: 'Active',
type: medicationTypes.VA,
},
{
prescriptionName: 'Medication 2',
status: 'Inactive',
type: medicationTypes.VA,
},
];
const result = generateBlueButtonData({ medications }, ['medications']);
expect(result).to.be.an('array').that.is.not.empty;
const medicationsSection = result.find(
section => section.type === blueButtonRecordTypes.MEDICATIONS,
);
expect(medicationsSection).to.exist;
expect(medicationsSection.records).to.have.lengthOf(2);
expect(medicationsSection.records[0].title).to.equal('Medication 1');
expect(medicationsSection.records[0].details[0].items[1].value).to.equal(
'Active',
);
});

it('should generate data for appointments', () => {
const appointments = [
{
isUpcoming: true,
date: '2022-01-01',
address: ['Facility 1'],
detailsShared: { reason: 'check-up', otherDetails: '' },
},
{
isUpcoming: false,
date: '2021-01-01',
address: ['Facility 2'],
detailsShared: { reason: 'check-up', otherDetails: '' },
},
];
const result = generateBlueButtonData({ appointments }, [
'upcomingAppts',
'pastAppts',
]);
expect(result).to.be.an('array').that.is.not.empty;
const appointmentsSection = result.find(
section => section.type === blueButtonRecordTypes.APPOINTMENTS,
);
expect(appointmentsSection).to.exist;
expect(appointmentsSection.records).to.have.lengthOf(2);
expect(appointmentsSection.records[0].title).to.equal(
'Upcoming appointments',
);
expect(appointmentsSection.records[0].results.items[0].header).to.equal(
'2022-01-01',
);
});

it('should generate data for demographics', () => {
const demographics = [
{
facility: 'Facility 1',
eligibility: {
serviceConnectedPercentage: NONE_RECORDED,
meansTestStatus: NONE_RECORDED,
primaryEligibilityCode: NONE_RECORDED,
},
employment: { occupation: 'Engineer' },
contactInfo: { homePhone: '5555551212' },
permanentAddress: { street: '123 main st' },
emergencyContact: {
name: 'Jane Doe',
address: { street: '123 main st' },
},
primaryNextOfKin: {
name: 'John Doe',
address: { street: '123 main st' },
},
civilGuardian: {
name: 'Joe Doe',
address: { street: '123 main st' },
},
vaGuardian: {
name: 'Jim Doe',
address: { street: '123 main st' },
},
activeInsurance: {
company: 'Company 1',
},
},
];
const result = generateBlueButtonData({ demographics }, ['demographics']);
expect(result).to.be.an('array').that.is.not.empty;
const demographicsSection = result.find(
section => section.type === blueButtonRecordTypes.DEMOGRAPHICS,
);
expect(demographicsSection).to.exist;
expect(demographicsSection.records).to.have.lengthOf(1);
expect(demographicsSection.records[0].title).to.equal(
'VA facility: Facility 1',
);
expect(
demographicsSection.records[0].results.items[1].items[0].value,
).to.equal('123 main st');
});

it('should generate data for military service', () => {
const militaryService = 'Army';
const result = generateBlueButtonData({ militaryService }, [
'militaryService',
]);
expect(result).to.be.an('array').that.is.not.empty;
const militaryServiceSection = result.find(
section => section.type === blueButtonRecordTypes.MILITARY_SERVICE,
);
expect(militaryServiceSection).to.exist;
expect(militaryServiceSection.records).to.have.lengthOf(1);
expect(militaryServiceSection.records[0].details.items[0].value).to.equal(
'Army',
);
});

it('should generate data for account summary', () => {
const accountSummary = {
authenticationSummary: {
source: 'Source 1',
authenticationStatus: 'Status 1',
authenticationDate: 'Date 1',
authenticationFacilityName: 'Facility 1',
authenticationFacilityID: '1',
},
vaTreatmentFacilities: [
{
facilityName: 'Facility 1',
type: 'VAMC',
},
],
};
const result = generateBlueButtonData({ accountSummary }, []);
expect(result).to.be.an('array').that.is.not.empty;
const accountSummarySection = result.find(
section => section.type === blueButtonRecordTypes.ACCOUNT_SUMMARY,
);
expect(accountSummarySection).to.exist;
expect(accountSummarySection.records).to.be.an('object');
expect(accountSummarySection.records.details.items[0].value).to.equal(
'Source 1',
);
expect(accountSummarySection.records.results.items[0].header).to.equal(
'Facility 1',
);
});
});
Loading

0 comments on commit 1eddab1

Please sign in to comment.