diff --git a/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.test.tsx b/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.test.tsx
index a2359f29f..95f069e4e 100644
--- a/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.test.tsx
+++ b/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.test.tsx
@@ -6,9 +6,11 @@ import { LG_RECORD_STAGE } from '../../../types/blocks/lloydGeorgeStages';
import useRole from '../../../helpers/hooks/useRole';
import { REPOSITORY_ROLE } from '../../../types/generic/authRole';
import { routes } from '../../../types/generic/routes';
+import useIsBSOL from '../../../helpers/hooks/useIsBSOL';
const mockSetStage = jest.fn();
const mockNavigate = jest.fn();
+jest.mock('../../../helpers/hooks/useIsBSOL');
jest.mock('react-router-dom', () => ({
__esModule: true,
@@ -22,6 +24,7 @@ jest.mock('react-router', () => ({
jest.mock('../../../helpers/hooks/useRole');
const mockUseRole = useRole as jest.Mock;
+const mockedIsBSOL = useIsBSOL as jest.Mock;
describe('LloydGeorgeRecordError', () => {
beforeEach(() => {
@@ -37,34 +40,53 @@ describe('LloydGeorgeRecordError', () => {
it("renders an error when the document download status is 'Timeout'", () => {
const timeoutStatus = DOWNLOAD_STAGE.TIMEOUT;
render(
- ,
+
);
expect(
- screen.getByText(/The Lloyd George document is too large to view in a browser/i),
+ screen.getByText(/The Lloyd George document is too large to view in a browser/i)
).toBeInTheDocument();
expect(screen.getByText(/please download instead/i)).toBeInTheDocument();
});
it("renders an error when the document download status is 'Failed'", () => {
const timeoutStatus = DOWNLOAD_STAGE.FAILED;
render(
- ,
+
);
expect(
- screen.getByText(/Sorry, the service is currently unavailable/i),
+ screen.getByText(/Sorry, the service is currently unavailable/i)
).toBeInTheDocument();
expect(
- screen.getByText(/An error has occurred when creating the Lloyd George preview/i),
+ screen.getByText(/An error has occurred when creating the Lloyd George preview/i)
).toBeInTheDocument();
});
- it("renders a message when the document download status is 'No records'", () => {
+ it("renders a message when the document download status is 'No records' and user is non BSOL", () => {
const timeoutStatus = DOWNLOAD_STAGE.NO_RECORDS;
+ mockedIsBSOL.mockReturnValue(false);
+
render(
- ,
+
);
expect(screen.getByText(/No documents are available/i)).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Upload patient record' })
+ ).not.toBeInTheDocument();
+ });
+ it("renders a message and upload button when the document download status is 'No records' and user is admin BSOL", () => {
+ const timeoutStatus = DOWNLOAD_STAGE.NO_RECORDS;
+ mockedIsBSOL.mockReturnValue(true);
+ mockUseRole.mockReturnValue(REPOSITORY_ROLE.GP_ADMIN);
+
+ render(
+
+ );
+
+ expect(screen.getByText('No records available for this patient')).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'Upload patient record' })
+ ).toBeInTheDocument();
});
});
@@ -72,24 +94,24 @@ describe('LloydGeorgeRecordError', () => {
it("renders a link that can navigate to the download all stage, when download status is 'Timeout'", () => {
const timeoutStatus = DOWNLOAD_STAGE.TIMEOUT;
render(
- ,
+
);
expect(
- screen.getByText(/The Lloyd George document is too large to view in a browser/i),
+ screen.getByText(/The Lloyd George document is too large to view in a browser/i)
).toBeInTheDocument();
expect(screen.getByText(/please download instead/i)).toBeInTheDocument();
expect(
screen.getByRole('link', {
name: 'please download instead',
- }),
+ })
).toBeInTheDocument();
});
it("navigates to the download all stage, when download status is 'Timeout' and the link is clicked: GP_ADMIN", () => {
const timeoutStatus = DOWNLOAD_STAGE.TIMEOUT;
render(
- ,
+
);
const downloadLink = screen.getByRole('link', {
@@ -97,7 +119,7 @@ describe('LloydGeorgeRecordError', () => {
});
expect(
- screen.getByText(/The Lloyd George document is too large to view in a browser/i),
+ screen.getByText(/The Lloyd George document is too large to view in a browser/i)
).toBeInTheDocument();
expect(screen.getByText(/please download instead/i)).toBeInTheDocument();
expect(downloadLink).toBeInTheDocument();
@@ -113,7 +135,7 @@ describe('LloydGeorgeRecordError', () => {
mockUseRole.mockReturnValue(REPOSITORY_ROLE.GP_CLINICAL);
const timeoutStatus = DOWNLOAD_STAGE.TIMEOUT;
render(
- ,
+
);
const downloadLink = screen.getByRole('link', {
@@ -121,7 +143,7 @@ describe('LloydGeorgeRecordError', () => {
});
expect(
- screen.getByText(/The Lloyd George document is too large to view in a browser/i),
+ screen.getByText(/The Lloyd George document is too large to view in a browser/i)
).toBeInTheDocument();
expect(screen.getByText(/please download instead/i)).toBeInTheDocument();
expect(downloadLink).toBeInTheDocument();
diff --git a/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.tsx b/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.tsx
index 516d637bd..a660519a5 100644
--- a/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.tsx
+++ b/app/src/components/blocks/lloydGeorgeRecordError/LloydGeorgeRecordError.tsx
@@ -6,6 +6,8 @@ import { LG_RECORD_STAGE } from '../../../types/blocks/lloydGeorgeStages';
import useRole from '../../../helpers/hooks/useRole';
import { REPOSITORY_ROLE } from '../../../types/generic/authRole';
import { routes } from '../../../types/generic/routes';
+import useIsBSOL from '../../../helpers/hooks/useIsBSOL';
+import { ButtonLink } from 'nhsuk-react-components';
type Props = {
downloadStage: DOWNLOAD_STAGE;
@@ -15,6 +17,7 @@ type Props = {
function LloydGeorgeRecordError({ downloadStage, setStage }: Props) {
const role = useRole();
const navigate = useNavigate();
+ const isBSOL = useIsBSOL();
if (downloadStage === DOWNLOAD_STAGE.TIMEOUT) {
return (
@@ -37,6 +40,25 @@ function LloydGeorgeRecordError({ downloadStage, setStage }: Props) {
);
+ } else if (
+ downloadStage === DOWNLOAD_STAGE.NO_RECORDS &&
+ role === REPOSITORY_ROLE.GP_ADMIN &&
+ isBSOL
+ ) {
+ return (
+
+ No records available for this patient
+
+ You can upload full or part of a patient record. You can upload supporting files
+ once the record is uploaded.
+
+
+
+ Upload patient record
+
+
+
+ );
} else if (downloadStage === DOWNLOAD_STAGE.NO_RECORDS) {
return No documents are available.;
} else {
diff --git a/app/src/components/blocks/lloydGeorgeRecordStage/LloydGeorgeRecordStage.tsx b/app/src/components/blocks/lloydGeorgeRecordStage/LloydGeorgeRecordStage.tsx
index 66206d1fd..05ffd5bb2 100644
--- a/app/src/components/blocks/lloydGeorgeRecordStage/LloydGeorgeRecordStage.tsx
+++ b/app/src/components/blocks/lloydGeorgeRecordStage/LloydGeorgeRecordStage.tsx
@@ -25,6 +25,7 @@ import WarningText from '../../generic/warningText/WarningText';
import ErrorBox from '../../layout/errorBox/ErrorBox';
import { useForm } from 'react-hook-form';
import { InputRef } from '../../../types/generic/inputRef';
+import BackButton from '../../generic/backButton/BackButton';
export type Props = {
downloadStage: DOWNLOAD_STAGE;
@@ -98,6 +99,7 @@ function LloydGeorgeRecordStage({
return (
+
{formState.errors.confirmDownloadRemove && (