@openmrs/esm-patient-immunizations-app 5.0.1-pre.2016 → 5.0.1-pre.2021
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-patient-immunizations-app.js +1 -1
- package/dist/openmrs-esm-patient-immunizations-app.js.buildmanifest.json +2 -2
- package/dist/routes.json +1 -1
- package/jest.config.js +3 -0
- package/package.json +6 -3
- package/src/__mocks__/immunizations.mock.ts +432 -0
- package/src/immunizations/immunizations-overview.test.tsx +7 -6
- package/tsconfig.json +1 -1
- package/src/immunizations/immunization-mapper.test.outdated.ts +0 -310
- package/src/immunizations/immunizations-detailed-summary.test.outdated.tsx +0 -65
- package/src/immunizations/immunizations-form.test.outdated.tsx +0 -347
- package/src/immunizations/immunizations.resource.test.outdated.tsx +0 -86
- package/src/immunizations/vaccination-row.test.outdated.tsx +0 -101
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { mapFromFHIRImmunizationBundle, mapToFHIRImmunizationResource } from './immunization-mapper';
|
|
2
|
-
import { FHIRImmunizationBundle, FHIRImmunizationResource, ImmunizationFormData } from './immunization-domain';
|
|
3
|
-
import { parseDate } from '@openmrs/esm-framework';
|
|
4
|
-
|
|
5
|
-
let rotavirusDose1: FHIRImmunizationResource = {
|
|
6
|
-
resourceType: 'Immunization',
|
|
7
|
-
id: 'b9c21a82-aed3-11ea-b3de-0242ac130001',
|
|
8
|
-
status: 'completed',
|
|
9
|
-
vaccineCode: {
|
|
10
|
-
coding: [
|
|
11
|
-
{
|
|
12
|
-
code: 'RotavirusUuid',
|
|
13
|
-
display: 'Rotavirus',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
patient: {
|
|
18
|
-
type: 'Patient',
|
|
19
|
-
reference: 'Patient/D1A903924D4443A7A388778D77D86155',
|
|
20
|
-
},
|
|
21
|
-
encounter: {
|
|
22
|
-
type: 'Encounter',
|
|
23
|
-
reference: 'Encounter/Example',
|
|
24
|
-
},
|
|
25
|
-
location: {
|
|
26
|
-
type: 'Location',
|
|
27
|
-
reference: 'Location/1',
|
|
28
|
-
},
|
|
29
|
-
performer: [{ actor: { type: 'Practitioner', reference: 'Practitioner/12334' } }],
|
|
30
|
-
manufacturer: {
|
|
31
|
-
display: 'Organization/hl7',
|
|
32
|
-
},
|
|
33
|
-
lotNumber: '123445',
|
|
34
|
-
occurrenceDateTime: parseDate('2018-09-21'),
|
|
35
|
-
expirationDate: parseDate('2025-12-15'),
|
|
36
|
-
protocolApplied: [
|
|
37
|
-
{
|
|
38
|
-
series: '4 Months',
|
|
39
|
-
doseNumberPositiveInt: 2,
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
let rotavirusDose2: FHIRImmunizationResource = {
|
|
44
|
-
resourceType: 'Immunization',
|
|
45
|
-
id: 'b9c21a82-aed3-11ea-b3de-0242ac130001',
|
|
46
|
-
status: 'completed',
|
|
47
|
-
vaccineCode: {
|
|
48
|
-
coding: [
|
|
49
|
-
{
|
|
50
|
-
code: 'RotavirusUuid',
|
|
51
|
-
display: 'Rotavirus',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
patient: {
|
|
56
|
-
type: 'Patient',
|
|
57
|
-
reference: 'Patient/D1A903924D4443A7A388778D77D86155',
|
|
58
|
-
},
|
|
59
|
-
encounter: {
|
|
60
|
-
type: 'Encounter',
|
|
61
|
-
reference: 'Encounter/Example',
|
|
62
|
-
},
|
|
63
|
-
location: {
|
|
64
|
-
type: 'Location',
|
|
65
|
-
reference: 'Location/1',
|
|
66
|
-
},
|
|
67
|
-
performer: [{ actor: { type: 'Practitioner', reference: 'Practitioner/12334' } }],
|
|
68
|
-
manufacturer: {
|
|
69
|
-
display: 'Organization/hl7',
|
|
70
|
-
},
|
|
71
|
-
lotNumber: '123454',
|
|
72
|
-
occurrenceDateTime: parseDate('2018-06-18'),
|
|
73
|
-
expirationDate: parseDate('2025-12-15'),
|
|
74
|
-
protocolApplied: [
|
|
75
|
-
{
|
|
76
|
-
series: '2 Months',
|
|
77
|
-
doseNumberPositiveInt: 1,
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
};
|
|
81
|
-
const immunizationsSearchResponseWithSingleEntry: FHIRImmunizationBundle = {
|
|
82
|
-
resourceType: 'Bundle',
|
|
83
|
-
entry: [
|
|
84
|
-
{
|
|
85
|
-
fullUrl: '',
|
|
86
|
-
resource: rotavirusDose2,
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
const immunizationsSearchResponseWithMultipleDoses: FHIRImmunizationBundle = {
|
|
91
|
-
resourceType: 'Bundle',
|
|
92
|
-
entry: [
|
|
93
|
-
{
|
|
94
|
-
fullUrl: '',
|
|
95
|
-
resource: rotavirusDose1,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
fullUrl: '',
|
|
99
|
-
resource: rotavirusDose2,
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
const immunizationsSearchResponseWithMultipleImmunizations: FHIRImmunizationBundle = {
|
|
104
|
-
resourceType: 'Bundle',
|
|
105
|
-
entry: [
|
|
106
|
-
{
|
|
107
|
-
fullUrl: '',
|
|
108
|
-
resource: rotavirusDose1,
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
fullUrl: '',
|
|
112
|
-
resource: rotavirusDose2,
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
fullUrl: '',
|
|
116
|
-
resource: {
|
|
117
|
-
resourceType: 'Immunization',
|
|
118
|
-
id: 'b9c21d5c-aed3-11ea-b3de-0242ac130002',
|
|
119
|
-
status: 'completed',
|
|
120
|
-
vaccineCode: {
|
|
121
|
-
coding: [
|
|
122
|
-
{
|
|
123
|
-
code: 'uuid2',
|
|
124
|
-
display: 'Polio',
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
patient: {
|
|
129
|
-
type: 'Patient',
|
|
130
|
-
reference: 'Patient/D1A903924D4443A7A388778D77D86155',
|
|
131
|
-
},
|
|
132
|
-
encounter: {
|
|
133
|
-
type: 'Encounter',
|
|
134
|
-
reference: 'Encounter/Example',
|
|
135
|
-
},
|
|
136
|
-
location: {
|
|
137
|
-
type: 'Location',
|
|
138
|
-
reference: 'Location/1',
|
|
139
|
-
},
|
|
140
|
-
performer: [{ actor: { type: 'Practitioner', reference: 'Practitioner/12334' } }],
|
|
141
|
-
manufacturer: {
|
|
142
|
-
display: 'Organization/hl7',
|
|
143
|
-
},
|
|
144
|
-
lotNumber: '123456',
|
|
145
|
-
occurrenceDateTime: parseDate('2018-05-21'),
|
|
146
|
-
expirationDate: parseDate('2025-12-15'),
|
|
147
|
-
protocolApplied: [
|
|
148
|
-
{
|
|
149
|
-
series: '2 Months',
|
|
150
|
-
doseNumberPositiveInt: 1,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
fullUrl: '',
|
|
157
|
-
resource: {
|
|
158
|
-
resourceType: 'Immunization',
|
|
159
|
-
id: 'b9c21d5c-aed3-11ea-b3de-0242ac130002',
|
|
160
|
-
status: 'completed',
|
|
161
|
-
vaccineCode: {
|
|
162
|
-
coding: [
|
|
163
|
-
{
|
|
164
|
-
code: 'uuid2',
|
|
165
|
-
display: 'Polio',
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
},
|
|
169
|
-
patient: {
|
|
170
|
-
type: 'Patient',
|
|
171
|
-
reference: 'Patient/D1A903924D4443A7A388778D77D86155',
|
|
172
|
-
},
|
|
173
|
-
encounter: {
|
|
174
|
-
type: 'Encounter',
|
|
175
|
-
reference: 'Encounter/Example',
|
|
176
|
-
},
|
|
177
|
-
location: {
|
|
178
|
-
type: 'Location',
|
|
179
|
-
reference: 'Location/1',
|
|
180
|
-
},
|
|
181
|
-
performer: [{ actor: { type: 'Practitioner', reference: 'Practitioner/12334' } }],
|
|
182
|
-
manufacturer: {
|
|
183
|
-
display: 'Organization/hl7',
|
|
184
|
-
},
|
|
185
|
-
lotNumber: '12345',
|
|
186
|
-
occurrenceDateTime: parseDate('2018-11-01'),
|
|
187
|
-
expirationDate: parseDate('2025-12-15'),
|
|
188
|
-
protocolApplied: [
|
|
189
|
-
{
|
|
190
|
-
series: '4 Months',
|
|
191
|
-
doseNumberPositiveInt: 2,
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
describe('ImmunizationMapper#mapFromFHIRImmunizationBundle', () => {
|
|
200
|
-
it('should map the Immunization FHIR Bundle', function () {
|
|
201
|
-
const immunizations = mapFromFHIRImmunizationBundle(immunizationsSearchResponseWithSingleEntry);
|
|
202
|
-
|
|
203
|
-
expect(immunizations.length).toBe(1);
|
|
204
|
-
expect(immunizations[0].vaccineName).toBe('Rotavirus');
|
|
205
|
-
expect(immunizations[0].existingDoses.length).toBe(1);
|
|
206
|
-
let expectedDose = {
|
|
207
|
-
sequenceNumber: 1,
|
|
208
|
-
sequenceLabel: '2 Months',
|
|
209
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130001',
|
|
210
|
-
expirationDate: '2025-12-15',
|
|
211
|
-
lotNumber: '123454',
|
|
212
|
-
manufacturer: 'Organization/hl7',
|
|
213
|
-
occurrenceDateTime: '2018-06-18',
|
|
214
|
-
};
|
|
215
|
-
expect(immunizations[0].existingDoses[0]).toEqual(expectedDose);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('should map multiple entries for same immunization as different doses', function () {
|
|
219
|
-
const immunizations = mapFromFHIRImmunizationBundle(immunizationsSearchResponseWithMultipleDoses);
|
|
220
|
-
|
|
221
|
-
expect(immunizations.length).toBe(1);
|
|
222
|
-
expect(immunizations[0].vaccineName).toBe('Rotavirus');
|
|
223
|
-
expect(immunizations[0].existingDoses.length).toBe(2);
|
|
224
|
-
let expectedDose1 = {
|
|
225
|
-
sequenceNumber: 2,
|
|
226
|
-
sequenceLabel: '4 Months',
|
|
227
|
-
expirationDate: '2025-12-15',
|
|
228
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130001',
|
|
229
|
-
lotNumber: '123445',
|
|
230
|
-
manufacturer: 'Organization/hl7',
|
|
231
|
-
occurrenceDateTime: '2018-09-21',
|
|
232
|
-
};
|
|
233
|
-
let expectedDose2 = {
|
|
234
|
-
sequenceNumber: 1,
|
|
235
|
-
sequenceLabel: '2 Months',
|
|
236
|
-
expirationDate: '2025-12-15',
|
|
237
|
-
lotNumber: '123454',
|
|
238
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130001',
|
|
239
|
-
manufacturer: 'Organization/hl7',
|
|
240
|
-
occurrenceDateTime: '2018-06-18',
|
|
241
|
-
};
|
|
242
|
-
expect(immunizations[0].existingDoses[1]).toEqual(expectedDose2);
|
|
243
|
-
expect(immunizations[0].existingDoses[0]).toEqual(expectedDose1);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('should map multiple entries for different immunization as different immunization', function () {
|
|
247
|
-
const immunizations = mapFromFHIRImmunizationBundle(immunizationsSearchResponseWithMultipleImmunizations);
|
|
248
|
-
|
|
249
|
-
expect(immunizations.length).toBe(2);
|
|
250
|
-
expect(immunizations[0].vaccineName).toBe('Rotavirus');
|
|
251
|
-
expect(immunizations[0].existingDoses.length).toBe(2);
|
|
252
|
-
|
|
253
|
-
expect(immunizations[1].vaccineName).toBe('Polio');
|
|
254
|
-
expect(immunizations[1].existingDoses.length).toBe(2);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
describe('ImmunizationMapper#mapToFHIRImmunizationResource', () => {
|
|
259
|
-
it('should map the form data to FHIR Resouce', function () {
|
|
260
|
-
const immunizationFormData: ImmunizationFormData = {
|
|
261
|
-
patientUuid: 'paitentUuid',
|
|
262
|
-
immunizationObsUuid: 'obsUuid',
|
|
263
|
-
vaccineName: 'Rotavirus',
|
|
264
|
-
vaccineUuid: 'rotavirusUuid',
|
|
265
|
-
manufacturer: 'HL7',
|
|
266
|
-
expirationDate: '2025-12-15',
|
|
267
|
-
vaccinationDate: '2020-12-15',
|
|
268
|
-
lotNumber: '12345',
|
|
269
|
-
currentDose: { sequenceLabel: '2 Months', sequenceNumber: 2 },
|
|
270
|
-
};
|
|
271
|
-
const fhirImmunization = mapToFHIRImmunizationResource(
|
|
272
|
-
immunizationFormData,
|
|
273
|
-
'visitUUid',
|
|
274
|
-
'locationUuid',
|
|
275
|
-
'providerUuid',
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
const expectedFHIRResource = {
|
|
279
|
-
resourceType: 'Immunization',
|
|
280
|
-
status: 'completed',
|
|
281
|
-
id: 'obsUuid',
|
|
282
|
-
vaccineCode: {
|
|
283
|
-
coding: [
|
|
284
|
-
{
|
|
285
|
-
code: 'rotavirusUuid',
|
|
286
|
-
display: 'Rotavirus',
|
|
287
|
-
},
|
|
288
|
-
],
|
|
289
|
-
},
|
|
290
|
-
patient: { type: 'Patient', reference: 'Patient/paitentUuid' },
|
|
291
|
-
encounter: { type: 'Encounter', reference: 'Encounter/visitUUid' },
|
|
292
|
-
expirationDate: parseDate('2025-12-15'),
|
|
293
|
-
occurrenceDateTime: parseDate('2020-12-15'),
|
|
294
|
-
location: { type: 'Location', reference: 'Location/locationUuid' },
|
|
295
|
-
performer: [
|
|
296
|
-
{
|
|
297
|
-
actor: {
|
|
298
|
-
type: 'Practitioner',
|
|
299
|
-
reference: 'Practitioner/providerUuid',
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
],
|
|
303
|
-
manufacturer: { display: 'HL7' },
|
|
304
|
-
lotNumber: '12345',
|
|
305
|
-
protocolApplied: [{ doseNumberPositiveInt: 2, series: '2 Months' }],
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
expect(fhirImmunization).toEqual(expectedFHIRResource);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import includes from 'lodash-es/includes';
|
|
3
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
4
|
-
import { render, waitFor, within } from '@testing-library/react';
|
|
5
|
-
import { openmrsFetch, getConfig } from '@openmrs/esm-framework';
|
|
6
|
-
import {
|
|
7
|
-
mockImmunizationConfig,
|
|
8
|
-
mockPatientImmunizationsSearchResponse,
|
|
9
|
-
mockVaccinesConceptSet,
|
|
10
|
-
} from '../../../../__mocks__/immunizations.mock';
|
|
11
|
-
import ImmunizationsDetailedSummary from './immunizations-detailed-summary.component';
|
|
12
|
-
|
|
13
|
-
const mockOpenmrsFetch = openmrsFetch as jest.Mock;
|
|
14
|
-
const mockGetConfig = getConfig as jest.Mock;
|
|
15
|
-
|
|
16
|
-
mockOpenmrsFetch.mockImplementation(jest.fn());
|
|
17
|
-
mockGetConfig.mockImplementation(jest.fn());
|
|
18
|
-
|
|
19
|
-
describe('<ImmunizationsDetailedSummary />', () => {
|
|
20
|
-
afterEach(mockGetConfig.mockReset);
|
|
21
|
-
|
|
22
|
-
it('should render detailed summary from config and search results', async () => {
|
|
23
|
-
mockOpenmrsFetch.mockImplementation((url) => {
|
|
24
|
-
return includes(url, 'concept')
|
|
25
|
-
? Promise.resolve({ data: mockVaccinesConceptSet })
|
|
26
|
-
: Promise.resolve({ data: mockPatientImmunizationsSearchResponse });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const { container } = render(
|
|
30
|
-
<BrowserRouter>
|
|
31
|
-
<ImmunizationsDetailedSummary immunizationsConfig={mockImmunizationConfig.immunizationsConfig} />
|
|
32
|
-
</BrowserRouter>,
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
await waitFor(() => {
|
|
36
|
-
const immunizationTable = container.querySelector('.immunizationTable');
|
|
37
|
-
expect(immunizationTable).toBeDefined();
|
|
38
|
-
const rows = immunizationTable.querySelectorAll('tr');
|
|
39
|
-
|
|
40
|
-
expect(rows.length).toBe(5);
|
|
41
|
-
|
|
42
|
-
expect(within(rows[0]).getByText('Vaccine')).toBeTruthy();
|
|
43
|
-
expect(within(rows[0]).getByText('Recent Vaccination')).toBeTruthy();
|
|
44
|
-
|
|
45
|
-
expect(within(rows[1]).getByText('Rotavirus')).toBeTruthy();
|
|
46
|
-
expect(within(rows[2]).getByText('Polio')).toBeTruthy();
|
|
47
|
-
expect(within(rows[3]).getByText('Influenza')).toBeTruthy();
|
|
48
|
-
expect(within(rows[4]).getByText('Adinovirus')).toBeTruthy();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should give link when immunization are not configured', async () => {
|
|
53
|
-
mockOpenmrsFetch.mockResolvedValueOnce({ data: {} }).mockResolvedValueOnce({ data: {} });
|
|
54
|
-
|
|
55
|
-
const { getByText } = render(
|
|
56
|
-
<BrowserRouter>
|
|
57
|
-
<ImmunizationsDetailedSummary immunizationsConfig={mockImmunizationConfig.immunizationsConfig} />
|
|
58
|
-
</BrowserRouter>,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
await waitFor(() => {
|
|
62
|
-
expect(getByText('No immunizations are configured.')).toBeTruthy();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|