fhir-react 0.3.2 → 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 +85 -2
- package/build/bootstrap-reboot.min.css +8 -2
- package/build/index.js +7 -14
- package/build/style.css +4 -5
- package/package.json +1 -1
- package/src/assets/containers/Binary/binary.svg +9 -0
- 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/Patient/patient.svg +6 -0
- package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
- package/src/components/containers/Accordion/Accordion.js +17 -12
- package/src/components/datatypes/Annotation/Annotation.js +4 -4
- package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
- package/src/components/datatypes/Coding/Coding.css +0 -1
- package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
- package/src/components/datatypes/Reference/Reference.css +3 -0
- package/src/components/datatypes/Reference/Reference.js +2 -0
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +86 -77
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +12 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +71 -0
- 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/Binary/Binary.js +30 -20
- package/src/components/resources/Binary/Binary.stories.js +12 -5
- package/src/components/resources/Binary/Binary.test.js +67 -0
- package/src/components/resources/CarePlan/CarePlan.js +111 -96
- package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
- package/src/components/resources/CarePlan/CarePlan.test.js +74 -2
- package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
- 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/Device/Device.js +54 -34
- 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.js +53 -43
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +8 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +71 -0
- package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +5 -0
- package/src/components/resources/DocumentReference/DocumentReference.test.js +71 -0
- 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/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +5 -0
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +72 -0
- package/src/components/resources/Goal/Goal.js +103 -85
- package/src/components/resources/Goal/Goal.stories.js +38 -7
- package/src/components/resources/Goal/Goal.test.js +70 -3
- 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/Medication/Medication.test.js +1 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +1 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +67 -0
- package/src/components/resources/MedicationRequest/MedicationRequest.js +64 -44
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +21 -5
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +67 -0
- package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
- package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
- package/src/components/resources/MedicationStatement/MedicationStatement.js +66 -118
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +7 -0
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +103 -6
- 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 +7 -8
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
- package/src/components/ui/bootstrap-reboot.min.css +8 -2
- package/src/components/ui/index.js +44 -25
- package/src/fixtures/example-icons.jsx +74 -22
- package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
- package/src/style.scss +1 -0
- package/src/utils/convertCamelCaseToSentence.js +9 -0
- package/src/utils/convertCamelCaseToSentence.test.js +9 -0
- package/src/utils/formatDate.js +6 -4
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
- package/src/components/resources/CarePlan/CarePlan.css +0 -7
|
@@ -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,
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import HeaderIcon from '../../datatypes/HeaderIcon';
|
|
1
|
+
import { Header, Root } from '../../ui';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
|
|
6
|
-
const ResourceCategory =
|
|
7
|
-
const { title, itemsCount, fhirIcons } = props;
|
|
8
|
-
|
|
5
|
+
const ResourceCategory = ({ title, itemsCount, fhirIcons }) => {
|
|
9
6
|
const parseNumber = value =>
|
|
10
7
|
/^[1-9]+\d*$/.test(value) ? Number.parseInt(value) : null;
|
|
11
8
|
|
|
12
9
|
const getItemsCountLabel = () =>
|
|
13
10
|
`${parsedItemsCount} ${parsedItemsCount === 1 ? 'item' : 'items'}`;
|
|
14
11
|
|
|
15
|
-
const headerIcon = fhirIcons && fhirIcons['ResourceCategory'];
|
|
16
12
|
const parsedItemsCount = parseNumber(itemsCount);
|
|
17
13
|
|
|
18
14
|
return (
|
|
@@ -22,8 +18,11 @@ const ResourceCategory = props => {
|
|
|
22
18
|
className="btn d-flex align-items-center justify-content-between w-100 py-4 px-4 bg-white"
|
|
23
19
|
>
|
|
24
20
|
<div className="d-flex gap-2">
|
|
25
|
-
<
|
|
26
|
-
|
|
21
|
+
<Header
|
|
22
|
+
resourceName={'ResourceCategory'}
|
|
23
|
+
title={title}
|
|
24
|
+
icon={fhirIcons}
|
|
25
|
+
/>
|
|
27
26
|
</div>
|
|
28
27
|
<div className="d-flex gap-2 align-items-center">
|
|
29
28
|
{parsedItemsCount > 0 && (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ResourceCategory from './ResourceCategory';
|
|
3
3
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
4
|
+
import ResourceCategoryIcon from '../../../assets/containers/ResourceCategory/resource-category.svg';
|
|
4
5
|
|
|
5
6
|
export default { title: 'ResourceCategory' };
|
|
6
7
|
|
|
@@ -9,7 +10,7 @@ export const ExampleWithAllProperties = () => {
|
|
|
9
10
|
<ResourceCategory
|
|
10
11
|
itemsCount={41}
|
|
11
12
|
title="Resource name"
|
|
12
|
-
fhirIcons={
|
|
13
|
+
fhirIcons={require('../../../assets/containers/ResourceCategory/resource-category.svg')}
|
|
13
14
|
/>
|
|
14
15
|
);
|
|
15
16
|
};
|
|
@@ -19,7 +20,7 @@ export const ExampleWith1Item = () => {
|
|
|
19
20
|
<ResourceCategory
|
|
20
21
|
itemsCount={'1'}
|
|
21
22
|
title="Resource name"
|
|
22
|
-
fhirIcons={
|
|
23
|
+
fhirIcons={ResourceCategoryIcon}
|
|
23
24
|
/>
|
|
24
25
|
);
|
|
25
26
|
};
|
|
@@ -27,3 +28,13 @@ export const ExampleWith1Item = () => {
|
|
|
27
28
|
export const ExampleWithoutItemsCount = () => {
|
|
28
29
|
return <ResourceCategory title="Resource name" fhirIcons={fhirIcons} />;
|
|
29
30
|
};
|
|
31
|
+
|
|
32
|
+
export const ExampleWith1ItemAndDisableIcon = () => {
|
|
33
|
+
return (
|
|
34
|
+
<ResourceCategory
|
|
35
|
+
itemsCount={'1'}
|
|
36
|
+
title="Resource name"
|
|
37
|
+
fhirIcons={false}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -5,42 +5,107 @@ import fhirIcons from '../../../fixtures/example-icons';
|
|
|
5
5
|
import ResourceCategory from './ResourceCategory';
|
|
6
6
|
|
|
7
7
|
describe('should render ResourceCategory component properly', () => {
|
|
8
|
-
|
|
8
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
itemsCount: '41',
|
|
11
|
+
title: 'Resource name',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const { getByAltText } = render(<ResourceCategory {...defaultProps} />);
|
|
15
|
+
const headerIcon = getByAltText('resource category');
|
|
16
|
+
|
|
17
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
21
|
+
const defaultProps = {
|
|
22
|
+
itemsCount: '41',
|
|
23
|
+
title: 'Resource name',
|
|
24
|
+
fhirIcons: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const { getByTestId } = render(<ResourceCategory {...defaultProps} />);
|
|
28
|
+
const headerIcon = getByTestId('placeholder');
|
|
29
|
+
|
|
30
|
+
expect(headerIcon).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
34
|
+
const defaultProps = {
|
|
35
|
+
itemsCount: '41',
|
|
36
|
+
title: 'Resource name',
|
|
37
|
+
fhirIcons: (
|
|
38
|
+
<img
|
|
39
|
+
src={require('../assets/containers/ResourceCategory/resource-category.svg')}
|
|
40
|
+
alt="resource category"
|
|
41
|
+
/>
|
|
42
|
+
),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const { getByAltText } = render(<ResourceCategory {...defaultProps} />);
|
|
46
|
+
const headerIcon = getByAltText('resource category');
|
|
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
|
+
itemsCount: '41',
|
|
54
|
+
title: 'Resource name',
|
|
55
|
+
fhirIcons: fhirIcons,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const { getByAltText } = render(<ResourceCategory {...defaultProps} />);
|
|
59
|
+
const headerIcon = getByAltText('resource category');
|
|
60
|
+
|
|
61
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
65
|
+
const avatarSrc =
|
|
66
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
67
|
+
const defaultProps = {
|
|
68
|
+
itemsCount: '41',
|
|
69
|
+
title: 'Resource name',
|
|
70
|
+
fhirIcons: avatarSrc,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const { getByAltText } = render(<ResourceCategory {...defaultProps} />);
|
|
74
|
+
const headerIcon = getByAltText('header icon');
|
|
75
|
+
|
|
76
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
77
|
+
});
|
|
9
78
|
|
|
10
|
-
it('should render ResourceCategory component with
|
|
79
|
+
it('should render ResourceCategory component with itemsCount > 1 correctly', () => {
|
|
11
80
|
const defaultProps = {
|
|
12
81
|
fhirIcons: fhirIcons,
|
|
13
82
|
itemsCount: '41',
|
|
14
83
|
title: 'Resource name',
|
|
15
84
|
};
|
|
16
85
|
|
|
17
|
-
const { container, getByTestId
|
|
86
|
+
const { container, getByTestId } = render(
|
|
18
87
|
<ResourceCategory {...defaultProps} />,
|
|
19
88
|
);
|
|
20
89
|
expect(container).not.toBeNull();
|
|
21
90
|
|
|
22
91
|
expect(getByTestId('itemsCount').textContent).toContain('41 items');
|
|
23
92
|
expect(getByTestId('title').textContent).toContain('Resource name');
|
|
24
|
-
const image = getByAltText(placeholderResource.alt);
|
|
25
|
-
expect(image.src).toContain(placeholderResource.src);
|
|
26
93
|
});
|
|
27
94
|
|
|
28
|
-
it('should render ResourceCategory component with
|
|
95
|
+
it('should render ResourceCategory component with itemsCount === 1 correctly', () => {
|
|
29
96
|
const defaultProps = {
|
|
30
97
|
fhirIcons: fhirIcons,
|
|
31
98
|
itemsCount: 1,
|
|
32
99
|
title: 'Resource name',
|
|
33
100
|
};
|
|
34
101
|
|
|
35
|
-
const { container, getByTestId
|
|
102
|
+
const { container, getByTestId } = render(
|
|
36
103
|
<ResourceCategory {...defaultProps} />,
|
|
37
104
|
);
|
|
38
105
|
expect(container).not.toBeNull();
|
|
39
106
|
|
|
40
107
|
expect(getByTestId('itemsCount').textContent).toContain('1 item');
|
|
41
108
|
expect(getByTestId('title').textContent).toContain('Resource name');
|
|
42
|
-
const image = getByAltText(placeholderResource.alt);
|
|
43
|
-
expect(image.src).toContain(placeholderResource.src);
|
|
44
109
|
});
|
|
45
110
|
|
|
46
111
|
it('should render ResourceCategory correctly with negative number passed as itemsCount', () => {
|
|
@@ -50,7 +115,7 @@ describe('should render ResourceCategory component properly', () => {
|
|
|
50
115
|
title: 'Resource name',
|
|
51
116
|
};
|
|
52
117
|
|
|
53
|
-
const { container, getByTestId,
|
|
118
|
+
const { container, getByTestId, queryByTestId } = render(
|
|
54
119
|
<ResourceCategory {...defaultProps} />,
|
|
55
120
|
);
|
|
56
121
|
expect(container).not.toBeNull();
|
|
@@ -58,8 +123,6 @@ describe('should render ResourceCategory component properly', () => {
|
|
|
58
123
|
const item = queryByTestId('itemsCount');
|
|
59
124
|
expect(item).toBeNull();
|
|
60
125
|
expect(getByTestId('title').textContent).toContain('Resource name');
|
|
61
|
-
const image = getByAltText(placeholderResource.alt);
|
|
62
|
-
expect(image.src).toContain(placeholderResource.src);
|
|
63
126
|
});
|
|
64
127
|
|
|
65
128
|
it('should render ResourceCategory correctly with invalid string passed as itemsCount', () => {
|
|
@@ -69,15 +132,13 @@ describe('should render ResourceCategory component properly', () => {
|
|
|
69
132
|
title: 'Resource name',
|
|
70
133
|
};
|
|
71
134
|
|
|
72
|
-
const { container, getByTestId,
|
|
135
|
+
const { container, getByTestId, queryByTestId } = render(
|
|
73
136
|
<ResourceCategory {...defaultProps} />,
|
|
74
137
|
);
|
|
75
138
|
expect(container).not.toBeNull();
|
|
76
139
|
const item = queryByTestId('itemsCount');
|
|
77
140
|
expect(item).toBeNull();
|
|
78
141
|
expect(getByTestId('title').textContent).toContain('Resource name');
|
|
79
|
-
const image = getByAltText(placeholderResource.alt);
|
|
80
|
-
expect(image.src).toContain(placeholderResource.src);
|
|
81
142
|
});
|
|
82
143
|
|
|
83
144
|
it('should render ResourceCategory correctly with floating point number passed as text in itemsCount', () => {
|
|
@@ -87,7 +148,7 @@ describe('should render ResourceCategory component properly', () => {
|
|
|
87
148
|
title: 'Resource name',
|
|
88
149
|
};
|
|
89
150
|
|
|
90
|
-
const { container, getByTestId,
|
|
151
|
+
const { container, getByTestId, queryByTestId } = render(
|
|
91
152
|
<ResourceCategory {...defaultProps} />,
|
|
92
153
|
);
|
|
93
154
|
expect(container).not.toBeNull();
|
|
@@ -95,7 +156,5 @@ describe('should render ResourceCategory component properly', () => {
|
|
|
95
156
|
const item = queryByTestId('itemsCount');
|
|
96
157
|
expect(item).toBeNull();
|
|
97
158
|
expect(getByTestId('title').textContent).toContain('Resource name');
|
|
98
|
-
const image = getByAltText(placeholderResource.alt);
|
|
99
|
-
expect(image.src).toContain(placeholderResource.src);
|
|
100
159
|
});
|
|
101
160
|
});
|
|
@@ -173,8 +173,14 @@ sup {
|
|
|
173
173
|
.fhir-resource kbd,
|
|
174
174
|
.fhir-resource pre,
|
|
175
175
|
.fhir-resource samp {
|
|
176
|
-
font-family:
|
|
177
|
-
|
|
176
|
+
font-family:
|
|
177
|
+
SFMono-Regular,
|
|
178
|
+
Menlo,
|
|
179
|
+
Monaco,
|
|
180
|
+
Consolas,
|
|
181
|
+
'Liberation Mono',
|
|
182
|
+
'Courier New',
|
|
183
|
+
monospace;
|
|
178
184
|
font-size: 1em;
|
|
179
185
|
}
|
|
180
186
|
|
|
@@ -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,10 +221,21 @@ 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
|
|
|
228
|
+
export const ValueSectionItem = props => {
|
|
229
|
+
return (
|
|
230
|
+
<div className="d-flex flex-column flex-sm-row my-2">
|
|
231
|
+
<div className="dataTable__value-label ps-0">
|
|
232
|
+
<Label>{props.label}</Label>
|
|
233
|
+
</div>
|
|
234
|
+
<Data data-testid={props['data-testid']}>{props.children}</Data>
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
220
239
|
export const NotEnoughData = props => (
|
|
221
240
|
<div data-testid={props['data-testid']} className="fhir-ui__NotEnoughData">
|
|
222
241
|
No additional data
|