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
|
@@ -11,8 +11,75 @@ import exampleObservationExcessSTU3 from '../../../fixtures/stu3/resources/obser
|
|
|
11
11
|
|
|
12
12
|
import example1ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example2.json';
|
|
13
13
|
import example2ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example3.json';
|
|
14
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
15
|
|
|
15
16
|
describe('should render component correctly', () => {
|
|
17
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
18
|
+
const defaultProps = {
|
|
19
|
+
fhirResource: exampleObservationIssued,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const { getByAltText } = render(<Observation {...defaultProps} />);
|
|
23
|
+
const headerIcon = getByAltText('observation');
|
|
24
|
+
|
|
25
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
29
|
+
const defaultProps = {
|
|
30
|
+
fhirResource: exampleObservationIssued,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<Observation {...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
|
+
fhirResource: exampleObservationIssued,
|
|
43
|
+
fhirIcons: (
|
|
44
|
+
<img
|
|
45
|
+
src={require('../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg')}
|
|
46
|
+
alt="observation"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { getByAltText } = render(<Observation {...defaultProps} />);
|
|
52
|
+
const headerIcon = getByAltText('observation');
|
|
53
|
+
|
|
54
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
58
|
+
const defaultProps = {
|
|
59
|
+
fhirResource: exampleObservationIssued,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<Observation {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('observation');
|
|
65
|
+
|
|
66
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
70
|
+
const avatarSrc =
|
|
71
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
72
|
+
const defaultProps = {
|
|
73
|
+
fhirResource: exampleObservationIssued,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<Observation {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
16
83
|
test('DSTU2 renders properly', () => {
|
|
17
84
|
const defaultProps = {
|
|
18
85
|
fhirResource: exampleObservationIssued,
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
4
|
import _isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import md5 from 'md5';
|
|
6
5
|
|
|
7
6
|
import HumanName from '../../datatypes/HumanName';
|
|
8
7
|
import Telecom from '../../datatypes/Telecom';
|
|
@@ -41,11 +40,15 @@ export function getGender(fhirResource) {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
function Patient(props) {
|
|
44
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
fhirResource,
|
|
45
|
+
fhirVersion,
|
|
46
|
+
renderName,
|
|
47
|
+
patientSimple,
|
|
48
|
+
fhirIcons,
|
|
49
|
+
} = props;
|
|
45
50
|
|
|
46
51
|
const id = getId(fhirResource);
|
|
47
|
-
const idHash = md5(id || '');
|
|
48
|
-
const avatarSrc = `http://www.gravatar.com/avatar/${idHash}?s=50&r=any&default=identicon&forcedefault=1`;
|
|
49
52
|
const patientName = getNames(fhirResource);
|
|
50
53
|
const patientBirthDate = getBirthDate(fhirResource);
|
|
51
54
|
const patientGender = getGender(fhirResource);
|
|
@@ -118,7 +121,7 @@ function Patient(props) {
|
|
|
118
121
|
<Accordion
|
|
119
122
|
headerContent={
|
|
120
123
|
<Header
|
|
121
|
-
resourceName=
|
|
124
|
+
resourceName="Patient"
|
|
122
125
|
additionalContent={
|
|
123
126
|
patientBirthDate && (
|
|
124
127
|
<span className="text-gray-600">
|
|
@@ -130,7 +133,7 @@ function Patient(props) {
|
|
|
130
133
|
</span>
|
|
131
134
|
)
|
|
132
135
|
}
|
|
133
|
-
icon={
|
|
136
|
+
icon={fhirIcons}
|
|
134
137
|
badges={
|
|
135
138
|
active && <Badge data-testid="activeStatus">{activeStatus}</Badge>
|
|
136
139
|
}
|
|
@@ -12,32 +12,39 @@ import example2PatientSTU3 from '../../../fixtures/stu3/resources/patient/exampl
|
|
|
12
12
|
import example1PatientR4 from '../../../fixtures/r4/resources/patient/example1.json';
|
|
13
13
|
import example2PatientR4 from '../../../fixtures/r4/resources/patient/example2.json';
|
|
14
14
|
import example3PatientR4 from '../../../fixtures/r4/resources/patient/example3.json';
|
|
15
|
+
import PatientIcon from '../../../assets/containers/Patient/patient.svg';
|
|
16
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
15
17
|
|
|
16
18
|
export default { title: 'Patient' };
|
|
17
19
|
|
|
18
20
|
export const DefaultVisualizationDSTU2 = () => {
|
|
19
21
|
const fhirResource = object('Resource', examplePatient);
|
|
20
|
-
return
|
|
22
|
+
return (
|
|
23
|
+
<Patient
|
|
24
|
+
fhirResource={fhirResource}
|
|
25
|
+
fhirIcons={require('../../../assets/containers/Patient/patient.svg')}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
21
28
|
};
|
|
22
29
|
|
|
23
30
|
export const Example2OfDSTU2 = () => {
|
|
24
31
|
const fhirResource = object('Resource', example2PatientDSTU2);
|
|
25
|
-
return <Patient fhirResource={fhirResource} />;
|
|
32
|
+
return <Patient fhirResource={fhirResource} fhirIcons={PatientIcon} />;
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
export const ExampleSTU3 = () => {
|
|
29
36
|
const fhirResource = object('Resource', examplePatientSTU3);
|
|
30
|
-
return <Patient fhirResource={fhirResource} />;
|
|
37
|
+
return <Patient fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
31
38
|
};
|
|
32
39
|
|
|
33
40
|
export const Example2STU3 = () => {
|
|
34
41
|
const fhirResource = object('Resource', example2PatientSTU3);
|
|
35
|
-
return <Patient fhirResource={fhirResource} />;
|
|
42
|
+
return <Patient fhirResource={fhirResource} fhirIcons={false} />;
|
|
36
43
|
};
|
|
37
44
|
|
|
38
45
|
export const Example1R4 = () => {
|
|
39
46
|
const fhirResource = object('Resource', example1PatientR4);
|
|
40
|
-
return <Patient fhirResource={fhirResource} />;
|
|
47
|
+
return <Patient fhirResource={fhirResource} fhirIcons={'random text'} />;
|
|
41
48
|
};
|
|
42
49
|
|
|
43
50
|
export const Example2R4 = () => {
|
|
@@ -7,8 +7,75 @@ import examplePatientSTU3 from '../../../fixtures/stu3/resources/patient/example
|
|
|
7
7
|
import example2PatientSTU3 from '../../../fixtures/stu3/resources/patient/example2.json';
|
|
8
8
|
import example1PatientR4 from '../../../fixtures/r4/resources/patient/example1.json';
|
|
9
9
|
import example3PatientR4 from '../../../fixtures/r4/resources/patient/example3.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render component correctly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirResource: examplePatient,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<Patient {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('patient');
|
|
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
|
+
fhirResource: examplePatient,
|
|
27
|
+
fhirIcons: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const { getByTestId } = render(<Patient {...defaultProps} />);
|
|
31
|
+
const headerIcon = getByTestId('placeholder');
|
|
32
|
+
|
|
33
|
+
expect(headerIcon).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
37
|
+
const defaultProps = {
|
|
38
|
+
fhirResource: examplePatient,
|
|
39
|
+
fhirIcons: (
|
|
40
|
+
<img
|
|
41
|
+
src={require('../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg.svg')}
|
|
42
|
+
alt="patient"
|
|
43
|
+
/>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const { getByAltText } = render(<Patient {...defaultProps} />);
|
|
48
|
+
const headerIcon = getByAltText('patient');
|
|
49
|
+
|
|
50
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
54
|
+
const defaultProps = {
|
|
55
|
+
fhirResource: examplePatient,
|
|
56
|
+
fhirIcons: fhirIcons,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const { getByAltText } = render(<Patient {...defaultProps} />);
|
|
60
|
+
const headerIcon = getByAltText('patient');
|
|
61
|
+
|
|
62
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
66
|
+
const avatarSrc =
|
|
67
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
68
|
+
const defaultProps = {
|
|
69
|
+
fhirResource: examplePatient,
|
|
70
|
+
fhirIcons: avatarSrc,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const { getByAltText } = render(<Patient {...defaultProps} />);
|
|
74
|
+
const headerIcon = getByAltText('header icon');
|
|
75
|
+
|
|
76
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
77
|
+
});
|
|
78
|
+
|
|
12
79
|
it('DSTU2', () => {
|
|
13
80
|
const defaultProps = {
|
|
14
81
|
fhirResource: examplePatient,
|
|
@@ -15,7 +15,6 @@ import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
|
15
15
|
import _get from 'lodash/get';
|
|
16
16
|
import _has from 'lodash/has';
|
|
17
17
|
import fhirVersions from '../fhirResourceVersions';
|
|
18
|
-
import md5 from 'md5';
|
|
19
18
|
|
|
20
19
|
const commonDTO = fhirResource => {
|
|
21
20
|
const id = _get(fhirResource, 'id', '');
|
|
@@ -83,8 +82,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
83
82
|
}
|
|
84
83
|
};
|
|
85
84
|
|
|
86
|
-
const Practitioner =
|
|
87
|
-
const { fhirResource, fhirVersion } = props;
|
|
85
|
+
const Practitioner = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
88
86
|
let fhirResourceData = {};
|
|
89
87
|
try {
|
|
90
88
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -93,7 +91,6 @@ const Practitioner = props => {
|
|
|
93
91
|
return <UnhandledResourceDataStructure resourceName="Practitioner" />;
|
|
94
92
|
}
|
|
95
93
|
const {
|
|
96
|
-
id,
|
|
97
94
|
identifier,
|
|
98
95
|
name,
|
|
99
96
|
gender,
|
|
@@ -155,17 +152,10 @@ const Practitioner = props => {
|
|
|
155
152
|
<Accordion
|
|
156
153
|
headerContent={
|
|
157
154
|
<Header
|
|
155
|
+
resourceName="Practitioner"
|
|
158
156
|
additionalContent={<p className="mb-0">{`(${use})`}</p>}
|
|
159
157
|
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
160
|
-
icon={
|
|
161
|
-
<img
|
|
162
|
-
className="header-icon__practitioner-avatar rounded-1"
|
|
163
|
-
src={`http://www.gravatar.com/avatar/${md5(
|
|
164
|
-
id,
|
|
165
|
-
)}?s=30&r=any&default=identicon&forcedefault=1`}
|
|
166
|
-
alt=""
|
|
167
|
-
/>
|
|
168
|
-
}
|
|
158
|
+
icon={fhirIcons}
|
|
169
159
|
title={<HumanName fhirData={name} isTitle />}
|
|
170
160
|
/>
|
|
171
161
|
}
|
|
@@ -11,6 +11,8 @@ import stu3Example1 from '../../../fixtures/stu3/resources/practitioner/example-
|
|
|
11
11
|
import r4Example1 from '../../../fixtures/r4/resources/practitioner/example1.json';
|
|
12
12
|
import r4Example2 from '../../../fixtures/r4/resources/practitioner/example2.json';
|
|
13
13
|
import r4Example3 from '../../../fixtures/r4/resources/practitioner/example3.json';
|
|
14
|
+
import PractitionerIcon from '../../../assets/containers/Practitioner/practitioner.svg';
|
|
15
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
16
|
|
|
15
17
|
export default { title: 'Practitioner' };
|
|
16
18
|
|
|
@@ -20,6 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
20
22
|
<Practitioner
|
|
21
23
|
fhirVersion={fhirVersions.DSTU2}
|
|
22
24
|
fhirResource={fhirResource}
|
|
25
|
+
fhirIcons={require('../../../assets/containers/Practitioner/practitioner.svg')}
|
|
23
26
|
/>
|
|
24
27
|
);
|
|
25
28
|
};
|
|
@@ -30,6 +33,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
30
33
|
<Practitioner
|
|
31
34
|
fhirVersion={fhirVersions.DSTU2}
|
|
32
35
|
fhirResource={fhirResource}
|
|
36
|
+
fhirIcons={PractitionerIcon}
|
|
33
37
|
/>
|
|
34
38
|
);
|
|
35
39
|
};
|
|
@@ -37,21 +41,33 @@ export const Example2OfDSTU2 = () => {
|
|
|
37
41
|
export const ExampleOfSTU3 = () => {
|
|
38
42
|
const fhirResource = object('Resource', stu3Example1);
|
|
39
43
|
return (
|
|
40
|
-
<Practitioner
|
|
44
|
+
<Practitioner
|
|
45
|
+
fhirVersion={fhirVersions.STU3}
|
|
46
|
+
fhirResource={fhirResource}
|
|
47
|
+
fhirIcons={fhirIcons}
|
|
48
|
+
/>
|
|
41
49
|
);
|
|
42
50
|
};
|
|
43
51
|
|
|
44
52
|
export const Example1OfR4 = () => {
|
|
45
53
|
const fhirResource = object('Resource', r4Example1);
|
|
46
54
|
return (
|
|
47
|
-
<Practitioner
|
|
55
|
+
<Practitioner
|
|
56
|
+
fhirVersion={fhirVersions.R4}
|
|
57
|
+
fhirResource={fhirResource}
|
|
58
|
+
fhirIcons={false}
|
|
59
|
+
/>
|
|
48
60
|
);
|
|
49
61
|
};
|
|
50
62
|
|
|
51
63
|
export const Example2OfR4 = () => {
|
|
52
64
|
const fhirResource = object('Resource', r4Example2);
|
|
53
65
|
return (
|
|
54
|
-
<Practitioner
|
|
66
|
+
<Practitioner
|
|
67
|
+
fhirVersion={fhirVersions.R4}
|
|
68
|
+
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={'random text'}
|
|
70
|
+
/>
|
|
55
71
|
);
|
|
56
72
|
};
|
|
57
73
|
|
|
@@ -7,8 +7,80 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/practitioner/exampl
|
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/practitioner/example-1.json';
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/practitioner/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/practitioner/example3.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('Practitioner should render component correctly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
16
|
+
fhirResource: dstu2Example1,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<Practitioner {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('practitioner');
|
|
21
|
+
|
|
22
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
28
|
+
fhirResource: dstu2Example1,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<Practitioner {...defaultProps} />);
|
|
33
|
+
const headerIcon = getByTestId('placeholder');
|
|
34
|
+
|
|
35
|
+
expect(headerIcon).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
41
|
+
fhirResource: dstu2Example1,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/Practitioner/practitioner.svg')}
|
|
45
|
+
alt="practitioner"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<Practitioner {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('practitioner');
|
|
52
|
+
|
|
53
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
57
|
+
const defaultProps = {
|
|
58
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
59
|
+
fhirResource: dstu2Example1,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<Practitioner {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('practitioner');
|
|
65
|
+
|
|
66
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
70
|
+
const avatarSrc =
|
|
71
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
72
|
+
const defaultProps = {
|
|
73
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
74
|
+
fhirResource: dstu2Example1,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<Practitioner {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
83
|
+
|
|
12
84
|
it('should render component correctly with DSTU2 source data', () => {
|
|
13
85
|
const defaultProps = {
|
|
14
86
|
fhirVersion: fhirVersions.DSTU2,
|
|
@@ -37,7 +37,6 @@ const Procedure = props => {
|
|
|
37
37
|
const note = _get(fhirResource, 'note', []);
|
|
38
38
|
const outcome = _get(fhirResource, 'outcome');
|
|
39
39
|
|
|
40
|
-
const headerIcon = fhirIcons[_get(fhirResource, 'resourceType')];
|
|
41
40
|
const tableData = [
|
|
42
41
|
{
|
|
43
42
|
label: 'Identification',
|
|
@@ -121,7 +120,7 @@ const Procedure = props => {
|
|
|
121
120
|
</>
|
|
122
121
|
}
|
|
123
122
|
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
124
|
-
icon={
|
|
123
|
+
icon={fhirIcons}
|
|
125
124
|
title={display}
|
|
126
125
|
/>
|
|
127
126
|
}
|
|
@@ -12,17 +12,23 @@ import r4Example2 from '../../../fixtures/r4/resources/procedure/example2.json';
|
|
|
12
12
|
import r4Example3 from '../../../fixtures/r4/resources/procedure/example3.json';
|
|
13
13
|
|
|
14
14
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
15
|
+
import ProcedureIcon from '../../../assets/containers/Procedure/procedure.svg';
|
|
15
16
|
|
|
16
17
|
export default { title: 'Procedure' };
|
|
17
18
|
|
|
18
19
|
export const DefaultVisualizationDSTU2 = () => {
|
|
19
20
|
const fhirResource = object('Resource', example1);
|
|
20
|
-
return
|
|
21
|
+
return (
|
|
22
|
+
<Procedure
|
|
23
|
+
fhirResource={fhirResource}
|
|
24
|
+
fhirIcons={require('../../../assets/containers/Procedure/procedure.svg')}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
export const ExampleOfSTU3 = () => {
|
|
24
30
|
const fhirResource = object('Resource', stu3Example1);
|
|
25
|
-
return <Procedure fhirResource={fhirResource} fhirIcons={
|
|
31
|
+
return <Procedure fhirResource={fhirResource} fhirIcons={ProcedureIcon} />;
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
export const Example2OfSTU3 = () => {
|
|
@@ -32,15 +38,15 @@ export const Example2OfSTU3 = () => {
|
|
|
32
38
|
|
|
33
39
|
export const Example1OfR4 = () => {
|
|
34
40
|
const fhirResource = object('Resource', r4Example1);
|
|
35
|
-
return <Procedure fhirResource={fhirResource} fhirIcons={
|
|
41
|
+
return <Procedure fhirResource={fhirResource} fhirIcons={false} />;
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
export const Example2OfR4 = () => {
|
|
39
45
|
const fhirResource = object('Resource', r4Example2);
|
|
40
|
-
return <Procedure fhirResource={fhirResource} fhirIcons={
|
|
46
|
+
return <Procedure fhirResource={fhirResource} fhirIcons={'random text'} />;
|
|
41
47
|
};
|
|
42
48
|
|
|
43
49
|
export const Example3OfR4 = () => {
|
|
44
50
|
const fhirResource = object('Resource', r4Example3);
|
|
45
|
-
return <Procedure fhirResource={fhirResource}
|
|
51
|
+
return <Procedure fhirResource={fhirResource} />;
|
|
46
52
|
};
|
|
@@ -5,10 +5,80 @@ import r4Example2 from '../../../fixtures/r4/resources/procedure/example2.json';
|
|
|
5
5
|
import r4Example3 from '../../../fixtures/r4/resources/procedure/example3.json';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/procedure/example1.json';
|
|
8
|
-
|
|
9
8
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
|
+
import fhirVersions from '../fhirResourceVersions';
|
|
10
10
|
|
|
11
11
|
describe('Procedure should render component correctly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
fhirResource: dstu2Example1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<Procedure {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('procedure');
|
|
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: dstu2Example1,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<Procedure {...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: dstu2Example1,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/Procedure/procedure.svg')}
|
|
44
|
+
alt="procedure"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<Procedure {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('procedure');
|
|
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: dstu2Example1,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<Procedure {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('procedure');
|
|
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
|
+
fhirResource: dstu2Example1,
|
|
73
|
+
fhirIcons: avatarSrc,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const { getByAltText } = render(<Procedure {...defaultProps} />);
|
|
77
|
+
const headerIcon = getByAltText('header icon');
|
|
78
|
+
|
|
79
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
80
|
+
});
|
|
81
|
+
|
|
12
82
|
it('should render component correctly with DSTU2 source data', () => {
|
|
13
83
|
const defaultProps = {
|
|
14
84
|
fhirResource: dstu2Example1,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Root, Title } from '../../ui';
|
|
2
|
-
import ChevronRight from '../../../assets/common/chevron-right.svg';
|
|
3
2
|
import HeaderIcon from '../../datatypes/HeaderIcon';
|
|
4
3
|
import React from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import { isUrl } from '../../../utils/isUrl';
|
|
6
6
|
|
|
7
7
|
const ResourceCategory = props => {
|
|
8
8
|
const { title, itemsCount, fhirIcons } = props;
|
|
@@ -13,7 +13,10 @@ const ResourceCategory = props => {
|
|
|
13
13
|
const getItemsCountLabel = () =>
|
|
14
14
|
`${parsedItemsCount} ${parsedItemsCount === 1 ? 'item' : 'items'}`;
|
|
15
15
|
|
|
16
|
-
const headerIcon = fhirIcons
|
|
16
|
+
const headerIcon = isUrl(fhirIcons)
|
|
17
|
+
? fhirIcons
|
|
18
|
+
: fhirIcons && fhirIcons['ResourceCategory'];
|
|
19
|
+
|
|
17
20
|
const parsedItemsCount = parseNumber(itemsCount);
|
|
18
21
|
|
|
19
22
|
return (
|
|
@@ -38,7 +41,7 @@ const ResourceCategory = props => {
|
|
|
38
41
|
</div>
|
|
39
42
|
)}
|
|
40
43
|
<img
|
|
41
|
-
src={
|
|
44
|
+
src={require('../../../assets/common/chevron-right.svg')}
|
|
42
45
|
alt="chevron"
|
|
43
46
|
style={{ height: 28, width: 28 }}
|
|
44
47
|
/>
|
|
@@ -5,7 +5,7 @@ import fhirIcons from '../../../fixtures/example-icons';
|
|
|
5
5
|
import ResourceCategory from './ResourceCategory';
|
|
6
6
|
|
|
7
7
|
describe('should render ResourceCategory component properly', () => {
|
|
8
|
-
const placeholderResource = fhirIcons['
|
|
8
|
+
const placeholderResource = fhirIcons['ResourceCategory'].props;
|
|
9
9
|
|
|
10
10
|
it('should render ResourceCategory component with icon and itemsCount > 1 correctly', () => {
|
|
11
11
|
const defaultProps = {
|
|
@@ -37,6 +37,7 @@ import Questionnaire from './resources/Questionnaire';
|
|
|
37
37
|
import QuestionnaireResponse from './resources/QuestionnaireResponse';
|
|
38
38
|
import ReferralRequest from './resources/ReferralRequest';
|
|
39
39
|
import ResearchStudy from './resources/ResearchStudy';
|
|
40
|
+
import ResourceCategory from './resources/ResourceCategory';
|
|
40
41
|
|
|
41
42
|
export {
|
|
42
43
|
Appointment,
|
|
@@ -78,4 +79,5 @@ export {
|
|
|
78
79
|
QuestionnaireResponse,
|
|
79
80
|
ReferralRequest,
|
|
80
81
|
ResearchStudy,
|
|
82
|
+
ResourceCategory,
|
|
81
83
|
};
|