Skip to content

Commit 82b57a5

Browse files
authored
[PRMT-572] Deceased patient in upload journey (#737)
* [PRMT-572] show no record when deceased patient and upload enabled
1 parent f97e7d7 commit 82b57a5

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

app/src/components/blocks/_lloydGeorge/lloydGeorgeRecordError/LloydGeorgeRecordError.test.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import useRole from '../../../../helpers/hooks/useRole';
77
import { REPOSITORY_ROLE } from '../../../../types/generic/authRole';
88
import { routeChildren, routes } from '../../../../types/generic/routes';
99
import useConfig from '../../../../helpers/hooks/useConfig';
10-
import { buildConfig } from '../../../../helpers/test/testBuilders';
10+
import { buildConfig, buildPatientDetails } from '../../../../helpers/test/testBuilders';
1111
import { runAxeTest } from '../../../../helpers/test/axeTestHelper';
1212
import { afterEach, beforeEach, describe, expect, it, vi, Mock } from 'vitest';
13+
import usePatient from '../../../../helpers/hooks/usePatient';
14+
import { PatientDetails } from '../../../../types/generic/patientDetails';
1315

1416
vi.mock('../../../../helpers/hooks/useRole');
1517
vi.mock('../../../../helpers/hooks/useConfig');
@@ -22,6 +24,8 @@ vi.mock('react-router-dom', () => ({
2224
const mockUseRole = useRole as Mock;
2325
const mockUseConfig = useConfig as Mock;
2426
const mockNavigate = vi.fn();
27+
const mockPatient = usePatient as Mock;
28+
const mockDeceasedPatientDetails: PatientDetails = buildPatientDetails({ deceased: true });
2529

2630
describe('LloydGeorgeRecordError', () => {
2731
beforeEach(() => {
@@ -145,6 +149,35 @@ describe('LloydGeorgeRecordError', () => {
145149
screen.queryByRole('button', { name: 'Upload files for this patient' }),
146150
).not.toBeInTheDocument();
147151
});
152+
153+
it.each([REPOSITORY_ROLE.GP_ADMIN, REPOSITORY_ROLE.GP_CLINICAL])(
154+
"renders a message but no upload button when the document download status is 'No records', user role is '%s' and upload flags are enabled and patient is deceased",
155+
(role) => {
156+
const noRecordsStatus = DOWNLOAD_STAGE.NO_RECORDS;
157+
mockPatient.mockReturnValue(mockDeceasedPatientDetails);
158+
mockUseConfig.mockReturnValue(
159+
buildConfig(
160+
{},
161+
{
162+
uploadLloydGeorgeWorkflowEnabled: true,
163+
uploadLambdaEnabled: true,
164+
},
165+
),
166+
);
167+
mockUseRole.mockReturnValue(role);
168+
169+
render(<LloydGeorgeRecordError downloadStage={noRecordsStatus} />);
170+
171+
expect(
172+
screen.getByText(
173+
/This patient does not have a Lloyd George record stored in this service/i,
174+
),
175+
).toBeInTheDocument();
176+
expect(
177+
screen.queryByRole('button', { name: 'Upload files for this patient' }),
178+
).not.toBeInTheDocument();
179+
},
180+
);
148181
});
149182

150183
describe('Accessibility', () => {

app/src/components/blocks/_lloydGeorge/lloydGeorgeRecordError/LloydGeorgeRecordError.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function LloydGeorgeRecordError({ downloadStage }: Readonly<Props>) {
3030
uploadJourneyEnabled &&
3131
!patient?.deceased;
3232
const renderNoRecords =
33-
downloadStage === DOWNLOAD_STAGE.NO_RECORDS && (!isGpRole || !uploadJourneyEnabled);
33+
downloadStage === DOWNLOAD_STAGE.NO_RECORDS &&
34+
(!isGpRole || !uploadJourneyEnabled || patient?.deceased);
3435
const renderUploadInProgress = downloadStage === DOWNLOAD_STAGE.UPLOADING;
3536

3637
if (renderTimeout) {

0 commit comments

Comments
 (0)