fhir-react 0.3.0 → 0.3.4
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/.github/workflows/publish_npmjs.yml +2 -0
- package/README.md +88 -5
- package/build/bootstrap-reboot.min.css +394 -0
- package/build/index.js +43 -0
- package/build/style.css +31 -0
- package/package.json +3 -2
- package/src/assets/containers/Patient/patient.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +7 -3
- package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
- package/src/components/resources/Appointment/Appointment.js +3 -3
- package/src/components/resources/Appointment/Appointment.stories.js +28 -5
- package/src/components/resources/Appointment/Appointment.test.js +72 -0
- package/src/components/resources/Condition/Condition.js +1 -2
- package/src/components/resources/Condition/Condition.stories.js +9 -19
- package/src/components/resources/Condition/Condition.test.js +71 -1
- package/src/components/resources/Encounter/Encounter.js +3 -4
- package/src/components/resources/Encounter/Encounter.stories.js +27 -5
- package/src/components/resources/Encounter/Encounter.test.js +72 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +26 -10
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +80 -3
- package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +21 -6
- package/src/components/resources/Immunization/Immunization.js +1 -2
- package/src/components/resources/Immunization/Immunization.stories.js +6 -9
- package/src/components/resources/Immunization/Immunization.test.js +71 -1
- package/src/components/resources/Observation/Observation.js +3 -3
- package/src/components/resources/Observation/Observation.stories.js +14 -5
- package/src/components/resources/Observation/Observation.test.js +67 -0
- package/src/components/resources/Patient/Patient.js +9 -6
- package/src/components/resources/Patient/Patient.stories.js +12 -5
- package/src/components/resources/Patient/Patient.test.js +67 -0
- package/src/components/resources/Practitioner/Practitioner.js +3 -13
- package/src/components/resources/Practitioner/Practitioner.stories.js +19 -3
- package/src/components/resources/Practitioner/Practitioner.test.js +72 -0
- package/src/components/resources/Procedure/Procedure.js +1 -2
- package/src/components/resources/Procedure/Procedure.stories.js +11 -5
- package/src/components/resources/Procedure/Procedure.test.js +71 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +6 -3
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +1 -1
- package/src/components/supportedFhirResourceList.js +2 -0
- package/src/components/ui/index.js +33 -25
- package/src/fixtures/example-icons.jsx +48 -10
- package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
- package/src/index.js +1 -0
- package/src/utils/convertCamelCaseToSentence.js +9 -0
- package/src/utils/convertCamelCaseToSentence.test.js +9 -0
- package/webpack.config.js +10 -1
|
@@ -9,8 +9,80 @@ import example2_STU3 from '../../../fixtures/stu3/resources/encounter/example-2.
|
|
|
9
9
|
import example1_R4 from '../../../fixtures/r4/resources/encounter/example1.json';
|
|
10
10
|
import example2_R4 from '../../../fixtures/r4/resources/encounter/example2.json';
|
|
11
11
|
import example3_R4 from '../../../fixtures/r4/resources/encounter/example3.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
13
|
|
|
13
14
|
describe('should render component correctly', () => {
|
|
15
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
fhirResource: example1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
22
|
+
const headerIcon = getByAltText('encounter');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<Encounter {...defaultProps} />);
|
|
35
|
+
const headerIcon = getByTestId('placeholder');
|
|
36
|
+
|
|
37
|
+
expect(headerIcon).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirResource: example1,
|
|
44
|
+
fhirIcons: (
|
|
45
|
+
<img
|
|
46
|
+
src={require('../assets/containers/Encounter/encounter.svg')}
|
|
47
|
+
alt="encounter"
|
|
48
|
+
/>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
53
|
+
const headerIcon = getByAltText('encounter');
|
|
54
|
+
|
|
55
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
59
|
+
const defaultProps = {
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirResource: example1,
|
|
62
|
+
fhirIcons: fhirIcons,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
66
|
+
const headerIcon = getByAltText('encounter');
|
|
67
|
+
|
|
68
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
72
|
+
const avatarSrc =
|
|
73
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirResource: example1,
|
|
77
|
+
fhirIcons: avatarSrc,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
81
|
+
const headerIcon = getByAltText('header icon');
|
|
82
|
+
|
|
83
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
84
|
+
});
|
|
85
|
+
|
|
14
86
|
it('DSTU2 - with PARTICIPANTS table', () => {
|
|
15
87
|
const defaultProps = {
|
|
16
88
|
fhirVersion: fhirVersions.DSTU2,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import CareTeam from './CareTeam';
|
|
15
15
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
16
16
|
import Coding from '../../datatypes/Coding';
|
|
17
|
+
import Quantity from '../../datatypes/Quantity';
|
|
17
18
|
import Date from '../../datatypes/Date';
|
|
18
19
|
import Diagnosis from './Diagnosis';
|
|
19
20
|
import Identifier from '../../datatypes/Identifier/Identifier';
|
|
@@ -80,9 +81,10 @@ const stu3DTO = fhirResource => {
|
|
|
80
81
|
services.map(serviceItem => {
|
|
81
82
|
const coding = _get(serviceItem, 'service.coding.0');
|
|
82
83
|
const servicedDate = _get(serviceItem, 'servicedDate');
|
|
84
|
+
const servicedPeriod = _get(serviceItem, 'servicedPeriod');
|
|
83
85
|
const quantity = _get(serviceItem, 'quantity.value');
|
|
84
86
|
const itemCost = _get(serviceItem, 'net');
|
|
85
|
-
return { coding, servicedDate, quantity, itemCost };
|
|
87
|
+
return { coding, servicedDate, servicedPeriod, quantity, itemCost };
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
return {
|
|
@@ -126,9 +128,10 @@ const r4DTO = fhirResource => {
|
|
|
126
128
|
services.map(serviceItem => {
|
|
127
129
|
const coding = _get(serviceItem, 'productOrService.coding.0');
|
|
128
130
|
const servicedDate = _get(serviceItem, 'servicedDate');
|
|
131
|
+
const servicedPeriod = _get(serviceItem, 'servicedPeriod');
|
|
129
132
|
const quantity = _get(serviceItem, 'quantity.value');
|
|
130
133
|
const itemCost = _get(serviceItem, 'net');
|
|
131
|
-
return { coding, servicedDate, quantity, itemCost };
|
|
134
|
+
return { coding, servicedDate, servicedPeriod, quantity, itemCost };
|
|
132
135
|
});
|
|
133
136
|
|
|
134
137
|
return {
|
|
@@ -225,8 +228,12 @@ const resourceDTO = (fhirVersion, fhirResource, withCarinBBProfile) => {
|
|
|
225
228
|
}
|
|
226
229
|
};
|
|
227
230
|
|
|
228
|
-
const ExplanationOfBenefit =
|
|
229
|
-
|
|
231
|
+
const ExplanationOfBenefit = ({
|
|
232
|
+
fhirResource,
|
|
233
|
+
fhirVersion,
|
|
234
|
+
withCarinBBProfile = false,
|
|
235
|
+
fhirIcons,
|
|
236
|
+
}) => {
|
|
230
237
|
let fhirResourceData = {};
|
|
231
238
|
try {
|
|
232
239
|
fhirResourceData = resourceDTO(
|
|
@@ -411,6 +418,7 @@ const ExplanationOfBenefit = props => {
|
|
|
411
418
|
</Value>
|
|
412
419
|
)
|
|
413
420
|
}
|
|
421
|
+
icon={fhirIcons}
|
|
414
422
|
/>
|
|
415
423
|
}
|
|
416
424
|
bodyContent={
|
|
@@ -453,11 +461,12 @@ const ExplanationOfBenefit = props => {
|
|
|
453
461
|
<Coding fhirData={serviceItem.coding} />
|
|
454
462
|
</TableCell>
|
|
455
463
|
<TableCell data-testid="explanation.servicedDate">
|
|
456
|
-
{serviceItem.servicedDate
|
|
464
|
+
{(serviceItem.servicedDate && (
|
|
457
465
|
<Date fhirData={serviceItem.servicedDate} />
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
|
|
466
|
+
)) ||
|
|
467
|
+
(serviceItem.servicedPeriod && (
|
|
468
|
+
<Period fhirData={serviceItem.servicedPeriod} />
|
|
469
|
+
)) || <MissingValue />}
|
|
461
470
|
</TableCell>
|
|
462
471
|
<TableCell data-testid="explanation.quantity">
|
|
463
472
|
{Number.isFinite(Number(serviceItem.quantity)) ? (
|
|
@@ -501,7 +510,14 @@ const ExplanationOfBenefit = props => {
|
|
|
501
510
|
informationItem,
|
|
502
511
|
'category.coding.0',
|
|
503
512
|
);
|
|
504
|
-
const
|
|
513
|
+
const infoKey = Object.keys(informationItem).filter(
|
|
514
|
+
key => {
|
|
515
|
+
return key !== 'sequence' && key !== 'category';
|
|
516
|
+
},
|
|
517
|
+
);
|
|
518
|
+
const infoStatus = _get(informationItem, infoKey);
|
|
519
|
+
const StatusComponent =
|
|
520
|
+
infoKey.toString() === 'timingDate' ? Date : Quantity;
|
|
505
521
|
|
|
506
522
|
return (
|
|
507
523
|
<TableRow key={`serviceItem-${i}`}>
|
|
@@ -514,7 +530,7 @@ const ExplanationOfBenefit = props => {
|
|
|
514
530
|
</TableCell>
|
|
515
531
|
<TableCell>
|
|
516
532
|
{infoStatus ? (
|
|
517
|
-
<
|
|
533
|
+
<StatusComponent fhirData={infoStatus} />
|
|
518
534
|
) : (
|
|
519
535
|
<MissingValue />
|
|
520
536
|
)}
|
|
@@ -12,6 +12,9 @@ import example2R4 from '../../../fixtures/r4/resources/explanationOfBenefit/eobF
|
|
|
12
12
|
import exampleC4BB from '../../../fixtures/r4/resources/explanationOfBenefit/c4bbExample.json';
|
|
13
13
|
import exampleC4BBExtendedDiagnosis from '../../../fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json';
|
|
14
14
|
|
|
15
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
16
|
+
import ExplanationOfBenefitIcon from '../../../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg';
|
|
17
|
+
|
|
15
18
|
export default {
|
|
16
19
|
title: 'ExplanationOfBenefit',
|
|
17
20
|
};
|
|
@@ -22,6 +25,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
22
25
|
<ExplanationOfBenefit
|
|
23
26
|
fhirVersion={fhirVersions.DSTU2}
|
|
24
27
|
fhirResource={fhirResource}
|
|
28
|
+
fhirIcons={require('../../../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg')}
|
|
25
29
|
/>
|
|
26
30
|
);
|
|
27
31
|
};
|
|
@@ -32,6 +36,7 @@ export const ExampleSTU3 = () => {
|
|
|
32
36
|
<ExplanationOfBenefit
|
|
33
37
|
fhirVersion={fhirVersions.STU3}
|
|
34
38
|
fhirResource={fhirResource}
|
|
39
|
+
fhirIcons={ExplanationOfBenefitIcon}
|
|
35
40
|
/>
|
|
36
41
|
);
|
|
37
42
|
};
|
|
@@ -41,6 +46,7 @@ export const Example2OfSTU3 = () => {
|
|
|
41
46
|
<ExplanationOfBenefit
|
|
42
47
|
fhirVersion={fhirVersions.STU3}
|
|
43
48
|
fhirResource={fhirResource}
|
|
49
|
+
fhirIcons={fhirIcons}
|
|
44
50
|
/>
|
|
45
51
|
);
|
|
46
52
|
};
|
|
@@ -50,6 +56,7 @@ export const PersonPrimaryCoverageR4 = () => {
|
|
|
50
56
|
<ExplanationOfBenefit
|
|
51
57
|
fhirVersion={fhirVersions.R4}
|
|
52
58
|
fhirResource={fhirResource}
|
|
59
|
+
fhirIcons={false}
|
|
53
60
|
/>
|
|
54
61
|
);
|
|
55
62
|
};
|
|
@@ -59,6 +66,7 @@ export const EOBForClaimWithErrorsR4 = () => {
|
|
|
59
66
|
<ExplanationOfBenefit
|
|
60
67
|
fhirVersion={fhirVersions.R4}
|
|
61
68
|
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={'random text'}
|
|
62
70
|
/>
|
|
63
71
|
);
|
|
64
72
|
};
|
|
@@ -9,8 +9,80 @@ import exampleC4BBExtendedDiagnosis from '../../../fixtures/r4/resources/explana
|
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
10
|
import { nbspRegex } from '../../../testUtils';
|
|
11
11
|
import { render } from '@testing-library/react';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
13
|
|
|
13
14
|
describe('should render ExplanationOfBenefit component properly', () => {
|
|
15
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
fhirResource: dstu2Example1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
22
|
+
const headerIcon = getByAltText('explanation of benefit');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
35
|
+
const headerIcon = getByTestId('placeholder');
|
|
36
|
+
|
|
37
|
+
expect(headerIcon).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirResource: dstu2Example1,
|
|
44
|
+
fhirIcons: (
|
|
45
|
+
<img
|
|
46
|
+
src={require('../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg.svg')}
|
|
47
|
+
alt="explanation of benefit"
|
|
48
|
+
/>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
53
|
+
const headerIcon = getByAltText('explanation of benefit');
|
|
54
|
+
|
|
55
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
59
|
+
const defaultProps = {
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirResource: dstu2Example1,
|
|
62
|
+
fhirIcons: fhirIcons,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
66
|
+
const headerIcon = getByAltText('explanation of benefit');
|
|
67
|
+
|
|
68
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
72
|
+
const avatarSrc =
|
|
73
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirResource: dstu2Example1,
|
|
77
|
+
fhirIcons: avatarSrc,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
81
|
+
const headerIcon = getByAltText('header icon');
|
|
82
|
+
|
|
83
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
84
|
+
});
|
|
85
|
+
|
|
14
86
|
it('should render with DSTU2 source data', () => {
|
|
15
87
|
const defaultProps = {
|
|
16
88
|
fhirResource: dstu2Example1,
|
|
@@ -200,13 +272,18 @@ describe('should render ExplanationOfBenefit component properly', () => {
|
|
|
200
272
|
'Condition/88bd5ac6-175b-5906-a4ee-6eedd667b0cc',
|
|
201
273
|
);
|
|
202
274
|
expect(getByTestId('diagnosisType').textContent).toContain('principal');
|
|
203
|
-
expect(getByTestId('supportingInfo.category').textContent).toContain(
|
|
275
|
+
expect(getByTestId('supportingInfo.0.category').textContent).toContain(
|
|
204
276
|
'clmrecvddate',
|
|
205
277
|
);
|
|
206
|
-
expect(getByTestId('supportingInfo.timingDate').textContent).toEqual(
|
|
278
|
+
expect(getByTestId('supportingInfo.0.timingDate').textContent).toEqual(
|
|
207
279
|
'1/5/2017',
|
|
208
280
|
);
|
|
209
|
-
|
|
281
|
+
expect(getByTestId('supportingInfo.1.category').textContent).toContain(
|
|
282
|
+
'dayssupply',
|
|
283
|
+
);
|
|
284
|
+
expect(getByTestId('supportingInfo.1.valueQuantity').textContent).toContain(
|
|
285
|
+
'30',
|
|
286
|
+
);
|
|
210
287
|
// checking if text content of each header cell is equal to mocked data
|
|
211
288
|
const headerCells = getAllByRole('columnheader')
|
|
212
289
|
.slice(0, 4)
|
|
@@ -4,6 +4,7 @@ import _get from 'lodash/get';
|
|
|
4
4
|
import { ValueSection, Value } from '../../ui/index';
|
|
5
5
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
6
6
|
import Date from '../../datatypes/Date';
|
|
7
|
+
import Quantity from '../../datatypes/Quantity';
|
|
7
8
|
|
|
8
9
|
const SupportingInfo = ({ fhirData }) => {
|
|
9
10
|
return fhirData.map((supportingInfo, index) => {
|
|
@@ -11,6 +12,7 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
11
12
|
const category = _get(supportingInfo, 'category');
|
|
12
13
|
const code = _get(supportingInfo, 'code ');
|
|
13
14
|
const timingDate = _get(supportingInfo, 'timingDate');
|
|
15
|
+
const valueQuantity = _get(supportingInfo, 'valueQuantity');
|
|
14
16
|
const timingPeriodStart = _get(supportingInfo, 'timingPeriod.start');
|
|
15
17
|
const timingPeriodEnd = _get(supportingInfo, 'timingPeriod.end');
|
|
16
18
|
|
|
@@ -18,20 +20,24 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
18
20
|
<div key={`total-${index}`}>
|
|
19
21
|
<ValueSection
|
|
20
22
|
label={`Supporting information ${sequence}.`}
|
|
21
|
-
data-testid=
|
|
23
|
+
data-testid={`supportingInfo.${index}`}
|
|
22
24
|
marginTop
|
|
23
25
|
>
|
|
24
26
|
{category && (
|
|
25
27
|
<Value
|
|
26
28
|
dirColumn
|
|
27
29
|
label="Category"
|
|
28
|
-
data-testid=
|
|
30
|
+
data-testid={`supportingInfo.${index}.category`}
|
|
29
31
|
>
|
|
30
32
|
<CodeableConcept fhirData={category} />
|
|
31
33
|
</Value>
|
|
32
34
|
)}
|
|
33
35
|
{code && (
|
|
34
|
-
<Value
|
|
36
|
+
<Value
|
|
37
|
+
dirColumn
|
|
38
|
+
label="Code"
|
|
39
|
+
data-testid={`supportingInfo.${index}.category`}
|
|
40
|
+
>
|
|
35
41
|
<CodeableConcept fhirData={code} />
|
|
36
42
|
</Value>
|
|
37
43
|
)}
|
|
@@ -39,16 +45,25 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
39
45
|
<Value
|
|
40
46
|
dirColumn
|
|
41
47
|
label="Date"
|
|
42
|
-
data-testid=
|
|
48
|
+
data-testid={`supportingInfo.${index}.timingDate`}
|
|
43
49
|
>
|
|
44
50
|
<Date fhirData={timingDate} />
|
|
45
51
|
</Value>
|
|
46
52
|
)}
|
|
53
|
+
{valueQuantity && (
|
|
54
|
+
<Value
|
|
55
|
+
dirColumn
|
|
56
|
+
label="Quantity"
|
|
57
|
+
data-testid={`supportingInfo.${index}.valueQuantity`}
|
|
58
|
+
>
|
|
59
|
+
<Quantity fhirData={valueQuantity} />
|
|
60
|
+
</Value>
|
|
61
|
+
)}
|
|
47
62
|
{timingPeriodStart && (
|
|
48
63
|
<Value
|
|
49
64
|
dirColumn
|
|
50
65
|
label="Start date"
|
|
51
|
-
data-testid=
|
|
66
|
+
data-testid={`supportingInfo.${index}.timingPeriodStart`}
|
|
52
67
|
>
|
|
53
68
|
<Date fhirData={timingPeriodStart} />
|
|
54
69
|
</Value>
|
|
@@ -57,7 +72,7 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
57
72
|
<Value
|
|
58
73
|
dirColumn
|
|
59
74
|
label="End date"
|
|
60
|
-
data-testid=
|
|
75
|
+
data-testid={`supportingInfo.${index}.timingPeriodEnd`}
|
|
61
76
|
>
|
|
62
77
|
<Date fhirData={timingPeriodEnd} />
|
|
63
78
|
</Value>
|
|
@@ -125,7 +125,6 @@ const Immunization = props => {
|
|
|
125
125
|
note,
|
|
126
126
|
} = resourceDTO(fhirVersion, fhirResource);
|
|
127
127
|
|
|
128
|
-
const headerIcon = fhirIcons[_get(fhirResource, 'resourceType')];
|
|
129
128
|
const tableData = [
|
|
130
129
|
{
|
|
131
130
|
label: 'Manufacturer Text',
|
|
@@ -237,7 +236,7 @@ const Immunization = props => {
|
|
|
237
236
|
)
|
|
238
237
|
}
|
|
239
238
|
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
240
|
-
icon={
|
|
239
|
+
icon={fhirIcons}
|
|
241
240
|
title={title}
|
|
242
241
|
/>
|
|
243
242
|
}
|
|
@@ -11,6 +11,7 @@ import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.jso
|
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
|
|
12
12
|
import r4Example3 from '../../../fixtures/r4/resources/immunization/example3.json';
|
|
13
13
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
|
+
import ImmunizationIcon from '../../../assets/containers/Immunization/immunization.svg';
|
|
14
15
|
|
|
15
16
|
export default {
|
|
16
17
|
title: 'Immunization',
|
|
@@ -22,7 +23,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
22
23
|
<Immunization
|
|
23
24
|
fhirResource={fhirResource}
|
|
24
25
|
fhirVersion={fhirVersions.DSTU2}
|
|
25
|
-
fhirIcons={
|
|
26
|
+
fhirIcons={require('../../../assets/containers/Immunization/immunization.svg')}
|
|
26
27
|
/>
|
|
27
28
|
);
|
|
28
29
|
};
|
|
@@ -33,7 +34,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
33
34
|
<Immunization
|
|
34
35
|
fhirResource={fhirResource}
|
|
35
36
|
fhirVersion={fhirVersions.DSTU2}
|
|
36
|
-
fhirIcons={
|
|
37
|
+
fhirIcons={ImmunizationIcon}
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
39
40
|
};
|
|
@@ -55,7 +56,7 @@ export const Example1R4 = () => {
|
|
|
55
56
|
<Immunization
|
|
56
57
|
fhirResource={fhirResource}
|
|
57
58
|
fhirVersion={fhirVersions.R4}
|
|
58
|
-
fhirIcons={
|
|
59
|
+
fhirIcons={false}
|
|
59
60
|
/>
|
|
60
61
|
);
|
|
61
62
|
};
|
|
@@ -65,17 +66,13 @@ export const Example2R4 = () => {
|
|
|
65
66
|
<Immunization
|
|
66
67
|
fhirResource={fhirResource}
|
|
67
68
|
fhirVersion={fhirVersions.R4}
|
|
68
|
-
fhirIcons={
|
|
69
|
+
fhirIcons={'random text'}
|
|
69
70
|
/>
|
|
70
71
|
);
|
|
71
72
|
};
|
|
72
73
|
export const Example3R4 = () => {
|
|
73
74
|
const fhirResource = object('Resource', r4Example3);
|
|
74
75
|
return (
|
|
75
|
-
<Immunization
|
|
76
|
-
fhirResource={fhirResource}
|
|
77
|
-
fhirVersion={fhirVersions.R4}
|
|
78
|
-
fhirIcons={fhirIcons}
|
|
79
|
-
/>
|
|
76
|
+
<Immunization fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
|
|
80
77
|
);
|
|
81
78
|
};
|
|
@@ -6,10 +6,80 @@ import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.jso
|
|
|
6
6
|
import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
|
|
7
7
|
import { render } from '@testing-library/react';
|
|
8
8
|
import stu3Example from '../../../fixtures/stu3/resources/immunization/example1.json';
|
|
9
|
-
|
|
10
9
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
10
|
|
|
12
11
|
describe('should render Immunization component properly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
fhirResource: dstu2Example,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('immunization');
|
|
20
|
+
|
|
21
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
25
|
+
const defaultProps = {
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirResource: dstu2Example,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<Immunization {...defaultProps} />);
|
|
32
|
+
const headerIcon = getByTestId('placeholder');
|
|
33
|
+
|
|
34
|
+
expect(headerIcon).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
38
|
+
const defaultProps = {
|
|
39
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
40
|
+
fhirResource: dstu2Example,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/Immunization/immunization.svg')}
|
|
44
|
+
alt="immunization"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('immunization');
|
|
51
|
+
|
|
52
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
56
|
+
const defaultProps = {
|
|
57
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
58
|
+
fhirResource: dstu2Example,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('immunization');
|
|
64
|
+
|
|
65
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
69
|
+
const avatarSrc =
|
|
70
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
71
|
+
const defaultProps = {
|
|
72
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
73
|
+
fhirResource: dstu2Example,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
13
83
|
it('should render with DSTU2 source data', () => {
|
|
14
84
|
const defaultProps = {
|
|
15
85
|
fhirResource: dstu2Example,
|
|
@@ -18,8 +18,7 @@ import {
|
|
|
18
18
|
} from '../../ui';
|
|
19
19
|
import Reference from '../../datatypes/Reference';
|
|
20
20
|
|
|
21
|
-
const Observation =
|
|
22
|
-
const { fhirResource } = props;
|
|
21
|
+
const Observation = ({ fhirResource, fhirIcons }) => {
|
|
23
22
|
const effectiveDate = _get(fhirResource, 'effectiveDateTime');
|
|
24
23
|
const codeCodingDisplay = _get(fhirResource, 'code.coding.0.display');
|
|
25
24
|
const codeText = _get(fhirResource, 'code.text', '');
|
|
@@ -72,7 +71,7 @@ const Observation = props => {
|
|
|
72
71
|
<Accordion
|
|
73
72
|
headerContent={
|
|
74
73
|
<Header
|
|
75
|
-
resourceName=
|
|
74
|
+
resourceName="Observation"
|
|
76
75
|
additionalContent={
|
|
77
76
|
issued && (
|
|
78
77
|
<Value label="Start date" data-testid="headerStartDate">
|
|
@@ -104,6 +103,7 @@ const Observation = props => {
|
|
|
104
103
|
small
|
|
105
104
|
/>
|
|
106
105
|
}
|
|
106
|
+
icon={fhirIcons}
|
|
107
107
|
/>
|
|
108
108
|
}
|
|
109
109
|
bodyContent={
|
|
@@ -12,32 +12,41 @@ import example3ObservationExcessSTU3 from '../../../fixtures/stu3/resources/obse
|
|
|
12
12
|
import example1ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example1.json';
|
|
13
13
|
import example2ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example2.json';
|
|
14
14
|
import example3ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example3.json';
|
|
15
|
+
import ObservationIcon from '../../../assets/containers/Observation/observation.svg';
|
|
16
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
15
17
|
|
|
16
18
|
export default { title: 'Observation' };
|
|
17
19
|
|
|
18
20
|
export const DefaultVisualizationDSTU2 = () => {
|
|
19
21
|
const fhirResource = object('Resource', exampleObservationIssued);
|
|
20
|
-
return
|
|
22
|
+
return (
|
|
23
|
+
<Observation
|
|
24
|
+
fhirResource={fhirResource}
|
|
25
|
+
fhirIcons={require('../../../assets/containers/Observation/observation.svg')}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
21
28
|
};
|
|
22
29
|
|
|
23
30
|
export const ExampleWithoutIssuedDSTU2 = () => {
|
|
24
31
|
const fhirResource = object('Resource', exampleObservation);
|
|
25
|
-
return
|
|
32
|
+
return (
|
|
33
|
+
<Observation fhirResource={fhirResource} fhirIcons={ObservationIcon} />
|
|
34
|
+
);
|
|
26
35
|
};
|
|
27
36
|
|
|
28
37
|
export const ExampleWithIssuedSTU3 = () => {
|
|
29
38
|
const fhirResource = object('Resource', exampleObservationExcessSTU3);
|
|
30
|
-
return <Observation fhirResource={fhirResource} />;
|
|
39
|
+
return <Observation fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
31
40
|
};
|
|
32
41
|
|
|
33
42
|
export const ExampleWithoutIssuedSTU3 = () => {
|
|
34
43
|
const fhirResource = object('Resource', exampleObservationSTU3);
|
|
35
|
-
return <Observation fhirResource={fhirResource} />;
|
|
44
|
+
return <Observation fhirResource={fhirResource} fhirIcons={false} />;
|
|
36
45
|
};
|
|
37
46
|
|
|
38
47
|
export const Example3OfSTU3 = () => {
|
|
39
48
|
const fhirResource = object('Resource', example3ObservationExcessSTU3);
|
|
40
|
-
return <Observation fhirResource={fhirResource} />;
|
|
49
|
+
return <Observation fhirResource={fhirResource} fhirIcons={'random text'} />;
|
|
41
50
|
};
|
|
42
51
|
|
|
43
52
|
export const Example1OfR4 = () => {
|