Skip to content

Commit 6ec655b

Browse files
authored
[PRMP-1710] Change inactive patient search error (#592)
* [PRMP-1710] add check for not deceased when patient is inactive * [PRMP-1710] add unit tests
1 parent 93e788b commit 6ec655b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

app/src/pages/patientSearchPage/PatientSearchPage.test.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,44 @@ describe('PatientSearchPage', () => {
145145
).toHaveLength(2);
146146
});
147147

148+
it('returns patient info when patient is inactive and deceased', async () => {
149+
const patientDetails = buildPatientDetails({
150+
active: false,
151+
deceased: true,
152+
});
153+
154+
mockedAxios.get.mockImplementation(() => Promise.resolve({ data: patientDetails }));
155+
156+
renderPatientSearchPage();
157+
userEvent.type(screen.getByRole('textbox', { name: 'Enter NHS number' }), '9000000000');
158+
userEvent.click(screen.getByRole('button', { name: 'Search' }));
159+
160+
await waitFor(() => {
161+
expect(mockedUseNavigate).toHaveBeenCalledWith(routes.VERIFY_PATIENT);
162+
});
163+
});
164+
165+
it('returns an error when patient is inactive and not deceased and user is clinical', async () => {
166+
const patientDetails = buildPatientDetails({
167+
active: false,
168+
deceased: false,
169+
});
170+
171+
mockedAxios.get.mockImplementation(() => Promise.resolve({ data: patientDetails }));
172+
173+
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.GP_CLINICAL);
174+
175+
renderPatientSearchPage();
176+
userEvent.type(screen.getByRole('textbox', { name: 'Enter NHS number' }), '9000000000');
177+
userEvent.click(screen.getByRole('button', { name: 'Search' }));
178+
179+
expect(
180+
await screen.findAllByText(
181+
"You cannot access this patient's record because they are not registered at your practice. The patient's current practice can access this record.",
182+
),
183+
).toHaveLength(2);
184+
});
185+
148186
it('returns a service error when service is down', async () => {
149187
const errorResponse = {
150188
response: {

app/src/pages/patientSearchPage/PatientSearchPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function PatientSearchPage() {
7575
baseHeaders,
7676
});
7777

78-
if (!patientDetails.active) {
78+
if (!patientDetails.active && !patientDetails.deceased) {
7979
if (
8080
userIsGPClinical ||
8181
(userIsGPAdmin &&

0 commit comments

Comments
 (0)