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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MissingValue,
|
|
3
|
+
Table,
|
|
4
|
+
TableCell,
|
|
5
|
+
TableHeader,
|
|
6
|
+
TableRow,
|
|
7
|
+
ValueSection,
|
|
8
|
+
} from '../../ui';
|
|
9
|
+
import Coding from '../../datatypes/Coding';
|
|
10
|
+
import Reference from '../../datatypes/Reference';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
|
|
13
|
+
const Diagnosis = ({ diagnosis }) => {
|
|
14
|
+
return (
|
|
15
|
+
<ValueSection label="Diagnosis" data-testid="diagnosis" marginTop>
|
|
16
|
+
<Table>
|
|
17
|
+
<thead>
|
|
18
|
+
<TableRow>
|
|
19
|
+
<TableHeader>Diagnosis</TableHeader>
|
|
20
|
+
<TableHeader>Type</TableHeader>
|
|
21
|
+
<TableHeader>Package code</TableHeader>
|
|
22
|
+
</TableRow>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody className="border-top-0">
|
|
25
|
+
{diagnosis.map((diagnosis, idx) => (
|
|
26
|
+
<TableRow key={idx}>
|
|
27
|
+
<TableCell data-testid="diagnosis.diagnosis" className="col-md-4">
|
|
28
|
+
{diagnosis.coding ? (
|
|
29
|
+
<Coding fhirData={diagnosis.coding} />
|
|
30
|
+
) : diagnosis.refrence ? (
|
|
31
|
+
<Reference fhirData={diagnosis.reference} />
|
|
32
|
+
) : (
|
|
33
|
+
<MissingValue />
|
|
34
|
+
)}
|
|
35
|
+
</TableCell>
|
|
36
|
+
<TableCell data-testid="diagnosis.type" className="col-md-4">
|
|
37
|
+
{diagnosis.typeCoding ? (
|
|
38
|
+
<Coding fhirData={diagnosis.typeCoding} />
|
|
39
|
+
) : (
|
|
40
|
+
<MissingValue />
|
|
41
|
+
)}
|
|
42
|
+
</TableCell>
|
|
43
|
+
<TableCell
|
|
44
|
+
data-testid="diagnosis.packageCode"
|
|
45
|
+
className="col-md-4"
|
|
46
|
+
>
|
|
47
|
+
{diagnosis.packageCodeCoding ? (
|
|
48
|
+
<Coding fhirData={diagnosis.packageCodeCoding} />
|
|
49
|
+
) : (
|
|
50
|
+
<MissingValue />
|
|
51
|
+
)}
|
|
52
|
+
</TableCell>
|
|
53
|
+
</TableRow>
|
|
54
|
+
))}
|
|
55
|
+
</tbody>
|
|
56
|
+
</Table>
|
|
57
|
+
</ValueSection>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default Diagnosis;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MissingValue,
|
|
3
|
+
Table,
|
|
4
|
+
TableCell,
|
|
5
|
+
TableHeader,
|
|
6
|
+
TableRow,
|
|
7
|
+
ValueSection,
|
|
8
|
+
} from '../../ui';
|
|
9
|
+
import Reference from '../../datatypes/Reference';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
const Insurance = ({ insurance }) => {
|
|
13
|
+
return (
|
|
14
|
+
<ValueSection label="Insurance" data-testid="insurance" marginTop>
|
|
15
|
+
<Table>
|
|
16
|
+
<thead>
|
|
17
|
+
<TableRow>
|
|
18
|
+
<TableHeader>Coverage</TableHeader>
|
|
19
|
+
<TableHeader>Business Arrangement</TableHeader>
|
|
20
|
+
<TableHeader>Claim Response</TableHeader>
|
|
21
|
+
</TableRow>
|
|
22
|
+
</thead>
|
|
23
|
+
<tbody className="border-top-0">
|
|
24
|
+
{insurance.map((insurance, idx) => (
|
|
25
|
+
<TableRow key={idx}>
|
|
26
|
+
<TableCell data-testid="insurance.coverage" className="col-md-4">
|
|
27
|
+
<Reference fhirData={insurance.coverage} />
|
|
28
|
+
{insurance.focal && ' (focal)'}
|
|
29
|
+
</TableCell>
|
|
30
|
+
<TableCell
|
|
31
|
+
data-testid="insurance.businessArrangement"
|
|
32
|
+
className="col-md-4"
|
|
33
|
+
>
|
|
34
|
+
{insurance.businessArrangement ? (
|
|
35
|
+
insurance.businessArrangement
|
|
36
|
+
) : (
|
|
37
|
+
<MissingValue />
|
|
38
|
+
)}
|
|
39
|
+
</TableCell>
|
|
40
|
+
<TableCell
|
|
41
|
+
data-testid="insurance.claimResponse"
|
|
42
|
+
className="col-md-4"
|
|
43
|
+
>
|
|
44
|
+
{insurance.claimResponse ? (
|
|
45
|
+
<Reference fhirData={insurance.claimResponse} />
|
|
46
|
+
) : (
|
|
47
|
+
<MissingValue />
|
|
48
|
+
)}
|
|
49
|
+
</TableCell>
|
|
50
|
+
</TableRow>
|
|
51
|
+
))}
|
|
52
|
+
</tbody>
|
|
53
|
+
</Table>
|
|
54
|
+
</ValueSection>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default Insurance;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Chevron, MissingValue, TableCell, TableRow } from '../../ui';
|
|
3
|
+
import Coding from '../../datatypes/Coding';
|
|
4
|
+
import Money from '../../datatypes/Money';
|
|
5
|
+
|
|
6
|
+
const Item = ({ item, parentSequences, parentId, isCollapse = false }) => {
|
|
7
|
+
const itemSequences = [...parentSequences, item.sequence];
|
|
8
|
+
const id = itemSequences.join('.');
|
|
9
|
+
const collapseId = parentSequences.length ? parentId : item.sequence;
|
|
10
|
+
|
|
11
|
+
const [rotate, setRotate] = useState(false);
|
|
12
|
+
const handleTableExpand = () => setRotate(!rotate);
|
|
13
|
+
|
|
14
|
+
const isExpandable =
|
|
15
|
+
parentSequences.length === 0 && item.subItems.length !== 0;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<TableRow
|
|
20
|
+
className={`${isCollapse ? `collapse item-${parentId}` : ''} ${
|
|
21
|
+
isExpandable ? 'fw-bold table-expandable-row border-top' : ''
|
|
22
|
+
}`}
|
|
23
|
+
data-bs-target={`.item-${collapseId}`}
|
|
24
|
+
data-bs-toggle={'collapse'}
|
|
25
|
+
aria-controls={id}
|
|
26
|
+
aria-expanded="false"
|
|
27
|
+
onClick={handleTableExpand}
|
|
28
|
+
>
|
|
29
|
+
<TableCell data-testid="items.sequence" className="col-md-2">
|
|
30
|
+
{id}
|
|
31
|
+
</TableCell>
|
|
32
|
+
<TableCell data-testid="items.service" className="col-md-2">
|
|
33
|
+
<Coding fhirData={item.service} />
|
|
34
|
+
</TableCell>
|
|
35
|
+
<TableCell data-testid="items.unitPrice" className="col-md-2">
|
|
36
|
+
{item.unitPrice ? (
|
|
37
|
+
<Money fhirData={item.unitPrice} />
|
|
38
|
+
) : (
|
|
39
|
+
<MissingValue />
|
|
40
|
+
)}
|
|
41
|
+
{item.factor != null ? (
|
|
42
|
+
<span> × {item.factor}</span>
|
|
43
|
+
) : null}
|
|
44
|
+
</TableCell>
|
|
45
|
+
<TableCell data-testid="items.quantity" className="col-md-2">
|
|
46
|
+
{item.quantity != null ? item.quantity : <MissingValue />}
|
|
47
|
+
</TableCell>
|
|
48
|
+
<TableCell data-testid="items.net" className="col-md-2">
|
|
49
|
+
{item.net ? <Money fhirData={item.net} /> : <MissingValue />}
|
|
50
|
+
</TableCell>
|
|
51
|
+
{isExpandable ? (
|
|
52
|
+
<TableCell className="col-md-2">
|
|
53
|
+
<button
|
|
54
|
+
className="fhir-container__Accordion__header-button w-100 p-0 border-0 rounded-1 collapsed text-dark bg-transparent shadow-none "
|
|
55
|
+
type="button"
|
|
56
|
+
>
|
|
57
|
+
<div className={` ${rotate ? ' header-rotate' : ''}`}>
|
|
58
|
+
<Chevron strokeColor={rotate ? '#2a6fd7' : '#6f83a9'} />
|
|
59
|
+
</div>
|
|
60
|
+
</button>
|
|
61
|
+
</TableCell>
|
|
62
|
+
) : (
|
|
63
|
+
<TableCell style={{ width: '64px' }} className="col-md-2" />
|
|
64
|
+
)}
|
|
65
|
+
</TableRow>
|
|
66
|
+
{item.subItems.map((subItem, idx) => (
|
|
67
|
+
<Item
|
|
68
|
+
key={idx}
|
|
69
|
+
item={subItem}
|
|
70
|
+
parentSequences={itemSequences}
|
|
71
|
+
parentId={collapseId}
|
|
72
|
+
isCollapse
|
|
73
|
+
/>
|
|
74
|
+
))}
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default Item;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Table, TableHeader, TableRow, ValueSection } from '../../ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Item from './Item';
|
|
4
|
+
|
|
5
|
+
const Items = ({ items }) => {
|
|
6
|
+
return (
|
|
7
|
+
<ValueSection label="Items" data-testid="items" marginTop>
|
|
8
|
+
<Table>
|
|
9
|
+
<thead>
|
|
10
|
+
<TableRow>
|
|
11
|
+
<TableHeader>ID</TableHeader>
|
|
12
|
+
<TableHeader>Service</TableHeader>
|
|
13
|
+
<TableHeader>Unit price</TableHeader>
|
|
14
|
+
<TableHeader>Quantity</TableHeader>
|
|
15
|
+
<TableHeader>Total</TableHeader>
|
|
16
|
+
<TableHeader></TableHeader>
|
|
17
|
+
</TableRow>
|
|
18
|
+
</thead>
|
|
19
|
+
<tbody className="border-top-0">
|
|
20
|
+
{items.map((item, idx) => (
|
|
21
|
+
<Item key={idx} item={item} parentSequences={[]} />
|
|
22
|
+
))}
|
|
23
|
+
</tbody>
|
|
24
|
+
</Table>
|
|
25
|
+
</ValueSection>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Items;
|
|
@@ -6,8 +6,9 @@ import Reference from '../../datatypes/Reference';
|
|
|
6
6
|
import Coding from '../../datatypes/Coding';
|
|
7
7
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
8
8
|
import fhirVersions from '../fhirResourceVersions';
|
|
9
|
-
import { Root, Header,
|
|
9
|
+
import { Root, Header, Body, Value } from '../../ui';
|
|
10
10
|
import Identifier from '../../datatypes/Identifier';
|
|
11
|
+
import Accordion from '../../containers/Accordion';
|
|
11
12
|
|
|
12
13
|
const commonDTO = fhirResource => {
|
|
13
14
|
const identifier = _get(fhirResource, 'identifier.0');
|
|
@@ -113,8 +114,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
|
|
116
|
-
const Coverage =
|
|
117
|
-
const { fhirResource, fhirVersion } = props;
|
|
117
|
+
const Coverage = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
118
118
|
let fhirResourceData = {};
|
|
119
119
|
try {
|
|
120
120
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -138,74 +138,101 @@ const Coverage = props => {
|
|
|
138
138
|
} = fhirResourceData;
|
|
139
139
|
const issuerReferenceType = _get(issuer, 'reference');
|
|
140
140
|
const issuerIdentifierType = _get(issuer, 'identifier');
|
|
141
|
+
|
|
142
|
+
const tableData = [
|
|
143
|
+
{
|
|
144
|
+
label: 'Issuer',
|
|
145
|
+
testId: 'issuer',
|
|
146
|
+
data: issuerReferenceType && <Reference fhirData={issuer} />,
|
|
147
|
+
status: issuerReferenceType,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
label: 'Issuer',
|
|
151
|
+
testId: 'issuer',
|
|
152
|
+
data: issuerIdentifierType && <Identifier fhirData={issuer.identifier} />,
|
|
153
|
+
status: issuerIdentifierType,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
label: 'PlanId',
|
|
157
|
+
testId: 'planId',
|
|
158
|
+
data: planId,
|
|
159
|
+
status: planId,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: 'Coverage',
|
|
163
|
+
testId: '',
|
|
164
|
+
data: period && (
|
|
165
|
+
<>
|
|
166
|
+
{coverageFrom && (
|
|
167
|
+
<span data-testid="coverageFrom">from: {coverageFrom}</span>
|
|
168
|
+
)}{' '}
|
|
169
|
+
{coverageTo && <span data-testid="coverageTo">to: {coverageTo}</span>}
|
|
170
|
+
</>
|
|
171
|
+
),
|
|
172
|
+
status: period,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: 'Type of coverage',
|
|
176
|
+
testId: 'type',
|
|
177
|
+
data: type && <Coding fhirData={type} />,
|
|
178
|
+
status: type,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: 'Details',
|
|
182
|
+
testId: 'details',
|
|
183
|
+
data: hasDetails && (
|
|
184
|
+
<>
|
|
185
|
+
<span>{details.planDescription}</span>
|
|
186
|
+
{details.classDescription && (
|
|
187
|
+
<>
|
|
188
|
+
{' | '}
|
|
189
|
+
<span>{details.classDescription}</span>
|
|
190
|
+
</>
|
|
191
|
+
)}
|
|
192
|
+
</>
|
|
193
|
+
),
|
|
194
|
+
status: hasDetails,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: 'Extension',
|
|
198
|
+
testId: 'extensions',
|
|
199
|
+
data:
|
|
200
|
+
hasExtension &&
|
|
201
|
+
extension.map((item, i) => {
|
|
202
|
+
const coding = Array.isArray(item.coding) ? item.coding : [];
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<span key={`item-${i}`}>
|
|
206
|
+
{item.name && <span>{item.name}</span>}
|
|
207
|
+
{coding.map((code, j) => (
|
|
208
|
+
<Coding key={`item-${j}`} fhirData={code} />
|
|
209
|
+
))}
|
|
210
|
+
</span>
|
|
211
|
+
);
|
|
212
|
+
}),
|
|
213
|
+
status: hasExtension,
|
|
214
|
+
},
|
|
215
|
+
];
|
|
216
|
+
|
|
141
217
|
return (
|
|
142
218
|
<Root name="coverage">
|
|
143
|
-
<
|
|
144
|
-
{
|
|
145
|
-
<
|
|
146
|
-
Coverage
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
)}
|
|
161
|
-
{planId && (
|
|
162
|
-
<Value label="PlanId" data-testid="planId">
|
|
163
|
-
{planId}
|
|
164
|
-
</Value>
|
|
165
|
-
)}
|
|
166
|
-
{period && (
|
|
167
|
-
<Value label="Coverage">
|
|
168
|
-
{coverageFrom && (
|
|
169
|
-
<span data-testid="coverageFrom">from: {coverageFrom}</span>
|
|
170
|
-
)}{' '}
|
|
171
|
-
{coverageTo && (
|
|
172
|
-
<span data-testid="coverageTo">to: {coverageTo}</span>
|
|
173
|
-
)}
|
|
174
|
-
</Value>
|
|
175
|
-
)}
|
|
176
|
-
{type && (
|
|
177
|
-
<Value label="Type of coverage" data-testid="type">
|
|
178
|
-
<Coding fhirData={type} />
|
|
179
|
-
</Value>
|
|
180
|
-
)}
|
|
181
|
-
{hasDetails && (
|
|
182
|
-
<Value label="Details" data-testid="details">
|
|
183
|
-
<span>{details.planDescription}</span>
|
|
184
|
-
{details.classDescription && (
|
|
185
|
-
<>
|
|
186
|
-
{' | '}
|
|
187
|
-
<span>{details.classDescription}</span>
|
|
188
|
-
</>
|
|
189
|
-
)}
|
|
190
|
-
</Value>
|
|
191
|
-
)}
|
|
192
|
-
{hasExtension && (
|
|
193
|
-
<Value label="Extension" data-testid="extensions">
|
|
194
|
-
{extension.map((item, i) => {
|
|
195
|
-
const coding = Array.isArray(item.coding) ? item.coding : [];
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<span key={`item-${i}`}>
|
|
199
|
-
{item.name && <span>{item.name}</span>}
|
|
200
|
-
{coding.map((code, j) => (
|
|
201
|
-
<Coding key={`item-${j}`} fhirData={code} />
|
|
202
|
-
))}
|
|
203
|
-
</span>
|
|
204
|
-
);
|
|
205
|
-
})}
|
|
206
|
-
</Value>
|
|
207
|
-
)}
|
|
208
|
-
</Body>
|
|
219
|
+
<Accordion
|
|
220
|
+
headerContent={
|
|
221
|
+
<Header
|
|
222
|
+
resourceName="Coverage"
|
|
223
|
+
additionalContent={
|
|
224
|
+
identifier && (
|
|
225
|
+
<Value label="Identifier">
|
|
226
|
+
<Identifier fhirData={identifier} valueOnly noCursive />
|
|
227
|
+
</Value>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
title="Coverage"
|
|
231
|
+
icon={fhirIcons}
|
|
232
|
+
/>
|
|
233
|
+
}
|
|
234
|
+
bodyContent={<Body tableData={tableData} />}
|
|
235
|
+
/>
|
|
209
236
|
</Root>
|
|
210
237
|
);
|
|
211
238
|
};
|
|
@@ -9,38 +9,64 @@ import exampleCoverageStu3 from '../../../fixtures/stu3/resources/coverage/examp
|
|
|
9
9
|
import example2CoverageStu3 from '../../../fixtures/stu3/resources/coverage/example2.json';
|
|
10
10
|
import exampleCoverageR4 from '../../../fixtures/r4/resources/coverage/example1.json';
|
|
11
11
|
import example2CoverageR4 from '../../../fixtures/r4/resources/coverage/example2.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import CoverageIcon from '../../../assets/containers/Coverage/coverage.svg';
|
|
12
14
|
|
|
13
15
|
export default { title: 'Coverage' };
|
|
14
16
|
|
|
15
17
|
export const DefaultVisualizationDSTU2 = () => {
|
|
16
18
|
const fhirResource = object('Resource', exampleCoverageDstu2);
|
|
17
19
|
return (
|
|
18
|
-
<Coverage
|
|
20
|
+
<Coverage
|
|
21
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={require('../../../assets/containers/Coverage/coverage.svg')}
|
|
24
|
+
/>
|
|
19
25
|
);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
export const ExampleOfSTU3 = () => {
|
|
23
29
|
const fhirResource = object('Resource', exampleCoverageStu3);
|
|
24
30
|
return (
|
|
25
|
-
<Coverage
|
|
31
|
+
<Coverage
|
|
32
|
+
fhirVersion={fhirVersions.STU3}
|
|
33
|
+
fhirResource={fhirResource}
|
|
34
|
+
fhirIcons={CoverageIcon}
|
|
35
|
+
/>
|
|
26
36
|
);
|
|
27
37
|
};
|
|
28
38
|
|
|
29
39
|
export const Example2OfSTU3 = () => {
|
|
30
40
|
const fhirResource = object('Resource', example2CoverageStu3);
|
|
31
41
|
return (
|
|
32
|
-
<Coverage
|
|
42
|
+
<Coverage
|
|
43
|
+
fhirVersion={fhirVersions.STU3}
|
|
44
|
+
fhirResource={fhirResource}
|
|
45
|
+
fhirIcons={fhirIcons}
|
|
46
|
+
/>
|
|
33
47
|
);
|
|
34
48
|
};
|
|
35
49
|
|
|
36
50
|
export const ExampleOfR4 = () => {
|
|
37
51
|
const fhirResource = object('Resource', exampleCoverageR4);
|
|
38
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
<Coverage
|
|
54
|
+
fhirResource={fhirResource}
|
|
55
|
+
fhirVersion={fhirVersions.R4}
|
|
56
|
+
fhirIcons={false}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
39
59
|
};
|
|
40
60
|
|
|
41
61
|
export const Example2OfR4 = () => {
|
|
42
62
|
const fhirResource = object('Resource', example2CoverageR4);
|
|
43
|
-
return
|
|
63
|
+
return (
|
|
64
|
+
<Coverage
|
|
65
|
+
fhirResource={fhirResource}
|
|
66
|
+
fhirVersion={fhirVersions.R4}
|
|
67
|
+
fhirIcons={'random text'}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
44
70
|
};
|
|
45
71
|
|
|
46
72
|
export const ExampleWithoutFhirVersionProperty = () => {
|
|
@@ -8,8 +8,80 @@ import exampleCoverage from '../../../fixtures/dstu2/resources/coverage/example1
|
|
|
8
8
|
import exampleCoverageStu3 from '../../../fixtures/stu3/resources/coverage/example1.json';
|
|
9
9
|
import example2CoverageStu3 from '../../../fixtures/stu3/resources/coverage/example2.json';
|
|
10
10
|
import exampleCoverageR4 from '../../../fixtures/r4/resources/coverage/example1.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
describe('should render component correctly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
fhirResource: exampleCoverage,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
21
|
+
const headerIcon = getByAltText('coverage');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirResource: exampleCoverage,
|
|
30
|
+
fhirIcons: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const { getByTestId } = render(<Coverage {...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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirResource: exampleCoverage,
|
|
43
|
+
fhirIcons: (
|
|
44
|
+
<img
|
|
45
|
+
src={require('../assets/containers/Coverage/coverage.svg')}
|
|
46
|
+
alt="coverage"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
52
|
+
const headerIcon = getByAltText('coverage');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirResource: exampleCoverage,
|
|
61
|
+
fhirIcons: fhirIcons,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
65
|
+
const headerIcon = getByAltText('coverage');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirResource: exampleCoverage,
|
|
76
|
+
fhirIcons: avatarSrc,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
80
|
+
const headerIcon = getByAltText('header icon');
|
|
81
|
+
|
|
82
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
83
|
+
});
|
|
84
|
+
|
|
13
85
|
it('should render with DSTU2 source data', () => {
|
|
14
86
|
const defaultProps = {
|
|
15
87
|
fhirResource: exampleCoverage,
|
|
@@ -18,7 +90,7 @@ describe('should render component correctly', () => {
|
|
|
18
90
|
const { getByTestId } = render(<Coverage {...defaultProps} />);
|
|
19
91
|
|
|
20
92
|
expect(getByTestId('title').textContent.replace(nbspRegex, ' ')).toContain(
|
|
21
|
-
'Coverage
|
|
93
|
+
'Coverage',
|
|
22
94
|
);
|
|
23
95
|
expect(getByTestId('issuer').textContent).toContain('Organization/2');
|
|
24
96
|
expect(getByTestId('planId').textContent).toContain('CBI35');
|
|
@@ -35,7 +107,7 @@ describe('should render component correctly', () => {
|
|
|
35
107
|
const { getByTestId } = render(<Coverage {...defaultProps} />);
|
|
36
108
|
|
|
37
109
|
expect(getByTestId('title').textContent.replace(nbspRegex, ' ')).toContain(
|
|
38
|
-
'Coverage
|
|
110
|
+
'Coverage',
|
|
39
111
|
);
|
|
40
112
|
expect(getByTestId('issuer').textContent).toContain('Organization/2');
|
|
41
113
|
expect(getByTestId('planId').textContent).toContain('B37FC');
|
|
@@ -70,7 +142,7 @@ describe('should render component correctly', () => {
|
|
|
70
142
|
);
|
|
71
143
|
|
|
72
144
|
expect(getByTestId('title').textContent.replace(nbspRegex, ' ')).toContain(
|
|
73
|
-
'Coverage
|
|
145
|
+
'Coverage',
|
|
74
146
|
);
|
|
75
147
|
expect(getByTestId('issuer').textContent).toContain('Organization/2');
|
|
76
148
|
expect(queryAllByTestId('planId').length).toEqual(0);
|