Skip to content

Commit 458d021

Browse files
[PRMP-1251] Add letters and docs config
1 parent 0bd8905 commit 458d021

File tree

15 files changed

+184
-52
lines changed

15 files changed

+184
-52
lines changed

app/src/components/blocks/_documentUpload/documentUploadCompleteStage/DocumentUploadCompleteStage.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ describe('DocumentUploadCompleteStage', () => {
7171

7272
const expectedDob = getFormattedDate(new Date(patientDetails.birthDate));
7373
expect(screen.getByTestId('dob').textContent).toEqual('Date of birth: ' + expectedDob);
74+
75+
expect(
76+
screen.queryByText(
77+
'You are not the data controller',
78+
{
79+
exact: false,
80+
}
81+
),
82+
).not.toBeInTheDocument();
7483
});
7584

7685
it('should navigate to search when clicking the search link', async () => {
@@ -153,6 +162,25 @@ describe('DocumentUploadCompleteStage', () => {
153162
expect(screen.getByText(documents[1].file.name)).toBeInTheDocument();
154163
});
155164

165+
it('should render non-data controller message when user is not data controller', async () => {
166+
vi.mocked(usePatient).mockReturnValueOnce(
167+
buildPatientDetails({
168+
canManageRecord: false,
169+
}),
170+
);
171+
172+
renderApp(documents);
173+
174+
expect(
175+
screen.getByText(
176+
'You are not the data controller',
177+
{
178+
exact: false,
179+
}
180+
),
181+
).toBeInTheDocument();
182+
});
183+
156184
const renderApp = (documents: UploadDocument[]) => {
157185
render(
158186
<MemoryRouter>

app/src/components/blocks/_documentUpload/documentUploadCompleteStage/DocumentUploadCompleteStage.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ const DocumentUploadCompleteStage = ({ documents, documentConfig }: Props): Reac
126126
</p>
127127
)}
128128

129+
{patientDetails.canManageRecord === false && (
130+
<p>
131+
You are not the data controller for this patient so you cannot view the files
132+
you have uploaded in this service.
133+
</p>
134+
)}
135+
129136
<p>
130137
If you think you've made a mistake, contact the Patient Record Management team at{' '}
131138
<a href="mailto:[email protected]">[email protected]</a>.

app/src/components/generic/patientSummary/PatientSummary.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ describe('PatientSummary', () => {
1616
vi.clearAllMocks();
1717
});
1818

19+
it('renders nothing when patient details are null', () => {
20+
mockedUsePatient.mockReturnValue(null);
21+
const { container } = render(<PatientSummary />);
22+
expect(container).toBeEmptyDOMElement();
23+
});
24+
1925
it('renders provided patient information', () => {
2026
const mockDetails = buildPatientDetails({
2127
familyName: 'Jones',

app/src/components/generic/patientSummary/PatientSummary.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,13 @@ const PatientSummary = ({
133133
if (reviewPatientDetails) {
134134
patientDetails = reviewPatientDetails;
135135
}
136+
136137
const patientDetailsContextValue = useMemo(() => ({ patientDetails }), [patientDetails]);
137138

139+
if (!patientDetails) {
140+
return <></>;
141+
}
142+
138143
if (oneLine) {
139144
const nameLengthLimit = 30;
140145
const givenName = patientDetails?.givenName.join(' ') || '';

app/src/config/documentTypesConfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,15 @@
2828
"upload_title": "",
2929
"upload_description": ""
3030
}
31+
},
32+
{
33+
"name": "Letters and Documents",
34+
"snomed_code": "162931000000103",
35+
"config_name": "lettersAndDocumentsConfig",
36+
"canUploadIndependently": true,
37+
"content": {
38+
"upload_title": "Other documents",
39+
"upload_description": "Upload other letters and documents that have arrived for this patient after they have left your practice. For example, letters, test results and referrals."
40+
}
3141
}
3242
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"snomedCode": "162931000000103",
3+
"displayName": "other docs and letters",
4+
"filenameOverride": "",
5+
"canBeUpdated": false,
6+
"associatedSnomed": "",
7+
"multifileUpload": true,
8+
"multifileZipped": false,
9+
"multifileReview": false,
10+
"canBeDiscarded": true,
11+
"stitched": false,
12+
"stitchedFilenamePrefix": "",
13+
"singleDocumentOnly": false,
14+
"acceptedFileTypes": [],
15+
"content": {
16+
"viewDocumentTitle": "Patient letters and documents",
17+
"addFilesSelectTitle": "",
18+
"uploadFilesSelectTitle": "Choose documents to upload",
19+
"uploadFilesBulletPoints": [
20+
"There is no maximum number of size of files you can upload",
21+
"You can upload files in any format except .zip and .exe files",
22+
"If there is a problem with your files during upload, you'll need to resolve these before continuing"
23+
],
24+
"chooseFilesMessage": "Choose files to upload",
25+
"chooseFilesButtonLabel": "Choose files",
26+
"chooseFilesWarningText": "",
27+
"skipDocumentLinkText": "",
28+
"confirmFilesTitle": "Check files are for the correct patient",
29+
"confirmFilesTableTitle": "Files to upload",
30+
"confirmFilesTableParagraph": "",
31+
"beforeYouUploadTitle": "Before you upload",
32+
"previewUploadTitle": "Preview your PDF files",
33+
"uploadFilesExtraParagraph": "",
34+
"reviewList": "Letters and documents"
35+
}
36+
}

app/src/helpers/utils/documentType.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ describe('documentType', () => {
5050
expect(config.multifileUpload).toBe(true);
5151
});
5252

53+
it('should return config for LETTERS_AND_DOCS', () => {
54+
const config = getConfigForDocType(DOCUMENT_TYPE.LETTERS_AND_DOCS);
55+
expect(config.snomedCode).toBe(DOCUMENT_TYPE.LETTERS_AND_DOCS);
56+
expect(config.displayName).toBe('other docs and letters');
57+
expect(config.multifileUpload).toBe(true);
58+
});
59+
5360
it('should throw error for unknown document type', () => {
5461
expect(() => getConfigForDocType('unknown' as DOCUMENT_TYPE)).toThrow(
5562
'No config found for document type: unknown',

app/src/helpers/utils/documentType.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import lloydGeorgeConfig from '../../config/lloydGeorgeConfig.json';
22
import electronicHealthRecordConfig from '../../config/electronicHealthRecordConfig.json';
33
import electronicHealthRecordAttachmentsConfig from '../../config/electronicHealthRecordAttachmentsConfig.json';
4+
import lettersAndDocumentsConfig from '../../config/lettersAndDocumentsConfig.json';
45

56
export enum DOCUMENT_TYPE {
67
LLOYD_GEORGE = '16521000000101',
@@ -83,6 +84,8 @@ export const getConfigForDocType = (docType: DOCUMENT_TYPE): DOCUMENT_TYPE_CONFI
8384
return electronicHealthRecordConfig as DOCUMENT_TYPE_CONFIG;
8485
case DOCUMENT_TYPE.EHR_ATTACHMENTS:
8586
return electronicHealthRecordAttachmentsConfig as DOCUMENT_TYPE_CONFIG;
87+
case DOCUMENT_TYPE.LETTERS_AND_DOCS:
88+
return lettersAndDocumentsConfig as DOCUMENT_TYPE_CONFIG;
8689
default:
8790
throw new Error(`No config found for document type: ${docType}`);
8891
}

app/src/pages/documentSearchResultsPage/DocumentSearchResultsPage.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ const DocumentSearchResultsPage = (): React.JSX.Element => {
8181
fileName: 'EHR Attachments.zip',
8282
contentType: 'application/zip',
8383
}),
84+
buildSearchResult({
85+
documentSnomedCodeType: DOCUMENT_TYPE.LETTERS_AND_DOCS,
86+
fileName: 'Later letter.pdf',
87+
contentType: 'application/pdf',
88+
}),
89+
buildSearchResult({
90+
documentSnomedCodeType: DOCUMENT_TYPE.LETTERS_AND_DOCS,
91+
fileName: 'Later letter 2.docx',
92+
contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
93+
}),
8494
]);
8595
setSubmissionState(SUBMISSION_STATE.SUCCEEDED);
8696
} else {

lambdas/enums/snomed_codes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class SnomedCodes(Enum):
2121
EHR_ATTACHMENTS = SnomedCode(
2222
code="24511000000107", display_name="Electronic Health Record Attachments"
2323
)
24+
LETTERS_AND_DOCUMENTS = SnomedCode(
25+
code="162931000000103", display_name="Care record elements"
26+
)
2427
# Temporary snomed code used.
2528
PATIENT_DATA = SnomedCode(
2629
code="717391000000106", display_name="Confidential patient data"

0 commit comments

Comments
 (0)