fhir-react 0.3.4 → 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/build/bootstrap-reboot.min.css +8 -2
- package/build/index.js +7 -7
- package/build/style.css +4 -5
- package/package.json +1 -1
- package/src/assets/containers/Binary/binary.svg +9 -0
- package/src/components/containers/Accordion/Accordion.js +10 -9
- 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/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/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/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/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/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/ui/bootstrap-reboot.min.css +8 -2
- package/src/components/ui/index.js +11 -0
- package/src/fixtures/example-icons.jsx +7 -0
- 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,7 @@ 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';
|
|
10
11
|
|
|
11
12
|
export default { title: 'Document Reference' };
|
|
12
13
|
|
|
@@ -16,6 +17,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
16
17
|
<DocumentReference
|
|
17
18
|
fhirResource={fhirResource}
|
|
18
19
|
fhirVersion={fhirVersions.DSTU2}
|
|
20
|
+
fhirIcons={fhirIcons}
|
|
19
21
|
/>
|
|
20
22
|
);
|
|
21
23
|
};
|
|
@@ -26,6 +28,7 @@ export const ExampleSTU3 = () => {
|
|
|
26
28
|
<DocumentReference
|
|
27
29
|
fhirResource={fhirResource}
|
|
28
30
|
fhirVersion={fhirVersions.STU3}
|
|
31
|
+
fhirIcons={fhirIcons}
|
|
29
32
|
/>
|
|
30
33
|
);
|
|
31
34
|
};
|
|
@@ -36,6 +39,7 @@ export const ExampleR4 = () => {
|
|
|
36
39
|
<DocumentReference
|
|
37
40
|
fhirResource={fhirResource}
|
|
38
41
|
fhirVersion={fhirVersions.R4}
|
|
42
|
+
fhirIcons={fhirIcons}
|
|
39
43
|
/>
|
|
40
44
|
);
|
|
41
45
|
};
|
|
@@ -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,7 @@ 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';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
title: 'FamilyMemberHistory',
|
|
@@ -19,6 +20,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
19
20
|
<FamilyMemberHistory
|
|
20
21
|
fhirVersion={fhirVersions.DSTU2}
|
|
21
22
|
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={fhirIcons}
|
|
22
24
|
/>
|
|
23
25
|
);
|
|
24
26
|
};
|
|
@@ -29,6 +31,7 @@ export const Example1OfSTU3 = () => {
|
|
|
29
31
|
<FamilyMemberHistory
|
|
30
32
|
fhirVersion={fhirVersions.STU3}
|
|
31
33
|
fhirResource={fhirResource}
|
|
34
|
+
fhirIcons={fhirIcons}
|
|
32
35
|
/>
|
|
33
36
|
);
|
|
34
37
|
};
|
|
@@ -39,6 +42,7 @@ export const Example2OfSTU3 = () => {
|
|
|
39
42
|
<FamilyMemberHistory
|
|
40
43
|
fhirVersion={fhirVersions.STU3}
|
|
41
44
|
fhirResource={fhirResource}
|
|
45
|
+
fhirIcons={fhirIcons}
|
|
42
46
|
/>
|
|
43
47
|
);
|
|
44
48
|
};
|
|
@@ -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',
|