fhir-react 0.3.4 → 0.3.7
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 +1 -1
- package/build/bootstrap-reboot.min.css +8 -2
- package/build/index.js +7 -7
- package/build/style.css +6 -6
- package/package.json +1 -1
- package/src/assets/containers/Binary/binary.svg +9 -0
- package/src/assets/containers/Coverage/coverage.svg +4 -0
- package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
- package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
- package/src/assets/containers/Organization/organization.svg +5 -0
- package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
- package/src/components/containers/Accordion/Accordion.js +10 -9
- package/src/components/datatypes/Annotation/Annotation.js +4 -4
- package/src/components/datatypes/Attachment/Attachment.css +5 -0
- package/src/components/datatypes/Attachment/Attachment.js +7 -2
- package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
- package/src/components/datatypes/Coding/Coding.css +0 -1
- package/src/components/datatypes/Identifier/Identifier.js +7 -3
- package/src/components/datatypes/Reference/Reference.css +3 -0
- package/src/components/datatypes/Reference/Reference.js +7 -1
- 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/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/Claim/CareTeam.js +55 -0
- package/src/components/resources/Claim/Claim.css +2 -11
- package/src/components/resources/Claim/Claim.js +157 -309
- package/src/components/resources/Claim/Claim.stories.js +37 -5
- package/src/components/resources/Claim/Claim.test.js +72 -0
- package/src/components/resources/Claim/Diagnosis.js +61 -0
- package/src/components/resources/Claim/Insurance.js +58 -0
- package/src/components/resources/Claim/Item.js +79 -0
- package/src/components/resources/Claim/Items.js +29 -0
- package/src/components/resources/Coverage/Coverage.js +96 -69
- package/src/components/resources/Coverage/Coverage.stories.js +31 -5
- package/src/components/resources/Coverage/Coverage.test.js +75 -3
- 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/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/Medication/Medication.js +90 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +77 -3
- 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/Organization/Organization.js +55 -37
- package/src/components/resources/Organization/Organization.stories.js +15 -2
- package/src/components/resources/Organization/Organization.test.js +73 -0
- package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
- 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 +22 -4
- package/src/fixtures/example-icons.jsx +46 -11
- package/src/style.scss +1 -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,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
|
};
|
|
@@ -9,6 +9,8 @@ import stu3Example1 from '../../../fixtures/stu3/resources/medicationStatement/e
|
|
|
9
9
|
import stu3Example2 from '../../../fixtures/stu3/resources/medicationStatement/example2.json';
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/medicationStatement/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/medicationStatement/example2.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import MedicationStatementIcon from '../../../assets/containers/MedicationStatement/medication-statement.svg';
|
|
12
14
|
|
|
13
15
|
export default {
|
|
14
16
|
title: 'MedicationStatement',
|
|
@@ -20,6 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
20
22
|
<MedicationStatement
|
|
21
23
|
fhirVersion={fhirVersions.DSTU2}
|
|
22
24
|
fhirResource={fhirResource}
|
|
25
|
+
fhirIcons={require('../../../assets/containers/MedicationStatement/medication-statement.svg')}
|
|
23
26
|
/>
|
|
24
27
|
);
|
|
25
28
|
};
|
|
@@ -30,6 +33,7 @@ export const ExampleOfSTU3 = () => {
|
|
|
30
33
|
<MedicationStatement
|
|
31
34
|
fhirVersion={fhirVersions.STU3}
|
|
32
35
|
fhirResource={fhirResource}
|
|
36
|
+
fhirIcons={MedicationStatementIcon}
|
|
33
37
|
/>
|
|
34
38
|
);
|
|
35
39
|
};
|
|
@@ -40,6 +44,7 @@ export const Example2OfSTU3 = () => {
|
|
|
40
44
|
<MedicationStatement
|
|
41
45
|
fhirVersion={fhirVersions.STU3}
|
|
42
46
|
fhirResource={fhirResource}
|
|
47
|
+
fhirIcons={fhirIcons}
|
|
43
48
|
/>
|
|
44
49
|
);
|
|
45
50
|
};
|
|
@@ -50,6 +55,7 @@ export const Example1OfR4 = () => {
|
|
|
50
55
|
<MedicationStatement
|
|
51
56
|
fhirVersion={fhirVersions.R4}
|
|
52
57
|
fhirResource={fhirResource}
|
|
58
|
+
fhirIcons={false}
|
|
53
59
|
/>
|
|
54
60
|
);
|
|
55
61
|
};
|
|
@@ -60,6 +66,7 @@ export const Example2OfR4 = () => {
|
|
|
60
66
|
<MedicationStatement
|
|
61
67
|
fhirVersion={fhirVersions.R4}
|
|
62
68
|
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={'random text'}
|
|
63
70
|
/>
|
|
64
71
|
);
|
|
65
72
|
};
|
|
@@ -5,8 +5,80 @@ import fhirVersions from '../fhirResourceVersions';
|
|
|
5
5
|
import example1MedicationStatement from '../../../fixtures/dstu2/resources/medicationStatement/example1.json';
|
|
6
6
|
import stu3Example from '../../../fixtures/stu3/resources/medicationStatement/example1.json';
|
|
7
7
|
import r4Example1 from '../../../fixtures/r4/resources/medicationStatement/example1.json';
|
|
8
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
8
9
|
|
|
9
10
|
describe('should render MedicationStatement component correctly', () => {
|
|
11
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
fhirResource: example1MedicationStatement,
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
|
|
18
|
+
const headerIcon = getByAltText('medication statement');
|
|
19
|
+
|
|
20
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
24
|
+
const defaultProps = {
|
|
25
|
+
fhirResource: example1MedicationStatement,
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirIcons: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const { getByTestId } = render(<MedicationStatement {...defaultProps} />);
|
|
31
|
+
const headerIcon = getByTestId('placeholder');
|
|
32
|
+
|
|
33
|
+
expect(headerIcon).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
37
|
+
const defaultProps = {
|
|
38
|
+
fhirResource: example1MedicationStatement,
|
|
39
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
40
|
+
fhirIcons: (
|
|
41
|
+
<img
|
|
42
|
+
src={require('../assets/containers/MedicationStatement/medication-statement.svg')}
|
|
43
|
+
alt="medication statement"
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
|
|
49
|
+
const headerIcon = getByAltText('medication statement');
|
|
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: example1MedicationStatement,
|
|
57
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
58
|
+
fhirIcons: fhirIcons,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
|
|
62
|
+
const headerIcon = getByAltText('medication statement');
|
|
63
|
+
|
|
64
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
68
|
+
const avatarSrc =
|
|
69
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
70
|
+
const defaultProps = {
|
|
71
|
+
fhirResource: example1MedicationStatement,
|
|
72
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
73
|
+
fhirIcons: avatarSrc,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
|
|
77
|
+
const headerIcon = getByAltText('header icon');
|
|
78
|
+
|
|
79
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
80
|
+
});
|
|
81
|
+
|
|
10
82
|
it('with DSTU2 source data', () => {
|
|
11
83
|
const defaultProps = {
|
|
12
84
|
fhirResource: example1MedicationStatement,
|
|
@@ -19,7 +91,7 @@ describe('should render MedicationStatement component correctly', () => {
|
|
|
19
91
|
expect(getByTestId('title').textContent).toContain(
|
|
20
92
|
'amphetamine-dextroamphetamine',
|
|
21
93
|
);
|
|
22
|
-
expect(getByTestId('
|
|
94
|
+
expect(getByTestId('startDate').textContent).toContain('4/19/2016');
|
|
23
95
|
expect(queryByTestId('medicationReference')).toBeNull();
|
|
24
96
|
|
|
25
97
|
expect(getByTestId('dosageInstruction').textContent).toContain(
|
|
@@ -32,19 +104,35 @@ describe('should render MedicationStatement component correctly', () => {
|
|
|
32
104
|
fhirResource: stu3Example,
|
|
33
105
|
fhirVersion: fhirVersions.STU3,
|
|
34
106
|
};
|
|
35
|
-
const { getByTestId, queryAllByTestId } = render(
|
|
107
|
+
const { getByTestId, queryAllByTestId, queryByTestId } = render(
|
|
36
108
|
<MedicationStatement {...defaultProps} />,
|
|
37
109
|
);
|
|
38
110
|
|
|
39
111
|
expect(getByTestId('title').textContent).toEqual('Medication Statement');
|
|
40
|
-
expect(queryAllByTestId('
|
|
112
|
+
expect(queryAllByTestId('startDate')).toHaveLength(0);
|
|
113
|
+
expect(queryAllByTestId('endDate')).toHaveLength(0);
|
|
41
114
|
|
|
42
115
|
expect(getByTestId('dosageInstruction').textContent).toContain(
|
|
43
116
|
'1-2 tablets once daily',
|
|
44
117
|
);
|
|
45
118
|
|
|
46
|
-
|
|
119
|
+
const ingredients = queryAllByTestId('ingredient-item').map(
|
|
120
|
+
x => x.textContent,
|
|
121
|
+
);
|
|
122
|
+
expect(ingredients).toHaveLength(2);
|
|
123
|
+
expect(ingredients).toEqual([
|
|
124
|
+
'Acetaminophen 500 MG',
|
|
125
|
+
'Diphenhydramine Hydrochloride 25 mg',
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
expect(getByTestId('dosageInstruction').textContent).toContain(
|
|
129
|
+
'1-2 tablets once daily at bedtime as needed for restless legs',
|
|
130
|
+
);
|
|
47
131
|
|
|
132
|
+
expect(queryByTestId('medicationReference').textContent).toContain(
|
|
133
|
+
'#med0309',
|
|
134
|
+
);
|
|
135
|
+
expect(getByTestId('hasNote').textContent).toContain('occasional');
|
|
48
136
|
expect(getByTestId('hasReasonCode').textContent).toContain('Legs');
|
|
49
137
|
});
|
|
50
138
|
|
|
@@ -58,14 +146,23 @@ describe('should render MedicationStatement component correctly', () => {
|
|
|
58
146
|
);
|
|
59
147
|
|
|
60
148
|
expect(getByTestId('title').textContent).toEqual('Medication Statement');
|
|
61
|
-
expect(queryAllByTestId('
|
|
149
|
+
expect(queryAllByTestId('startDate')).toHaveLength(0);
|
|
150
|
+
expect(queryAllByTestId('endDate')).toHaveLength(0);
|
|
62
151
|
|
|
63
152
|
expect(getByTestId('dosageInstruction').textContent).toContain(
|
|
64
153
|
'1-2 tablets once daily',
|
|
65
154
|
);
|
|
66
155
|
|
|
67
|
-
|
|
156
|
+
const ingredients = queryAllByTestId('ingredient-item').map(
|
|
157
|
+
x => x.textContent,
|
|
158
|
+
);
|
|
159
|
+
expect(ingredients).toHaveLength(2);
|
|
160
|
+
expect(ingredients).toEqual([
|
|
161
|
+
'Acetaminophen 500 MG',
|
|
162
|
+
'Diphenhydramine Hydrochloride 25 mg',
|
|
163
|
+
]);
|
|
68
164
|
|
|
165
|
+
expect(getByTestId('hasNote').textContent).toContain('occasional');
|
|
69
166
|
expect(getByTestId('hasReasonCode').textContent).toContain('Legs');
|
|
70
167
|
expect(getByTestId('medicationReference').textContent).toContain(
|
|
71
168
|
'#med0309',
|
|
@@ -8,7 +8,8 @@ import Telecom from '../../datatypes/Telecom';
|
|
|
8
8
|
import Identifier from '../../datatypes/Identifier';
|
|
9
9
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
10
10
|
import fhirVersions from '../fhirResourceVersions';
|
|
11
|
-
import { Root, Header,
|
|
11
|
+
import { Root, Header, Body, NotEnoughData } from '../../ui';
|
|
12
|
+
import Accordion from '../../containers/Accordion';
|
|
12
13
|
|
|
13
14
|
const commonDTO = fhirResource => {
|
|
14
15
|
const identifier = _get(fhirResource, 'identifier', '');
|
|
@@ -54,8 +55,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
const Organization =
|
|
58
|
-
const { fhirResource, fhirVersion } = props;
|
|
58
|
+
const Organization = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
59
59
|
let fhirResourceData = {};
|
|
60
60
|
try {
|
|
61
61
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -74,42 +74,60 @@ const Organization = props => {
|
|
|
74
74
|
const hasTelecom = Array.isArray(telecom) && telecom.length > 0;
|
|
75
75
|
const hasTypes = Array.isArray(typeCodings) && typeCodings.length > 0;
|
|
76
76
|
const notEnoughData = !hasAddresses && !hasTelecom && !hasTypes;
|
|
77
|
+
|
|
78
|
+
const tableData = [
|
|
79
|
+
{
|
|
80
|
+
label: 'Identifiers',
|
|
81
|
+
testId: 'identifier',
|
|
82
|
+
data: identifier && <Identifier fhirData={identifier} noCursive />,
|
|
83
|
+
status: identifier,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
label: 'Addresses',
|
|
87
|
+
testId: 'address',
|
|
88
|
+
data:
|
|
89
|
+
hasAddresses &&
|
|
90
|
+
addresses.map((item, i) => (
|
|
91
|
+
<Address key={`item-${i}`} fhirData={item} />
|
|
92
|
+
)),
|
|
93
|
+
status: hasAddresses,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: 'Contacts',
|
|
97
|
+
testId: 'contact',
|
|
98
|
+
data:
|
|
99
|
+
hasTelecom &&
|
|
100
|
+
telecom.map((item, i) => <Telecom key={`item-${i}`} fhirData={item} />),
|
|
101
|
+
status: hasTelecom,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
label: 'Type',
|
|
105
|
+
testId: 'type',
|
|
106
|
+
data:
|
|
107
|
+
hasTypes &&
|
|
108
|
+
typeCodings.map((typeCoding, idx) => (
|
|
109
|
+
<Coding key={idx} fhirData={typeCoding} />
|
|
110
|
+
)),
|
|
111
|
+
status: hasTypes,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: '',
|
|
115
|
+
testId: '',
|
|
116
|
+
data: notEnoughData && <NotEnoughData data-testid="NotEnoughData" />,
|
|
117
|
+
status: notEnoughData,
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
|
|
77
121
|
return (
|
|
78
122
|
<Root name="Organization">
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
<Identifier fhirData={identifier} />
|
|
88
|
-
</Value>
|
|
89
|
-
)}
|
|
90
|
-
{hasAddresses && (
|
|
91
|
-
<Value label="Addresses" data-testid="address">
|
|
92
|
-
{addresses.map((item, i) => (
|
|
93
|
-
<Address key={`item-${i}`} fhirData={item} />
|
|
94
|
-
))}
|
|
95
|
-
</Value>
|
|
96
|
-
)}
|
|
97
|
-
{hasTelecom && (
|
|
98
|
-
<Value label="Contacts" data-testid="contact">
|
|
99
|
-
{telecom.map((item, i) => (
|
|
100
|
-
<Telecom key={`item-${i}`} fhirData={item} />
|
|
101
|
-
))}
|
|
102
|
-
</Value>
|
|
103
|
-
)}
|
|
104
|
-
{hasTypes && (
|
|
105
|
-
<Value label="Type" data-testid="type">
|
|
106
|
-
{typeCodings.map((typeCoding, idx) => (
|
|
107
|
-
<Coding key={idx} fhirData={typeCoding} />
|
|
108
|
-
))}
|
|
109
|
-
</Value>
|
|
110
|
-
)}
|
|
111
|
-
{notEnoughData && <NotEnoughData data-testid="NotEnoughData" />}
|
|
112
|
-
</Body>
|
|
123
|
+
<Accordion
|
|
124
|
+
headerContent={
|
|
125
|
+
name && (
|
|
126
|
+
<Header resourceName="Organization" title={name} icon={fhirIcons} />
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
bodyContent={<Body tableData={tableData} />}
|
|
130
|
+
/>
|
|
113
131
|
</Root>
|
|
114
132
|
);
|
|
115
133
|
};
|
|
@@ -14,6 +14,9 @@ import r4Example1 from '../../../fixtures/r4/resources/organization/example1.jso
|
|
|
14
14
|
import r4Example2 from '../../../fixtures/r4/resources/organization/example2.json';
|
|
15
15
|
import r4Example3 from '../../../fixtures/r4/resources/organization/example3.json';
|
|
16
16
|
|
|
17
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
18
|
+
import OrganizationIcon from '../../../assets/containers/Organization/organization.svg';
|
|
19
|
+
|
|
17
20
|
export default {
|
|
18
21
|
title: 'Organization',
|
|
19
22
|
};
|
|
@@ -24,6 +27,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
24
27
|
<Organization
|
|
25
28
|
fhirResource={fhirResource}
|
|
26
29
|
fhirVersion={fhirVersions.DSTU2}
|
|
30
|
+
fhirIcons={OrganizationIcon}
|
|
27
31
|
/>
|
|
28
32
|
);
|
|
29
33
|
};
|
|
@@ -34,6 +38,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
34
38
|
<Organization
|
|
35
39
|
fhirResource={fhirResource}
|
|
36
40
|
fhirVersion={fhirVersions.DSTU2}
|
|
41
|
+
fhirIcons={fhirIcons}
|
|
37
42
|
/>
|
|
38
43
|
);
|
|
39
44
|
};
|
|
@@ -41,14 +46,22 @@ export const Example2OfDSTU2 = () => {
|
|
|
41
46
|
export const Example1OfSTU3 = () => {
|
|
42
47
|
const fhirResource = object('Resource', stu3Example1);
|
|
43
48
|
return (
|
|
44
|
-
<Organization
|
|
49
|
+
<Organization
|
|
50
|
+
fhirResource={fhirResource}
|
|
51
|
+
fhirVersion={fhirVersions.STU3}
|
|
52
|
+
fhirIcons={false}
|
|
53
|
+
/>
|
|
45
54
|
);
|
|
46
55
|
};
|
|
47
56
|
|
|
48
57
|
export const Example2OfSTU3 = () => {
|
|
49
58
|
const fhirResource = object('Resource', stu3Example2);
|
|
50
59
|
return (
|
|
51
|
-
<Organization
|
|
60
|
+
<Organization
|
|
61
|
+
fhirResource={fhirResource}
|
|
62
|
+
fhirVersion={fhirVersions.STU3}
|
|
63
|
+
fhirIcons={'random text'}
|
|
64
|
+
/>
|
|
52
65
|
);
|
|
53
66
|
};
|
|
54
67
|
|
|
@@ -14,7 +14,80 @@ import r4Example1 from '../../../fixtures/r4/resources/organization/example1.jso
|
|
|
14
14
|
import r4Example2 from '../../../fixtures/r4/resources/organization/example2.json';
|
|
15
15
|
import r4Example3 from '../../../fixtures/r4/resources/organization/example3.json';
|
|
16
16
|
|
|
17
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
18
|
+
|
|
17
19
|
describe('should render Organization component properly', () => {
|
|
20
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
21
|
+
const defaultProps = {
|
|
22
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
23
|
+
fhirResource: dstu2Example1,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
27
|
+
const headerIcon = getByAltText('organization');
|
|
28
|
+
|
|
29
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
33
|
+
const defaultProps = {
|
|
34
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
35
|
+
fhirResource: dstu2Example1,
|
|
36
|
+
fhirIcons: false,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const { getByTestId } = render(<Organization {...defaultProps} />);
|
|
40
|
+
const headerIcon = getByTestId('placeholder');
|
|
41
|
+
|
|
42
|
+
expect(headerIcon).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
46
|
+
const defaultProps = {
|
|
47
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
48
|
+
fhirResource: dstu2Example1,
|
|
49
|
+
fhirIcons: (
|
|
50
|
+
<img
|
|
51
|
+
src={require('../assets/containers/Organization/organization.svg')}
|
|
52
|
+
alt="organization"
|
|
53
|
+
/>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
58
|
+
const headerIcon = getByAltText('organization');
|
|
59
|
+
|
|
60
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
64
|
+
const defaultProps = {
|
|
65
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
66
|
+
fhirResource: dstu2Example1,
|
|
67
|
+
fhirIcons: fhirIcons,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
71
|
+
const headerIcon = getByAltText('organization');
|
|
72
|
+
|
|
73
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
77
|
+
const avatarSrc =
|
|
78
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
79
|
+
const defaultProps = {
|
|
80
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
81
|
+
fhirResource: dstu2Example1,
|
|
82
|
+
fhirIcons: avatarSrc,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
86
|
+
const headerIcon = getByAltText('header icon');
|
|
87
|
+
|
|
88
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
89
|
+
});
|
|
90
|
+
|
|
18
91
|
it('should render with DSTU2 source data', () => {
|
|
19
92
|
const defaultProps = {
|
|
20
93
|
fhirResource: dstu2Example1,
|