fhir-react 0.3.2 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -2
- package/build/bootstrap-reboot.min.css +8 -2
- package/build/index.js +7 -14
- package/build/style.css +4 -5
- package/package.json +1 -1
- package/src/assets/containers/Binary/binary.svg +9 -0
- package/src/assets/containers/{Medication/medication.svg → MedicationOrder/medication-order.svg} +0 -0
- package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
- package/src/assets/containers/Patient/patient.svg +6 -0
- package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
- package/src/components/containers/Accordion/Accordion.js +17 -12
- package/src/components/datatypes/Annotation/Annotation.js +4 -4
- package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
- package/src/components/datatypes/Coding/Coding.css +0 -1
- package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
- package/src/components/datatypes/Reference/Reference.css +3 -0
- package/src/components/datatypes/Reference/Reference.js +2 -0
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +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/Appointment/Appointment.js +3 -3
- package/src/components/resources/Appointment/Appointment.stories.js +28 -5
- package/src/components/resources/Appointment/Appointment.test.js +72 -0
- package/src/components/resources/Binary/Binary.js +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/Condition/Condition.js +1 -3
- package/src/components/resources/Condition/Condition.stories.js +9 -19
- package/src/components/resources/Condition/Condition.test.js +71 -1
- package/src/components/resources/Device/Device.js +54 -34
- package/src/components/resources/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/Encounter/Encounter.js +3 -4
- package/src/components/resources/Encounter/Encounter.stories.js +27 -5
- package/src/components/resources/Encounter/Encounter.test.js +72 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +26 -10
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +80 -3
- package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +21 -6
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +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/Immunization/Immunization.js +1 -2
- package/src/components/resources/Immunization/Immunization.stories.js +6 -9
- package/src/components/resources/Immunization/Immunization.test.js +71 -1
- package/src/components/resources/Medication/Medication.test.js +1 -1
- 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/Observation/Observation.js +3 -3
- package/src/components/resources/Observation/Observation.stories.js +14 -5
- package/src/components/resources/Observation/Observation.test.js +67 -0
- package/src/components/resources/Patient/Patient.js +9 -6
- package/src/components/resources/Patient/Patient.stories.js +12 -5
- package/src/components/resources/Patient/Patient.test.js +67 -0
- package/src/components/resources/Practitioner/Practitioner.js +3 -13
- package/src/components/resources/Practitioner/Practitioner.stories.js +19 -3
- package/src/components/resources/Practitioner/Practitioner.test.js +72 -0
- package/src/components/resources/Procedure/Procedure.js +1 -2
- package/src/components/resources/Procedure/Procedure.stories.js +11 -5
- package/src/components/resources/Procedure/Procedure.test.js +71 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -8
- 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 +44 -25
- package/src/fixtures/example-icons.jsx +74 -22
- package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
- package/src/style.scss +1 -0
- package/src/utils/convertCamelCaseToSentence.js +9 -0
- package/src/utils/convertCamelCaseToSentence.test.js +9 -0
- package/src/utils/formatDate.js +6 -4
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
- package/src/components/resources/CarePlan/CarePlan.css +0 -7
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M5 20H15C15.5523 20 16 19.5523 16 19V8.72076C16 8.29033 15.7246 7.90819 15.3162 7.77208L13.5208 7.17359C13.1964 7.06547 12.9498 6.79914 12.8669 6.46744L12.4394 4.75746C12.3281 4.3123 11.9281 4 11.4692 4H5C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20Z" fill="#0D6EFD" stroke="#0D6EFD"/>
|
|
3
|
+
<mask id="path-2-outside-1_2206_5395" maskUnits="userSpaceOnUse" x="11" y="3" width="6" height="6" fill="black">
|
|
4
|
+
<rect fill="white" x="11" y="3" width="6" height="6"/>
|
|
5
|
+
<path d="M12 4V7.18534C12 7.4014 12.0858 7.60861 12.2386 7.76139C12.3914 7.91417 12.5986 8 12.8147 8H16"/>
|
|
6
|
+
</mask>
|
|
7
|
+
<path d="M12 4V7.18534C12 7.4014 12.0858 7.60861 12.2386 7.76139C12.3914 7.91417 12.5986 8 12.8147 8H16" fill="#6EA8FE"/>
|
|
8
|
+
<path d="M12 4V7.18534C12 7.4014 12.0858 7.60861 12.2386 7.76139C12.3914 7.91417 12.5986 8 12.8147 8H16" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" mask="url(#path-2-outside-1_2206_5395)"/>
|
|
9
|
+
</svg>
|
package/src/assets/containers/{Medication/medication.svg → MedicationOrder/medication-order.svg}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M4.52175 9.0435C7.01904 9.0435 9.0435 7.01904 9.0435 4.52175C9.0435 2.02446 7.01904 0 4.52175 0C2.02446 0 0 2.02446 0 4.52175C0 7.01904 2.02446 9.0435 4.52175 9.0435Z" fill="#FD7E14"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.6396 15.0832C11.0525 15.6702 10.2563 16.0001 9.42605 16.0001C8.5958 16.0001 7.79956 15.6702 7.21248 15.0832C6.62541 14.4961 6.29559 13.6998 6.29559 12.8696C6.29559 12.0394 6.62541 11.2431 7.21248 10.656L8.58067 9.28784L8.58071 9.28788L13.0078 13.715L11.6396 15.0832ZM10.656 7.21254L9.28778 8.58073L9.28782 8.58077L13.7149 13.0079L15.0831 11.6397C15.6702 11.0526 16 10.2564 16 9.42611C16 8.59587 15.6702 7.79962 15.0831 7.21254C14.496 6.62547 13.6998 6.29565 12.8695 6.29565C12.0393 6.29565 11.243 6.62547 10.656 7.21254ZM12.6279 8.21057C12.8683 8.16276 13.1175 8.18732 13.344 8.28116C13.5991 8.38687 13.8916 8.26576 13.9973 8.01065C14.103 7.75554 13.9819 7.46304 13.7268 7.35733C13.3176 7.18776 12.8672 7.14338 12.4328 7.22979C11.9984 7.3162 11.5993 7.52952 11.2861 7.84278C11.0909 8.03806 11.0909 8.35464 11.2862 8.54988C11.4815 8.74512 11.7981 8.74509 11.9933 8.5498C12.1666 8.37645 12.3875 8.25839 12.6279 8.21057Z" fill="#FEB272"/>
|
|
4
|
+
<rect x="1" y="4" width="7" height="1" rx="0.5" fill="white"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M0 12C0 8.27247 0 6.4087 0.608964 4.93853C1.42092 2.97831 2.97831 1.42092 4.93853 0.608964C6.4087 0 8.27247 0 12 0C15.7275 0 17.5913 0 19.0615 0.608964C21.0217 1.42092 22.5791 2.97831 23.391 4.93853C24 6.4087 24 8.27247 24 12C24 15.7275 24 17.5913 23.391 19.0615C22.5791 21.0217 21.0217 22.5791 19.0615 23.391C17.5913 24 15.7275 24 12 24C8.27247 24 6.4087 24 4.93853 23.391C2.97831 22.5791 1.42092 21.0217 0.608964 19.0615C0 17.5913 0 15.7275 0 12Z" fill="#F8F9FA"/>
|
|
3
|
+
<path d="M12 11C13.933 11 15.5 9.433 15.5 7.5C15.5 5.567 13.933 4 12 4C10.067 4 8.5 5.567 8.5 7.5C8.5 9.433 10.067 11 12 11Z" stroke="#3D8BFD" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M9.5 5C10.0015 5.63268 10.6029 6.13588 11.268 6.47953C11.9332 6.82317 12.6485 7.00019 13.3712 7C14.1033 7.00035 14.8277 6.81885 15.5 6.46662" stroke="#3D8BFD" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M4 20C4 18.1435 4.84285 16.363 6.34315 15.0503C7.84344 13.7375 9.87827 13 12 13C14.1217 13 16.1566 13.7375 17.6569 15.0503C19.1571 16.363 20 18.1435 20 20" stroke="#3D8BFD" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
</svg>
|
package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg}
RENAMED
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Chevron } from '../../ui';
|
|
3
|
+
import uniqueId from 'lodash/uniqueId';
|
|
3
4
|
|
|
4
5
|
const CHEVRON_DOWN_COLOR = '#6f83a9';
|
|
5
6
|
const CHEVRON_UP_COLOR = '#2a6fd7';
|
|
@@ -8,18 +9,22 @@ const Accordion = props => {
|
|
|
8
9
|
const { headerContent, bodyContent } = props;
|
|
9
10
|
const [rotate, setRotate] = useState(false);
|
|
10
11
|
const handleAccordionClick = () => setRotate(!rotate);
|
|
12
|
+
const accordionId = uniqueId(
|
|
13
|
+
`accordion-type-${headerContent.props.resourceName || 'default'}-`,
|
|
14
|
+
);
|
|
11
15
|
|
|
12
16
|
const isAccordionOpenable = () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const tableDataCondition =
|
|
18
|
+
bodyContent.props.tableData &&
|
|
19
|
+
bodyContent.props.tableData.filter(x => 'data' in x && x.data).length > 0;
|
|
20
|
+
const childrenCondition =
|
|
21
|
+
bodyContent.props.children &&
|
|
22
|
+
(bodyContent.props.children.length > 0 || bodyContent.props.children);
|
|
23
|
+
if (tableDataCondition || childrenCondition) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
21
26
|
|
|
22
|
-
return
|
|
27
|
+
return false;
|
|
23
28
|
};
|
|
24
29
|
|
|
25
30
|
const getChevron = () =>
|
|
@@ -49,9 +54,9 @@ const Accordion = props => {
|
|
|
49
54
|
isAccordionOpenable() ? '' : 'pe-none'
|
|
50
55
|
}`}
|
|
51
56
|
type="button"
|
|
52
|
-
data-bs-target=
|
|
57
|
+
data-bs-target={`#${accordionId}`}
|
|
53
58
|
data-bs-toggle={isAccordionOpenable() ? 'collapse' : null}
|
|
54
|
-
aria-controls=
|
|
59
|
+
aria-controls={accordionId}
|
|
55
60
|
aria-expanded="false"
|
|
56
61
|
onClick={handleAccordionClick}
|
|
57
62
|
>
|
|
@@ -65,7 +70,7 @@ const Accordion = props => {
|
|
|
65
70
|
</div>
|
|
66
71
|
<div
|
|
67
72
|
className="fhir-container__Accordion__data accordion-collapse collapse"
|
|
68
|
-
id=
|
|
73
|
+
id={accordionId}
|
|
69
74
|
>
|
|
70
75
|
<div className="fhir-container__Accordion__data-text accordion-body ps-4 pt-3 pe-4 border-top">
|
|
71
76
|
{bodyContent}
|
|
@@ -7,13 +7,13 @@ const Annotation = props => {
|
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
return (
|
|
10
|
-
<
|
|
10
|
+
<div className="fhir-datatype__Annotation">
|
|
11
11
|
{fhirData.map((item, i) => (
|
|
12
|
-
<
|
|
12
|
+
<p className="fhir-datatype__Annotation__item" key={`item-${i}`}>
|
|
13
13
|
{item.text}
|
|
14
|
-
</
|
|
14
|
+
</p>
|
|
15
15
|
))}
|
|
16
|
-
</
|
|
16
|
+
</div>
|
|
17
17
|
);
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -1,31 +1,76 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import { convertCamelCaseToSentence } from '../../../utils/convertCamelCaseToSentence';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const PlaceholderImage = () => {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
className="header-icon__placeholder rounded-1"
|
|
9
|
+
data-testid="placeholder"
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defaultIconOrPlaceholder = (headerIcon, resourceName) => {
|
|
15
|
+
let imageSrc;
|
|
16
|
+
const svgFileName =
|
|
17
|
+
resourceName && convertCamelCaseToSentence(resourceName).replace(/ /g, '-');
|
|
18
|
+
try {
|
|
19
|
+
imageSrc = require(`../../../assets/containers/${resourceName}/${svgFileName}.svg`);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
imageSrc = null;
|
|
22
|
+
}
|
|
23
|
+
return imageSrc && headerIcon !== false ? (
|
|
24
|
+
<img
|
|
25
|
+
className="header-icon__image"
|
|
26
|
+
src={imageSrc}
|
|
27
|
+
alt={convertCamelCaseToSentence(resourceName)}
|
|
28
|
+
/>
|
|
29
|
+
) : (
|
|
30
|
+
<PlaceholderImage />
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const useImageError = () => {
|
|
35
|
+
const [error, setError] = useState(false);
|
|
36
|
+
const ref = useRef();
|
|
37
|
+
|
|
38
|
+
const onError = () => {
|
|
39
|
+
setError(true);
|
|
7
40
|
};
|
|
8
41
|
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
typeof headerIcon.type === 'string'
|
|
13
|
-
) {
|
|
14
|
-
return headerIcon;
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (ref.current && ref.current.error) {
|
|
44
|
+
onError();
|
|
15
45
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return [ref, error, onError];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const HeaderIcon = ({ headerIcon, resourceName }) => {
|
|
52
|
+
const [ref, error, onError] = useImageError();
|
|
53
|
+
if (!headerIcon) {
|
|
54
|
+
return defaultIconOrPlaceholder(headerIcon, resourceName);
|
|
55
|
+
}
|
|
56
|
+
if (headerIcon[resourceName]) {
|
|
57
|
+
return headerIcon[resourceName];
|
|
58
|
+
}
|
|
59
|
+
if (React.isValidElement(headerIcon) && typeof headerIcon.type === 'string') {
|
|
60
|
+
return headerIcon;
|
|
61
|
+
}
|
|
27
62
|
|
|
28
|
-
return
|
|
63
|
+
return !error ? (
|
|
64
|
+
<img
|
|
65
|
+
ref={ref}
|
|
66
|
+
onError={onError}
|
|
67
|
+
className="header-icon__image"
|
|
68
|
+
src={headerIcon}
|
|
69
|
+
alt="header icon"
|
|
70
|
+
/>
|
|
71
|
+
) : (
|
|
72
|
+
defaultIconOrPlaceholder(headerIcon, resourceName)
|
|
73
|
+
);
|
|
29
74
|
};
|
|
30
75
|
|
|
31
76
|
export default HeaderIcon;
|
|
@@ -3,23 +3,15 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
|
|
4
4
|
import _get from 'lodash/get';
|
|
5
5
|
|
|
6
|
+
import Accordion from '../../containers/Accordion';
|
|
6
7
|
import Reference from '../../datatypes/Reference';
|
|
7
8
|
import Coding from '../../datatypes/Coding';
|
|
8
9
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
9
10
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
11
|
import Date from '../../datatypes/Date';
|
|
11
12
|
import Annotation from '../../datatypes/Annotation';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
Root,
|
|
16
|
-
Header,
|
|
17
|
-
Title,
|
|
18
|
-
Badge,
|
|
19
|
-
BadgeSecondary,
|
|
20
|
-
Body,
|
|
21
|
-
Value,
|
|
22
|
-
} from '../../ui';
|
|
13
|
+
|
|
14
|
+
import { Root, Header, Badge, BadgeSecondary, Body } from '../../ui';
|
|
23
15
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
24
16
|
|
|
25
17
|
const commonDTO = fhirResource => {
|
|
@@ -131,8 +123,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
131
123
|
}
|
|
132
124
|
};
|
|
133
125
|
|
|
134
|
-
const AllergyIntolerance =
|
|
135
|
-
const { fhirResource, fhirVersion } = props;
|
|
126
|
+
const AllergyIntolerance = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
136
127
|
let fhirResourceData = {};
|
|
137
128
|
try {
|
|
138
129
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -157,72 +148,90 @@ const AllergyIntolerance = props => {
|
|
|
157
148
|
patient,
|
|
158
149
|
} = fhirResourceData;
|
|
159
150
|
|
|
151
|
+
const tableData = [
|
|
152
|
+
{
|
|
153
|
+
label: 'Substance',
|
|
154
|
+
testId: 'substance',
|
|
155
|
+
data:
|
|
156
|
+
hasSubstanceCoding &&
|
|
157
|
+
substanceCoding.map((item, i) => (
|
|
158
|
+
<Coding key={`item-${i}`} fhirData={item} />
|
|
159
|
+
)),
|
|
160
|
+
status: hasSubstanceCoding,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
label: 'Type',
|
|
164
|
+
testId: 'type',
|
|
165
|
+
data: type,
|
|
166
|
+
status: type,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: 'Category',
|
|
170
|
+
testId: 'category',
|
|
171
|
+
data: category,
|
|
172
|
+
status: category,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: 'Patient',
|
|
176
|
+
testId: 'patient',
|
|
177
|
+
data: <Reference fhirData={patient} />,
|
|
178
|
+
status: patient,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: 'Asserted by',
|
|
182
|
+
testId: 'asserter',
|
|
183
|
+
data: asserter && <Reference fhirData={asserter} />,
|
|
184
|
+
status: asserter,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: 'Manifestation',
|
|
188
|
+
testId: 'manifestation',
|
|
189
|
+
data: reaction.map((reaction, i) => {
|
|
190
|
+
const manifestations = _get(reaction, 'manifestation', []);
|
|
191
|
+
const severity = _get(reaction, 'severity');
|
|
192
|
+
return manifestations.map((manifestation, j) => {
|
|
193
|
+
return (
|
|
194
|
+
<div key={`item-${i}${j}`} className="d-flex">
|
|
195
|
+
<CodeableConcept fhirData={manifestation} />
|
|
196
|
+
{severity && (
|
|
197
|
+
<span className="ms-4">
|
|
198
|
+
<BadgeSecondary>{severity}</BadgeSecondary>
|
|
199
|
+
</span>
|
|
200
|
+
)}
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
}),
|
|
205
|
+
status: hasReaction,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
label: 'Notes',
|
|
209
|
+
testId: 'hasNote',
|
|
210
|
+
data: hasNote && <Annotation fhirData={note} />,
|
|
211
|
+
status: hasNote,
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
|
|
160
215
|
return (
|
|
161
216
|
<Root name="AllergyIntolerance">
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
)}
|
|
181
|
-
{type && (
|
|
182
|
-
<Value label="Type" data-testid="type">
|
|
183
|
-
{type}
|
|
184
|
-
</Value>
|
|
185
|
-
)}
|
|
186
|
-
{category && (
|
|
187
|
-
<Value label="Category" data-testid="category">
|
|
188
|
-
{category}
|
|
189
|
-
</Value>
|
|
190
|
-
)}
|
|
191
|
-
{patient && (
|
|
192
|
-
<Value label="Patient" data-testid="patient">
|
|
193
|
-
<Reference fhirData={patient} />
|
|
194
|
-
</Value>
|
|
195
|
-
)}
|
|
196
|
-
{asserter && (
|
|
197
|
-
<Value label="Asserted by" data-testid="asserter">
|
|
198
|
-
<Reference fhirData={asserter} />
|
|
199
|
-
</Value>
|
|
200
|
-
)}
|
|
201
|
-
{hasReaction && (
|
|
202
|
-
<Value label="Manifestation" data-testid="manifestation">
|
|
203
|
-
{reaction.map((reaction, i) => {
|
|
204
|
-
const manifestations = _get(reaction, 'manifestation', []);
|
|
205
|
-
const severity = _get(reaction, 'severity');
|
|
206
|
-
return manifestations.map((manifestation, j) => {
|
|
207
|
-
return (
|
|
208
|
-
<div
|
|
209
|
-
key={`item-${i}${j}`}
|
|
210
|
-
className="fhir-resource__AllergyIntolerance__grouping"
|
|
211
|
-
>
|
|
212
|
-
<CodeableConcept fhirData={manifestation} />
|
|
213
|
-
{severity && <BadgeSecondary>{severity}</BadgeSecondary>}
|
|
214
|
-
</div>
|
|
215
|
-
);
|
|
216
|
-
});
|
|
217
|
-
})}
|
|
218
|
-
</Value>
|
|
219
|
-
)}
|
|
220
|
-
{hasNote && (
|
|
221
|
-
<Value label="Notes" data-testid="hasNote">
|
|
222
|
-
<Annotation fhirData={note} />
|
|
223
|
-
</Value>
|
|
224
|
-
)}
|
|
225
|
-
</Body>
|
|
217
|
+
<Accordion
|
|
218
|
+
headerContent={
|
|
219
|
+
<Header
|
|
220
|
+
resourceName="AllergyIntolerance"
|
|
221
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
222
|
+
title={title}
|
|
223
|
+
icon={fhirIcons}
|
|
224
|
+
rightAdditionalContent={
|
|
225
|
+
recordedDate && (
|
|
226
|
+
<BadgeSecondary data-testid="recordedDate">
|
|
227
|
+
recorded on <Date fhirData={recordedDate} />
|
|
228
|
+
</BadgeSecondary>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
/>
|
|
232
|
+
}
|
|
233
|
+
bodyContent={<Body tableData={tableData} />}
|
|
234
|
+
/>
|
|
226
235
|
</Root>
|
|
227
236
|
);
|
|
228
237
|
};
|
|
@@ -10,7 +10,9 @@ import example2AllergyIntoleranceSTU3 from '../../../fixtures/stu3/resources/all
|
|
|
10
10
|
import example1AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example1.json';
|
|
11
11
|
import example2AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example2.json';
|
|
12
12
|
import example3AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example3.json';
|
|
13
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
14
|
import fhirVersions from '../fhirResourceVersions';
|
|
15
|
+
import AllergyIntoleranceIcon from '../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg';
|
|
14
16
|
|
|
15
17
|
export default { title: 'AllergyIntolerance' };
|
|
16
18
|
|
|
@@ -20,6 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
20
22
|
<AllergyIntolerance
|
|
21
23
|
fhirVersion={fhirVersions.DSTU2}
|
|
22
24
|
fhirResource={fhirResource}
|
|
25
|
+
fhirIcons={require('../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg')}
|
|
23
26
|
/>
|
|
24
27
|
);
|
|
25
28
|
};
|
|
@@ -30,6 +33,7 @@ export const Example2ofDSTU2 = () => {
|
|
|
30
33
|
<AllergyIntolerance
|
|
31
34
|
fhirVersion={fhirVersions.DSTU2}
|
|
32
35
|
fhirResource={fhirResource}
|
|
36
|
+
fhirIcons={AllergyIntoleranceIcon}
|
|
33
37
|
/>
|
|
34
38
|
);
|
|
35
39
|
};
|
|
@@ -40,6 +44,7 @@ export const ExampleDiagnosticReportSTU3 = () => {
|
|
|
40
44
|
<AllergyIntolerance
|
|
41
45
|
fhirVersion={fhirVersions.STU3}
|
|
42
46
|
fhirResource={fhirResource}
|
|
47
|
+
fhirIcons={fhirIcons}
|
|
43
48
|
/>
|
|
44
49
|
);
|
|
45
50
|
};
|
|
@@ -50,6 +55,7 @@ export const Example2DiagnosticReportSTU3 = () => {
|
|
|
50
55
|
<AllergyIntolerance
|
|
51
56
|
fhirVersion={fhirVersions.STU3}
|
|
52
57
|
fhirResource={fhirResource}
|
|
58
|
+
fhirIcons={false}
|
|
53
59
|
/>
|
|
54
60
|
);
|
|
55
61
|
};
|
|
@@ -60,6 +66,7 @@ export const Example1R4 = () => {
|
|
|
60
66
|
<AllergyIntolerance
|
|
61
67
|
fhirVersion={fhirVersions.R4}
|
|
62
68
|
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={'random text'}
|
|
63
70
|
/>
|
|
64
71
|
);
|
|
65
72
|
};
|
|
@@ -70,6 +77,7 @@ export const Example2R4 = () => {
|
|
|
70
77
|
<AllergyIntolerance
|
|
71
78
|
fhirVersion={fhirVersions.R4}
|
|
72
79
|
fhirResource={fhirResource}
|
|
80
|
+
fhirIcons={fhirIcons}
|
|
73
81
|
/>
|
|
74
82
|
);
|
|
75
83
|
};
|
|
@@ -80,11 +88,14 @@ export const Example3R4 = () => {
|
|
|
80
88
|
<AllergyIntolerance
|
|
81
89
|
fhirVersion={fhirVersions.R4}
|
|
82
90
|
fhirResource={fhirResource}
|
|
91
|
+
fhirIcons={fhirIcons}
|
|
83
92
|
/>
|
|
84
93
|
);
|
|
85
94
|
};
|
|
86
95
|
|
|
87
96
|
export const ExampleWithoutFhirVersionProperty = () => {
|
|
88
97
|
const fhirResource = object('Resource', example2AllergyIntoleranceSTU3);
|
|
89
|
-
return
|
|
98
|
+
return (
|
|
99
|
+
<AllergyIntolerance fhirResource={fhirResource} fhirIcons={fhirIcons} />
|
|
100
|
+
);
|
|
90
101
|
};
|
|
@@ -7,8 +7,79 @@ import exampleAllergyIntoleranceSTU3 from '../../../fixtures/stu3/resources/alle
|
|
|
7
7
|
import exampleAllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example1.json';
|
|
8
8
|
import example2AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example3.json';
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render component correctly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('allergy intolerance');
|
|
21
|
+
|
|
22
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<AllergyIntolerance {...defaultProps} />);
|
|
33
|
+
const headerIcon = getByTestId('placeholder');
|
|
34
|
+
|
|
35
|
+
expect(headerIcon).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/AllergyIntolerance/allergy-intolerance.svg')}
|
|
45
|
+
alt="allergy intolerance"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('allergy intolerance');
|
|
52
|
+
|
|
53
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
57
|
+
const defaultProps = {
|
|
58
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
59
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('allergy intolerance');
|
|
65
|
+
|
|
66
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
70
|
+
const avatarSrc =
|
|
71
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
72
|
+
const defaultProps = {
|
|
73
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
74
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<AllergyIntolerance {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
12
83
|
it('should render with DSTU2 source data', () => {
|
|
13
84
|
const defaultProps = {
|
|
14
85
|
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
@@ -144,8 +144,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
const Appointment =
|
|
148
|
-
const { fhirResource, fhirVersion } = props;
|
|
147
|
+
const Appointment = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
149
148
|
const {
|
|
150
149
|
description,
|
|
151
150
|
status,
|
|
@@ -208,7 +207,7 @@ const Appointment = props => {
|
|
|
208
207
|
<Accordion
|
|
209
208
|
headerContent={
|
|
210
209
|
<Header
|
|
211
|
-
resourceName=
|
|
210
|
+
resourceName="Appointment"
|
|
212
211
|
additionalContent={
|
|
213
212
|
start && (
|
|
214
213
|
<Value label="Start date" data-testid="headerStartDate">
|
|
@@ -218,6 +217,7 @@ const Appointment = props => {
|
|
|
218
217
|
}
|
|
219
218
|
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
220
219
|
title={description}
|
|
220
|
+
icon={fhirIcons}
|
|
221
221
|
/>
|
|
222
222
|
}
|
|
223
223
|
bodyContent={
|