Skip to content

Commit

Permalink
[AVS] Account for null med changes summary field (#28230)
Browse files Browse the repository at this point in the history
* Account for nulled med changes summary

* Re-add test for med changes subsections
  • Loading branch information
acrollet committed Feb 28, 2024
1 parent 81a675c commit 2911a0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/applications/avs/components/YourTreatmentPlan.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const YourTreatmentPlan = props => {
const { avs } = props;
const { medChangesSummary, orders } = avs;

const medChanges = !allArraysEmpty(medChangesSummary)
? medChangesSummary
: null;
const medChanges =
medChangesSummary && !allArraysEmpty(medChangesSummary)
? medChangesSummary
: null;

const medsIntro = (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ describe('Avs: Your Treatment Plan', () => {
delete avs.orders;
delete avs.patientInstructions;
delete avs.clinicalReminders;
avs.medChangesSummary.discontinuedMeds = [];
avs.medChangesSummary.newMedications = [];
avs.medChangesSummary.changedMedications = [];
avs.medChangesSummary = null;
const props = { avs };
const screen = render(<YourTreatmentPlan {...props} />);
expect(screen.queryByTestId('new-orders-heading')).to.not.exist;
Expand All @@ -73,4 +71,14 @@ describe('Avs: Your Treatment Plan', () => {
expect(screen.queryByTestId('discontinued-medications-list')).to.not.exist;
expect(screen.queryByTestId('changed-medications-list')).to.not.exist;
});

it('Med Changes section is not shown if all sub-sections are empty', async () => {
const avs = replacementFunctions.cloneDeep(avsData);
avs.medChangesSummary.discontinuedMeds = [];
avs.medChangesSummary.newMedications = [];
avs.medChangesSummary.changedMedications = [];
const props = { avs };
const screen = render(<YourTreatmentPlan {...props} />);
expect(screen.queryByTestId('changed-medications-list')).to.not.exist;
});
});

0 comments on commit 2911a0c

Please sign in to comment.