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
|
@@ -5,17 +5,16 @@ import prettyBytes from 'pretty-bytes';
|
|
|
5
5
|
|
|
6
6
|
import fhirVersions from '../fhirResourceVersions';
|
|
7
7
|
import Coding from '../../datatypes/Coding';
|
|
8
|
-
import DateType from '../../datatypes/Date';
|
|
9
8
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
9
|
+
import Accordion from '../../containers/Accordion';
|
|
10
|
+
import Date from '../../datatypes/Date';
|
|
10
11
|
|
|
11
12
|
import {
|
|
12
13
|
Root,
|
|
13
14
|
Body,
|
|
14
15
|
Header,
|
|
15
|
-
Title,
|
|
16
16
|
Badge,
|
|
17
|
-
|
|
18
|
-
Value,
|
|
17
|
+
ValueSectionItem,
|
|
19
18
|
ValueSection,
|
|
20
19
|
Table,
|
|
21
20
|
TableRow,
|
|
@@ -202,7 +201,7 @@ const Content = props => {
|
|
|
202
201
|
<ContentItem key={i} item={item} />
|
|
203
202
|
));
|
|
204
203
|
return (
|
|
205
|
-
<ValueSection label="Content">
|
|
204
|
+
<ValueSection label="Content" marginTop>
|
|
206
205
|
<Table>
|
|
207
206
|
<thead>
|
|
208
207
|
<TableRow>
|
|
@@ -211,14 +210,14 @@ const Content = props => {
|
|
|
211
210
|
<TableHeader>Resource</TableHeader>
|
|
212
211
|
</TableRow>
|
|
213
212
|
</thead>
|
|
214
|
-
<tbody>{allContent}</tbody>
|
|
213
|
+
<tbody className="border-top-0">{allContent}</tbody>
|
|
215
214
|
</Table>
|
|
216
215
|
</ValueSection>
|
|
217
216
|
);
|
|
218
217
|
};
|
|
219
218
|
|
|
220
219
|
const DocumentReference = props => {
|
|
221
|
-
const { fhirVersion, fhirResource } = props;
|
|
220
|
+
const { fhirVersion, fhirResource, fhirIcons } = props;
|
|
222
221
|
let fhirResourceData = {};
|
|
223
222
|
try {
|
|
224
223
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -241,67 +240,104 @@ const DocumentReference = props => {
|
|
|
241
240
|
const hasContent = content.length > 0;
|
|
242
241
|
const hasPeriod = context.periodStart || context.periodEnd;
|
|
243
242
|
|
|
243
|
+
const tableData = [
|
|
244
|
+
{
|
|
245
|
+
label: 'Document type',
|
|
246
|
+
testId: 'type',
|
|
247
|
+
data: <Coding fhirData={typeCoding} />,
|
|
248
|
+
status: typeCoding,
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
label: 'Document categorization',
|
|
252
|
+
testId: 'class',
|
|
253
|
+
data: <Coding fhirData={classCoding} />,
|
|
254
|
+
status: classCoding,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
label: 'Security Label',
|
|
258
|
+
testId: 'securityLabel',
|
|
259
|
+
data: <Coding fhirData={securityLabelCoding} />,
|
|
260
|
+
status: securityLabelCoding,
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
label: 'Created At',
|
|
264
|
+
testId: 'createdAt',
|
|
265
|
+
data: <Date fhirData={createdAt} isBlack />,
|
|
266
|
+
status: createdAt,
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
const contextTable = [
|
|
271
|
+
{
|
|
272
|
+
label: 'Event',
|
|
273
|
+
testId: 'context.event',
|
|
274
|
+
data: <Coding fhirData={context.eventCoding} />,
|
|
275
|
+
status: context.eventCoding,
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
label: 'Facility',
|
|
279
|
+
testId: 'context.facilityType',
|
|
280
|
+
data: <Coding fhirData={context.facilityTypeCoding} />,
|
|
281
|
+
status: context.facilityTypeCoding,
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
label: 'Practice Setting',
|
|
285
|
+
testId: 'context.practiceSetting',
|
|
286
|
+
data: <Coding fhirData={context.practiceSettingCoding} />,
|
|
287
|
+
status: context.practiceSettingCoding,
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
label: 'Period',
|
|
291
|
+
testId: 'context.period',
|
|
292
|
+
data: (
|
|
293
|
+
<>
|
|
294
|
+
{context.periodStart && (
|
|
295
|
+
<Date fhirData={context.periodStart} isBlack />
|
|
296
|
+
)}
|
|
297
|
+
{' - '}
|
|
298
|
+
{context.periodEnd && <Date fhirData={context.periodEnd} isBlack />}
|
|
299
|
+
</>
|
|
300
|
+
),
|
|
301
|
+
status: hasPeriod,
|
|
302
|
+
},
|
|
303
|
+
];
|
|
304
|
+
|
|
305
|
+
const getValueSectionItem = (item, index) =>
|
|
306
|
+
item.status && (
|
|
307
|
+
<ValueSectionItem
|
|
308
|
+
key={`context-item-${index}`}
|
|
309
|
+
label={item.label}
|
|
310
|
+
data-testid={item.testId}
|
|
311
|
+
>
|
|
312
|
+
{item.data}
|
|
313
|
+
</ValueSectionItem>
|
|
314
|
+
);
|
|
315
|
+
|
|
244
316
|
return (
|
|
245
317
|
<Root name="DocumentReference">
|
|
246
|
-
<
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
)}
|
|
264
|
-
{securityLabelCoding && (
|
|
265
|
-
<Value label="Security Label" data-testid="securityLabel">
|
|
266
|
-
<Coding fhirData={securityLabelCoding} />
|
|
267
|
-
</Value>
|
|
268
|
-
)}
|
|
269
|
-
{createdAt && (
|
|
270
|
-
<Value label="Created At" data-testid="createdAt">
|
|
271
|
-
<DateType fhirData={createdAt} />
|
|
272
|
-
</Value>
|
|
273
|
-
)}
|
|
274
|
-
<ValueSection label="Context">
|
|
275
|
-
{context.eventCoding && (
|
|
276
|
-
<Value label="Event" data-testid="context.event">
|
|
277
|
-
<Coding fhirData={context.eventCoding} />
|
|
278
|
-
</Value>
|
|
279
|
-
)}
|
|
280
|
-
{context.facilityTypeCoding && (
|
|
281
|
-
<Value label="Facility" data-testid="context.facilityType">
|
|
282
|
-
<Coding fhirData={context.facilityTypeCoding} />
|
|
283
|
-
</Value>
|
|
284
|
-
)}
|
|
285
|
-
{context.practiceSettingCoding && (
|
|
286
|
-
<Value
|
|
287
|
-
label="Practice Setting"
|
|
288
|
-
data-testid="context.practiceSetting"
|
|
289
|
-
>
|
|
290
|
-
<Coding fhirData={context.practiceSettingCoding} />
|
|
291
|
-
</Value>
|
|
292
|
-
)}
|
|
293
|
-
{hasPeriod && (
|
|
294
|
-
<Value label="Period" data-testid="context.period">
|
|
295
|
-
{context.periodStart && (
|
|
296
|
-
<DateType fhirData={context.periodStart} />
|
|
318
|
+
<Accordion
|
|
319
|
+
headerContent={
|
|
320
|
+
<Header
|
|
321
|
+
icon={fhirIcons}
|
|
322
|
+
resourceName="DocumentReference"
|
|
323
|
+
title={description}
|
|
324
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
325
|
+
additionalBadge={
|
|
326
|
+
docStatus && <Badge data-testid="docStatus">{docStatus}</Badge>
|
|
327
|
+
}
|
|
328
|
+
/>
|
|
329
|
+
}
|
|
330
|
+
bodyContent={
|
|
331
|
+
<Body tableData={tableData}>
|
|
332
|
+
<ValueSection label="Context" marginTop>
|
|
333
|
+
{contextTable.map((item, index) =>
|
|
334
|
+
getValueSectionItem(item, index),
|
|
297
335
|
)}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
{hasContent && <Content content={content} />}
|
|
304
|
-
</Body>
|
|
336
|
+
</ValueSection>
|
|
337
|
+
{hasContent && <Content content={content} />}
|
|
338
|
+
</Body>
|
|
339
|
+
}
|
|
340
|
+
/>
|
|
305
341
|
</Root>
|
|
306
342
|
);
|
|
307
343
|
};
|
|
@@ -7,6 +7,8 @@ import DocumentReference from './DocumentReference';
|
|
|
7
7
|
import exampleDocumentReference from '../../../fixtures/dstu2/resources/documentReference/example1.json';
|
|
8
8
|
import exampleDocumentReferenceSTU3 from '../../../fixtures/stu3/resources/documentReference/example1.json';
|
|
9
9
|
import example1DocumentReferenceR4 from '../../../fixtures/r4/resources/documentReference/example1.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
|
+
import DocumentReferenceIcon from '../../../assets/containers/DocumentReference/document-reference.svg';
|
|
10
12
|
|
|
11
13
|
export default { title: 'Document Reference' };
|
|
12
14
|
|
|
@@ -16,6 +18,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
16
18
|
<DocumentReference
|
|
17
19
|
fhirResource={fhirResource}
|
|
18
20
|
fhirVersion={fhirVersions.DSTU2}
|
|
21
|
+
fhirIcons={require('../../../assets/containers/DocumentReference/document-reference.svg')}
|
|
19
22
|
/>
|
|
20
23
|
);
|
|
21
24
|
};
|
|
@@ -26,6 +29,7 @@ export const ExampleSTU3 = () => {
|
|
|
26
29
|
<DocumentReference
|
|
27
30
|
fhirResource={fhirResource}
|
|
28
31
|
fhirVersion={fhirVersions.STU3}
|
|
32
|
+
fhirIcons={DocumentReferenceIcon}
|
|
29
33
|
/>
|
|
30
34
|
);
|
|
31
35
|
};
|
|
@@ -36,6 +40,7 @@ export const ExampleR4 = () => {
|
|
|
36
40
|
<DocumentReference
|
|
37
41
|
fhirResource={fhirResource}
|
|
38
42
|
fhirVersion={fhirVersions.R4}
|
|
43
|
+
fhirIcons={fhirIcons}
|
|
39
44
|
/>
|
|
40
45
|
);
|
|
41
46
|
};
|
|
@@ -8,8 +8,79 @@ import DocumentReference from './DocumentReference';
|
|
|
8
8
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/documentReference/example1.json';
|
|
9
9
|
import stu3Example1 from '../../../fixtures/stu3/resources/documentReference/example1.json';
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/documentReference/example1.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
describe('should render the DocumentReference component properly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirResource: dstu2Example1,
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
21
|
+
const headerIcon = getByAltText('document reference');
|
|
22
|
+
|
|
23
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
fhirResource: dstu2Example1,
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirIcons: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const { getByTestId } = render(<DocumentReference {...defaultProps} />);
|
|
34
|
+
const headerIcon = getByTestId('placeholder');
|
|
35
|
+
|
|
36
|
+
expect(headerIcon).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
40
|
+
const defaultProps = {
|
|
41
|
+
fhirResource: dstu2Example1,
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirIcons: (
|
|
44
|
+
<img
|
|
45
|
+
src={require('../assets/containers/DocumentReference/document-reference.svg')}
|
|
46
|
+
alt="document reference"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
52
|
+
const headerIcon = getByAltText('document reference');
|
|
53
|
+
|
|
54
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
58
|
+
const defaultProps = {
|
|
59
|
+
fhirResource: dstu2Example1,
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirIcons: fhirIcons,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
65
|
+
const headerIcon = getByAltText('document reference');
|
|
66
|
+
|
|
67
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
71
|
+
const avatarSrc =
|
|
72
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
73
|
+
const defaultProps = {
|
|
74
|
+
fhirResource: dstu2Example1,
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirIcons: avatarSrc,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
80
|
+
const headerIcon = getByAltText('header icon');
|
|
81
|
+
|
|
82
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
83
|
+
});
|
|
13
84
|
it('should render with DSTU2 source data', () => {
|
|
14
85
|
const { getByTestId } = render(
|
|
15
86
|
<DocumentReference
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
+
import Accordion from '../../containers/Accordion/Accordion';
|
|
4
5
|
import Coding from '../../datatypes/Coding';
|
|
5
6
|
import Reference from '../../datatypes/Reference';
|
|
6
7
|
import Annotation from '../../datatypes/Annotation';
|
|
7
8
|
|
|
8
9
|
import _get from 'lodash/get';
|
|
9
|
-
import {
|
|
10
|
-
Root,
|
|
11
|
-
Header,
|
|
12
|
-
Title,
|
|
13
|
-
BadgeSecondary,
|
|
14
|
-
Badge,
|
|
15
|
-
Body,
|
|
16
|
-
Value,
|
|
17
|
-
} from '../../ui';
|
|
10
|
+
import { Root, Header, Badge, Body } from '../../ui';
|
|
18
11
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
19
12
|
import fhirVersions from '../fhirResourceVersions';
|
|
20
13
|
import Date from '../../datatypes/Date';
|
|
@@ -78,7 +71,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
78
71
|
};
|
|
79
72
|
|
|
80
73
|
const FamilyMemberHistory = props => {
|
|
81
|
-
const { fhirResource, fhirVersion } = props;
|
|
74
|
+
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
82
75
|
let fhirResourceData = {};
|
|
83
76
|
try {
|
|
84
77
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -97,36 +90,52 @@ const FamilyMemberHistory = props => {
|
|
|
97
90
|
notes,
|
|
98
91
|
} = fhirResourceData;
|
|
99
92
|
|
|
93
|
+
const tableData = [
|
|
94
|
+
{
|
|
95
|
+
label: 'Patient',
|
|
96
|
+
testId: 'patient',
|
|
97
|
+
data: patient && <Reference fhirData={patient} />,
|
|
98
|
+
status: patient,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: 'Relationship',
|
|
102
|
+
testId: 'hasRelationship',
|
|
103
|
+
data:
|
|
104
|
+
hasRelationship &&
|
|
105
|
+
relationship.map((item, i) => (
|
|
106
|
+
<Coding key={`relationship-item-${i}`} fhirData={item} />
|
|
107
|
+
)),
|
|
108
|
+
status: hasRelationship,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: 'Note',
|
|
112
|
+
testId: 'noteText',
|
|
113
|
+
data: hasNotes && <Annotation fhirData={notes} />,
|
|
114
|
+
status: hasNotes,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
|
|
100
118
|
return (
|
|
101
119
|
<Root name="FamilyMemberHistory">
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
))}
|
|
122
|
-
</Value>
|
|
123
|
-
)}
|
|
124
|
-
{hasNotes && (
|
|
125
|
-
<Value label="Note" data-testid="noteText">
|
|
126
|
-
<Annotation fhirData={notes} />
|
|
127
|
-
</Value>
|
|
128
|
-
)}
|
|
129
|
-
</Body>
|
|
120
|
+
<Accordion
|
|
121
|
+
headerContent={
|
|
122
|
+
<Header
|
|
123
|
+
resourceName="FamilyMemberHistory"
|
|
124
|
+
additionalContent={
|
|
125
|
+
date && (
|
|
126
|
+
<>
|
|
127
|
+
<span className="me-2">On</span>
|
|
128
|
+
<Date fhirData={date} />
|
|
129
|
+
</>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
133
|
+
icon={fhirIcons}
|
|
134
|
+
title={title}
|
|
135
|
+
/>
|
|
136
|
+
}
|
|
137
|
+
bodyContent={<Body tableData={tableData} />}
|
|
138
|
+
/>
|
|
130
139
|
</Root>
|
|
131
140
|
);
|
|
132
141
|
};
|
|
@@ -8,6 +8,8 @@ import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory
|
|
|
8
8
|
|
|
9
9
|
import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
|
|
10
10
|
import example2STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example2.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import FamilyMemberHistoryIcon from '../../../assets/containers/FamilyMemberHistory/family-member-history.svg';
|
|
11
13
|
|
|
12
14
|
export default {
|
|
13
15
|
title: 'FamilyMemberHistory',
|
|
@@ -19,6 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
19
21
|
<FamilyMemberHistory
|
|
20
22
|
fhirVersion={fhirVersions.DSTU2}
|
|
21
23
|
fhirResource={fhirResource}
|
|
24
|
+
fhirIcons={require('../../../assets/containers/FamilyMemberHistory/family-member-history.svg')}
|
|
22
25
|
/>
|
|
23
26
|
);
|
|
24
27
|
};
|
|
@@ -29,6 +32,7 @@ export const Example1OfSTU3 = () => {
|
|
|
29
32
|
<FamilyMemberHistory
|
|
30
33
|
fhirVersion={fhirVersions.STU3}
|
|
31
34
|
fhirResource={fhirResource}
|
|
35
|
+
fhirIcons={FamilyMemberHistoryIcon}
|
|
32
36
|
/>
|
|
33
37
|
);
|
|
34
38
|
};
|
|
@@ -39,6 +43,7 @@ export const Example2OfSTU3 = () => {
|
|
|
39
43
|
<FamilyMemberHistory
|
|
40
44
|
fhirVersion={fhirVersions.STU3}
|
|
41
45
|
fhirResource={fhirResource}
|
|
46
|
+
fhirIcons={fhirIcons}
|
|
42
47
|
/>
|
|
43
48
|
);
|
|
44
49
|
};
|
|
@@ -5,8 +5,80 @@ import fhirVersions from '../fhirResourceVersions';
|
|
|
5
5
|
|
|
6
6
|
import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory/example1.json';
|
|
7
7
|
import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
|
|
8
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
8
9
|
|
|
9
10
|
describe('should render FamilyMemberHistory component correctly', () => {
|
|
11
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
fhirResource: example1DSTU2,
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
18
|
+
const headerIcon = getByAltText('family member history');
|
|
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: example1DSTU2,
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirIcons: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const { getByTestId } = render(<FamilyMemberHistory {...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: example1DSTU2,
|
|
39
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
40
|
+
fhirIcons: (
|
|
41
|
+
<img
|
|
42
|
+
src={require('../assets/containers/FamilyMemberHistory/family-member-history.svg')}
|
|
43
|
+
alt="family member history"
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
49
|
+
const headerIcon = getByAltText('family member history');
|
|
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: example1DSTU2,
|
|
57
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
58
|
+
fhirIcons: fhirIcons,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
62
|
+
const headerIcon = getByAltText('family member history');
|
|
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: example1DSTU2,
|
|
72
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
73
|
+
fhirIcons: avatarSrc,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
77
|
+
const headerIcon = getByAltText('header icon');
|
|
78
|
+
|
|
79
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
80
|
+
});
|
|
81
|
+
|
|
10
82
|
it('DSTU2', () => {
|
|
11
83
|
const defaultProps = {
|
|
12
84
|
fhirResource: example1DSTU2,
|