fhir-react 0.3.3 → 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/README.md +85 -2
- package/build/index.js +7 -14
- package/package.json +1 -1
- 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 -3
- 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 +7 -2
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +72 -0
- 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 +5 -1
- package/src/components/ui/index.js +33 -25
- package/src/fixtures/example-icons.jsx +47 -9
- package/src/utils/convertCamelCaseToSentence.js +9 -0
- package/src/utils/convertCamelCaseToSentence.test.js +9 -0
|
@@ -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 && 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,
|
|
@@ -2,6 +2,7 @@ import { Root, Title } from '../../ui';
|
|
|
2
2
|
import HeaderIcon from '../../datatypes/HeaderIcon';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import { isUrl } from '../../../utils/isUrl';
|
|
5
6
|
|
|
6
7
|
const ResourceCategory = props => {
|
|
7
8
|
const { title, itemsCount, fhirIcons } = props;
|
|
@@ -12,7 +13,10 @@ const ResourceCategory = props => {
|
|
|
12
13
|
const getItemsCountLabel = () =>
|
|
13
14
|
`${parsedItemsCount} ${parsedItemsCount === 1 ? 'item' : 'items'}`;
|
|
14
15
|
|
|
15
|
-
const headerIcon = fhirIcons
|
|
16
|
+
const headerIcon = isUrl(fhirIcons)
|
|
17
|
+
? fhirIcons
|
|
18
|
+
: fhirIcons && fhirIcons['ResourceCategory'];
|
|
19
|
+
|
|
16
20
|
const parsedItemsCount = parseNumber(itemsCount);
|
|
17
21
|
|
|
18
22
|
return (
|
|
@@ -3,62 +3,70 @@ import React from 'react';
|
|
|
3
3
|
import { getBadgeColor } from '../../utils/getBadgeColor';
|
|
4
4
|
import HeaderIcon from '../datatypes/HeaderIcon';
|
|
5
5
|
|
|
6
|
-
export const Header =
|
|
6
|
+
export const Header = ({
|
|
7
|
+
resourceName,
|
|
8
|
+
isAccordionOpenable,
|
|
9
|
+
icon,
|
|
10
|
+
titleTestID,
|
|
11
|
+
title,
|
|
12
|
+
prefixBadge,
|
|
13
|
+
badges,
|
|
14
|
+
additionalBadge,
|
|
15
|
+
additionalContent,
|
|
16
|
+
rightAdditionalContent,
|
|
17
|
+
children,
|
|
18
|
+
}) => {
|
|
7
19
|
const rightItemsClass = 'align-items-center flex-fill d-flex';
|
|
8
20
|
|
|
9
21
|
return (
|
|
10
22
|
<>
|
|
11
23
|
{// This condition was left due to fact, that to much changes in Header will generate many errors in tests. This condition will be removed after all changes have been made.
|
|
12
|
-
|
|
24
|
+
children || (
|
|
13
25
|
<div
|
|
14
|
-
className={`fhir-ui__${
|
|
26
|
+
className={`fhir-ui__${resourceName}-Header w-100 p-4 position-relative`}
|
|
15
27
|
>
|
|
16
28
|
<div
|
|
17
|
-
className={`fhir-ui__${
|
|
18
|
-
|
|
29
|
+
className={`fhir-ui__${resourceName}-Header__title-data ${
|
|
30
|
+
isAccordionOpenable ? 'header__title-row' : ''
|
|
19
31
|
} d-flex w-100 flex-column flex-sm-row`}
|
|
20
32
|
>
|
|
21
33
|
<div className="d-flex">
|
|
22
34
|
<div
|
|
23
|
-
className={`fhir-ui__${
|
|
35
|
+
className={`fhir-ui__${resourceName}-Header__icon d-flex align-items-center flex-shrink-1 m-half me-2`}
|
|
24
36
|
>
|
|
25
|
-
<HeaderIcon headerIcon={
|
|
37
|
+
<HeaderIcon headerIcon={icon} resourceName={resourceName} />
|
|
26
38
|
</div>
|
|
27
39
|
<div
|
|
28
|
-
className={`fhir-ui__${
|
|
40
|
+
className={`fhir-ui__${resourceName}-Header__title flex-fill text-start`}
|
|
29
41
|
>
|
|
30
|
-
<Title data-testid={
|
|
31
|
-
{
|
|
42
|
+
<Title data-testid={titleTestID || 'title'}>
|
|
43
|
+
{title || ''}
|
|
32
44
|
</Title>
|
|
33
45
|
</div>
|
|
34
46
|
</div>
|
|
35
47
|
|
|
36
48
|
<div
|
|
37
|
-
className={`fhir-ui__${
|
|
49
|
+
className={`fhir-ui__${resourceName}-Header__badges ps-1 ps-sm-2 mt-3 mt-sm-0 badges-max-width-sm flex-wrap flex-sm-nowrap justify-content-between justify-content-sm-end ${rightItemsClass}`}
|
|
38
50
|
>
|
|
39
|
-
{
|
|
40
|
-
<div className="me-3">{props.prefixBadge}</div>
|
|
41
|
-
)}
|
|
51
|
+
{prefixBadge && <div className="me-3">{prefixBadge}</div>}
|
|
42
52
|
<div className="d-flex">
|
|
43
|
-
{
|
|
44
|
-
{
|
|
45
|
-
<div className="ms-3">{
|
|
53
|
+
{badges}
|
|
54
|
+
{additionalBadge && (
|
|
55
|
+
<div className="ms-3">{additionalBadge}</div>
|
|
46
56
|
)}
|
|
47
57
|
</div>
|
|
48
58
|
</div>
|
|
49
59
|
</div>
|
|
50
60
|
<div
|
|
51
|
-
className={`fhir-ui__${
|
|
52
|
-
|
|
53
|
-
}-Header__additional-content w-100 justify-content-start d-flex ${
|
|
54
|
-
props.additionalContent ? ' pt-2' : ''
|
|
61
|
+
className={`fhir-ui__${resourceName}-Header__additional-content w-100 justify-content-start d-flex ${
|
|
62
|
+
additionalContent ? ' pt-2' : ''
|
|
55
63
|
}`}
|
|
56
64
|
>
|
|
57
|
-
{
|
|
65
|
+
{additionalContent}
|
|
58
66
|
<div
|
|
59
|
-
className={`fhir-ui__${
|
|
67
|
+
className={`fhir-ui__${resourceName}-Header__rightAdditionalContent justify-content-end ${rightItemsClass}`}
|
|
60
68
|
>
|
|
61
|
-
{
|
|
69
|
+
{rightAdditionalContent}
|
|
62
70
|
</div>
|
|
63
71
|
</div>
|
|
64
72
|
</div>
|
|
@@ -213,7 +221,7 @@ export const ValueSection = props => (
|
|
|
213
221
|
</div>
|
|
214
222
|
);
|
|
215
223
|
|
|
216
|
-
export const MissingValue =
|
|
224
|
+
export const MissingValue = () => (
|
|
217
225
|
<span className="fhir-ui__MissingValue">-</span>
|
|
218
226
|
);
|
|
219
227
|
|