Skip to content

Commit

Permalink
MHV-65317 Select allergies when medications is selected in BB PDF (#3…
Browse files Browse the repository at this point in the history
…3636)

* MHV-65316 Select allergies with medications

* MHV-65317 Added some tests

* MHV-65317 Fixed some logic
  • Loading branch information
mmoyer-va authored Dec 18, 2024
1 parent 5e412c8 commit bce8967
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,67 @@ describe('generateBlueButtonData', () => {
'Facility 1',
);
});

it('should include allergies if medications is present', () => {
const input = {
allergies: [
{ name: 'Allergy 1' },
{ name: 'Allergy 2', isOracleHealthData: true },
],
medications: [{ prescriptionName: 'Medication 1' }],
};

const recordFilter = ['medications'];
const result = generateBlueButtonData(input, recordFilter);
const allergiesSection = result.find(
section => section.type === recordType.ALLERGIES,
);

expect(allergiesSection).to.exist;
expect(allergiesSection.selected).to.be.true;
expect(allergiesSection.records.results.items).to.have.lengthOf(2);
expect(allergiesSection.records.results.items[0].header).to.equal(
'Allergy 1',
);
});

it('should not include allergies if neither allergies nor medications are present', () => {
const input = {
labsAndTests: [],
notes: [],
vaccines: [],
allergies: [],
conditions: [],
vitals: [],
medications: [],
appointments: [],
demographics: [],
militaryService: [],
accountSummary: null,
};

const recordFilter = [];
const result = generateBlueButtonData(input, recordFilter);
const allergiesSection = result.find(
section => section.type === recordType.ALLERGIES,
);

expect(allergiesSection).to.exist;
expect(allergiesSection.selected).to.be.false;
expect(allergiesSection.records.length).to.eq(0);
});

it('should not include allergies if medications is selected but empty', () => {
const input = { allergies: [{ name: 'Allergy 1' }] };

const recordFilter = ['medications'];
const result = generateBlueButtonData(input, recordFilter);
const allergiesSection = result.find(
section => section.type === recordType.ALLERGIES,
);

expect(allergiesSection).to.exist;
expect(allergiesSection.selected).to.be.false;
expect(allergiesSection.records.results.items).to.have.lengthOf(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export const generateBlueButtonData = (
'This list includes all allergies, reactions, and side effects in your VA medical records. If you have allergies or reactions that are missing from this list, tell your care team at your next appointment.',
`Showing ${allergies?.length} records from newest to oldest`,
],
selected: recordFilter.includes('allergies'),
selected:
recordFilter.includes('allergies') ||
(recordFilter.includes('medications') && medications?.length > 0),
records: allergies?.length ? generateAllergiesContent(allergies) : [],
});

Expand Down

0 comments on commit bce8967

Please sign in to comment.