fhir-react 0.3.5 → 0.3.6
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 +1 -1
- package/build/index.js +6 -6
- package/package.json +1 -1
- package/src/assets/containers/{Medication/medication.svg → MedicationOrder/medication-order.svg} +0 -0
- package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
- package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +3 -5
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +5 -4
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +71 -0
- package/src/components/resources/Binary/Binary.js +1 -2
- package/src/components/resources/Binary/Binary.stories.js +10 -4
- package/src/components/resources/Binary/Binary.test.js +67 -0
- package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
- package/src/components/resources/CarePlan/CarePlan.test.js +72 -0
- package/src/components/resources/Device/Device.stories.js +33 -5
- package/src/components/resources/Device/Device.test.js +72 -0
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +5 -4
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +71 -0
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +3 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +71 -0
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +3 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +72 -0
- package/src/components/resources/Goal/Goal.js +1 -2
- package/src/components/resources/Goal/Goal.stories.js +5 -4
- package/src/components/resources/Goal/Goal.test.js +69 -0
- package/src/components/resources/Medication/Medication.test.js +1 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +1 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +2 -2
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +1 -2
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +67 -0
- package/src/components/resources/MedicationRequest/MedicationRequest.js +2 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +11 -6
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +67 -0
- package/src/components/resources/MedicationStatement/MedicationDosage.js +2 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.js +1 -0
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +5 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +72 -0
- package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
- package/src/fixtures/example-icons.jsx +20 -13
package/package.json
CHANGED
package/src/assets/containers/{Medication/medication.svg → MedicationOrder/medication-order.svg}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M4.52175 9.0435C7.01904 9.0435 9.0435 7.01904 9.0435 4.52175C9.0435 2.02446 7.01904 0 4.52175 0C2.02446 0 0 2.02446 0 4.52175C0 7.01904 2.02446 9.0435 4.52175 9.0435Z" fill="#FD7E14"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.6396 15.0832C11.0525 15.6702 10.2563 16.0001 9.42605 16.0001C8.5958 16.0001 7.79956 15.6702 7.21248 15.0832C6.62541 14.4961 6.29559 13.6998 6.29559 12.8696C6.29559 12.0394 6.62541 11.2431 7.21248 10.656L8.58067 9.28784L8.58071 9.28788L13.0078 13.715L11.6396 15.0832ZM10.656 7.21254L9.28778 8.58073L9.28782 8.58077L13.7149 13.0079L15.0831 11.6397C15.6702 11.0526 16 10.2564 16 9.42611C16 8.59587 15.6702 7.79962 15.0831 7.21254C14.496 6.62547 13.6998 6.29565 12.8695 6.29565C12.0393 6.29565 11.243 6.62547 10.656 7.21254ZM12.6279 8.21057C12.8683 8.16276 13.1175 8.18732 13.344 8.28116C13.5991 8.38687 13.8916 8.26576 13.9973 8.01065C14.103 7.75554 13.9819 7.46304 13.7268 7.35733C13.3176 7.18776 12.8672 7.14338 12.4328 7.22979C11.9984 7.3162 11.5993 7.52952 11.2861 7.84278C11.0909 8.03806 11.0909 8.35464 11.2862 8.54988C11.4815 8.74512 11.7981 8.74509 11.9933 8.5498C12.1666 8.37645 12.3875 8.25839 12.6279 8.21057Z" fill="#FEB272"/>
|
|
4
|
+
<rect x="1" y="4" width="7" height="1" rx="0.5" fill="white"/>
|
|
5
|
+
</svg>
|
package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg}
RENAMED
|
File without changes
|
|
@@ -123,9 +123,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
const AllergyIntolerance =
|
|
127
|
-
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
128
|
-
const headerIcon = fhirIcons && fhirIcons['AllergyIntolerance'];
|
|
126
|
+
const AllergyIntolerance = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
129
127
|
let fhirResourceData = {};
|
|
130
128
|
try {
|
|
131
129
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -219,10 +217,10 @@ const AllergyIntolerance = props => {
|
|
|
219
217
|
<Accordion
|
|
220
218
|
headerContent={
|
|
221
219
|
<Header
|
|
222
|
-
resourceName="
|
|
220
|
+
resourceName="AllergyIntolerance"
|
|
223
221
|
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
224
222
|
title={title}
|
|
225
|
-
icon={
|
|
223
|
+
icon={fhirIcons}
|
|
226
224
|
rightAdditionalContent={
|
|
227
225
|
recordedDate && (
|
|
228
226
|
<BadgeSecondary data-testid="recordedDate">
|
|
@@ -12,6 +12,7 @@ import example2AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergy
|
|
|
12
12
|
import example3AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example3.json';
|
|
13
13
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
14
|
import fhirVersions from '../fhirResourceVersions';
|
|
15
|
+
import AllergyIntoleranceIcon from '../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg';
|
|
15
16
|
|
|
16
17
|
export default { title: 'AllergyIntolerance' };
|
|
17
18
|
|
|
@@ -21,7 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
21
22
|
<AllergyIntolerance
|
|
22
23
|
fhirVersion={fhirVersions.DSTU2}
|
|
23
24
|
fhirResource={fhirResource}
|
|
24
|
-
fhirIcons={
|
|
25
|
+
fhirIcons={require('../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg')}
|
|
25
26
|
/>
|
|
26
27
|
);
|
|
27
28
|
};
|
|
@@ -32,7 +33,7 @@ export const Example2ofDSTU2 = () => {
|
|
|
32
33
|
<AllergyIntolerance
|
|
33
34
|
fhirVersion={fhirVersions.DSTU2}
|
|
34
35
|
fhirResource={fhirResource}
|
|
35
|
-
fhirIcons={
|
|
36
|
+
fhirIcons={AllergyIntoleranceIcon}
|
|
36
37
|
/>
|
|
37
38
|
);
|
|
38
39
|
};
|
|
@@ -54,7 +55,7 @@ export const Example2DiagnosticReportSTU3 = () => {
|
|
|
54
55
|
<AllergyIntolerance
|
|
55
56
|
fhirVersion={fhirVersions.STU3}
|
|
56
57
|
fhirResource={fhirResource}
|
|
57
|
-
fhirIcons={
|
|
58
|
+
fhirIcons={false}
|
|
58
59
|
/>
|
|
59
60
|
);
|
|
60
61
|
};
|
|
@@ -65,7 +66,7 @@ export const Example1R4 = () => {
|
|
|
65
66
|
<AllergyIntolerance
|
|
66
67
|
fhirVersion={fhirVersions.R4}
|
|
67
68
|
fhirResource={fhirResource}
|
|
68
|
-
fhirIcons={
|
|
69
|
+
fhirIcons={'random text'}
|
|
69
70
|
/>
|
|
70
71
|
);
|
|
71
72
|
};
|
|
@@ -7,8 +7,79 @@ import exampleAllergyIntoleranceSTU3 from '../../../fixtures/stu3/resources/alle
|
|
|
7
7
|
import exampleAllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example1.json';
|
|
8
8
|
import example2AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example3.json';
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
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: exampleAllergyIntoleranceDSTU2,
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('allergy intolerance');
|
|
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
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<AllergyIntolerance {...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
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/AllergyIntolerance/allergy-intolerance.svg')}
|
|
45
|
+
alt="allergy intolerance"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('allergy intolerance');
|
|
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
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
59
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('allergy intolerance');
|
|
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: exampleAllergyIntoleranceDSTU2,
|
|
74
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
12
83
|
it('should render with DSTU2 source data', () => {
|
|
13
84
|
const defaultProps = {
|
|
14
85
|
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
@@ -7,7 +7,6 @@ import { Body, Header } from '../../ui';
|
|
|
7
7
|
|
|
8
8
|
const Binary = props => {
|
|
9
9
|
const { fhirResource, fhirIcons } = props;
|
|
10
|
-
const headerIcon = fhirIcons && fhirIcons['Binary'];
|
|
11
10
|
|
|
12
11
|
const loadBinaryFile = () => {
|
|
13
12
|
switch (fhirResource.contentType) {
|
|
@@ -34,7 +33,7 @@ const Binary = props => {
|
|
|
34
33
|
<Header
|
|
35
34
|
resourceName="Binary"
|
|
36
35
|
title={`Binary file: ${fhirResource.contentType}`}
|
|
37
|
-
icon={
|
|
36
|
+
icon={fhirIcons}
|
|
38
37
|
/>
|
|
39
38
|
}
|
|
40
39
|
bodyContent={<Body>{loadBinaryFile()}</Body>}
|
|
@@ -9,6 +9,7 @@ import stu3ExamplePdf from '../../../fixtures/stu3/resources/binary/example-pdf.
|
|
|
9
9
|
import stu3ExampleJpeg from '../../../fixtures/stu3/resources/binary/example-jpeg.json';
|
|
10
10
|
import stu3ExampleJson from '../../../fixtures/stu3/resources/binary/example-json.json';
|
|
11
11
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import BinaryIcon from '../../../assets/containers/Binary/binary.svg';
|
|
12
13
|
|
|
13
14
|
export default {
|
|
14
15
|
title: 'Binary',
|
|
@@ -16,22 +17,27 @@ export default {
|
|
|
16
17
|
|
|
17
18
|
export const PdfDSTU2 = () => {
|
|
18
19
|
const fhirResource = object('Resource', dstu2ExamplePdf);
|
|
19
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<Binary
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={require('../../../assets/containers/Binary/binary.svg')}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
export const JpegDSTU2 = () => {
|
|
23
29
|
const fhirResource = object('Resource', dstu2ExampleJpeg);
|
|
24
|
-
return <Binary fhirResource={fhirResource} fhirIcons={
|
|
30
|
+
return <Binary fhirResource={fhirResource} fhirIcons={BinaryIcon} />;
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
export const PdfSTU3 = () => {
|
|
28
34
|
const fhirResource = object('Resource', stu3ExamplePdf);
|
|
29
|
-
return <Binary fhirResource={fhirResource} fhirIcons={
|
|
35
|
+
return <Binary fhirResource={fhirResource} fhirIcons={false} />;
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
export const JpegSTU3 = () => {
|
|
33
39
|
const fhirResource = object('Resource', stu3ExampleJpeg);
|
|
34
|
-
return <Binary fhirResource={fhirResource} fhirIcons={
|
|
40
|
+
return <Binary fhirResource={fhirResource} fhirIcons={'random text'} />;
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
export const JsonSTU3 = () => {
|
|
@@ -5,8 +5,75 @@ import Binary from './Binary';
|
|
|
5
5
|
import stu3ExamplePdf from '../../../fixtures/stu3/resources/binary/example-pdf.json';
|
|
6
6
|
import stu3ExampleJpeg from '../../../fixtures/stu3/resources/binary/example-jpeg.json';
|
|
7
7
|
import stu3ExampleJson from '../../../fixtures/stu3/resources/binary/example-json.json';
|
|
8
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
8
9
|
|
|
9
10
|
describe('should render component correctly', () => {
|
|
11
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
fhirResource: stu3ExamplePdf,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const { getByAltText } = render(<Binary {...defaultProps} />);
|
|
17
|
+
const headerIcon = getByAltText('binary');
|
|
18
|
+
|
|
19
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
fhirResource: stu3ExamplePdf,
|
|
25
|
+
fhirIcons: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const { getByTestId } = render(<Binary {...defaultProps} />);
|
|
29
|
+
const headerIcon = getByTestId('placeholder');
|
|
30
|
+
|
|
31
|
+
expect(headerIcon).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
35
|
+
const defaultProps = {
|
|
36
|
+
fhirResource: stu3ExamplePdf,
|
|
37
|
+
fhirIcons: (
|
|
38
|
+
<img
|
|
39
|
+
src={require('../assets/containers/Binary/binary.svg')}
|
|
40
|
+
alt="binary"
|
|
41
|
+
/>
|
|
42
|
+
),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const { getByAltText } = render(<Binary {...defaultProps} />);
|
|
46
|
+
const headerIcon = getByAltText('binary');
|
|
47
|
+
|
|
48
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
52
|
+
const defaultProps = {
|
|
53
|
+
fhirResource: stu3ExamplePdf,
|
|
54
|
+
fhirIcons: fhirIcons,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const { getByAltText } = render(<Binary {...defaultProps} />);
|
|
58
|
+
const headerIcon = getByAltText('binary');
|
|
59
|
+
|
|
60
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
64
|
+
const avatarSrc =
|
|
65
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
66
|
+
const defaultProps = {
|
|
67
|
+
fhirResource: stu3ExamplePdf,
|
|
68
|
+
fhirIcons: avatarSrc,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const { getByAltText } = render(<Binary {...defaultProps} />);
|
|
72
|
+
const headerIcon = getByAltText('header icon');
|
|
73
|
+
|
|
74
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
75
|
+
});
|
|
76
|
+
|
|
10
77
|
it('PDF binary file', () => {
|
|
11
78
|
const { container } = render(<Binary fhirResource={stu3ExamplePdf} />);
|
|
12
79
|
expect(container).not.toBe(null);
|
|
@@ -10,38 +10,64 @@ import weightLossCarePlanR4 from '../../../fixtures/r4/resources/carePlan/weight
|
|
|
10
10
|
import pregnancyCarePlanR4 from '../../../fixtures/r4/resources/carePlan/pregnancyPlan.json';
|
|
11
11
|
import heartOperationCarePlanR4 from '../../../fixtures/r4/resources/carePlan/heartOperationPlan.json';
|
|
12
12
|
import fhirVersions from '../fhirResourceVersions';
|
|
13
|
+
import CarePlanIcon from '../../../assets/containers/CarePlan/care-plan.svg';
|
|
14
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
15
|
|
|
14
16
|
export default { title: 'CarePlan' };
|
|
15
17
|
|
|
16
18
|
export const DefaultVisualizationDSTU2 = () => {
|
|
17
19
|
const fhirResource = object('Resource', exampleCarePlanDSTU2);
|
|
18
20
|
return (
|
|
19
|
-
<CarePlan
|
|
21
|
+
<CarePlan
|
|
22
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
23
|
+
fhirResource={fhirResource}
|
|
24
|
+
fhirIcons={require('../../../assets/containers/CarePlan/care-plan.svg')}
|
|
25
|
+
/>
|
|
20
26
|
);
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
export const ExampleCarePlanSTU3 = () => {
|
|
24
30
|
const fhirResource = object('Resource', exampleCarePlanSTU3);
|
|
25
31
|
return (
|
|
26
|
-
<CarePlan
|
|
32
|
+
<CarePlan
|
|
33
|
+
fhirVersion={fhirVersions.STU3}
|
|
34
|
+
fhirResource={fhirResource}
|
|
35
|
+
fhirIcons={CarePlanIcon}
|
|
36
|
+
/>
|
|
27
37
|
);
|
|
28
38
|
};
|
|
29
39
|
|
|
30
40
|
export const Example2CarePlanSTU3 = () => {
|
|
31
41
|
const fhirResource = object('Resource', example2CarePlanSTU3);
|
|
32
42
|
return (
|
|
33
|
-
<CarePlan
|
|
43
|
+
<CarePlan
|
|
44
|
+
fhirVersion={fhirVersions.STU3}
|
|
45
|
+
fhirResource={fhirResource}
|
|
46
|
+
fhirIcons={fhirIcons}
|
|
47
|
+
/>
|
|
34
48
|
);
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
export const WeightLossCarePlanR4 = () => {
|
|
38
52
|
const fhirResource = object('Resource', weightLossCarePlanR4);
|
|
39
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
<CarePlan
|
|
55
|
+
fhirVersion={fhirVersions.R4}
|
|
56
|
+
fhirResource={fhirResource}
|
|
57
|
+
fhirIcons={false}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
40
60
|
};
|
|
41
61
|
|
|
42
62
|
export const PregnancyCarePlanR4 = () => {
|
|
43
63
|
const fhirResource = object('Resource', pregnancyCarePlanR4);
|
|
44
|
-
return
|
|
64
|
+
return (
|
|
65
|
+
<CarePlan
|
|
66
|
+
fhirVersion={fhirVersions.R4}
|
|
67
|
+
fhirResource={fhirResource}
|
|
68
|
+
fhirIcons={'random text'}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
45
71
|
};
|
|
46
72
|
|
|
47
73
|
export const HeartOperatioCarePlanR4 = () => {
|
|
@@ -7,8 +7,80 @@ import examplecarePlanDSTU2 from '../../../fixtures/dstu2/resources/carePlan/exa
|
|
|
7
7
|
import exampleCarePlanSTU3 from '../../../fixtures/stu3/resources/carePlan/example1.json';
|
|
8
8
|
import example1CarePlanR4 from '../../../fixtures/r4/resources/carePlan/weightLossPlan.json';
|
|
9
9
|
import example2CarePlanR4 from '../../../fixtures/r4/resources/carePlan/pregnancyPlan.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: examplecarePlanDSTU2,
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('care plan');
|
|
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
|
+
fhirResource: examplecarePlanDSTU2,
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<CarePlan {...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
|
+
fhirResource: examplecarePlanDSTU2,
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/CarePlan/care-plan.svg')}
|
|
45
|
+
alt="care plan"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('care plan');
|
|
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
|
+
fhirResource: examplecarePlanDSTU2,
|
|
59
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('care plan');
|
|
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: examplecarePlanDSTU2,
|
|
74
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
83
|
+
|
|
12
84
|
it('should render with DSTU2 source data', () => {
|
|
13
85
|
const defaultProps = {
|
|
14
86
|
fhirResource: examplecarePlanDSTU2,
|
|
@@ -10,6 +10,8 @@ import stu3Example2 from '../../../fixtures/stu3/resources/device/example2.json'
|
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/device/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/device/example2.json';
|
|
12
12
|
import fhirVersions from '../fhirResourceVersions';
|
|
13
|
+
import DeviceIcon from '../../../assets/containers/Device/device.svg';
|
|
14
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
15
|
|
|
14
16
|
export default {
|
|
15
17
|
title: 'Device',
|
|
@@ -18,29 +20,55 @@ export default {
|
|
|
18
20
|
export const DefaultVisualizationDSTU2 = () => {
|
|
19
21
|
const fhirResource = object('Resource', dstu2Example1);
|
|
20
22
|
return (
|
|
21
|
-
<Device
|
|
23
|
+
<Device
|
|
24
|
+
fhirResource={fhirResource}
|
|
25
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
26
|
+
fhirIcons={require('../../../assets/containers/Device/device.svg')}
|
|
27
|
+
/>
|
|
22
28
|
);
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
export const ExampleOfDSTU2 = () => {
|
|
26
32
|
const fhirResource = object('Resource', dstu2Example2);
|
|
27
33
|
return (
|
|
28
|
-
<Device
|
|
34
|
+
<Device
|
|
35
|
+
fhirResource={fhirResource}
|
|
36
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
37
|
+
fhirIcons={DeviceIcon}
|
|
38
|
+
/>
|
|
29
39
|
);
|
|
30
40
|
};
|
|
31
41
|
|
|
32
42
|
export const Example1OfSTU3 = () => {
|
|
33
43
|
const fhirResource = object('Resource', stu3Example1);
|
|
34
|
-
return
|
|
44
|
+
return (
|
|
45
|
+
<Device
|
|
46
|
+
fhirResource={fhirResource}
|
|
47
|
+
fhirVersion={fhirVersions.STU3}
|
|
48
|
+
fhirIcons={fhirIcons}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
35
51
|
};
|
|
36
52
|
export const Example2OfSTU3 = () => {
|
|
37
53
|
const fhirResource = object('Resource', stu3Example2);
|
|
38
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
<Device
|
|
56
|
+
fhirResource={fhirResource}
|
|
57
|
+
fhirVersion={fhirVersions.STU3}
|
|
58
|
+
fhirIcons={false}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
39
61
|
};
|
|
40
62
|
|
|
41
63
|
export const Example1OfR4 = () => {
|
|
42
64
|
const fhirResource = object('Resource', r4Example1);
|
|
43
|
-
return
|
|
65
|
+
return (
|
|
66
|
+
<Device
|
|
67
|
+
fhirResource={fhirResource}
|
|
68
|
+
fhirVersion={fhirVersions.R4}
|
|
69
|
+
fhirIcons={'random text'}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
44
72
|
};
|
|
45
73
|
|
|
46
74
|
export const Example2OfR4 = () => {
|
|
@@ -6,8 +6,80 @@ import fhirVersions from '../fhirResourceVersions';
|
|
|
6
6
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/device/example.json';
|
|
7
7
|
import stu3Example2 from '../../../fixtures/stu3/resources/device/example2.json';
|
|
8
8
|
import r4Example2 from '../../../fixtures/r4/resources/device/example2.json';
|
|
9
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
10
|
|
|
10
11
|
describe('should render Device component properly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirResource: dstu2Example1,
|
|
15
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('device');
|
|
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: dstu2Example1,
|
|
27
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<Device {...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
|
+
fhirResource: dstu2Example1,
|
|
40
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/Device/device.svg')}
|
|
44
|
+
alt="device"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('device');
|
|
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
|
+
fhirResource: dstu2Example1,
|
|
58
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('device');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
11
83
|
it('should render with DSTU2 source data', () => {
|
|
12
84
|
const defaultProps = {
|
|
13
85
|
fhirResource: dstu2Example1,
|
|
@@ -10,6 +10,7 @@ import exampleDiagnosticReportR4 from '../../../fixtures/r4/resources/diagnostic
|
|
|
10
10
|
import example2DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example2.json';
|
|
11
11
|
import example3DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example3.json';
|
|
12
12
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import DiagnosticReportIcon from '../../../assets/containers/DiagnosticReport/diagnostic-report.svg';
|
|
13
14
|
|
|
14
15
|
export default { title: 'DiagnosticReport' };
|
|
15
16
|
|
|
@@ -19,7 +20,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
19
20
|
<DiagnosticReport
|
|
20
21
|
fhirVersion={fhirVersions.DSTU2}
|
|
21
22
|
fhirResource={fhirResource}
|
|
22
|
-
fhirIcons={
|
|
23
|
+
fhirIcons={require('../../../assets/containers/DiagnosticReport/diagnostic-report.svg')}
|
|
23
24
|
/>
|
|
24
25
|
);
|
|
25
26
|
};
|
|
@@ -30,7 +31,7 @@ export const ExampleDiagnosticReportSTU3 = () => {
|
|
|
30
31
|
<DiagnosticReport
|
|
31
32
|
fhirVersion={fhirVersions.STU3}
|
|
32
33
|
fhirResource={fhirResource}
|
|
33
|
-
fhirIcons={
|
|
34
|
+
fhirIcons={DiagnosticReportIcon}
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
@@ -52,7 +53,7 @@ export const Example2DiagnosticReportR4 = () => {
|
|
|
52
53
|
<DiagnosticReport
|
|
53
54
|
fhirVersion={fhirVersions.R4}
|
|
54
55
|
fhirResource={fhirResource}
|
|
55
|
-
fhirIcons={
|
|
56
|
+
fhirIcons={false}
|
|
56
57
|
/>
|
|
57
58
|
);
|
|
58
59
|
};
|
|
@@ -63,7 +64,7 @@ export const Example3DiagnosticReportR4 = () => {
|
|
|
63
64
|
<DiagnosticReport
|
|
64
65
|
fhirVersion={fhirVersions.R4}
|
|
65
66
|
fhirResource={fhirResource}
|
|
66
|
-
fhirIcons={
|
|
67
|
+
fhirIcons={'random text'}
|
|
67
68
|
/>
|
|
68
69
|
);
|
|
69
70
|
};
|