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
|
@@ -3,20 +3,13 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import Reference from '../../datatypes/Reference';
|
|
4
4
|
import Coding from '../../datatypes/Coding';
|
|
5
5
|
import Date from '../../datatypes/Date';
|
|
6
|
+
import Accordion from '../../containers/Accordion/Accordion';
|
|
6
7
|
import _get from 'lodash/get';
|
|
7
8
|
import _has from 'lodash/has';
|
|
8
9
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
9
10
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
-
Root,
|
|
13
|
-
Header,
|
|
14
|
-
Title,
|
|
15
|
-
Badge,
|
|
16
|
-
BadgeSecondary,
|
|
17
|
-
Body,
|
|
18
|
-
Value,
|
|
19
|
-
} from '../../ui';
|
|
12
|
+
import { Root, Header, Badge, Body, Value } from '../../ui';
|
|
20
13
|
|
|
21
14
|
const commonDTO = fhirResource => {
|
|
22
15
|
const title = _get(fhirResource, 'note[0].text', 'Goal');
|
|
@@ -107,7 +100,8 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
107
100
|
};
|
|
108
101
|
|
|
109
102
|
const Goal = props => {
|
|
110
|
-
const { fhirResource, fhirVersion } = props;
|
|
103
|
+
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
104
|
+
|
|
111
105
|
let fhirResourceData = {};
|
|
112
106
|
try {
|
|
113
107
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -135,83 +129,107 @@ const Goal = props => {
|
|
|
135
129
|
statusDate,
|
|
136
130
|
} = fhirResourceData;
|
|
137
131
|
|
|
132
|
+
const tableData = [
|
|
133
|
+
{
|
|
134
|
+
label: 'Subject',
|
|
135
|
+
testId: 'subject',
|
|
136
|
+
data: subject && <Reference fhirData={subject} />,
|
|
137
|
+
status: subject,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
label: 'Subject',
|
|
141
|
+
testId: 'statusDate',
|
|
142
|
+
data: statusDate && <Date fhirData={statusDate} />,
|
|
143
|
+
status: statusDate,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: 'Description',
|
|
147
|
+
testId: 'description',
|
|
148
|
+
data: description,
|
|
149
|
+
status: description,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
label: 'Category',
|
|
153
|
+
testId: 'category',
|
|
154
|
+
data:
|
|
155
|
+
hasCategory &&
|
|
156
|
+
category.map((item, i) => {
|
|
157
|
+
const coding = _get(item, 'coding', []);
|
|
158
|
+
if (!Array.isArray(coding)) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return coding.map((codingItem, j) => (
|
|
162
|
+
<Coding key={`coding-item-${j}`} fhirData={codingItem} />
|
|
163
|
+
));
|
|
164
|
+
}),
|
|
165
|
+
status: hasCategory,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
label: 'Universal Device Identifier',
|
|
169
|
+
testId: 'udi',
|
|
170
|
+
data: udi,
|
|
171
|
+
status: hasUdi,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: 'Addresses',
|
|
175
|
+
testId: 'addresses',
|
|
176
|
+
data:
|
|
177
|
+
hasAddresses &&
|
|
178
|
+
addresses.map((address, i) => (
|
|
179
|
+
<Reference key={`address-item-${i}`} fhirData={address} />
|
|
180
|
+
)),
|
|
181
|
+
status: hasAddresses,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: 'Priority',
|
|
185
|
+
testId: 'priority',
|
|
186
|
+
data: priority && <Coding fhirData={priority} />,
|
|
187
|
+
status: priority,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: 'Author',
|
|
191
|
+
testId: 'author',
|
|
192
|
+
data: author && <Reference fhirData={author} />,
|
|
193
|
+
status: author,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
label: 'Outcome',
|
|
197
|
+
testId: 'outcomeReference',
|
|
198
|
+
data:
|
|
199
|
+
outcomeReference &&
|
|
200
|
+
outcomeReference.map((item, i) => (
|
|
201
|
+
<Reference key={`outcome-reference-item-${i}`} fhirData={item} />
|
|
202
|
+
)),
|
|
203
|
+
status: outcomeReference,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
label: 'Achievement Status',
|
|
207
|
+
testId: 'achievementStatus',
|
|
208
|
+
data: achievementStatus && <Coding fhirData={achievementStatus} />,
|
|
209
|
+
status: achievementStatus,
|
|
210
|
+
},
|
|
211
|
+
];
|
|
212
|
+
|
|
138
213
|
return (
|
|
139
214
|
<Root name="Goal">
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
</Value>
|
|
159
|
-
)}
|
|
160
|
-
{description && (
|
|
161
|
-
<Value label="Description" data-testid="description">
|
|
162
|
-
{description}
|
|
163
|
-
</Value>
|
|
164
|
-
)}
|
|
165
|
-
{hasCategory && (
|
|
166
|
-
<Value label="Category" data-testid="category">
|
|
167
|
-
{category.map((item, i) => {
|
|
168
|
-
const coding = _get(item, 'coding', []);
|
|
169
|
-
if (!Array.isArray(coding)) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
return coding.map((codingItem, j) => (
|
|
173
|
-
<div key={`item-${j}`}>
|
|
174
|
-
<Coding fhirData={codingItem} />
|
|
175
|
-
</div>
|
|
176
|
-
));
|
|
177
|
-
})}
|
|
178
|
-
</Value>
|
|
179
|
-
)}
|
|
180
|
-
{hasUdi && <Value label="Universal Device Identifier"> {udi}</Value>}
|
|
181
|
-
{hasAddresses && (
|
|
182
|
-
<Value label="Addresses" data-testid="addresses">
|
|
183
|
-
{addresses.map((address, i) => {
|
|
184
|
-
return (
|
|
185
|
-
<div key={`item-${i}`}>
|
|
186
|
-
<Reference fhirData={address} />
|
|
187
|
-
</div>
|
|
188
|
-
);
|
|
189
|
-
})}
|
|
190
|
-
</Value>
|
|
191
|
-
)}
|
|
192
|
-
{priority && (
|
|
193
|
-
<Value label="Priority" data-testid="priority">
|
|
194
|
-
<Coding fhirData={priority} />
|
|
195
|
-
</Value>
|
|
196
|
-
)}
|
|
197
|
-
{author && (
|
|
198
|
-
<Value label="Author" data-testid="author">
|
|
199
|
-
<Reference fhirData={author} />
|
|
200
|
-
</Value>
|
|
201
|
-
)}
|
|
202
|
-
{outcomeReference && (
|
|
203
|
-
<Value label="Outcome" data-testid="outcomeReference">
|
|
204
|
-
{outcomeReference.map((item, i) => (
|
|
205
|
-
<Reference key={`item-${i}`} fhirData={item} />
|
|
206
|
-
))}
|
|
207
|
-
</Value>
|
|
208
|
-
)}
|
|
209
|
-
{achievementStatus && (
|
|
210
|
-
<Value label="Achievement Status" data-testid="achievementStatus">
|
|
211
|
-
<Coding fhirData={achievementStatus} />
|
|
212
|
-
</Value>
|
|
213
|
-
)}
|
|
214
|
-
</Body>
|
|
215
|
+
<Accordion
|
|
216
|
+
headerContent={
|
|
217
|
+
<Header
|
|
218
|
+
resourceName="Goal"
|
|
219
|
+
additionalContent={
|
|
220
|
+
startDate && (
|
|
221
|
+
<Value label="Started" data-testid="headerStartDate">
|
|
222
|
+
<Date fhirData={startDate} isBlack />
|
|
223
|
+
</Value>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
badges={hasStatus && <Badge data-testid="status">{status}</Badge>}
|
|
227
|
+
icon={fhirIcons}
|
|
228
|
+
title={title}
|
|
229
|
+
/>
|
|
230
|
+
}
|
|
231
|
+
bodyContent={<Body tableData={tableData} />}
|
|
232
|
+
/>
|
|
215
233
|
</Root>
|
|
216
234
|
);
|
|
217
235
|
};
|
|
@@ -2,13 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { object } from '@storybook/addon-knobs';
|
|
3
3
|
|
|
4
4
|
import Goal from './Goal';
|
|
5
|
-
|
|
5
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
6
6
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/goal/example1.json';
|
|
7
7
|
import dstu2Example2 from '../../../fixtures/dstu2/resources/goal/example2.json';
|
|
8
8
|
import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
|
|
9
9
|
import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
|
|
10
10
|
import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
|
|
11
11
|
import fhirVersions from '../fhirResourceVersions';
|
|
12
|
+
import GoalIcon from '../../../assets/containers/Goal/goal.svg';
|
|
12
13
|
|
|
13
14
|
export default {
|
|
14
15
|
title: 'Goal',
|
|
@@ -16,30 +17,60 @@ export default {
|
|
|
16
17
|
|
|
17
18
|
export const DefaultVisualizationDSTU2 = () => {
|
|
18
19
|
const fhirResource = object('Resource', dstu2Example1);
|
|
19
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<Goal
|
|
22
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
23
|
+
fhirResource={fhirResource}
|
|
24
|
+
fhirIcons={require('../../../assets/containers/Goal/goal.svg')}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
20
27
|
};
|
|
21
28
|
|
|
22
29
|
export const Example2OfDSTU2 = () => {
|
|
23
30
|
const fhirResource = object('Resource', dstu2Example2);
|
|
24
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<Goal
|
|
33
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
34
|
+
fhirResource={fhirResource}
|
|
35
|
+
fhirIcons={GoalIcon}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
25
38
|
};
|
|
26
39
|
|
|
27
40
|
export const ExampleOfSTU3 = () => {
|
|
28
41
|
const fhirResource = object('Resource', stu3Example1);
|
|
29
|
-
return
|
|
42
|
+
return (
|
|
43
|
+
<Goal
|
|
44
|
+
fhirVersion={fhirVersions.STU3}
|
|
45
|
+
fhirResource={fhirResource}
|
|
46
|
+
fhirIcons={fhirIcons}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
30
49
|
};
|
|
31
50
|
|
|
32
51
|
export const Example1OfR4 = () => {
|
|
33
52
|
const fhirResource = object('Resource', r4Example1);
|
|
34
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
<Goal
|
|
55
|
+
fhirVersion={fhirVersions.R4}
|
|
56
|
+
fhirResource={fhirResource}
|
|
57
|
+
fhirIcons={false}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
35
60
|
};
|
|
36
61
|
|
|
37
62
|
export const Example2OfR4 = () => {
|
|
38
63
|
const fhirResource = object('Resource', r4Example2);
|
|
39
|
-
return
|
|
64
|
+
return (
|
|
65
|
+
<Goal
|
|
66
|
+
fhirVersion={fhirVersions.R4}
|
|
67
|
+
fhirResource={fhirResource}
|
|
68
|
+
fhirIcons={'random text'}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
40
71
|
};
|
|
41
72
|
|
|
42
73
|
export const ExampleWithoutFhirVersionProperty = () => {
|
|
43
74
|
const fhirResource = object('Resource', stu3Example1);
|
|
44
|
-
return <Goal fhirResource={fhirResource} />;
|
|
75
|
+
return <Goal fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
45
76
|
};
|
|
@@ -7,8 +7,77 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/goal/example1.json'
|
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render Goal component properly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirResource: dstu2Example1,
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<Goal {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('goal');
|
|
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: dstu2Example1,
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<Goal {...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: dstu2Example1,
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img src={require('../assets/containers/Goal/goal.svg')} alt="goal" />
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const { getByAltText } = render(<Goal {...defaultProps} />);
|
|
48
|
+
const headerIcon = getByAltText('goal');
|
|
49
|
+
|
|
50
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
54
|
+
const defaultProps = {
|
|
55
|
+
fhirResource: dstu2Example1,
|
|
56
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
57
|
+
fhirIcons: fhirIcons,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const { getByAltText } = render(<Goal {...defaultProps} />);
|
|
61
|
+
const headerIcon = getByAltText('goal');
|
|
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: dstu2Example1,
|
|
71
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
72
|
+
fhirIcons: avatarSrc,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const { getByAltText } = render(<Goal {...defaultProps} />);
|
|
76
|
+
const headerIcon = getByAltText('header icon');
|
|
77
|
+
|
|
78
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
79
|
+
});
|
|
80
|
+
|
|
12
81
|
it('should render with DSTU2 source data', () => {
|
|
13
82
|
const defaultProps = {
|
|
14
83
|
fhirResource: dstu2Example1,
|
|
@@ -100,9 +169,7 @@ describe('should render Goal component properly', () => {
|
|
|
100
169
|
|
|
101
170
|
expect(getByTestId('status').textContent).toEqual('completed');
|
|
102
171
|
|
|
103
|
-
expect(getByTestId('
|
|
104
|
-
'starting on 2015-04-05',
|
|
105
|
-
);
|
|
172
|
+
expect(getByTestId('headerStartDate').textContent).toEqual('4/5/2015');
|
|
106
173
|
|
|
107
174
|
expect(getByTestId('subject').textContent).toContain(
|
|
108
175
|
'Peter James Chalmers',
|
|
@@ -125,7 +125,6 @@ const Immunization = props => {
|
|
|
125
125
|
note,
|
|
126
126
|
} = resourceDTO(fhirVersion, fhirResource);
|
|
127
127
|
|
|
128
|
-
const headerIcon = fhirIcons && fhirIcons[_get(fhirResource, 'resourceType')];
|
|
129
128
|
const tableData = [
|
|
130
129
|
{
|
|
131
130
|
label: 'Manufacturer Text',
|
|
@@ -237,7 +236,7 @@ const Immunization = props => {
|
|
|
237
236
|
)
|
|
238
237
|
}
|
|
239
238
|
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
240
|
-
icon={
|
|
239
|
+
icon={fhirIcons}
|
|
241
240
|
title={title}
|
|
242
241
|
/>
|
|
243
242
|
}
|
|
@@ -11,6 +11,7 @@ import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.jso
|
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
|
|
12
12
|
import r4Example3 from '../../../fixtures/r4/resources/immunization/example3.json';
|
|
13
13
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
|
+
import ImmunizationIcon from '../../../assets/containers/Immunization/immunization.svg';
|
|
14
15
|
|
|
15
16
|
export default {
|
|
16
17
|
title: 'Immunization',
|
|
@@ -22,7 +23,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
22
23
|
<Immunization
|
|
23
24
|
fhirResource={fhirResource}
|
|
24
25
|
fhirVersion={fhirVersions.DSTU2}
|
|
25
|
-
fhirIcons={
|
|
26
|
+
fhirIcons={require('../../../assets/containers/Immunization/immunization.svg')}
|
|
26
27
|
/>
|
|
27
28
|
);
|
|
28
29
|
};
|
|
@@ -33,7 +34,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
33
34
|
<Immunization
|
|
34
35
|
fhirResource={fhirResource}
|
|
35
36
|
fhirVersion={fhirVersions.DSTU2}
|
|
36
|
-
fhirIcons={
|
|
37
|
+
fhirIcons={ImmunizationIcon}
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
39
40
|
};
|
|
@@ -55,7 +56,7 @@ export const Example1R4 = () => {
|
|
|
55
56
|
<Immunization
|
|
56
57
|
fhirResource={fhirResource}
|
|
57
58
|
fhirVersion={fhirVersions.R4}
|
|
58
|
-
fhirIcons={
|
|
59
|
+
fhirIcons={false}
|
|
59
60
|
/>
|
|
60
61
|
);
|
|
61
62
|
};
|
|
@@ -65,17 +66,13 @@ export const Example2R4 = () => {
|
|
|
65
66
|
<Immunization
|
|
66
67
|
fhirResource={fhirResource}
|
|
67
68
|
fhirVersion={fhirVersions.R4}
|
|
68
|
-
fhirIcons={
|
|
69
|
+
fhirIcons={'random text'}
|
|
69
70
|
/>
|
|
70
71
|
);
|
|
71
72
|
};
|
|
72
73
|
export const Example3R4 = () => {
|
|
73
74
|
const fhirResource = object('Resource', r4Example3);
|
|
74
75
|
return (
|
|
75
|
-
<Immunization
|
|
76
|
-
fhirResource={fhirResource}
|
|
77
|
-
fhirVersion={fhirVersions.R4}
|
|
78
|
-
fhirIcons={fhirIcons}
|
|
79
|
-
/>
|
|
76
|
+
<Immunization fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
|
|
80
77
|
);
|
|
81
78
|
};
|
|
@@ -6,10 +6,80 @@ import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.jso
|
|
|
6
6
|
import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
|
|
7
7
|
import { render } from '@testing-library/react';
|
|
8
8
|
import stu3Example from '../../../fixtures/stu3/resources/immunization/example1.json';
|
|
9
|
-
|
|
10
9
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
10
|
|
|
12
11
|
describe('should render Immunization component properly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
fhirResource: dstu2Example,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('immunization');
|
|
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: dstu2Example,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<Immunization {...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: dstu2Example,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/Immunization/immunization.svg')}
|
|
44
|
+
alt="immunization"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('immunization');
|
|
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: dstu2Example,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('immunization');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
73
|
+
fhirResource: dstu2Example,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<Immunization {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
13
83
|
it('should render with DSTU2 source data', () => {
|
|
14
84
|
const defaultProps = {
|
|
15
85
|
fhirResource: dstu2Example,
|
|
@@ -10,7 +10,7 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medication/example2.j
|
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/medication/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/medication/example2.json';
|
|
12
12
|
|
|
13
|
-
describe('should render
|
|
13
|
+
describe('should render MedicationOrder component properly', () => {
|
|
14
14
|
it('should render with DSTU2 source data', () => {
|
|
15
15
|
const defaultProps = {
|
|
16
16
|
fhirResource: dstu2Example1,
|
|
@@ -142,7 +142,7 @@ const MedicationKnowledge = props => {
|
|
|
142
142
|
<Root name="MedicationKnowledge">
|
|
143
143
|
<Header>
|
|
144
144
|
<Title>
|
|
145
|
-
{id ? `Medication knowledge ID: ${id}` : '
|
|
145
|
+
{id ? `Medication knowledge ID: ${id}` : 'MedicationOrder knowledge'}{' '}
|
|
146
146
|
{status && <Badge data-testid="status">{status}</Badge>}
|
|
147
147
|
</Title>
|
|
148
148
|
</Header>
|
|
@@ -1,14 +1,16 @@
|
|
|
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
|
|
|
8
|
-
import { Root, Header,
|
|
9
|
+
import { Root, Header, Body } from '../../ui';
|
|
9
10
|
|
|
10
11
|
const MedicationOrder = props => {
|
|
11
|
-
const { fhirResource } = props;
|
|
12
|
+
const { fhirResource, fhirIcons } = props;
|
|
13
|
+
|
|
12
14
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
13
15
|
const medicationCodeableConcept = _get(
|
|
14
16
|
fhirResource,
|
|
@@ -22,34 +24,49 @@ const MedicationOrder = props => {
|
|
|
22
24
|
const dosageInstruction = _get(fhirResource, 'dosageInstruction');
|
|
23
25
|
const hasDosageInstruction =
|
|
24
26
|
Array.isArray(dosageInstruction) && dosageInstruction.length > 0;
|
|
27
|
+
|
|
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: 'Reason',
|
|
39
|
+
testId: 'reasonCode',
|
|
40
|
+
data: reasonCode && <CodeableConcept fhirData={reasonCode} />,
|
|
41
|
+
status: reasonCode,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Dosage',
|
|
45
|
+
testId: 'hasDosageInstruction',
|
|
46
|
+
data:
|
|
47
|
+
hasDosageInstruction &&
|
|
48
|
+
dosageInstruction.map((item, i) => (
|
|
49
|
+
<p key={`dosage-instruction-item-${i}`}>{item.text}</p>
|
|
50
|
+
)),
|
|
51
|
+
status: hasDosageInstruction,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
25
54
|
return (
|
|
26
55
|
<Root name="MedicationOrder">
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</Value>
|
|
42
|
-
)}
|
|
43
|
-
{hasDosageInstruction && (
|
|
44
|
-
<Value label="Dosage" data-testid="hasDosageInstruction">
|
|
45
|
-
<ul>
|
|
46
|
-
{dosageInstruction.map((item, i) => (
|
|
47
|
-
<li key={`item-${i}`}>{item.text}</li>
|
|
48
|
-
))}
|
|
49
|
-
</ul>
|
|
50
|
-
</Value>
|
|
51
|
-
)}
|
|
52
|
-
</Body>
|
|
56
|
+
<Accordion
|
|
57
|
+
headerContent={
|
|
58
|
+
<Header
|
|
59
|
+
icon={fhirIcons}
|
|
60
|
+
resourceName="MedicationOrder"
|
|
61
|
+
title={
|
|
62
|
+
medicationReference && (
|
|
63
|
+
<Reference fhirData={medicationReference} />
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
/>
|
|
67
|
+
}
|
|
68
|
+
bodyContent={<Body tableData={tableData} />}
|
|
69
|
+
/>
|
|
53
70
|
</Root>
|
|
54
71
|
);
|
|
55
72
|
};
|