@openmrs/esm-patient-orders-app 11.3.1-pre.9383 → 11.3.1-pre.9390

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.
@@ -2,31 +2,34 @@ import React from 'react';
2
2
  import { render, screen, waitFor } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import {
5
- useOrderConceptByUuid,
5
+ useOrderConceptsByUuids,
6
6
  useLabEncounter,
7
7
  useObservation,
8
8
  type LabOrderConcept,
9
9
  updateOrderResult,
10
10
  type Datatype,
11
- useCompletedLabResults,
11
+ useCompletedLabResultsArray,
12
12
  } from './lab-results.resource';
13
+ import { usePatient } from '@openmrs/esm-framework/src';
13
14
  import LabResultsForm from './lab-results-form.component';
14
15
  import { type Order } from '@openmrs/esm-patient-common-lib';
15
16
  import { type Encounter } from '../types/encounter';
16
17
  import { mockPatient } from 'tools';
17
18
 
18
- const mockUseOrderConceptByUuid = jest.mocked(useOrderConceptByUuid);
19
+ const mockUseOrderConceptByUuids = jest.mocked(useOrderConceptsByUuids);
19
20
  const mockUseLabEncounter = jest.mocked(useLabEncounter);
20
21
  const mockUseObservation = jest.mocked(useObservation);
21
- const mockUseCompletedLabResults = jest.mocked(useCompletedLabResults);
22
+ const mockUseCompletedLabResultsArray = jest.mocked(useCompletedLabResultsArray);
23
+ const mockUsePatient = jest.mocked(usePatient);
22
24
 
23
25
  jest.mock('./lab-results.resource', () => ({
24
26
  ...jest.requireActual('./lab-results.resource'),
25
27
  useOrderConceptByUuid: jest.fn(),
28
+ useOrderConceptsByUuids: jest.fn(),
26
29
  useLabEncounter: jest.fn(),
27
30
  useObservation: jest.fn(),
28
31
  updateOrderResult: jest.fn().mockResolvedValue({}),
29
- useCompletedLabResults: jest.fn(),
32
+ useCompletedLabResultsArray: jest.fn(),
30
33
  }));
31
34
 
32
35
  const mockOrder = {
@@ -53,21 +56,23 @@ const testProps = {
53
56
 
54
57
  describe('LabResultsForm', () => {
55
58
  beforeEach(() => {
56
- mockUseOrderConceptByUuid.mockReturnValue({
57
- concept: {
58
- uuid: 'concept-uuid',
59
- display: 'Test Concept',
60
- setMembers: [],
61
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
62
- hiAbsolute: 100,
63
- hiCritical: 80,
64
- hiNormal: 70,
65
- lowAbsolute: 0,
66
- lowCritical: 40,
67
- lowNormal: 50,
68
- units: 'mg/dL',
69
- allowDecimal: false,
70
- } as LabOrderConcept,
59
+ mockUseOrderConceptByUuids.mockReturnValue({
60
+ concepts: [
61
+ {
62
+ uuid: 'concept-uuid',
63
+ display: 'Test Concept',
64
+ setMembers: [],
65
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
66
+ hiAbsolute: 100,
67
+ hiCritical: 80,
68
+ hiNormal: 70,
69
+ lowAbsolute: 0,
70
+ lowCritical: 40,
71
+ lowNormal: 50,
72
+ units: 'mg/dL',
73
+ allowDecimal: false,
74
+ },
75
+ ] as LabOrderConcept[],
71
76
  isLoading: false,
72
77
  error: null,
73
78
  isValidating: false,
@@ -87,12 +92,18 @@ describe('LabResultsForm', () => {
87
92
  isValidating: false,
88
93
  mutate: jest.fn(),
89
94
  });
90
- mockUseCompletedLabResults.mockReturnValue({
91
- completeLabResult: null,
95
+ mockUseCompletedLabResultsArray.mockReturnValue({
96
+ completeLabResults: [],
92
97
  isLoading: false,
93
98
  error: null,
94
99
  mutate: jest.fn(),
95
100
  });
101
+ mockUsePatient.mockReturnValue({
102
+ isLoading: false,
103
+ patient: mockPatient,
104
+ patientUuid: '',
105
+ error: null,
106
+ });
96
107
  });
97
108
 
98
109
  test('validates numeric input correctly', async () => {
@@ -113,21 +124,23 @@ describe('LabResultsForm', () => {
113
124
  test('validate when we have a concept with allowDecimal set to true', async () => {
114
125
  const user = userEvent.setup();
115
126
  // if allowDecimal is true, we should allow decimal values
116
- mockUseOrderConceptByUuid.mockReturnValue({
117
- concept: {
118
- uuid: 'concept-uuid',
119
- display: 'Test Concept',
120
- setMembers: [],
121
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
122
- hiAbsolute: 100,
123
- lowAbsolute: null,
124
- lowCritical: null,
125
- lowNormal: null,
126
- hiCritical: null,
127
- hiNormal: null,
128
- units: 'mg/dL',
129
- allowDecimal: true,
130
- } as LabOrderConcept,
127
+ mockUseOrderConceptByUuids.mockReturnValue({
128
+ concepts: [
129
+ {
130
+ uuid: 'concept-uuid',
131
+ display: 'Test Concept',
132
+ setMembers: [],
133
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
134
+ hiAbsolute: 100,
135
+ lowAbsolute: null,
136
+ lowCritical: null,
137
+ lowNormal: null,
138
+ hiCritical: null,
139
+ hiNormal: null,
140
+ units: 'mg/dL',
141
+ allowDecimal: true,
142
+ },
143
+ ] as LabOrderConcept[],
131
144
  isLoading: false,
132
145
  error: null,
133
146
  isValidating: false,
@@ -193,20 +206,22 @@ describe('LabResultsForm', () => {
193
206
 
194
207
  test('validate numeric input with concept having only hiAbsolute', async () => {
195
208
  const user = userEvent.setup();
196
- mockUseOrderConceptByUuid.mockReturnValue({
197
- concept: {
198
- uuid: 'concept-uuid',
199
- display: 'Test Concept',
200
- setMembers: [],
201
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
202
- hiAbsolute: 100,
203
- lowAbsolute: null,
204
- lowCritical: null,
205
- lowNormal: null,
206
- hiCritical: null,
207
- hiNormal: null,
208
- units: 'mg/dL',
209
- } as LabOrderConcept,
209
+ mockUseOrderConceptByUuids.mockReturnValue({
210
+ concepts: [
211
+ {
212
+ uuid: 'concept-uuid',
213
+ display: 'Test Concept',
214
+ setMembers: [],
215
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
216
+ hiAbsolute: 100,
217
+ lowAbsolute: null,
218
+ lowCritical: null,
219
+ lowNormal: null,
220
+ hiCritical: null,
221
+ hiNormal: null,
222
+ units: 'mg/dL',
223
+ },
224
+ ] as LabOrderConcept[],
210
225
  isLoading: false,
211
226
  error: null,
212
227
  isValidating: false,
@@ -229,20 +244,22 @@ describe('LabResultsForm', () => {
229
244
 
230
245
  test('validate numeric input with concept having only lowAbsolute', async () => {
231
246
  const user = userEvent.setup();
232
- mockUseOrderConceptByUuid.mockReturnValue({
233
- concept: {
234
- uuid: 'concept-uuid',
235
- display: 'Test Concept',
236
- setMembers: [],
237
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
238
- lowAbsolute: 0,
239
- lowCritical: null,
240
- lowNormal: null,
241
- hiCritical: null,
242
- hiNormal: null,
243
- hiAbsolute: null,
244
- units: 'mg/dL',
245
- } as LabOrderConcept,
247
+ mockUseOrderConceptByUuids.mockReturnValue({
248
+ concepts: [
249
+ {
250
+ uuid: 'concept-uuid',
251
+ display: 'Test Concept',
252
+ setMembers: [],
253
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
254
+ lowAbsolute: 0,
255
+ lowCritical: null,
256
+ lowNormal: null,
257
+ hiCritical: null,
258
+ hiNormal: null,
259
+ hiAbsolute: null,
260
+ units: 'mg/dL',
261
+ },
262
+ ] as LabOrderConcept[],
246
263
  isLoading: false,
247
264
  error: null,
248
265
  isValidating: false,
@@ -263,6 +280,63 @@ describe('LabResultsForm', () => {
263
280
  });
264
281
  });
265
282
 
283
+ test('validate numeric input for multiple fields', async () => {
284
+ const user = userEvent.setup();
285
+ mockUseOrderConceptByUuids.mockReturnValue({
286
+ concepts: [
287
+ {
288
+ uuid: 'concept-uuid',
289
+ display: 'Test Concept',
290
+ setMembers: [],
291
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
292
+ hiAbsolute: 60,
293
+ lowAbsolute: 0,
294
+ lowCritical: null,
295
+ lowNormal: null,
296
+ hiCritical: null,
297
+ hiNormal: null,
298
+ units: 'mg/dL',
299
+ allowDecimal: true,
300
+ },
301
+ {
302
+ uuid: 'concept-uuid2',
303
+ display: 'Test Concept Percentage',
304
+ setMembers: [],
305
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
306
+ hiAbsolute: 100,
307
+ lowAbsolute: 0,
308
+ lowCritical: null,
309
+ lowNormal: null,
310
+ hiCritical: null,
311
+ hiNormal: null,
312
+ units: '%',
313
+ allowDecimal: true,
314
+ },
315
+ ] as LabOrderConcept[],
316
+ isLoading: false,
317
+ error: null,
318
+ isValidating: false,
319
+ mutate: jest.fn(),
320
+ });
321
+ render(<LabResultsForm {...testProps} />);
322
+
323
+ const input = await screen.findByLabelText(`Test Concept (0 - 60 mg/dL)`);
324
+ await user.type(input, '80');
325
+
326
+ const input2 = await screen.findByLabelText(`Test Concept Percentage (0 - 100 %)`);
327
+ await user.type(input2, '120');
328
+
329
+ const saveButton = screen.getByRole('button', { name: /Save and close/i });
330
+ await user.click(saveButton);
331
+
332
+ await waitFor(() => {
333
+ expect(screen.getByText('Test Concept must be between 0 and 60')).toBeInTheDocument();
334
+ });
335
+ await waitFor(() => {
336
+ expect(screen.getByText('Test Concept Percentage must be between 0 and 100')).toBeInTheDocument();
337
+ });
338
+ });
339
+
266
340
  test('submits form with valid data', async () => {
267
341
  const user = userEvent.setup();
268
342
  const mockCloseWorkspace = jest.fn();
@@ -287,49 +361,114 @@ describe('LabResultsForm', () => {
287
361
  });
288
362
  });
289
363
 
364
+ test('submits form with valid data for multiple Results', async () => {
365
+ const user = userEvent.setup();
366
+ mockUseOrderConceptByUuids.mockReturnValue({
367
+ concepts: [
368
+ {
369
+ uuid: 'concept-uuid',
370
+ display: 'Test Concept',
371
+ setMembers: [],
372
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
373
+ hiAbsolute: 60,
374
+ lowAbsolute: 0,
375
+ lowCritical: null,
376
+ lowNormal: null,
377
+ hiCritical: null,
378
+ hiNormal: null,
379
+ units: 'mg/dL',
380
+ allowDecimal: true,
381
+ },
382
+ {
383
+ uuid: 'concept-uuid2',
384
+ display: 'Test Concept Percentage',
385
+ setMembers: [],
386
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
387
+ hiAbsolute: 100,
388
+ lowAbsolute: 0,
389
+ lowCritical: null,
390
+ lowNormal: null,
391
+ hiCritical: null,
392
+ hiNormal: null,
393
+ units: '%',
394
+ allowDecimal: true,
395
+ },
396
+ ] as LabOrderConcept[],
397
+ isLoading: false,
398
+ error: null,
399
+ isValidating: false,
400
+ mutate: jest.fn(),
401
+ });
402
+ const mockCloseWorkspace = jest.fn();
403
+ const mockCloseWorkspaceWithSavedChanges = jest.fn();
404
+
405
+ render(
406
+ <LabResultsForm
407
+ {...testProps}
408
+ closeWorkspace={mockCloseWorkspace}
409
+ closeWorkspaceWithSavedChanges={mockCloseWorkspaceWithSavedChanges}
410
+ />,
411
+ );
412
+
413
+ const input = await screen.findByLabelText(`Test Concept (0 - 60 mg/dL)`);
414
+ await user.type(input, '50');
415
+
416
+ const input2 = await screen.findByLabelText(`Test Concept Percentage (0 - 100 %)`);
417
+ await user.type(input2, '90');
418
+
419
+ const saveButton = screen.getByRole('button', { name: /Save and close/i });
420
+ await user.click(saveButton);
421
+
422
+ await waitFor(() => {
423
+ expect(mockCloseWorkspaceWithSavedChanges).toHaveBeenCalled();
424
+ });
425
+ });
426
+
290
427
  test('validate numeric input where concept is a set', async () => {
291
428
  const user = userEvent.setup();
292
- mockUseOrderConceptByUuid.mockReturnValue({
293
- concept: {
294
- uuid: 'concept-uuid',
295
- display: 'Test Concept',
296
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
297
- lowAbsolute: 0,
298
- lowCritical: null,
299
- lowNormal: null,
300
- hiCritical: null,
301
- hiNormal: null,
302
- hiAbsolute: null,
303
- units: 'mg/dL',
304
- setMembers: [
305
- {
306
- uuid: 'set-member-uuid',
307
- display: 'Set Member',
308
- setMembers: [],
309
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
310
- lowAbsolute: 50,
311
- lowCritical: 70,
312
- lowNormal: 80,
313
- hiCritical: 140,
314
- hiNormal: 120,
315
- hiAbsolute: 150,
316
- units: 'mg/dL',
317
- },
318
- {
319
- uuid: 'set-member-uuid-2',
320
- display: 'Set Member 2',
321
- setMembers: [],
322
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
323
- lowAbsolute: 5,
324
- lowCritical: 10,
325
- lowNormal: 15,
326
- hiCritical: 20,
327
- hiNormal: 25,
328
- hiAbsolute: 30,
329
- units: 'mg/dL',
330
- },
331
- ],
332
- } as LabOrderConcept,
429
+ mockUseOrderConceptByUuids.mockReturnValue({
430
+ concepts: [
431
+ {
432
+ uuid: 'concept-uuid',
433
+ display: 'Test Concept',
434
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
435
+ lowAbsolute: 0,
436
+ lowCritical: null,
437
+ lowNormal: null,
438
+ hiCritical: null,
439
+ hiNormal: null,
440
+ hiAbsolute: null,
441
+ units: 'mg/dL',
442
+ setMembers: [
443
+ {
444
+ uuid: 'set-member-uuid',
445
+ display: 'Set Member',
446
+ setMembers: [],
447
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
448
+ lowAbsolute: 50,
449
+ lowCritical: 70,
450
+ lowNormal: 80,
451
+ hiCritical: 140,
452
+ hiNormal: 120,
453
+ hiAbsolute: 150,
454
+ units: 'mg/dL',
455
+ },
456
+ {
457
+ uuid: 'set-member-uuid-2',
458
+ display: 'Set Member 2',
459
+ setMembers: [],
460
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
461
+ lowAbsolute: 5,
462
+ lowCritical: 10,
463
+ lowNormal: 15,
464
+ hiCritical: 20,
465
+ hiNormal: 25,
466
+ hiAbsolute: 30,
467
+ units: 'mg/dL',
468
+ },
469
+ ],
470
+ },
471
+ ] as LabOrderConcept[],
333
472
  isLoading: false,
334
473
  error: null,
335
474
  isValidating: false,
@@ -363,20 +502,22 @@ describe('LabResultsForm', () => {
363
502
 
364
503
  test('lab results form submits the correct lab result payload when the concept is not a set', async () => {
365
504
  const user = userEvent.setup();
366
- mockUseOrderConceptByUuid.mockReturnValue({
367
- concept: {
368
- uuid: 'concept-uuid',
369
- display: 'Test Concept',
370
- setMembers: [],
371
- datatype: { display: 'Text', hl7Abbreviation: 'ST' } as Datatype,
372
- hiAbsolute: 100,
373
- lowAbsolute: 0,
374
- lowCritical: null,
375
- lowNormal: null,
376
- hiCritical: null,
377
- hiNormal: null,
378
- units: 'mg/dL',
379
- } as LabOrderConcept,
505
+ mockUseOrderConceptByUuids.mockReturnValue({
506
+ concepts: [
507
+ {
508
+ uuid: 'concept-uuid',
509
+ display: 'Test Concept',
510
+ setMembers: [],
511
+ datatype: { display: 'Text', hl7Abbreviation: 'ST' } as Datatype,
512
+ hiAbsolute: 100,
513
+ lowAbsolute: 0,
514
+ lowCritical: null,
515
+ lowNormal: null,
516
+ hiCritical: null,
517
+ hiNormal: null,
518
+ units: 'mg/dL',
519
+ },
520
+ ] as LabOrderConcept[],
380
521
  isLoading: false,
381
522
  error: null,
382
523
  isValidating: false,
@@ -410,48 +551,50 @@ describe('LabResultsForm', () => {
410
551
 
411
552
  test('lab results forms submits correct payload when the concept is a set and one set member is keyed', async () => {
412
553
  const user = userEvent.setup();
413
- mockUseOrderConceptByUuid.mockReturnValue({
414
- concept: {
415
- uuid: 'concept-uuid',
416
- display: 'Test Concept',
417
- set: true,
418
- setMembers: [
419
- {
420
- uuid: 'set-member-uuid-1',
421
- display: 'Set Member 1',
422
- concept: { uuid: 'concept-uuid-1', display: 'Concept 1' },
423
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' } as Datatype,
424
- hiAbsolute: 100,
425
- lowAbsolute: 0,
426
- lowCritical: null,
427
- lowNormal: null,
428
- hiCritical: null,
429
- hiNormal: null,
430
- units: 'mg/dL',
431
- },
432
- {
433
- uuid: 'set-member-uuid-2',
434
- display: 'Set Member 2',
435
- concept: { uuid: 'concept-uuid-2', display: 'Concept 2' },
436
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' } as Datatype,
437
- hiAbsolute: 80,
438
- lowAbsolute: 0,
439
- lowCritical: null,
440
- lowNormal: null,
441
- hiCritical: null,
442
- hiNormal: null,
443
- units: 'mmol/L',
444
- },
445
- ],
446
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
447
- hiAbsolute: 100,
448
- lowAbsolute: 0,
449
- lowCritical: null,
450
- lowNormal: null,
451
- hiCritical: null,
452
- hiNormal: null,
453
- units: 'mg/dL',
454
- } as unknown as LabOrderConcept,
554
+ mockUseOrderConceptByUuids.mockReturnValue({
555
+ concepts: [
556
+ {
557
+ uuid: 'concept-uuid',
558
+ display: 'Test Concept',
559
+ set: true,
560
+ setMembers: [
561
+ {
562
+ uuid: 'set-member-uuid-1',
563
+ display: 'Set Member 1',
564
+ concept: { uuid: 'concept-uuid-1', display: 'Concept 1' },
565
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' } as Datatype,
566
+ hiAbsolute: 100,
567
+ lowAbsolute: 0,
568
+ lowCritical: null,
569
+ lowNormal: null,
570
+ hiCritical: null,
571
+ hiNormal: null,
572
+ units: 'mg/dL',
573
+ },
574
+ {
575
+ uuid: 'set-member-uuid-2',
576
+ display: 'Set Member 2',
577
+ concept: { uuid: 'concept-uuid-2', display: 'Concept 2' },
578
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' } as Datatype,
579
+ hiAbsolute: 80,
580
+ lowAbsolute: 0,
581
+ lowCritical: null,
582
+ lowNormal: null,
583
+ hiCritical: null,
584
+ hiNormal: null,
585
+ units: 'mmol/L',
586
+ },
587
+ ],
588
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
589
+ hiAbsolute: 100,
590
+ lowAbsolute: 0,
591
+ lowCritical: null,
592
+ lowNormal: null,
593
+ hiCritical: null,
594
+ hiNormal: null,
595
+ units: 'mg/dL',
596
+ },
597
+ ] as unknown as LabOrderConcept[],
455
598
  isLoading: false,
456
599
  error: null,
457
600
  isValidating: false,
@@ -514,48 +657,50 @@ describe('LabResultsForm', () => {
514
657
 
515
658
  test('lab results form submits correct payload when the concept is a set and both set members are keyed', async () => {
516
659
  const user = userEvent.setup();
517
- mockUseOrderConceptByUuid.mockReturnValue({
518
- concept: {
519
- uuid: 'concept-uuid',
520
- display: 'Test Concept',
521
- set: true,
522
- setMembers: [
523
- {
524
- uuid: 'set-member-uuid-1',
525
- display: 'Set Member 1',
526
- concept: { uuid: 'concept-uuid-1', display: 'Concept 1' },
527
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
528
- hiAbsolute: 100,
529
- lowAbsolute: 0,
530
- lowCritical: null,
531
- lowNormal: null,
532
- hiCritical: null,
533
- hiNormal: null,
534
- units: 'mg/dL',
535
- },
536
- {
537
- uuid: 'set-member-uuid-2',
538
- display: 'Set Member 2',
539
- concept: { uuid: 'concept-uuid-2', display: 'Concept 2' },
540
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
541
- hiAbsolute: 80,
542
- lowAbsolute: 0,
543
- lowCritical: null,
544
- lowNormal: null,
545
- hiCritical: null,
546
- hiNormal: null,
547
- units: 'mmol/L',
548
- },
549
- ],
550
- datatype: { display: 'Numeric' },
551
- hiAbsolute: 100,
552
- lowAbsolute: 0,
553
- lowCritical: null,
554
- lowNormal: null,
555
- hiCritical: null,
556
- hiNormal: null,
557
- units: 'mg/dL',
558
- } as unknown as LabOrderConcept,
660
+ mockUseOrderConceptByUuids.mockReturnValue({
661
+ concepts: [
662
+ {
663
+ uuid: 'concept-uuid',
664
+ display: 'Test Concept',
665
+ set: true,
666
+ setMembers: [
667
+ {
668
+ uuid: 'set-member-uuid-1',
669
+ display: 'Set Member 1',
670
+ concept: { uuid: 'concept-uuid-1', display: 'Concept 1' },
671
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
672
+ hiAbsolute: 100,
673
+ lowAbsolute: 0,
674
+ lowCritical: null,
675
+ lowNormal: null,
676
+ hiCritical: null,
677
+ hiNormal: null,
678
+ units: 'mg/dL',
679
+ },
680
+ {
681
+ uuid: 'set-member-uuid-2',
682
+ display: 'Set Member 2',
683
+ concept: { uuid: 'concept-uuid-2', display: 'Concept 2' },
684
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
685
+ hiAbsolute: 80,
686
+ lowAbsolute: 0,
687
+ lowCritical: null,
688
+ lowNormal: null,
689
+ hiCritical: null,
690
+ hiNormal: null,
691
+ units: 'mmol/L',
692
+ },
693
+ ],
694
+ datatype: { display: 'Numeric' },
695
+ hiAbsolute: 100,
696
+ lowAbsolute: 0,
697
+ lowCritical: null,
698
+ lowNormal: null,
699
+ hiCritical: null,
700
+ hiNormal: null,
701
+ units: 'mg/dL',
702
+ },
703
+ ] as unknown as LabOrderConcept[],
559
704
  isLoading: false,
560
705
  error: null,
561
706
  isValidating: false,
@@ -630,13 +775,15 @@ describe('LabResultsForm', () => {
630
775
  });
631
776
 
632
777
  test('display error notification when the concept datatype is N/A', async () => {
633
- mockUseOrderConceptByUuid.mockReturnValue({
634
- concept: {
635
- uuid: 'concept-uuid',
636
- display: 'Test Concept',
637
- setMembers: [],
638
- datatype: { display: 'N/A' },
639
- } as LabOrderConcept,
778
+ mockUseOrderConceptByUuids.mockReturnValue({
779
+ concepts: [
780
+ {
781
+ uuid: 'concept-uuid',
782
+ display: 'Test Concept',
783
+ setMembers: [],
784
+ datatype: { display: 'N/A' },
785
+ },
786
+ ] as LabOrderConcept[],
640
787
  isLoading: false,
641
788
  error: null,
642
789
  isValidating: false,
@@ -655,78 +802,80 @@ describe('LabResultsForm', () => {
655
802
 
656
803
  test('should display second level of set members for a given concept, if present', () => {
657
804
  const user = userEvent.setup();
658
- mockUseOrderConceptByUuid.mockReturnValue({
659
- concept: {
660
- uuid: 'concept-uuid',
661
- display: 'Test Concept',
662
- set: true,
663
- setMembers: [
664
- {
665
- uuid: 'set-member-uuid-1',
666
- display: 'Set Member 1',
667
- concept: { uuid: 'concept-uuid-1', display: 'Concept 1' },
668
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
669
- hiAbsolute: 100,
670
- lowAbsolute: 0,
671
- lowCritical: null,
672
- lowNormal: null,
673
- hiCritical: null,
674
- hiNormal: null,
675
- units: 'mg/dL',
676
- },
677
- {
678
- uuid: 'set-member-uuid-2',
679
- display: 'Set Member 2',
680
- concept: { uuid: 'concept-uuid-2', display: 'Concept 2' },
681
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
682
- hiAbsolute: 80,
683
- lowAbsolute: 0,
684
- lowCritical: null,
685
- lowNormal: null,
686
- hiCritical: null,
687
- hiNormal: null,
688
- units: 'mmol/L',
689
- },
690
- {
691
- uuid: 'set-member-uuid-3',
692
- display: 'Set Member 3',
693
- concept: { uuid: 'concept-uuid-3', display: 'Concept 3' },
694
- datatype: { display: 'N/A', hl7Abbreviation: 'ZZ' },
695
- set: true,
696
- setMembers: [
697
- {
698
- uuid: 'set-member-uuid-3.1',
699
- display: 'Set Member 3.1',
700
- concept: { uuid: 'concept-uuid-3.1', display: 'Concept 3.1' },
701
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
702
- hiAbsolute: 80,
703
- lowAbsolute: 0,
704
- lowCritical: null,
705
- lowNormal: null,
706
- units: 'mg/dL',
707
- },
708
- {
709
- uuid: 'set-member-uuid-3.2',
710
- display: 'Set Member 3.2',
711
- concept: { uuid: 'concept-uuid-3.2', display: 'Concept 3.2' },
712
- datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
713
- hiAbsolute: 80,
714
- lowAbsolute: 0,
715
- lowCritical: null,
716
- units: 'mg/dL',
717
- },
718
- ],
719
- },
720
- ],
721
- datatype: { display: 'Numeric' },
722
- hiAbsolute: 100,
723
- lowAbsolute: 0,
724
- lowCritical: null,
725
- lowNormal: null,
726
- hiCritical: null,
727
- hiNormal: null,
728
- units: 'mg/dL',
729
- } as unknown as LabOrderConcept,
805
+ mockUseOrderConceptByUuids.mockReturnValue({
806
+ concepts: [
807
+ {
808
+ uuid: 'concept-uuid',
809
+ display: 'Test Concept',
810
+ set: true,
811
+ setMembers: [
812
+ {
813
+ uuid: 'set-member-uuid-1',
814
+ display: 'Set Member 1',
815
+ concept: { uuid: 'concept-uuid-1', display: 'Concept 1' },
816
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
817
+ hiAbsolute: 100,
818
+ lowAbsolute: 0,
819
+ lowCritical: null,
820
+ lowNormal: null,
821
+ hiCritical: null,
822
+ hiNormal: null,
823
+ units: 'mg/dL',
824
+ },
825
+ {
826
+ uuid: 'set-member-uuid-2',
827
+ display: 'Set Member 2',
828
+ concept: { uuid: 'concept-uuid-2', display: 'Concept 2' },
829
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
830
+ hiAbsolute: 80,
831
+ lowAbsolute: 0,
832
+ lowCritical: null,
833
+ lowNormal: null,
834
+ hiCritical: null,
835
+ hiNormal: null,
836
+ units: 'mmol/L',
837
+ },
838
+ {
839
+ uuid: 'set-member-uuid-3',
840
+ display: 'Set Member 3',
841
+ concept: { uuid: 'concept-uuid-3', display: 'Concept 3' },
842
+ datatype: { display: 'N/A', hl7Abbreviation: 'ZZ' },
843
+ set: true,
844
+ setMembers: [
845
+ {
846
+ uuid: 'set-member-uuid-3.1',
847
+ display: 'Set Member 3.1',
848
+ concept: { uuid: 'concept-uuid-3.1', display: 'Concept 3.1' },
849
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
850
+ hiAbsolute: 80,
851
+ lowAbsolute: 0,
852
+ lowCritical: null,
853
+ lowNormal: null,
854
+ units: 'mg/dL',
855
+ },
856
+ {
857
+ uuid: 'set-member-uuid-3.2',
858
+ display: 'Set Member 3.2',
859
+ concept: { uuid: 'concept-uuid-3.2', display: 'Concept 3.2' },
860
+ datatype: { display: 'Numeric', hl7Abbreviation: 'NM' },
861
+ hiAbsolute: 80,
862
+ lowAbsolute: 0,
863
+ lowCritical: null,
864
+ units: 'mg/dL',
865
+ },
866
+ ],
867
+ },
868
+ ],
869
+ datatype: { display: 'Numeric' },
870
+ hiAbsolute: 100,
871
+ lowAbsolute: 0,
872
+ lowCritical: null,
873
+ lowNormal: null,
874
+ hiCritical: null,
875
+ hiNormal: null,
876
+ units: 'mg/dL',
877
+ },
878
+ ] as unknown as LabOrderConcept[],
730
879
  isLoading: false,
731
880
  error: null,
732
881
  isValidating: false,