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
|
@@ -13,38 +13,61 @@ import example1AppointmentR4 from '../../../fixtures/r4/resources/appointment/ex
|
|
|
13
13
|
import example2AppointmentR4 from '../../../fixtures/r4/resources/appointment/example2.json';
|
|
14
14
|
import example3AppointmentR4 from '../../../fixtures/r4/resources/appointment/example3.json';
|
|
15
15
|
|
|
16
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
17
|
+
import AppointmentIcon from '../../../assets/containers/Appointment/appointment.svg';
|
|
18
|
+
|
|
16
19
|
export default { title: 'Appointment' };
|
|
17
20
|
|
|
18
21
|
export const DefaultVisualizationDSTU2 = () => {
|
|
19
22
|
const fhirResource = object('Resource', exampleAppointmentDSTU2);
|
|
20
23
|
return (
|
|
21
|
-
<Appointment
|
|
24
|
+
<Appointment
|
|
25
|
+
fhirResource={fhirResource}
|
|
26
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
27
|
+
fhirIcons={require('../../../assets/containers/Appointment/appointment.svg')}
|
|
28
|
+
/>
|
|
22
29
|
);
|
|
23
30
|
};
|
|
24
31
|
|
|
25
32
|
export const Example2OfDSTU2 = () => {
|
|
26
33
|
const fhirResource = object('Resource', example2AppointmentDSTU2);
|
|
27
34
|
return (
|
|
28
|
-
<Appointment
|
|
35
|
+
<Appointment
|
|
36
|
+
fhirResource={fhirResource}
|
|
37
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
38
|
+
fhirIcons={AppointmentIcon}
|
|
39
|
+
/>
|
|
29
40
|
);
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
export const Example1OfSTU3 = () => {
|
|
33
44
|
const fhirResource = object('Resource', example1AppointmentSTU3);
|
|
34
45
|
return (
|
|
35
|
-
<Appointment
|
|
46
|
+
<Appointment
|
|
47
|
+
fhirResource={fhirResource}
|
|
48
|
+
fhirVersion={fhirVersions.STU3}
|
|
49
|
+
fhirIcons={fhirIcons}
|
|
50
|
+
/>
|
|
36
51
|
);
|
|
37
52
|
};
|
|
38
53
|
export const Example2OfSTU3 = () => {
|
|
39
54
|
const fhirResource = object('Resource', example2AppointmentSTU3);
|
|
40
55
|
return (
|
|
41
|
-
<Appointment
|
|
56
|
+
<Appointment
|
|
57
|
+
fhirResource={fhirResource}
|
|
58
|
+
fhirVersion={fhirVersions.STU3}
|
|
59
|
+
fhirIcons={false}
|
|
60
|
+
/>
|
|
42
61
|
);
|
|
43
62
|
};
|
|
44
63
|
export const Example3OfSTU3 = () => {
|
|
45
64
|
const fhirResource = object('Resource', example3AppointmentSTU3);
|
|
46
65
|
return (
|
|
47
|
-
<Appointment
|
|
66
|
+
<Appointment
|
|
67
|
+
fhirResource={fhirResource}
|
|
68
|
+
fhirVersion={fhirVersions.STU3}
|
|
69
|
+
fhirIcons={'random text'}
|
|
70
|
+
/>
|
|
48
71
|
);
|
|
49
72
|
};
|
|
50
73
|
|
|
@@ -11,8 +11,80 @@ import example3AppointmentSTU3 from '../../../fixtures/stu3/resources/appointmen
|
|
|
11
11
|
import example1AppointmentR4 from '../../../fixtures/r4/resources/appointment/example1.json';
|
|
12
12
|
import example2AppointmentR4 from '../../../fixtures/r4/resources/appointment/example2.json';
|
|
13
13
|
import example3AppointmentR4 from '../../../fixtures/r4/resources/appointment/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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
20
|
+
fhirResource: exampleAppointmentDSTU2,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const { getByAltText } = render(<Appointment {...defaultProps} />);
|
|
24
|
+
const headerIcon = getByAltText('appointment');
|
|
25
|
+
|
|
26
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
30
|
+
const defaultProps = {
|
|
31
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
32
|
+
fhirResource: exampleAppointmentDSTU2,
|
|
33
|
+
fhirIcons: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const { getByTestId } = render(<Appointment {...defaultProps} />);
|
|
37
|
+
const headerIcon = getByTestId('placeholder');
|
|
38
|
+
|
|
39
|
+
expect(headerIcon).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
43
|
+
const defaultProps = {
|
|
44
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
45
|
+
fhirResource: exampleAppointmentDSTU2,
|
|
46
|
+
fhirIcons: (
|
|
47
|
+
<img
|
|
48
|
+
src={require('../assets/containers/Appointment/appointment.svg')}
|
|
49
|
+
alt="appointment"
|
|
50
|
+
/>
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const { getByAltText } = render(<Appointment {...defaultProps} />);
|
|
55
|
+
const headerIcon = getByAltText('appointment');
|
|
56
|
+
|
|
57
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
61
|
+
const defaultProps = {
|
|
62
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
63
|
+
fhirResource: exampleAppointmentDSTU2,
|
|
64
|
+
fhirIcons: fhirIcons,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const { getByAltText } = render(<Appointment {...defaultProps} />);
|
|
68
|
+
const headerIcon = getByAltText('appointment');
|
|
69
|
+
|
|
70
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
74
|
+
const avatarSrc =
|
|
75
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
76
|
+
const defaultProps = {
|
|
77
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
78
|
+
fhirResource: exampleAppointmentDSTU2,
|
|
79
|
+
fhirIcons: avatarSrc,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const { getByAltText } = render(<Appointment {...defaultProps} />);
|
|
83
|
+
const headerIcon = getByAltText('header icon');
|
|
84
|
+
|
|
85
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
86
|
+
});
|
|
87
|
+
|
|
16
88
|
it('should render with DSTU2 source data', () => {
|
|
17
89
|
const defaultProps = {
|
|
18
90
|
fhirResource: exampleAppointmentDSTU2,
|
|
@@ -2,32 +2,42 @@ import React from 'react';
|
|
|
2
2
|
import Img from '../../datatypes/Img';
|
|
3
3
|
import Pdf from '../../datatypes/Pdf';
|
|
4
4
|
import BinaryText from '../../datatypes/BinaryText';
|
|
5
|
+
import Accordion from '../../containers/Accordion/Accordion';
|
|
6
|
+
import { Body, Header } from '../../ui';
|
|
5
7
|
|
|
6
8
|
const Binary = props => {
|
|
7
|
-
const { fhirResource } = props;
|
|
9
|
+
const { fhirResource, fhirIcons } = props;
|
|
10
|
+
|
|
11
|
+
const loadBinaryFile = () => {
|
|
12
|
+
switch (fhirResource.contentType) {
|
|
13
|
+
case 'application/pdf':
|
|
14
|
+
if (props.children && typeof props.children === 'function') {
|
|
15
|
+
return props.children(fhirResource.content, fhirResource.contentType);
|
|
16
|
+
}
|
|
17
|
+
return <Pdf fhirResource={fhirResource} />;
|
|
18
|
+
case 'image/jpeg':
|
|
19
|
+
return <Img fhirResource={fhirResource} />;
|
|
20
|
+
case 'application/xml':
|
|
21
|
+
return <BinaryText fhirResource={fhirResource} />;
|
|
22
|
+
case 'application/json':
|
|
23
|
+
return <BinaryText fhirResource={fhirResource} />;
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
8
28
|
|
|
9
29
|
return (
|
|
10
30
|
<div>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
return <Pdf fhirResource={fhirResource} />;
|
|
21
|
-
case 'image/jpeg':
|
|
22
|
-
return <Img fhirResource={fhirResource} />;
|
|
23
|
-
case 'application/xml':
|
|
24
|
-
return <BinaryText fhirResource={fhirResource} />;
|
|
25
|
-
case 'application/json':
|
|
26
|
-
return <BinaryText fhirResource={fhirResource} />;
|
|
27
|
-
default:
|
|
28
|
-
return null;
|
|
31
|
+
<Accordion
|
|
32
|
+
headerContent={
|
|
33
|
+
<Header
|
|
34
|
+
resourceName="Binary"
|
|
35
|
+
title={`Binary file: ${fhirResource.contentType}`}
|
|
36
|
+
icon={fhirIcons}
|
|
37
|
+
/>
|
|
29
38
|
}
|
|
30
|
-
|
|
39
|
+
bodyContent={<Body>{loadBinaryFile()}</Body>}
|
|
40
|
+
/>
|
|
31
41
|
</div>
|
|
32
42
|
);
|
|
33
43
|
};
|
|
@@ -8,6 +8,8 @@ import dstu2ExampleJpeg from '../../../fixtures/dstu2/resources/binary/example-j
|
|
|
8
8
|
import stu3ExamplePdf from '../../../fixtures/stu3/resources/binary/example-pdf.json';
|
|
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
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import BinaryIcon from '../../../assets/containers/Binary/binary.svg';
|
|
11
13
|
|
|
12
14
|
export default {
|
|
13
15
|
title: 'Binary',
|
|
@@ -15,25 +17,30 @@ export default {
|
|
|
15
17
|
|
|
16
18
|
export const PdfDSTU2 = () => {
|
|
17
19
|
const fhirResource = object('Resource', dstu2ExamplePdf);
|
|
18
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<Binary
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={require('../../../assets/containers/Binary/binary.svg')}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
19
26
|
};
|
|
20
27
|
|
|
21
28
|
export const JpegDSTU2 = () => {
|
|
22
29
|
const fhirResource = object('Resource', dstu2ExampleJpeg);
|
|
23
|
-
return <Binary fhirResource={fhirResource} />;
|
|
30
|
+
return <Binary fhirResource={fhirResource} fhirIcons={BinaryIcon} />;
|
|
24
31
|
};
|
|
25
32
|
|
|
26
33
|
export const PdfSTU3 = () => {
|
|
27
34
|
const fhirResource = object('Resource', stu3ExamplePdf);
|
|
28
|
-
return <Binary fhirResource={fhirResource} />;
|
|
35
|
+
return <Binary fhirResource={fhirResource} fhirIcons={false} />;
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
export const JpegSTU3 = () => {
|
|
32
39
|
const fhirResource = object('Resource', stu3ExampleJpeg);
|
|
33
|
-
return <Binary fhirResource={fhirResource} />;
|
|
40
|
+
return <Binary fhirResource={fhirResource} fhirIcons={'random text'} />;
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
export const JsonSTU3 = () => {
|
|
37
44
|
const fhirResource = object('Resource', stu3ExampleJson);
|
|
38
|
-
return <Binary fhirResource={fhirResource} />;
|
|
45
|
+
return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
39
46
|
};
|
|
@@ -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,18 +10,17 @@ import { isNotEmptyArray } from '../../../utils';
|
|
|
10
10
|
import fhirVersions from '../fhirResourceVersions';
|
|
11
11
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
12
12
|
import CarePlanActivity from './CarePlanActivity';
|
|
13
|
-
import './CarePlan.css';
|
|
14
13
|
|
|
15
14
|
import {
|
|
16
15
|
Root,
|
|
17
16
|
Header,
|
|
18
|
-
Title,
|
|
19
17
|
Badge,
|
|
20
18
|
BadgeSecondary,
|
|
21
19
|
Body,
|
|
22
|
-
Value,
|
|
23
20
|
MissingValue,
|
|
21
|
+
ValueSectionItem,
|
|
24
22
|
} from '../../ui';
|
|
23
|
+
import Accordion from '../../containers/Accordion';
|
|
25
24
|
|
|
26
25
|
const commonDTO = fhirResource => {
|
|
27
26
|
const status = _get(fhirResource, 'status', '');
|
|
@@ -163,8 +162,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
163
162
|
}
|
|
164
163
|
};
|
|
165
164
|
|
|
166
|
-
const CarePlan =
|
|
167
|
-
const { fhirResource, fhirVersion } = props;
|
|
165
|
+
const CarePlan = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
168
166
|
let fhirResourceData = {};
|
|
169
167
|
try {
|
|
170
168
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -197,99 +195,116 @@ const CarePlan = props => {
|
|
|
197
195
|
const authorArr = Array.isArray(author) ? author : [author];
|
|
198
196
|
return (
|
|
199
197
|
<Root name="CarePlan">
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
198
|
+
<Accordion
|
|
199
|
+
headerContent={
|
|
200
|
+
<Header
|
|
201
|
+
icon={fhirIcons}
|
|
202
|
+
resourceName="CarePlan"
|
|
203
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
204
|
+
title={'Care Plan'}
|
|
205
|
+
additionalContent={
|
|
206
|
+
expiry && <BadgeSecondary>expires on ${expiry}</BadgeSecondary>
|
|
207
|
+
}
|
|
208
|
+
/>
|
|
209
|
+
}
|
|
210
|
+
bodyContent={
|
|
211
|
+
<Body>
|
|
212
|
+
{hasCategory && (
|
|
213
|
+
<ValueSectionItem label="Category" data-testid="category">
|
|
214
|
+
{category.map((category, i) =>
|
|
215
|
+
(category.coding || []).map((coding, j) => (
|
|
216
|
+
<Coding key={`item-${i}${j}`} fhirData={coding} />
|
|
217
|
+
)),
|
|
218
|
+
)}
|
|
219
|
+
</ValueSectionItem>
|
|
212
220
|
)}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
{intent}
|
|
218
|
-
</Value>
|
|
219
|
-
)}
|
|
220
|
-
{hasGoals && (
|
|
221
|
-
<Value label="Goals" data-testid="goals">
|
|
222
|
-
{goals.map((goal, i) => (
|
|
223
|
-
<div key={`goal-${i}`}>
|
|
224
|
-
<Reference fhirData={goal} />
|
|
225
|
-
</div>
|
|
226
|
-
))}
|
|
227
|
-
</Value>
|
|
228
|
-
)}
|
|
229
|
-
{description && (
|
|
230
|
-
<Value label="Description" data-testid="description">
|
|
231
|
-
{description}
|
|
232
|
-
</Value>
|
|
233
|
-
)}
|
|
234
|
-
{subject && (
|
|
235
|
-
<Value label="Subject" data-testid="subject">
|
|
236
|
-
<Reference fhirData={subject} />
|
|
237
|
-
</Value>
|
|
238
|
-
)}
|
|
239
|
-
{hasValue(author) && (
|
|
240
|
-
<Value label="Author" data-testid="author">
|
|
241
|
-
{authorArr.map((item, i) => (
|
|
242
|
-
<Reference key={`author-${i}`} fhirData={item} />
|
|
243
|
-
))}
|
|
244
|
-
</Value>
|
|
245
|
-
)}
|
|
246
|
-
{periodStart && (
|
|
247
|
-
<Value label="Plan Period Start" data-testid="periodStart">
|
|
248
|
-
{periodStart ? (
|
|
249
|
-
<DateType fhirData={periodStart} />
|
|
250
|
-
) : (
|
|
251
|
-
<MissingValue />
|
|
221
|
+
{intent && (
|
|
222
|
+
<ValueSectionItem label="Intent" data-testid="intent">
|
|
223
|
+
{intent}
|
|
224
|
+
</ValueSectionItem>
|
|
252
225
|
)}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
{
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
</
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
226
|
+
{hasGoals && (
|
|
227
|
+
<ValueSectionItem label="Goals" data-testid="goals">
|
|
228
|
+
{goals.map((goal, i) => (
|
|
229
|
+
<div key={`goal-${i}`}>
|
|
230
|
+
<Reference fhirData={goal} />
|
|
231
|
+
</div>
|
|
232
|
+
))}
|
|
233
|
+
</ValueSectionItem>
|
|
234
|
+
)}
|
|
235
|
+
{description && (
|
|
236
|
+
<ValueSectionItem label="Description" data-testid="description">
|
|
237
|
+
{description}
|
|
238
|
+
</ValueSectionItem>
|
|
239
|
+
)}
|
|
240
|
+
{subject && (
|
|
241
|
+
<ValueSectionItem label="Subject" data-testid="subject">
|
|
242
|
+
<Reference fhirData={subject} />
|
|
243
|
+
</ValueSectionItem>
|
|
244
|
+
)}
|
|
245
|
+
{hasValue(author) && (
|
|
246
|
+
<ValueSectionItem label="Author" data-testid="author">
|
|
247
|
+
{authorArr.map((item, i) => (
|
|
248
|
+
<Reference key={`author-${i}`} fhirData={item} />
|
|
249
|
+
))}
|
|
250
|
+
</ValueSectionItem>
|
|
251
|
+
)}
|
|
252
|
+
{periodStart && (
|
|
253
|
+
<ValueSectionItem
|
|
254
|
+
label="Plan Period Start"
|
|
255
|
+
data-testid="periodStart"
|
|
256
|
+
>
|
|
257
|
+
{periodStart ? (
|
|
258
|
+
<DateType fhirData={periodStart} isBlack />
|
|
259
|
+
) : (
|
|
260
|
+
<MissingValue />
|
|
261
|
+
)}
|
|
262
|
+
</ValueSectionItem>
|
|
263
|
+
)}
|
|
264
|
+
{periodEnd && (
|
|
265
|
+
<ValueSectionItem label="Plan Period End" data-testid="periodEnd">
|
|
266
|
+
{periodEnd ? (
|
|
267
|
+
<DateType fhirData={periodEnd} isBlack />
|
|
268
|
+
) : (
|
|
269
|
+
<MissingValue />
|
|
270
|
+
)}
|
|
271
|
+
</ValueSectionItem>
|
|
272
|
+
)}
|
|
273
|
+
{hasAddresses && (
|
|
274
|
+
<ValueSectionItem label="Addresses" data-testid="addresses">
|
|
275
|
+
{addresses.map((address, i) => (
|
|
276
|
+
<div key={`item-${i}`}>
|
|
277
|
+
<Reference fhirData={address} />
|
|
278
|
+
</div>
|
|
279
|
+
))}
|
|
280
|
+
</ValueSectionItem>
|
|
281
|
+
)}
|
|
282
|
+
{isNotEmptyArray(basedOn) && (
|
|
283
|
+
<ValueSectionItem label="Based on" data-testid="basedOn">
|
|
284
|
+
{basedOn.map((item, i) => (
|
|
285
|
+
<Reference key={`based-on-${i}`} fhirData={item} />
|
|
286
|
+
))}
|
|
287
|
+
</ValueSectionItem>
|
|
288
|
+
)}
|
|
289
|
+
{isNotEmptyArray(partOf) && (
|
|
290
|
+
<ValueSectionItem label="Part of" data-testid="partOf">
|
|
291
|
+
{partOf.map((item, i) => (
|
|
292
|
+
<Reference key={`part-of-${i}`} fhirData={item} />
|
|
293
|
+
))}
|
|
294
|
+
</ValueSectionItem>
|
|
295
|
+
)}
|
|
296
|
+
{hasActivity && (
|
|
297
|
+
<ValueSectionItem label="Activity" data-testid="activity">
|
|
298
|
+
{activity.map((activity, i) => (
|
|
299
|
+
<div key={`item-${i}`}>
|
|
300
|
+
<CarePlanActivity fhirData={activity} />
|
|
301
|
+
</div>
|
|
302
|
+
))}
|
|
303
|
+
</ValueSectionItem>
|
|
304
|
+
)}
|
|
305
|
+
</Body>
|
|
306
|
+
}
|
|
307
|
+
/>
|
|
293
308
|
</Root>
|
|
294
309
|
);
|
|
295
310
|
};
|
|
@@ -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 = () => {
|