@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,347 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ImmunizationsForm from './immunizations-form.component';
|
|
3
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
4
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
|
-
import { of } from 'rxjs/internal/observable/of';
|
|
6
|
-
import { openmrsObservableFetch, getStartedVisit, VisitItem, parseDate } from '@openmrs/esm-framework';
|
|
7
|
-
import { savePatientImmunization } from './immunizations.resource';
|
|
8
|
-
import { mockSessionDataResponse } from '../../../../__mocks__/session.mock';
|
|
9
|
-
import { mockPatient } from '../../../../__mocks__/patient.mock';
|
|
10
|
-
|
|
11
|
-
const mockPatientId = mockPatient.id;
|
|
12
|
-
const mockSavePatientImmunization = savePatientImmunization as jest.Mock;
|
|
13
|
-
const mockOpenmrsObservableFetch = openmrsObservableFetch as jest.Mock;
|
|
14
|
-
let testMatch: any = { params: {} };
|
|
15
|
-
|
|
16
|
-
const renderImmunizationsForm = () => {
|
|
17
|
-
render(
|
|
18
|
-
<BrowserRouter>
|
|
19
|
-
<ImmunizationsForm match={testMatch} />
|
|
20
|
-
</BrowserRouter>,
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
mockOpenmrsObservableFetch.mockImplementation(jest.fn());
|
|
25
|
-
|
|
26
|
-
jest.mock('./immunizations.resource', () => ({
|
|
27
|
-
savePatientImmunization: jest.fn(),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
describe('<ImmunizationsForm />', () => {
|
|
31
|
-
getStartedVisit.getValue = function () {
|
|
32
|
-
const mockVisitItem: VisitItem = {
|
|
33
|
-
visitData: { uuid: 'visitUuid' } as any,
|
|
34
|
-
} as any;
|
|
35
|
-
return mockVisitItem;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
mockOpenmrsObservableFetch.mockImplementation(() => of(mockSessionDataResponse));
|
|
39
|
-
|
|
40
|
-
afterEach(mockSavePatientImmunization.mockReset);
|
|
41
|
-
|
|
42
|
-
it('renders immunization form without dying', async () => {
|
|
43
|
-
testMatch.params = {
|
|
44
|
-
vaccineName: 'Rotavirus',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
renderImmunizationsForm();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('displays the appropriate fields when adding a new immunization without sequence', async () => {
|
|
51
|
-
testMatch.params = {
|
|
52
|
-
vaccineName: 'Rotavirus',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
renderImmunizationsForm();
|
|
56
|
-
|
|
57
|
-
await screen.findByText('Add Vaccine: Rotavirus');
|
|
58
|
-
|
|
59
|
-
expect(screen.getByText('Add Vaccine: Rotavirus')).toBeInTheDocument();
|
|
60
|
-
expect(screen.queryByText('Sequence')).toBeNull();
|
|
61
|
-
expect(screen.getByText('Vaccination Date')).toBeInTheDocument();
|
|
62
|
-
expect(screen.getByText('Expiration Date')).toBeInTheDocument();
|
|
63
|
-
expect(screen.getByText('Lot Number')).toBeInTheDocument();
|
|
64
|
-
expect(screen.getByText('Manufacturer')).toBeInTheDocument();
|
|
65
|
-
expect(screen.getByText('Cancel')).toBeInTheDocument();
|
|
66
|
-
expect(screen.getByText('Save')).toBeInTheDocument();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('displays the appropriate fields when adding a new immunization with sequence', async () => {
|
|
70
|
-
testMatch.params = {
|
|
71
|
-
vaccineName: 'Rotavirus',
|
|
72
|
-
sequences: [
|
|
73
|
-
{ sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
74
|
-
{ sequenceLabel: '4 Months', sequenceNumber: 2 },
|
|
75
|
-
{ sequenceLabel: '6 Months', sequenceNumber: 3 },
|
|
76
|
-
],
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
renderImmunizationsForm();
|
|
80
|
-
|
|
81
|
-
await screen.findByText('Add Vaccine: Rotavirus');
|
|
82
|
-
expect(screen.getByText('Vaccination Date')).toBeInTheDocument();
|
|
83
|
-
expect(screen.getByText('Expiration Date')).toBeInTheDocument();
|
|
84
|
-
expect(screen.getByText('Lot Number')).toBeInTheDocument();
|
|
85
|
-
expect(screen.getByText('Sequence')).toBeInTheDocument();
|
|
86
|
-
expect(screen.getByText('Manufacturer')).toBeInTheDocument();
|
|
87
|
-
expect(screen.getByText('Cancel')).toBeInTheDocument();
|
|
88
|
-
expect(screen.getByText('Save')).toBeInTheDocument();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('displays the appropriate fields and values when editing an existing immunization without sequence', async () => {
|
|
92
|
-
testMatch.params = {
|
|
93
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130004',
|
|
94
|
-
vaccineName: 'Rotavirus',
|
|
95
|
-
manufacturer: 'Organization/hl7',
|
|
96
|
-
expirationDate: '2018-12-15',
|
|
97
|
-
vaccinationDate: '2018-06-18',
|
|
98
|
-
lotNumber: '12345',
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
renderImmunizationsForm();
|
|
102
|
-
|
|
103
|
-
await screen.findByText('Edit Vaccine: Rotavirus');
|
|
104
|
-
|
|
105
|
-
expect(screen.getByText('Edit Vaccine: Rotavirus')).toBeInTheDocument();
|
|
106
|
-
expect(screen.getByLabelText('Vaccination Date')).toHaveDisplayValue('2018-06-18');
|
|
107
|
-
expect(screen.getByLabelText('Expiration Date')).toHaveDisplayValue('2018-12-15');
|
|
108
|
-
expect(screen.getByLabelText('Lot Number')).toHaveDisplayValue('12345');
|
|
109
|
-
expect(screen.getByLabelText('Manufacturer')).toHaveDisplayValue('Organization/hl7');
|
|
110
|
-
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
|
|
111
|
-
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('displays the appropriate fields and values when editing an existing immunization with sequence', async () => {
|
|
115
|
-
testMatch.params = {
|
|
116
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130004',
|
|
117
|
-
vaccineName: 'Rotavirus',
|
|
118
|
-
manufacturer: 'Organization/hl7',
|
|
119
|
-
expirationDate: '2018-12-15',
|
|
120
|
-
vaccinationDate: '2018-06-18',
|
|
121
|
-
lotNumber: '12345',
|
|
122
|
-
sequences: [
|
|
123
|
-
{ sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
124
|
-
{ sequenceLabel: '4 Months', sequenceNumber: 2 },
|
|
125
|
-
{ sequenceLabel: '6 Months', sequenceNumber: 3 },
|
|
126
|
-
],
|
|
127
|
-
currentDose: { sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
renderImmunizationsForm();
|
|
131
|
-
|
|
132
|
-
await screen.findByText('Edit Vaccine: Rotavirus');
|
|
133
|
-
expect(screen.getByText('Edit Vaccine: Rotavirus')).toBeInTheDocument();
|
|
134
|
-
|
|
135
|
-
expect(screen.getByLabelText('Vaccination Date')).toHaveDisplayValue('2018-06-18');
|
|
136
|
-
expect(screen.getByLabelText('Expiration Date')).toHaveDisplayValue('2018-12-15');
|
|
137
|
-
expect(screen.getByLabelText('Lot Number')).toHaveDisplayValue('12345');
|
|
138
|
-
expect(screen.getByLabelText('Manufacturer')).toHaveDisplayValue('Organization/hl7');
|
|
139
|
-
expect(screen.getByText('Cancel')).toBeInTheDocument();
|
|
140
|
-
expect(screen.getByText('Save')).toBeInTheDocument();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('should have save button disabled unless data entered', () => {
|
|
144
|
-
mockSavePatientImmunization.mockResolvedValue({ status: 200 });
|
|
145
|
-
testMatch.params = {
|
|
146
|
-
vaccineName: 'Rotavirus',
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
renderImmunizationsForm();
|
|
150
|
-
|
|
151
|
-
expect(screen.getByText('Save')).toBeDisabled();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('should enable save button when mandatory fields are selected', async () => {
|
|
155
|
-
mockSavePatientImmunization.mockResolvedValue({ status: 200 });
|
|
156
|
-
testMatch.params = {
|
|
157
|
-
vaccineName: 'Rotavirus',
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
renderImmunizationsForm();
|
|
161
|
-
|
|
162
|
-
await screen.findByLabelText('Vaccination Date');
|
|
163
|
-
expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
|
|
164
|
-
|
|
165
|
-
const vaccinationDate = screen.getByLabelText('Vaccination Date');
|
|
166
|
-
fireEvent.change(vaccinationDate, { target: { value: '2020-06-15' } });
|
|
167
|
-
|
|
168
|
-
expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('makes a call to create new immnunization without sequence', async () => {
|
|
172
|
-
mockSavePatientImmunization.mockResolvedValue({ status: 200 });
|
|
173
|
-
testMatch.params = {
|
|
174
|
-
vaccineName: 'Rotavirus',
|
|
175
|
-
vaccineUuid: 'RotavirusUuid',
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
renderImmunizationsForm();
|
|
179
|
-
|
|
180
|
-
await screen.findByLabelText('Vaccination Date');
|
|
181
|
-
|
|
182
|
-
const vaccinationDate = screen.getByLabelText('Vaccination Date');
|
|
183
|
-
fireEvent.change(vaccinationDate, { target: { value: '2020-06-15' } });
|
|
184
|
-
|
|
185
|
-
const vaccinationExpiration = screen.getByLabelText('Expiration Date');
|
|
186
|
-
fireEvent.change(vaccinationExpiration, {
|
|
187
|
-
target: { value: '2020-06-30' },
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const lotNumber = screen.getByLabelText('Lot Number');
|
|
191
|
-
fireEvent.change(lotNumber, { target: { value: '19876' } });
|
|
192
|
-
|
|
193
|
-
const manufacturer = screen.getByLabelText('Manufacturer');
|
|
194
|
-
fireEvent.change(manufacturer, { target: { value: 'XYTR4' } });
|
|
195
|
-
|
|
196
|
-
fireEvent.submit(screen.getByTestId('immunization-form'));
|
|
197
|
-
|
|
198
|
-
expect(mockSavePatientImmunization).toBeCalled();
|
|
199
|
-
|
|
200
|
-
const firstArgument = mockSavePatientImmunization.mock.calls[0][0];
|
|
201
|
-
expectImmunization(firstArgument, undefined, 'visitUuid', undefined, undefined, '19876');
|
|
202
|
-
|
|
203
|
-
const secondArgument = mockSavePatientImmunization.mock.calls[0][1];
|
|
204
|
-
expect(secondArgument).toBe(mockPatientId);
|
|
205
|
-
|
|
206
|
-
const thirdArgument = mockSavePatientImmunization.mock.calls[0][2];
|
|
207
|
-
expect(thirdArgument).toBeUndefined();
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('makes a call to create new immnunization with sequence', async () => {
|
|
211
|
-
mockSavePatientImmunization.mockResolvedValue({ status: 200 });
|
|
212
|
-
testMatch.params = {
|
|
213
|
-
vaccineName: 'Rotavirus',
|
|
214
|
-
vaccineUuid: 'RotavirusUuid',
|
|
215
|
-
sequences: [
|
|
216
|
-
{ sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
217
|
-
{ sequenceLabel: '4 Months', sequenceNumber: 2 },
|
|
218
|
-
{ sequenceLabel: '6 Months', sequenceNumber: 3 },
|
|
219
|
-
],
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
renderImmunizationsForm();
|
|
223
|
-
|
|
224
|
-
await screen.findByLabelText('Sequence');
|
|
225
|
-
const sequence = screen.getByLabelText('Sequence');
|
|
226
|
-
fireEvent.change(sequence, { target: { value: 2 } });
|
|
227
|
-
|
|
228
|
-
const vaccinationDate = screen.getByLabelText('Vaccination Date');
|
|
229
|
-
fireEvent.change(vaccinationDate, { target: { value: '2020-06-15' } });
|
|
230
|
-
|
|
231
|
-
const vaccinationExpiration = screen.getByLabelText('Expiration Date');
|
|
232
|
-
fireEvent.change(vaccinationExpiration, {
|
|
233
|
-
target: { value: '2020-06-30' },
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const lotNumber = screen.getByLabelText('Lot Number');
|
|
237
|
-
fireEvent.change(lotNumber, { target: { value: '19876' } });
|
|
238
|
-
|
|
239
|
-
const manufacturer = screen.getByLabelText('Manufacturer');
|
|
240
|
-
fireEvent.change(manufacturer, { target: { value: 'XYTR4' } });
|
|
241
|
-
|
|
242
|
-
fireEvent.submit(screen.getByTestId('immunization-form'));
|
|
243
|
-
expect(mockSavePatientImmunization).toBeCalled();
|
|
244
|
-
|
|
245
|
-
const firstArgument = mockSavePatientImmunization.mock.calls[0][0];
|
|
246
|
-
expectImmunization(firstArgument, undefined, 'visitUuid', '4 Months', 2, '19876');
|
|
247
|
-
|
|
248
|
-
const secondArgument = mockSavePatientImmunization.mock.calls[0][1];
|
|
249
|
-
expect(secondArgument).toBe(mockPatientId);
|
|
250
|
-
|
|
251
|
-
const thirdArgument = mockSavePatientImmunization.mock.calls[0][2];
|
|
252
|
-
expect(thirdArgument).toBeUndefined();
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('should have save button disabled unless data changed in edit mode', async () => {
|
|
256
|
-
mockSavePatientImmunization.mockResolvedValue({ status: 200 });
|
|
257
|
-
testMatch.params = {
|
|
258
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130004',
|
|
259
|
-
vaccineName: 'Rotavirus',
|
|
260
|
-
manufacturer: { display: 'Organization/hl7' },
|
|
261
|
-
expirationDate: '2018-12-15',
|
|
262
|
-
vaccinationDate: '2018-06-18',
|
|
263
|
-
lotNumber: 'PT123F',
|
|
264
|
-
sequence: [
|
|
265
|
-
{ sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
266
|
-
{ sequenceLabel: '4 Months', sequenceNumber: 2 },
|
|
267
|
-
{ sequenceLabel: '6 Months', sequenceNumber: 3 },
|
|
268
|
-
],
|
|
269
|
-
currentDose: { sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
renderImmunizationsForm();
|
|
273
|
-
|
|
274
|
-
await screen.findByRole('button', { name: 'Save' });
|
|
275
|
-
expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('makes a call to edit existing immnunization with sequence', async () => {
|
|
279
|
-
mockSavePatientImmunization.mockResolvedValue({ status: 200 });
|
|
280
|
-
testMatch.params = {
|
|
281
|
-
immunizationObsUuid: 'b9c21a82-aed3-11ea-b3de-0242ac130004',
|
|
282
|
-
vaccineName: 'Rotavirus',
|
|
283
|
-
vaccineUuid: 'RotavirusUuid',
|
|
284
|
-
manufacturer: 'XYTR4',
|
|
285
|
-
expirationDate: '2020-06-30',
|
|
286
|
-
vaccinationDate: '2020-06-15',
|
|
287
|
-
lotNumber: 'PT123F',
|
|
288
|
-
sequences: [
|
|
289
|
-
{ sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
290
|
-
{ sequenceLabel: '4 Months', sequenceNumber: 2 },
|
|
291
|
-
{ sequenceLabel: '6 Months', sequenceNumber: 3 },
|
|
292
|
-
],
|
|
293
|
-
currentDose: { sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
renderImmunizationsForm();
|
|
297
|
-
|
|
298
|
-
await screen.findByLabelText('Lot Number');
|
|
299
|
-
const lotNumber = screen.getByLabelText('Lot Number');
|
|
300
|
-
|
|
301
|
-
fireEvent.change(lotNumber, { target: { value: '12345' } });
|
|
302
|
-
fireEvent.submit(screen.getByTestId('immunization-form'));
|
|
303
|
-
|
|
304
|
-
expect(mockSavePatientImmunization).toBeCalled();
|
|
305
|
-
|
|
306
|
-
const firstArgument = mockSavePatientImmunization.mock.calls[0][0];
|
|
307
|
-
expectImmunization(firstArgument, 'b9c21a82-aed3-11ea-b3de-0242ac130004', 'visitUuid', '2 Months', 1, '12345');
|
|
308
|
-
|
|
309
|
-
const secondArgument = mockSavePatientImmunization.mock.calls[0][1];
|
|
310
|
-
expect(secondArgument).toBe(mockPatientId);
|
|
311
|
-
|
|
312
|
-
const thirdArgument = mockSavePatientImmunization.mock.calls[0][2];
|
|
313
|
-
expect(thirdArgument).toBe('b9c21a82-aed3-11ea-b3de-0242ac130004');
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
function expectImmunization(
|
|
318
|
-
immunizationParam,
|
|
319
|
-
immunizationObsUuid,
|
|
320
|
-
expectedEncounterUuid,
|
|
321
|
-
expectedSeries,
|
|
322
|
-
sequenceNumber,
|
|
323
|
-
expectedLotNumber,
|
|
324
|
-
) {
|
|
325
|
-
expect(immunizationParam.resourceType).toBe('Immunization');
|
|
326
|
-
expect(immunizationParam.id).toBe(immunizationObsUuid);
|
|
327
|
-
expect(immunizationParam.vaccineCode.coding[0].display).toBe('Rotavirus');
|
|
328
|
-
expect(immunizationParam.vaccineCode.coding[0].code).toBe('RotavirusUuid');
|
|
329
|
-
expect(immunizationParam.patient.reference).toBe(`Patient/${mockPatientId}`);
|
|
330
|
-
|
|
331
|
-
expect(immunizationParam.encounter).toBeTruthy();
|
|
332
|
-
expect(immunizationParam.encounter.reference).toBe(`Encounter/${expectedEncounterUuid}`);
|
|
333
|
-
|
|
334
|
-
expect(immunizationParam.location).toBeTruthy();
|
|
335
|
-
expect(immunizationParam.location.reference).toBe('Location/b1a8b05e-3542-4037-bbd3-998ee9c40574');
|
|
336
|
-
|
|
337
|
-
expect(immunizationParam.performer[0].actor).toBeTruthy();
|
|
338
|
-
expect(immunizationParam.performer[0].actor.reference).toBe('Practitioner/b1a8b05e-3542-4037-bbd3-998ee9c4057z');
|
|
339
|
-
|
|
340
|
-
expect(immunizationParam.manufacturer.display).toBe('XYTR4');
|
|
341
|
-
expect(immunizationParam.lotNumber).toBe(expectedLotNumber);
|
|
342
|
-
|
|
343
|
-
expect(immunizationParam.protocolApplied[0].series).toBe(expectedSeries);
|
|
344
|
-
expect(immunizationParam.protocolApplied[0].doseNumberPositiveInt).toBe(sequenceNumber);
|
|
345
|
-
expect(immunizationParam.occurrenceDateTime.toISOString()).toBe(parseDate('2020-06-15').toISOString());
|
|
346
|
-
expect(immunizationParam.expirationDate.toISOString()).toBe(parseDate('2020-06-30').toISOString());
|
|
347
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
-
import { getImmunizationsConceptSet, performPatientImmunizationsSearch } from './immunizations.resource';
|
|
3
|
-
import { mockPatientImmunizationsSearchResponse } from '../../../../__mocks__/immunizations.mock';
|
|
4
|
-
import { FHIRImmunizationBundle, OpenmrsConcept } from './immunization-domain';
|
|
5
|
-
|
|
6
|
-
const mockOpenmrsFetch = openmrsFetch as jest.Mock;
|
|
7
|
-
|
|
8
|
-
mockOpenmrsFetch.mockImplementation(jest.fn());
|
|
9
|
-
|
|
10
|
-
describe('<ImmunizationResource />', () => {
|
|
11
|
-
beforeEach(mockOpenmrsFetch.mockReset);
|
|
12
|
-
|
|
13
|
-
it('should fetch immunization concept set by concept uuid', async () => {
|
|
14
|
-
mockOpenmrsFetch.mockResolvedValueOnce({
|
|
15
|
-
data: {
|
|
16
|
-
uuid: 'conceptSetUuid',
|
|
17
|
-
display: 'conceptSetName',
|
|
18
|
-
setMembers: [
|
|
19
|
-
{ uuid: 'member1Uuid', display: 'member1Name' },
|
|
20
|
-
{ uuid: 'member2Uuid', display: 'member2Name' },
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const abortController = new AbortController();
|
|
26
|
-
const immunizationsConceptSet: OpenmrsConcept = await getImmunizationsConceptSet('conceptSetUuid', abortController);
|
|
27
|
-
|
|
28
|
-
expect(immunizationsConceptSet.uuid).toBe('conceptSetUuid');
|
|
29
|
-
expect(immunizationsConceptSet.display).toBe('conceptSetName');
|
|
30
|
-
expect(immunizationsConceptSet.setMembers.length).toBe(2);
|
|
31
|
-
|
|
32
|
-
expect(mockOpenmrsFetch).toHaveBeenCalledTimes(1);
|
|
33
|
-
const mockCalls = mockOpenmrsFetch.mock.calls[0];
|
|
34
|
-
expect(mockCalls[0]).toBe('/ws/rest/v1/concept/conceptSetUuid?v=full');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should fetch immunization concept set by mapping', async () => {
|
|
38
|
-
mockOpenmrsFetch.mockResolvedValueOnce({
|
|
39
|
-
data: {
|
|
40
|
-
results: [
|
|
41
|
-
{
|
|
42
|
-
uuid: 'conceptSetUuid',
|
|
43
|
-
display: 'conceptSetName',
|
|
44
|
-
setMembers: [
|
|
45
|
-
{ uuid: 'member1Uuid', display: 'member1Name' },
|
|
46
|
-
{ uuid: 'member2Uuid', display: 'member2Name' },
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const abortController = new AbortController();
|
|
54
|
-
const immunizationsConceptSet: OpenmrsConcept = await getImmunizationsConceptSet('CIEL:12345', abortController);
|
|
55
|
-
|
|
56
|
-
expect(immunizationsConceptSet.uuid).toBe('conceptSetUuid');
|
|
57
|
-
expect(immunizationsConceptSet.display).toBe('conceptSetName');
|
|
58
|
-
expect(immunizationsConceptSet.setMembers.length).toBe(2);
|
|
59
|
-
|
|
60
|
-
expect(mockOpenmrsFetch).toHaveBeenCalledTimes(1);
|
|
61
|
-
const mockCalls = mockOpenmrsFetch.mock.calls[0];
|
|
62
|
-
expect(mockCalls[0]).toBe('/ws/rest/v1/concept?source=CIEL&code=12345&v=full');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should fetch immiunization bundles for a given patient', async () => {
|
|
66
|
-
mockOpenmrsFetch.mockResolvedValueOnce({
|
|
67
|
-
data: mockPatientImmunizationsSearchResponse,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const abortController = new AbortController();
|
|
71
|
-
const fhirImmunizationBundle: FHIRImmunizationBundle = await performPatientImmunizationsSearch(
|
|
72
|
-
'12345',
|
|
73
|
-
'patientUuid',
|
|
74
|
-
abortController,
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
expect(mockOpenmrsFetch).toHaveBeenCalledTimes(1);
|
|
78
|
-
expect(fhirImmunizationBundle.resourceType).toBe('Bundle');
|
|
79
|
-
expect(fhirImmunizationBundle.entry.length).toBe(6);
|
|
80
|
-
expect(fhirImmunizationBundle.entry[0].resource.vaccineCode.coding[0].display).toBe('Rotavirus');
|
|
81
|
-
expect(fhirImmunizationBundle.entry[1].resource.vaccineCode.coding[0].display).toBe('Rotavirus');
|
|
82
|
-
expect(fhirImmunizationBundle.entry[2].resource.vaccineCode.coding[0].display).toBe('Polio');
|
|
83
|
-
expect(fhirImmunizationBundle.entry[3].resource.vaccineCode.coding[0].display).toBe('Polio');
|
|
84
|
-
expect(fhirImmunizationBundle.entry[4].resource.vaccineCode.coding[0].display).toBe('Influenza');
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import VaccinationRow from './vaccination-row.component';
|
|
3
|
-
import { render, within, screen, fireEvent } from '@testing-library/react';
|
|
4
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
5
|
-
|
|
6
|
-
const match = { params: {}, isExact: false, path: '/', url: '/' };
|
|
7
|
-
|
|
8
|
-
const renderVaccinationRow = (immunization) => {
|
|
9
|
-
const tbody = document.createElement('tbody');
|
|
10
|
-
render(
|
|
11
|
-
<BrowserRouter>
|
|
12
|
-
<VaccinationRow immunization={immunization} />
|
|
13
|
-
</BrowserRouter>,
|
|
14
|
-
{ container: document.body.appendChild(tbody) },
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
describe('<VaccinationRow />', () => {
|
|
19
|
-
it('should show just vaccine name and add button when no doses are given', async () => {
|
|
20
|
-
const immunization = {
|
|
21
|
-
vaccineName: 'Rotavirus',
|
|
22
|
-
existingDoses: [],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
renderVaccinationRow(immunization);
|
|
26
|
-
|
|
27
|
-
await screen.findByText('Rotavirus');
|
|
28
|
-
const vaccinationRow = screen.getByRole('row', { name: /Rotavirus +/ });
|
|
29
|
-
const expandButton = screen.getByRole('button', { name: '+' });
|
|
30
|
-
|
|
31
|
-
expect(expandButton).toBeTruthy();
|
|
32
|
-
expect(within(vaccinationRow).getByText('Rotavirus')).toBeTruthy();
|
|
33
|
-
expect(within(vaccinationRow).getByText('+')).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should show vaccine name with expand button and recent vaccination date when existing doses are present', async () => {
|
|
37
|
-
const immunization = {
|
|
38
|
-
vaccineName: 'Rotavirus',
|
|
39
|
-
existingDoses: [
|
|
40
|
-
{
|
|
41
|
-
series: '4 Months',
|
|
42
|
-
occurrenceDateTime: '2019-06-18',
|
|
43
|
-
doseNumberPositiveInt: 1,
|
|
44
|
-
expirationDate: '2019-06-18',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
series: '2 Months',
|
|
48
|
-
occurrenceDateTime: '2018-06-18',
|
|
49
|
-
doseNumberPositiveInt: 1,
|
|
50
|
-
expirationDate: '2018-06-18',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
renderVaccinationRow(immunization);
|
|
56
|
-
|
|
57
|
-
await screen.findByText('Rotavirus');
|
|
58
|
-
const vaccinationRow = screen.getByRole('row', { name: /Rotavirus +/ });
|
|
59
|
-
const expandButton = screen.getByRole('button', { name: '+' });
|
|
60
|
-
|
|
61
|
-
expect(expandButton).toBeTruthy();
|
|
62
|
-
expect(within(vaccinationRow).getByText('Rotavirus')).toBeTruthy();
|
|
63
|
-
expect(within(vaccinationRow).getByText('Single Dose on 18-Jun-2019')).toBeTruthy();
|
|
64
|
-
expect(within(vaccinationRow).getByText('+')).toBeTruthy();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should show vaccine all doses of vaccine along with recent vaccination date when expanded', async () => {
|
|
68
|
-
const immunization = {
|
|
69
|
-
vaccineName: 'Rotavirus',
|
|
70
|
-
sequences: [
|
|
71
|
-
{ sequenceLabel: '2 Months', sequenceNumber: 1 },
|
|
72
|
-
{ sequenceLabel: '4 Months', sequenceNumber: 2 },
|
|
73
|
-
{ sequenceLabel: '6 Months', sequenceNumber: 3 },
|
|
74
|
-
],
|
|
75
|
-
existingDoses: [
|
|
76
|
-
{
|
|
77
|
-
sequenceLabel: '4 Months',
|
|
78
|
-
occurrenceDateTime: '2019-05-18',
|
|
79
|
-
doseNumberPositiveInt: 2,
|
|
80
|
-
expirationDate: '2019-06-18',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
sequenceLabel: '2 Months',
|
|
84
|
-
occurrenceDateTime: '2018-05-18',
|
|
85
|
-
doseNumberPositiveInt: 1,
|
|
86
|
-
expirationDate: '2018-06-18',
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
renderVaccinationRow(immunization);
|
|
92
|
-
|
|
93
|
-
await screen.findByText('Rotavirus');
|
|
94
|
-
const vaccinationRow = screen.getByRole('row', { name: /Rotavirus +/ });
|
|
95
|
-
const expandButton = screen.getByRole('button', { name: '+' });
|
|
96
|
-
|
|
97
|
-
fireEvent.click(expandButton);
|
|
98
|
-
|
|
99
|
-
await screen.findByText(/4 Months/i);
|
|
100
|
-
});
|
|
101
|
-
});
|