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
|
@@ -4,8 +4,75 @@ import { render } from '@testing-library/react';
|
|
|
4
4
|
import MedicationOrder from './MedicationOrder';
|
|
5
5
|
|
|
6
6
|
import example from '../../../fixtures/dstu2/resources/medicationOrder/example.json';
|
|
7
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
7
8
|
|
|
8
9
|
describe('should render MedicationOrder component properly', () => {
|
|
10
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
11
|
+
const defaultProps = {
|
|
12
|
+
fhirResource: example,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
16
|
+
const headerIcon = getByAltText('medication order');
|
|
17
|
+
|
|
18
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
fhirResource: example,
|
|
24
|
+
fhirIcons: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const { getByTestId } = render(<MedicationOrder {...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
|
+
fhirResource: example,
|
|
36
|
+
fhirIcons: (
|
|
37
|
+
<img
|
|
38
|
+
src={require('../assets/containers/MedicationOrder/medication-order.svg')}
|
|
39
|
+
alt="medication order"
|
|
40
|
+
/>
|
|
41
|
+
),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
45
|
+
const headerIcon = getByAltText('medication order');
|
|
46
|
+
|
|
47
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
51
|
+
const defaultProps = {
|
|
52
|
+
fhirResource: example,
|
|
53
|
+
fhirIcons: fhirIcons,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
57
|
+
const headerIcon = getByAltText('medication order');
|
|
58
|
+
|
|
59
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
63
|
+
const avatarSrc =
|
|
64
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
65
|
+
const defaultProps = {
|
|
66
|
+
fhirResource: example,
|
|
67
|
+
fhirIcons: avatarSrc,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
71
|
+
const headerIcon = getByAltText('header icon');
|
|
72
|
+
|
|
73
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
74
|
+
});
|
|
75
|
+
|
|
9
76
|
it('should render with DSTU2 source data', () => {
|
|
10
77
|
const defaultProps = {
|
|
11
78
|
fhirResource: example,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
|
+
import Accordion from '../../containers/Accordion/Accordion';
|
|
4
5
|
import Reference from '../../datatypes/Reference';
|
|
5
6
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
6
7
|
import Coding from '../../datatypes/Coding';
|
|
7
8
|
import Date from '../../datatypes/Date';
|
|
8
9
|
|
|
9
|
-
import { Root, Header,
|
|
10
|
+
import { Root, Header, Body } from '../../ui';
|
|
10
11
|
|
|
11
|
-
const MedicationRequest =
|
|
12
|
-
const { fhirResource } = props;
|
|
12
|
+
const MedicationRequest = ({ fhirResource, fhirIcons }) => {
|
|
13
13
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
14
14
|
const medicationCodeableConcept = _get(
|
|
15
15
|
fhirResource,
|
|
@@ -25,49 +25,69 @@ const MedicationRequest = props => {
|
|
|
25
25
|
_get(fhirResource, 'requester.agent') || _get(fhirResource, 'requester');
|
|
26
26
|
const created = _get(fhirResource, 'authoredOn');
|
|
27
27
|
const intent = _get(fhirResource, 'intent');
|
|
28
|
+
const tableData = [
|
|
29
|
+
{
|
|
30
|
+
label: 'Medication',
|
|
31
|
+
testId: 'medication',
|
|
32
|
+
data: showMedicationCodeableConcept && (
|
|
33
|
+
<Coding fhirData={medicationCodeableConcept} />
|
|
34
|
+
),
|
|
35
|
+
status: showMedicationCodeableConcept,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Requester',
|
|
39
|
+
testId: 'requester',
|
|
40
|
+
data: requester && <Reference fhirData={requester} />,
|
|
41
|
+
status: requester,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Created',
|
|
45
|
+
testId: 'created',
|
|
46
|
+
data: created && <Date fhirData={created} />,
|
|
47
|
+
status: created,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'Type of request',
|
|
51
|
+
testId: 'intent',
|
|
52
|
+
data: intent,
|
|
53
|
+
status: intent,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Reason',
|
|
57
|
+
testId: 'reasonCode',
|
|
58
|
+
data: reasonCode && <CodeableConcept fhirData={reasonCode} />,
|
|
59
|
+
status: reasonCode,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: 'Dosage',
|
|
63
|
+
testId: 'hasDosageInstruction',
|
|
64
|
+
data:
|
|
65
|
+
hasDosageInstruction &&
|
|
66
|
+
dosageInstruction.map((item, i) => (
|
|
67
|
+
<p key={`dosage-instruction-item-${i}`}>{item.text}</p>
|
|
68
|
+
)),
|
|
69
|
+
status: hasDosageInstruction,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
28
73
|
return (
|
|
29
74
|
<Root name="MedicationRequest">
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{created && (
|
|
47
|
-
<Value label="Created" data-testid="created">
|
|
48
|
-
<Date fhirData={created} />
|
|
49
|
-
</Value>
|
|
50
|
-
)}
|
|
51
|
-
{intent && (
|
|
52
|
-
<Value label="Type of request" data-testid="intent">
|
|
53
|
-
{intent}
|
|
54
|
-
</Value>
|
|
55
|
-
)}
|
|
56
|
-
{reasonCode && (
|
|
57
|
-
<Value label="Reason" data-testid="reasonCode">
|
|
58
|
-
<CodeableConcept fhirData={reasonCode} />
|
|
59
|
-
</Value>
|
|
60
|
-
)}
|
|
61
|
-
{hasDosageInstruction && (
|
|
62
|
-
<Value label="Dosage" data-testid="hasDosageInstruction">
|
|
63
|
-
<ul>
|
|
64
|
-
{dosageInstruction.map((item, i) => (
|
|
65
|
-
<li key={`item-${i}`}>{item.text}</li>
|
|
66
|
-
))}
|
|
67
|
-
</ul>
|
|
68
|
-
</Value>
|
|
69
|
-
)}
|
|
70
|
-
</Body>
|
|
75
|
+
<Accordion
|
|
76
|
+
headerContent={
|
|
77
|
+
<Header
|
|
78
|
+
icon={fhirIcons}
|
|
79
|
+
resourceName="MedicationRequest"
|
|
80
|
+
title={
|
|
81
|
+
medicationReference ? (
|
|
82
|
+
<Reference fhirData={medicationReference} />
|
|
83
|
+
) : (
|
|
84
|
+
'Medication request'
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
}
|
|
89
|
+
bodyContent={<Body tableData={tableData} />}
|
|
90
|
+
/>
|
|
71
91
|
</Root>
|
|
72
92
|
);
|
|
73
93
|
};
|
|
@@ -8,6 +8,8 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medicationRequest/exa
|
|
|
8
8
|
import R4Example1 from '../../../fixtures/r4/resources/medicationRequest/example1.json';
|
|
9
9
|
import R4Example2 from '../../../fixtures/r4/resources/medicationRequest/example2.json';
|
|
10
10
|
import R4Example3 from '../../../fixtures/r4/resources/medicationRequest/example3.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import MedicationRequestIcon from '../../../assets/containers/MedicationRequest/medication-request.svg';
|
|
11
13
|
|
|
12
14
|
export default {
|
|
13
15
|
title: 'MedicationRequest',
|
|
@@ -15,25 +17,39 @@ export default {
|
|
|
15
17
|
|
|
16
18
|
export const DefaultVisualizationSTU3 = () => {
|
|
17
19
|
const fhirResource = object('Resource', stu3Example1);
|
|
18
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<MedicationRequest
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={require('../../../assets/containers/MedicationRequest/medication-request.svg')}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
19
26
|
};
|
|
20
27
|
|
|
21
28
|
export const Example2OfSTU3 = () => {
|
|
22
29
|
const fhirResource = object('Resource', stu3Example2);
|
|
23
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
<MedicationRequest
|
|
32
|
+
fhirResource={fhirResource}
|
|
33
|
+
fhirIcons={MedicationRequestIcon}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
24
36
|
};
|
|
25
37
|
|
|
26
38
|
export const Example1OfR4 = () => {
|
|
27
39
|
const fhirResource = object('Resource', R4Example1);
|
|
28
|
-
return
|
|
40
|
+
return (
|
|
41
|
+
<MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
|
|
42
|
+
);
|
|
29
43
|
};
|
|
30
44
|
|
|
31
45
|
export const Example2OfR4 = () => {
|
|
32
46
|
const fhirResource = object('Resource', R4Example2);
|
|
33
|
-
return <MedicationRequest fhirResource={fhirResource} />;
|
|
47
|
+
return <MedicationRequest fhirResource={fhirResource} fhirIcons={false} />;
|
|
34
48
|
};
|
|
35
49
|
|
|
36
50
|
export const Example3OfR4 = () => {
|
|
37
51
|
const fhirResource = object('Resource', R4Example3);
|
|
38
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
<MedicationRequest fhirResource={fhirResource} fhirIcons={'random text'} />
|
|
54
|
+
);
|
|
39
55
|
};
|
|
@@ -8,8 +8,75 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medicationRequest/exa
|
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/medicationRequest/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/medicationRequest/example2.json';
|
|
10
10
|
import r4Example3 from '../../../fixtures/r4/resources/medicationRequest/example3.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
describe('should render MedicationRequest component properly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirResource: stu3Example1,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('medication request');
|
|
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: stu3Example1,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<MedicationRequest {...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: stu3Example1,
|
|
40
|
+
fhirIcons: (
|
|
41
|
+
<img
|
|
42
|
+
src={require('../assets/containers/MedicationOrder/medication-request.svg')}
|
|
43
|
+
alt="medication request"
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
49
|
+
const headerIcon = getByAltText('medication request');
|
|
50
|
+
|
|
51
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
55
|
+
const defaultProps = {
|
|
56
|
+
fhirResource: stu3Example1,
|
|
57
|
+
fhirIcons: fhirIcons,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
61
|
+
const headerIcon = getByAltText('medication request');
|
|
62
|
+
|
|
63
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
67
|
+
const avatarSrc =
|
|
68
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
69
|
+
const defaultProps = {
|
|
70
|
+
fhirResource: stu3Example1,
|
|
71
|
+
fhirIcons: avatarSrc,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
75
|
+
const headerIcon = getByAltText('header icon');
|
|
76
|
+
|
|
77
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
78
|
+
});
|
|
79
|
+
|
|
13
80
|
it('should render with STU3 source data', () => {
|
|
14
81
|
const defaultProps = {
|
|
15
82
|
fhirResource: stu3Example1,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ValueSection, ValueSectionItem } from '../../ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Reference from '../../datatypes/Reference';
|
|
4
|
+
import _get from 'lodash/get';
|
|
5
|
+
|
|
6
|
+
const MedicationDetails = props => {
|
|
7
|
+
const {
|
|
8
|
+
medication,
|
|
9
|
+
expiration,
|
|
10
|
+
ingredient,
|
|
11
|
+
medicationReference,
|
|
12
|
+
hasReasonCode,
|
|
13
|
+
reasonCode,
|
|
14
|
+
} = props;
|
|
15
|
+
return (
|
|
16
|
+
<ValueSection label={medication} marginBottom>
|
|
17
|
+
<ValueSectionItem label="Expiration date" data-testid="expirationDate">
|
|
18
|
+
{expiration}
|
|
19
|
+
</ValueSectionItem>
|
|
20
|
+
{ingredient && (
|
|
21
|
+
<ValueSectionItem label="Ingredient" data-testid="ingredient">
|
|
22
|
+
{ingredient.map((item, i) => (
|
|
23
|
+
<div key={`item-${i}`} data-testid="ingredient-item">
|
|
24
|
+
{_get(item, 'itemCodeableConcept.coding.0.display', '')}
|
|
25
|
+
</div>
|
|
26
|
+
))}
|
|
27
|
+
</ValueSectionItem>
|
|
28
|
+
)}
|
|
29
|
+
{medicationReference && (
|
|
30
|
+
<ValueSectionItem
|
|
31
|
+
label="Medication reference"
|
|
32
|
+
data-testid="medicationReference"
|
|
33
|
+
>
|
|
34
|
+
{<Reference fhirData={medicationReference} />}
|
|
35
|
+
</ValueSectionItem>
|
|
36
|
+
)}
|
|
37
|
+
{hasReasonCode && (
|
|
38
|
+
<ValueSectionItem label="Reasons" data-testid="hasReasonCode">
|
|
39
|
+
{reasonCode.map((item, i) => {
|
|
40
|
+
const display = _get(item, 'coding.0.display');
|
|
41
|
+
if (display) {
|
|
42
|
+
return <div key={`item-${i}`}>{display}</div>;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
})}
|
|
46
|
+
</ValueSectionItem>
|
|
47
|
+
)}
|
|
48
|
+
</ValueSection>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default MedicationDetails;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ValueSection, ValueSectionItem } from '../../ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _get from 'lodash/get';
|
|
4
|
+
|
|
5
|
+
const MedicationDosage = props => {
|
|
6
|
+
const { dosage, hasNote, note, itemNumber } = props;
|
|
7
|
+
|
|
8
|
+
const instructions = _get(dosage, 'text');
|
|
9
|
+
const additionalInstructionText = _get(
|
|
10
|
+
dosage,
|
|
11
|
+
'additionalInstruction[0].text',
|
|
12
|
+
);
|
|
13
|
+
const route =
|
|
14
|
+
_get(dosage, 'route.coding[0].display') ||
|
|
15
|
+
`${_get(dosage, 'route.text', '')} ${_get(dosage, 'text', '')}`;
|
|
16
|
+
const hasRoute = route.trim() !== '';
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ValueSection label="Dosage" key={itemNumber}>
|
|
20
|
+
<ValueSectionItem label="Instructions" data-testid="dosageInstruction">
|
|
21
|
+
{instructions}
|
|
22
|
+
</ValueSectionItem>
|
|
23
|
+
{additionalInstructionText && (
|
|
24
|
+
<ValueSectionItem
|
|
25
|
+
label="Additional instruction"
|
|
26
|
+
data-testid="additionalInstruction"
|
|
27
|
+
>
|
|
28
|
+
{additionalInstructionText}
|
|
29
|
+
</ValueSectionItem>
|
|
30
|
+
)}
|
|
31
|
+
{hasRoute && (
|
|
32
|
+
<ValueSectionItem label="Route" data-testid="route">
|
|
33
|
+
{route}
|
|
34
|
+
</ValueSectionItem>
|
|
35
|
+
)}
|
|
36
|
+
{hasNote && (
|
|
37
|
+
<ValueSectionItem label="Notes" data-testid="hasNote">
|
|
38
|
+
{note.map((item, i) => (
|
|
39
|
+
<div key={`note-${i}`}>{item.text}</div>
|
|
40
|
+
))}
|
|
41
|
+
</ValueSectionItem>
|
|
42
|
+
)}
|
|
43
|
+
</ValueSection>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
export default MedicationDosage;
|
|
@@ -3,42 +3,13 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
|
|
4
4
|
import _get from 'lodash/get';
|
|
5
5
|
import _has from 'lodash/has';
|
|
6
|
-
import Date from '../../datatypes/Date';
|
|
7
6
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
8
7
|
import fhirVersions from '../fhirResourceVersions';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Title,
|
|
15
|
-
Badge,
|
|
16
|
-
BadgeSecondary,
|
|
17
|
-
Body,
|
|
18
|
-
Value,
|
|
19
|
-
ValueSection,
|
|
20
|
-
} from '../../ui';
|
|
21
|
-
|
|
22
|
-
const MedicationDetails = props => {
|
|
23
|
-
const { medication, expiration, ingredient } = props;
|
|
24
|
-
return (
|
|
25
|
-
<div>
|
|
26
|
-
<h5>{medication} </h5>
|
|
27
|
-
<Value label="Expiration date">{expiration}</Value>
|
|
28
|
-
{ingredient && (
|
|
29
|
-
<Value label="Ingredient">
|
|
30
|
-
<ul>
|
|
31
|
-
{ingredient.map((item, i) => (
|
|
32
|
-
<li key={`item-${i}`}>
|
|
33
|
-
{_get(item, 'itemCodeableConcept.coding.0.display', '')}
|
|
34
|
-
</li>
|
|
35
|
-
))}
|
|
36
|
-
</ul>
|
|
37
|
-
</Value>
|
|
38
|
-
)}
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
8
|
+
import Accordion from '../../containers/Accordion';
|
|
9
|
+
import DatePeriod from '../../datatypes/DatePeriod/DatePeriod';
|
|
10
|
+
import MedicationDetails from './MedicationDetails';
|
|
11
|
+
import { Root, Header, Badge, Body } from '../../ui';
|
|
12
|
+
import MedicationDosage from './MedicationDosage';
|
|
42
13
|
|
|
43
14
|
const DEFAULT_TITLE = 'Medication Statement';
|
|
44
15
|
|
|
@@ -137,7 +108,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
137
108
|
};
|
|
138
109
|
|
|
139
110
|
const MedicationStatement = props => {
|
|
140
|
-
const { fhirResource, fhirVersion } = props;
|
|
111
|
+
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
141
112
|
let fhirResourceData = {};
|
|
142
113
|
try {
|
|
143
114
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -165,94 +136,71 @@ const MedicationStatement = props => {
|
|
|
165
136
|
|
|
166
137
|
return (
|
|
167
138
|
<Root name="MedicationStatement">
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
'code.coding[0].display',
|
|
186
|
-
);
|
|
187
|
-
if (hasMedicationDetails) {
|
|
188
|
-
return (
|
|
189
|
-
<MedicationDetails
|
|
190
|
-
key={`item-${i}`}
|
|
191
|
-
medication={_get(medication, 'code.coding[0].display')}
|
|
192
|
-
expiration={_get(
|
|
193
|
-
medication,
|
|
194
|
-
'package.batch[0].expirationDate',
|
|
195
|
-
)}
|
|
196
|
-
ingredient={_get(medication, 'ingredient', [])}
|
|
139
|
+
<Accordion
|
|
140
|
+
headerContent={
|
|
141
|
+
<Header
|
|
142
|
+
icon={fhirIcons}
|
|
143
|
+
resourceName="MedicationStatement"
|
|
144
|
+
badges={status && <Badge data-testid="hasStatus">{status}</Badge>}
|
|
145
|
+
title={title}
|
|
146
|
+
additionalContent={
|
|
147
|
+
hasEffectivePeriod && (
|
|
148
|
+
<>
|
|
149
|
+
<DatePeriod
|
|
150
|
+
periodBeginLabel="Start date"
|
|
151
|
+
periodBeginDate={statusDesc.from}
|
|
152
|
+
periodBeginTestId="startDate"
|
|
153
|
+
periodEndLabel="End date"
|
|
154
|
+
periodEndDate={statusDesc.to}
|
|
155
|
+
periodEndTestId="endDate"
|
|
197
156
|
/>
|
|
157
|
+
<span>{reported}</span>
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
/>
|
|
162
|
+
}
|
|
163
|
+
bodyContent={
|
|
164
|
+
<Body>
|
|
165
|
+
{hasMedications &&
|
|
166
|
+
contained.map((medication, i) => {
|
|
167
|
+
const hasMedicationDetails = _has(
|
|
168
|
+
medication,
|
|
169
|
+
'code.coding[0].display',
|
|
198
170
|
);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return <li key={`item-${i}`}>{display}</li>;
|
|
171
|
+
if (hasMedicationDetails) {
|
|
172
|
+
return (
|
|
173
|
+
<MedicationDetails
|
|
174
|
+
key={`item-${i}`}
|
|
175
|
+
itemNumber={`item-${i}`}
|
|
176
|
+
medication={_get(medication, 'code.coding[0].display')}
|
|
177
|
+
expiration={_get(
|
|
178
|
+
medication,
|
|
179
|
+
'package.batch[0].expirationDate',
|
|
180
|
+
)}
|
|
181
|
+
ingredient={_get(medication, 'ingredient', [])}
|
|
182
|
+
medicationReference={medicationReference}
|
|
183
|
+
hasReasonCode={hasReasonCode}
|
|
184
|
+
reasonCode={reasonCode}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
216
187
|
}
|
|
217
188
|
return null;
|
|
218
189
|
})}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const hasRoute = route.trim() !== '';
|
|
234
|
-
return (
|
|
235
|
-
<div key={`dosage-${i}`}>
|
|
236
|
-
<Value label="Instructions" data-testid="dosageInstruction">
|
|
237
|
-
{text}
|
|
238
|
-
</Value>
|
|
239
|
-
{additionalInstructionText && (
|
|
240
|
-
<Value label="Additional Instruction">
|
|
241
|
-
{additionalInstructionText}
|
|
242
|
-
</Value>
|
|
243
|
-
)}
|
|
244
|
-
{hasRoute && <Value label="Route">{route}</Value>}
|
|
245
|
-
</div>
|
|
246
|
-
);
|
|
247
|
-
})}
|
|
248
|
-
</ValueSection>
|
|
249
|
-
)}
|
|
250
|
-
{hasNote && (
|
|
251
|
-
<Value label="Notes" data-testid="hasNote">
|
|
252
|
-
<Annotation fhirData={note} />
|
|
253
|
-
</Value>
|
|
254
|
-
)}
|
|
255
|
-
</Body>
|
|
190
|
+
{hasDosage &&
|
|
191
|
+
fhirResource.dosage.map((dosage, i) => {
|
|
192
|
+
return (
|
|
193
|
+
<MedicationDosage
|
|
194
|
+
key={`dosage-${i}`}
|
|
195
|
+
dosage={dosage}
|
|
196
|
+
hasNote={hasNote}
|
|
197
|
+
note={note}
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
})}
|
|
201
|
+
</Body>
|
|
202
|
+
}
|
|
203
|
+
/>
|
|
256
204
|
</Root>
|
|
257
205
|
);
|
|
258
206
|
};
|