Skip to content

Commit 8ecc5a5

Browse files
[PRMP-861] [WIP] Add configs for doc types (#906)
1 parent a949945 commit 8ecc5a5

File tree

6 files changed

+237
-0
lines changed

6 files changed

+237
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[
2+
{
3+
"name": "Scanned Paper Notes",
4+
"snomed_code": "16521000000101",
5+
"config_name": "scannedPaperNotesConfig",
6+
"content": [
7+
{
8+
"upload_title": "Scanned Lloyd George notes",
9+
"upload_description": "Upload and add files to a scanned paper Lloyd George record."
10+
}
11+
]
12+
},
13+
{
14+
"name": "Electronic Health Record",
15+
"snomed_code": "16521000000102",
16+
"config_name": "electronicHealthRecordConfig",
17+
"content": [
18+
{
19+
"upload_title": "Electronic health record (EHR) summary",
20+
"upload_description": "Upload the summary file of an electronic health record. You might also call these a 'journal' or 'practice notes'. Upload this suymmary if, for example, GP2GP fails."
21+
}
22+
]
23+
},
24+
{
25+
"name": "Electronic Health Record Attachments",
26+
"snomed_code": "16521000000103",
27+
"config_name": "electronicHealthRecordAttachmentsConfig",
28+
"content": [
29+
{
30+
"upload_title": "Attachments to an electronic health record",
31+
"upload_description": "Upload other files that are part of the patient's EHR on your clinical system. For example, letters, laboratory reports and imaging. Upload these files if, for example GP2GP fails."
32+
}
33+
]
34+
}
35+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"snomedCode": "16521000000103",
3+
"displayName": "Electronic Health Record Attachments",
4+
"canBeUpdated": false,
5+
"associatedSnomed": "",
6+
"multifileUpload": false,
7+
"multifileZipped": true,
8+
"multifileReview": false,
9+
"canBeDiscarded": true,
10+
"stitched": false,
11+
"acceptedFileTypes": [],
12+
"content": []
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"snomedCode": "16521000000102",
3+
"displayName": "Electronic Health Record",
4+
"canBeUpdated": false,
5+
"associatedSnomed": "16521000000103",
6+
"multifileUpload": false,
7+
"multifileZipped": false,
8+
"multifileReview": false,
9+
"canBeDiscarded": true,
10+
"stitched": false,
11+
"acceptedFileTypes": [],
12+
"content": []
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"snomedCode": "16521000000101",
3+
"displayName": "Scanned Paper Notes",
4+
"canBeUpdated": true,
5+
"associatedSnomed": "",
6+
"multifileUpload": true,
7+
"multifileZipped": false,
8+
"multifileReview": true,
9+
"canBeDiscarded": true,
10+
"stitched": true,
11+
"acceptedFileTypes": [
12+
".pdf"
13+
],
14+
"content": []
15+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { describe, it, expect, vi } from 'vitest';
2+
import { DOCUMENT_TYPE, getDocumentTypeLabel, getConfigForDocType } from './documentType';
3+
4+
// Mock the JSON config files
5+
vi.mock('../../config/lloydGeorgeConfig.json', () => ({
6+
default: {
7+
snomedCode: '16521000000101',
8+
displayName: 'Scanned paper notes',
9+
canBeUpdated: true,
10+
associatedSnomed: 'test-snomed',
11+
multifileUpload: true,
12+
multifileZipped: false,
13+
multifileReview: true,
14+
canBeDiscarded: false,
15+
stitched: true,
16+
acceptedFileTypes: ['pdf'],
17+
content: [{ key: 'test', value: 'test' }]
18+
}
19+
}));
20+
21+
vi.mock('../../config/electronicHealthRecordConfig.json', () => ({
22+
default: {
23+
snomedCode: '16521000000102',
24+
displayName: 'Electronic health record',
25+
canBeUpdated: false,
26+
associatedSnomed: 'ehr-snomed',
27+
multifileUpload: false,
28+
multifileZipped: true,
29+
multifileReview: false,
30+
canBeDiscarded: true,
31+
stitched: false,
32+
acceptedFileTypes: ['xml', 'json'],
33+
content: [{ key: 'ehr', value: 'data' }]
34+
}
35+
}));
36+
37+
vi.mock('../../config/electronicHealthRecordAttachmentsConfig.json', () => ({
38+
default: {
39+
snomedCode: '16521000000103',
40+
displayName: 'Electronic health record attachments',
41+
canBeUpdated: true,
42+
associatedSnomed: 'attachment-snomed',
43+
multifileUpload: true,
44+
multifileZipped: true,
45+
multifileReview: true,
46+
canBeDiscarded: true,
47+
stitched: false,
48+
acceptedFileTypes: ['pdf', 'jpg', 'png'],
49+
content: [{ key: 'attachment', value: 'file' }]
50+
}
51+
}));
52+
53+
describe('documentType', () => {
54+
describe('getDocumentTypeLabel', () => {
55+
it('should return correct label for LLOYD_GEORGE', () => {
56+
expect(getDocumentTypeLabel(DOCUMENT_TYPE.LLOYD_GEORGE)).toBe('Scanned paper notes');
57+
});
58+
59+
it('should return correct label for EHR', () => {
60+
expect(getDocumentTypeLabel(DOCUMENT_TYPE.EHR)).toBe('Electronic health record');
61+
});
62+
63+
it('should return correct label for EHR_ATTACHMENTS', () => {
64+
expect(getDocumentTypeLabel(DOCUMENT_TYPE.EHR_ATTACHMENTS)).toBe('Electronic health record attachments');
65+
});
66+
67+
it('should return correct label for LETTERS_AND_DOCS', () => {
68+
expect(getDocumentTypeLabel(DOCUMENT_TYPE.LETTERS_AND_DOCS)).toBe('Patient letters and documents');
69+
});
70+
71+
it('should return empty string for unknown document type', () => {
72+
expect(getDocumentTypeLabel('unknown' as DOCUMENT_TYPE)).toBe('');
73+
});
74+
});
75+
76+
describe('getConfigForDocType', () => {
77+
it('should return config for LLOYD_GEORGE', () => {
78+
const config = getConfigForDocType(DOCUMENT_TYPE.LLOYD_GEORGE);
79+
expect(config.snomedCode).toBe('16521000000101');
80+
expect(config.displayName).toBe('Scanned paper notes');
81+
expect(config.canBeUpdated).toBe(true);
82+
});
83+
84+
it('should return config for EHR', () => {
85+
const config = getConfigForDocType(DOCUMENT_TYPE.EHR);
86+
expect(config.snomedCode).toBe('16521000000102');
87+
expect(config.displayName).toBe('Electronic health record');
88+
expect(config.canBeUpdated).toBe(false);
89+
});
90+
91+
it('should return config for EHR_ATTACHMENTS', () => {
92+
const config = getConfigForDocType(DOCUMENT_TYPE.EHR_ATTACHMENTS);
93+
expect(config.snomedCode).toBe('16521000000103');
94+
expect(config.displayName).toBe('Electronic health record attachments');
95+
expect(config.multifileUpload).toBe(true);
96+
});
97+
98+
it('should throw error for unsupported document type', () => {
99+
expect(() => getConfigForDocType(DOCUMENT_TYPE.LETTERS_AND_DOCS))
100+
.toThrow('No config found for document type: 16521000000104');
101+
});
102+
103+
it('should throw error for unknown document type', () => {
104+
expect(() => getConfigForDocType('unknown' as DOCUMENT_TYPE))
105+
.toThrow('No config found for document type: unknown');
106+
});
107+
});
108+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import lloydGeorgeConfig from '../../config/lloydGeorgeConfig.json';
2+
import electronicHealthRecordConfig from '../../config/electronicHealthRecordConfig.json';
3+
import electronicHealthRecordAttachmentsConfig from '../../config/electronicHealthRecordAttachmentsConfig.json';
4+
5+
export enum DOCUMENT_TYPE {
6+
LLOYD_GEORGE = '16521000000101',
7+
EHR = '16521000000102', // TBC
8+
EHR_ATTACHMENTS = '16521000000103', // TBC
9+
LETTERS_AND_DOCS = '16521000000104', // TBC
10+
ALL = '16521000000101,16521000000102,16521000000103,16521000000104', // TBC
11+
}
12+
13+
export type DOCUMENT_TYPE_CONFIG = {
14+
snomedCode: string;
15+
displayName: string;
16+
canBeUpdated: boolean;
17+
associatedSnomed: string;
18+
multifileUpload: boolean;
19+
multifileZipped: boolean;
20+
multifileReview: boolean;
21+
canBeDiscarded: boolean;
22+
stitched: boolean;
23+
acceptedFileTypes: string[];
24+
content: { key: string, value: string }[];
25+
}
26+
27+
export const getDocumentTypeLabel = (docType: DOCUMENT_TYPE): string => {
28+
switch (docType) {
29+
case DOCUMENT_TYPE.LLOYD_GEORGE:
30+
return 'Scanned paper notes';
31+
case DOCUMENT_TYPE.EHR:
32+
return 'Electronic health record';
33+
case DOCUMENT_TYPE.EHR_ATTACHMENTS:
34+
return 'Electronic health record attachments';
35+
case DOCUMENT_TYPE.LETTERS_AND_DOCS:
36+
return 'Patient letters and documents';
37+
default:
38+
return '';
39+
}
40+
};
41+
42+
export const getConfigForDocType = (docType: DOCUMENT_TYPE): DOCUMENT_TYPE_CONFIG => {
43+
switch (docType) {
44+
case DOCUMENT_TYPE.LLOYD_GEORGE:
45+
return lloydGeorgeConfig as DOCUMENT_TYPE_CONFIG;
46+
case DOCUMENT_TYPE.EHR:
47+
return electronicHealthRecordConfig as DOCUMENT_TYPE_CONFIG;
48+
case DOCUMENT_TYPE.EHR_ATTACHMENTS:
49+
return electronicHealthRecordAttachmentsConfig as DOCUMENT_TYPE_CONFIG;
50+
default:
51+
throw new Error(`No config found for document type: ${docType}`);
52+
}
53+
};

0 commit comments

Comments
 (0)