fhir-react 0.3.1 → 0.3.5
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 +26 -239
- package/package.json +3 -2
- package/src/assets/containers/Binary/binary.svg +9 -0
- package/src/assets/containers/Patient/patient.svg +6 -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 +87 -76
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +11 -1
- 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 +31 -20
- package/src/components/resources/Binary/Binary.stories.js +6 -5
- package/src/components/resources/CarePlan/CarePlan.js +111 -96
- package/src/components/resources/CarePlan/CarePlan.test.js +2 -2
- package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
- package/src/components/resources/Condition/Condition.js +1 -2
- 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/DiagnosticReport/DiagnosticReport.js +53 -43
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +7 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +4 -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 +4 -0
- package/src/components/resources/Goal/Goal.js +104 -85
- package/src/components/resources/Goal/Goal.stories.js +37 -7
- package/src/components/resources/Goal/Goal.test.js +1 -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/MedicationOrder/MedicationOrder.js +45 -28
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +2 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.js +65 -43
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +16 -5
- 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 +65 -118
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +6 -0
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +31 -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 +6 -3
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +1 -1
- package/src/components/supportedFhirResourceList.js +2 -0
- package/src/components/ui/bootstrap-reboot.min.css +8 -2
- package/src/components/ui/index.js +44 -25
- package/src/fixtures/example-icons.jsx +55 -10
- package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
- package/src/index.js +1 -0
- 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/webpack.config.js +10 -1
- 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,9 @@ 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
|
+
const headerIcon = fhirIcons && fhirIcons['Goal'];
|
|
105
|
+
|
|
111
106
|
let fhirResourceData = {};
|
|
112
107
|
try {
|
|
113
108
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -135,83 +130,107 @@ const Goal = props => {
|
|
|
135
130
|
statusDate,
|
|
136
131
|
} = fhirResourceData;
|
|
137
132
|
|
|
133
|
+
const tableData = [
|
|
134
|
+
{
|
|
135
|
+
label: 'Subject',
|
|
136
|
+
testId: 'subject',
|
|
137
|
+
data: subject && <Reference fhirData={subject} />,
|
|
138
|
+
status: subject,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'Subject',
|
|
142
|
+
testId: 'statusDate',
|
|
143
|
+
data: statusDate && <Date fhirData={statusDate} />,
|
|
144
|
+
status: statusDate,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
label: 'Description',
|
|
148
|
+
testId: 'description',
|
|
149
|
+
data: description,
|
|
150
|
+
status: description,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
label: 'Category',
|
|
154
|
+
testId: 'category',
|
|
155
|
+
data:
|
|
156
|
+
hasCategory &&
|
|
157
|
+
category.map((item, i) => {
|
|
158
|
+
const coding = _get(item, 'coding', []);
|
|
159
|
+
if (!Array.isArray(coding)) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
return coding.map((codingItem, j) => (
|
|
163
|
+
<Coding key={`coding-item-${j}`} fhirData={codingItem} />
|
|
164
|
+
));
|
|
165
|
+
}),
|
|
166
|
+
status: hasCategory,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: 'Universal Device Identifier',
|
|
170
|
+
testId: 'udi',
|
|
171
|
+
data: udi,
|
|
172
|
+
status: hasUdi,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: 'Addresses',
|
|
176
|
+
testId: 'addresses',
|
|
177
|
+
data:
|
|
178
|
+
hasAddresses &&
|
|
179
|
+
addresses.map((address, i) => (
|
|
180
|
+
<Reference key={`address-item-${i}`} fhirData={address} />
|
|
181
|
+
)),
|
|
182
|
+
status: hasAddresses,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: 'Priority',
|
|
186
|
+
testId: 'priority',
|
|
187
|
+
data: priority && <Coding fhirData={priority} />,
|
|
188
|
+
status: priority,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: 'Author',
|
|
192
|
+
testId: 'author',
|
|
193
|
+
data: author && <Reference fhirData={author} />,
|
|
194
|
+
status: author,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: 'Outcome',
|
|
198
|
+
testId: 'outcomeReference',
|
|
199
|
+
data:
|
|
200
|
+
outcomeReference &&
|
|
201
|
+
outcomeReference.map((item, i) => (
|
|
202
|
+
<Reference key={`outcome-reference-item-${i}`} fhirData={item} />
|
|
203
|
+
)),
|
|
204
|
+
status: outcomeReference,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
label: 'Achievement Status',
|
|
208
|
+
testId: 'achievementStatus',
|
|
209
|
+
data: achievementStatus && <Coding fhirData={achievementStatus} />,
|
|
210
|
+
status: achievementStatus,
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
|
|
138
214
|
return (
|
|
139
215
|
<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>
|
|
216
|
+
<Accordion
|
|
217
|
+
headerContent={
|
|
218
|
+
<Header
|
|
219
|
+
resourceName="Goal"
|
|
220
|
+
additionalContent={
|
|
221
|
+
startDate && (
|
|
222
|
+
<Value label="Started" data-testid="headerStartDate">
|
|
223
|
+
<Date fhirData={startDate} isBlack />
|
|
224
|
+
</Value>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
badges={hasStatus && <Badge data-testid="status">{status}</Badge>}
|
|
228
|
+
icon={headerIcon}
|
|
229
|
+
title={title}
|
|
230
|
+
/>
|
|
231
|
+
}
|
|
232
|
+
bodyContent={<Body tableData={tableData} />}
|
|
233
|
+
/>
|
|
215
234
|
</Root>
|
|
216
235
|
);
|
|
217
236
|
};
|
|
@@ -2,7 +2,7 @@ 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';
|
|
@@ -16,30 +16,60 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
export const DefaultVisualizationDSTU2 = () => {
|
|
18
18
|
const fhirResource = object('Resource', dstu2Example1);
|
|
19
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
<Goal
|
|
21
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={fhirIcons}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
export const Example2OfDSTU2 = () => {
|
|
23
29
|
const fhirResource = object('Resource', dstu2Example2);
|
|
24
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
<Goal
|
|
32
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
33
|
+
fhirResource={fhirResource}
|
|
34
|
+
fhirIcons={fhirIcons}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
25
37
|
};
|
|
26
38
|
|
|
27
39
|
export const ExampleOfSTU3 = () => {
|
|
28
40
|
const fhirResource = object('Resource', stu3Example1);
|
|
29
|
-
return
|
|
41
|
+
return (
|
|
42
|
+
<Goal
|
|
43
|
+
fhirVersion={fhirVersions.STU3}
|
|
44
|
+
fhirResource={fhirResource}
|
|
45
|
+
fhirIcons={fhirIcons}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
30
48
|
};
|
|
31
49
|
|
|
32
50
|
export const Example1OfR4 = () => {
|
|
33
51
|
const fhirResource = object('Resource', r4Example1);
|
|
34
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
<Goal
|
|
54
|
+
fhirVersion={fhirVersions.R4}
|
|
55
|
+
fhirResource={fhirResource}
|
|
56
|
+
fhirIcons={fhirIcons}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
35
59
|
};
|
|
36
60
|
|
|
37
61
|
export const Example2OfR4 = () => {
|
|
38
62
|
const fhirResource = object('Resource', r4Example2);
|
|
39
|
-
return
|
|
63
|
+
return (
|
|
64
|
+
<Goal
|
|
65
|
+
fhirVersion={fhirVersions.R4}
|
|
66
|
+
fhirResource={fhirResource}
|
|
67
|
+
fhirIcons={fhirIcons}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
40
70
|
};
|
|
41
71
|
|
|
42
72
|
export const ExampleWithoutFhirVersionProperty = () => {
|
|
43
73
|
const fhirResource = object('Resource', stu3Example1);
|
|
44
|
-
return <Goal fhirResource={fhirResource} />;
|
|
74
|
+
return <Goal fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
45
75
|
};
|
|
@@ -100,9 +100,7 @@ describe('should render Goal component properly', () => {
|
|
|
100
100
|
|
|
101
101
|
expect(getByTestId('status').textContent).toEqual('completed');
|
|
102
102
|
|
|
103
|
-
expect(getByTestId('
|
|
104
|
-
'starting on 2015-04-05',
|
|
105
|
-
);
|
|
103
|
+
expect(getByTestId('headerStartDate').textContent).toEqual('4/5/2015');
|
|
106
104
|
|
|
107
105
|
expect(getByTestId('subject').textContent).toContain(
|
|
108
106
|
'Peter James Chalmers',
|
|
@@ -125,7 +125,6 @@ const Immunization = props => {
|
|
|
125
125
|
note,
|
|
126
126
|
} = resourceDTO(fhirVersion, fhirResource);
|
|
127
127
|
|
|
128
|
-
const headerIcon = 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,
|
|
@@ -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
|
+
const headerIcon = fhirIcons && fhirIcons['Medication'];
|
|
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={headerIcon}
|
|
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
|
};
|
|
@@ -4,6 +4,7 @@ import { object } from '@storybook/addon-knobs';
|
|
|
4
4
|
import MedicationOrder from './MedicationOrder';
|
|
5
5
|
|
|
6
6
|
import dstu2Example from '../../../fixtures/dstu2/resources/medicationOrder/example.json';
|
|
7
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: 'MedicationOrder',
|
|
@@ -11,5 +12,5 @@ export default {
|
|
|
11
12
|
|
|
12
13
|
export const DefaultVisualizationDSTU2 = () => {
|
|
13
14
|
const fhirResource = object('Resource', dstu2Example);
|
|
14
|
-
return <MedicationOrder fhirResource={fhirResource} />;
|
|
15
|
+
return <MedicationOrder fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
15
16
|
};
|