fhir-react 0.3.7 → 0.3.10
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/.circleci/config.yml +1 -1
- package/.eslintrc +10 -1
- package/.storybook/main.js +5 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview.js +7 -0
- package/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +9 -9
- package/package.json +59 -57
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Generic/generic.svg +3 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
- package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
- package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +44 -13
- package/src/components/containers/Accordion/Accordion.stories.js +74 -58
- package/src/components/containers/ResourceContainer/ResourceContainer.css +4 -0
- package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
- package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +46 -22
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -5
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/defaultArgTypes.js +12 -0
- package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +19 -11
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +46 -70
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +9 -1
- package/src/components/resources/Appointment/Appointment.stories.js +51 -62
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +2 -1
- package/src/components/resources/Binary/Binary.stories.js +27 -21
- package/src/components/resources/Bundle/Bundle.css +7 -0
- package/src/components/resources/Bundle/Bundle.js +15 -11
- package/src/components/resources/Bundle/Bundle.stories.js +59 -115
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +9 -1
- package/src/components/resources/CarePlan/CarePlan.stories.js +44 -54
- package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
- package/src/components/resources/CareTeam/CareTeam.js +79 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +25 -14
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- package/src/components/resources/Claim/Claim.js +9 -1
- package/src/components/resources/Claim/Claim.stories.js +36 -49
- package/src/components/resources/Claim/Claim.test.js +32 -1
- package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
- package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
- package/src/components/resources/ClaimResponse/ClaimResponse.js +144 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +44 -41
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
- package/src/components/resources/ClaimResponse/Item.js +44 -9
- package/src/components/resources/ClaimResponse/Items.js +5 -4
- package/src/components/resources/Condition/Condition.js +10 -3
- package/src/components/resources/Condition/Condition.stories.js +47 -62
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +9 -1
- package/src/components/resources/Coverage/Coverage.stories.js +38 -50
- package/src/components/resources/Coverage/Coverage.test.js +36 -1
- package/src/components/resources/Device/Device.js +9 -1
- package/src/components/resources/Device/Device.stories.js +40 -52
- package/src/components/resources/Device/Device.test.js +36 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +9 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +38 -50
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +25 -29
- package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
- package/src/components/resources/Encounter/Encounter.js +9 -1
- package/src/components/resources/Encounter/Encounter.stories.js +43 -59
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +53 -67
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js +74 -38
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +22 -28
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
- package/src/components/resources/Generic/Generic.js +21 -7
- package/src/components/resources/Generic/Generic.stories.js +22 -12
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +9 -3
- package/src/components/resources/Goal/Goal.stories.js +35 -49
- package/src/components/resources/Goal/Goal.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +9 -2
- package/src/components/resources/Immunization/Immunization.stories.js +38 -51
- package/src/components/resources/Immunization/Immunization.test.js +36 -1
- package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
- package/src/components/resources/List/Entries.js +3 -3
- package/src/components/resources/List/List.js +137 -88
- package/src/components/resources/List/List.stories.js +69 -40
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +66 -47
- package/src/components/resources/Location/Location.stories.js +25 -13
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +9 -1
- package/src/components/resources/Medication/Medication.stories.js +42 -64
- package/src/components/resources/Medication/Medication.test.js +36 -1
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +34 -41
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
- package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.js +70 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +41 -52
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +117 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +51 -54
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -3
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +11 -4
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +27 -30
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +32 -46
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
- package/src/components/resources/Observation/Observation.js +3 -1
- package/src/components/resources/Observation/Observation.stories.js +39 -33
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Observation/ObservationGraph.js +1 -1
- package/src/components/resources/Organization/Organization.js +10 -2
- package/src/components/resources/Organization/Organization.stories.js +40 -52
- package/src/components/resources/Organization/Organization.test.js +36 -1
- package/src/components/resources/Patient/Patient.js +4 -0
- package/src/components/resources/Patient/Patient.stories.js +36 -28
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +9 -1
- package/src/components/resources/Practitioner/Practitioner.stories.js +39 -52
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +45 -58
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +3 -2
- package/src/components/resources/Procedure/Procedure.stories.js +33 -25
- package/src/components/resources/Procedure/Procedure.test.js +30 -1
- package/src/components/resources/Questionnaire/Group.js +53 -0
- package/src/components/resources/Questionnaire/Items.js +45 -0
- package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
- package/src/components/resources/Questionnaire/Questionnaire.js +38 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +50 -57
- package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
- package/src/components/resources/Questionnaire/Questions.js +40 -0
- package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
- package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
- package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
- package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +54 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +46 -58
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
- package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
- package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
- package/src/components/resources/ReferralRequest/ReferralRequest.js +72 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.stories.js +20 -20
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +42 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
- package/src/components/resources/RelatedPerson/index.js +3 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.js +167 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +18 -14
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +40 -27
- package/src/components/ui/index.js +48 -31
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +42 -0
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +14 -1
- package/.storybook/addons.js +0 -1
- package/.storybook/config.js +0 -26
- package/.storybook/presets.js +0 -1
|
@@ -19,8 +19,7 @@ export const hasValue = data => {
|
|
|
19
19
|
return false;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const CodeableConcept =
|
|
23
|
-
const { fhirData } = props;
|
|
22
|
+
const CodeableConcept = ({ fhirData, isCursive = false }) => {
|
|
24
23
|
if (!_isObject(fhirData)) return null;
|
|
25
24
|
|
|
26
25
|
const data = Array.isArray(fhirData) ? fhirData : [fhirData];
|
|
@@ -40,7 +39,11 @@ const CodeableConcept = props => {
|
|
|
40
39
|
</span>
|
|
41
40
|
)}
|
|
42
41
|
{coding.map((codingData, j) => (
|
|
43
|
-
<Coding
|
|
42
|
+
<Coding
|
|
43
|
+
key={`codingData-${j}`}
|
|
44
|
+
fhirData={codingData}
|
|
45
|
+
isCursive={isCursive}
|
|
46
|
+
/>
|
|
44
47
|
))}
|
|
45
48
|
</div>
|
|
46
49
|
);
|
|
@@ -4,8 +4,7 @@ import _get from 'lodash/get';
|
|
|
4
4
|
|
|
5
5
|
import './Coding.css';
|
|
6
6
|
|
|
7
|
-
const Coding =
|
|
8
|
-
const { fhirData } = props;
|
|
7
|
+
const Coding = ({ fhirData, isCursive = false }) => {
|
|
9
8
|
const display = _get(fhirData, 'display', '');
|
|
10
9
|
const code = _get(fhirData, 'code', '');
|
|
11
10
|
const system = _get(fhirData, 'system', '');
|
|
@@ -14,7 +13,12 @@ const Coding = props => {
|
|
|
14
13
|
<div className="fhir-datatype__Coding">
|
|
15
14
|
<span className="fhir-datatype__Coding__title">{display}</span>
|
|
16
15
|
{hasAdditionalInfo && (
|
|
17
|
-
<span
|
|
16
|
+
<span
|
|
17
|
+
className={`${
|
|
18
|
+
isCursive ? 'fst-italic' : ''
|
|
19
|
+
} fhir-datatype__Coding__code`}
|
|
20
|
+
title={system}
|
|
21
|
+
>
|
|
18
22
|
({code || '?'})
|
|
19
23
|
</span>
|
|
20
24
|
)}
|
|
@@ -7,17 +7,19 @@ const Reference = props => {
|
|
|
7
7
|
const { fhirData } = props;
|
|
8
8
|
const display = _get(fhirData, 'display');
|
|
9
9
|
const reference = _get(fhirData, 'reference', '');
|
|
10
|
+
|
|
10
11
|
return (
|
|
11
12
|
<div
|
|
12
13
|
className="fhir-datatype__Reference d-inline-block"
|
|
13
14
|
data-testid={props['data-testid']}
|
|
14
15
|
>
|
|
15
16
|
{display && <span className="mr-2 pe-1">{display}</span>}
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
{!display &&
|
|
18
|
+
(reference.startsWith('http://') || reference.startsWith('https://') ? (
|
|
19
|
+
<a href={reference}>{reference}</a>
|
|
20
|
+
) : (
|
|
21
|
+
<span>{reference}</span>
|
|
22
|
+
))}
|
|
21
23
|
</div>
|
|
22
24
|
);
|
|
23
25
|
};
|
|
@@ -3,8 +3,7 @@ import _get from 'lodash/get';
|
|
|
3
3
|
|
|
4
4
|
import './Telecom.css';
|
|
5
5
|
|
|
6
|
-
const Telecom =
|
|
7
|
-
const { fhirData } = props;
|
|
6
|
+
const Telecom = ({ fhirData, noSystemData = false }) => {
|
|
8
7
|
if (Array.isArray(fhirData)) {
|
|
9
8
|
return (
|
|
10
9
|
<div className="fhir-datatype__Telecom">
|
|
@@ -12,7 +11,7 @@ const Telecom = props => {
|
|
|
12
11
|
const system = _get(item, 'system', '');
|
|
13
12
|
return (
|
|
14
13
|
<div className="fhir-datatype__Telecom__item" key={`phone-${i}`}>
|
|
15
|
-
{system && (
|
|
14
|
+
{!noSystemData && system && (
|
|
16
15
|
<span className="fhir-datatype__Telecom__item-label">
|
|
17
16
|
{system}
|
|
18
17
|
</span>
|
|
@@ -2,11 +2,19 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Root,
|
|
7
|
+
Header,
|
|
8
|
+
Body,
|
|
9
|
+
ValueSection,
|
|
10
|
+
ValueSectionItem,
|
|
11
|
+
Value,
|
|
12
|
+
} from '../../ui';
|
|
6
13
|
import Reference from '../../datatypes/Reference';
|
|
7
14
|
import Date from '../../datatypes/Date';
|
|
8
15
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
9
16
|
import CodeableConcept, { hasValue } from '../../datatypes/CodeableConcept';
|
|
17
|
+
import Accordion from '../../containers/Accordion';
|
|
10
18
|
|
|
11
19
|
const commonDTO = fhirResource => {
|
|
12
20
|
const subject = _get(fhirResource, 'subject');
|
|
@@ -63,8 +71,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
63
71
|
}
|
|
64
72
|
};
|
|
65
73
|
|
|
66
|
-
const AdverseEvent =
|
|
67
|
-
|
|
74
|
+
const AdverseEvent = ({
|
|
75
|
+
fhirResource,
|
|
76
|
+
fhirVersion,
|
|
77
|
+
fhirIcons,
|
|
78
|
+
onClick,
|
|
79
|
+
rawOnClick,
|
|
80
|
+
}) => {
|
|
68
81
|
let fhirResourceData = {};
|
|
69
82
|
try {
|
|
70
83
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -86,47 +99,80 @@ const AdverseEvent = props => {
|
|
|
86
99
|
hasEvent,
|
|
87
100
|
} = fhirResourceData;
|
|
88
101
|
|
|
102
|
+
const tableData = [
|
|
103
|
+
{
|
|
104
|
+
label: 'Event',
|
|
105
|
+
testId: 'event',
|
|
106
|
+
data: hasEventType && <CodeableConcept fhirData={eventType} />,
|
|
107
|
+
status: hasEventType,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: 'Event',
|
|
111
|
+
testId: 'event',
|
|
112
|
+
data: hasEvent && <CodeableConcept fhirData={event} />,
|
|
113
|
+
status: hasEvent,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: 'Seriousness',
|
|
117
|
+
testId: 'hasSeriousness',
|
|
118
|
+
data: hasSeriousness && (
|
|
119
|
+
<CodeableConcept fhirData={seriousness} isCursive />
|
|
120
|
+
),
|
|
121
|
+
status: hasSeriousness,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
label: 'Actuality',
|
|
125
|
+
testId: 'actuality',
|
|
126
|
+
data: actuality,
|
|
127
|
+
status: actuality,
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
|
|
89
131
|
return (
|
|
90
132
|
<Root name="AdverseEvent">
|
|
91
|
-
<
|
|
92
|
-
{
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
<Accordion
|
|
134
|
+
headerContent={
|
|
135
|
+
<Header
|
|
136
|
+
resourceName={'AdverseEvent'}
|
|
137
|
+
title={subject && <Reference fhirData={subject} />}
|
|
138
|
+
icon={fhirIcons}
|
|
139
|
+
additionalContent={
|
|
140
|
+
date && (
|
|
141
|
+
<Value label="Date" data-testid="date">
|
|
142
|
+
<Date fhirData={date} isBlack />
|
|
143
|
+
</Value>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
/>
|
|
147
|
+
}
|
|
148
|
+
bodyContent={
|
|
149
|
+
<Body>
|
|
150
|
+
{description && (
|
|
151
|
+
<ValueSection
|
|
152
|
+
label="Comment"
|
|
153
|
+
data-testid="description"
|
|
154
|
+
marginBottom
|
|
155
|
+
>
|
|
156
|
+
<span className="text-secondary">{description}</span>
|
|
157
|
+
</ValueSection>
|
|
158
|
+
)}
|
|
159
|
+
{tableData.map(
|
|
160
|
+
(item, index) =>
|
|
161
|
+
item.status && (
|
|
162
|
+
<ValueSectionItem
|
|
163
|
+
key={`adverse-event-item-${index}`}
|
|
164
|
+
label={item.label}
|
|
165
|
+
data-testid={item.testId}
|
|
166
|
+
>
|
|
167
|
+
{item.data}
|
|
168
|
+
</ValueSectionItem>
|
|
169
|
+
),
|
|
170
|
+
)}
|
|
171
|
+
</Body>
|
|
172
|
+
}
|
|
173
|
+
onClick={onClick}
|
|
174
|
+
rawOnClick={rawOnClick}
|
|
175
|
+
/>
|
|
130
176
|
</Root>
|
|
131
177
|
);
|
|
132
178
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import AdverseEvent from './AdverseEvent';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -7,20 +7,28 @@ import fhirVersions from '../fhirResourceVersions';
|
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/adverseEvent/example1.json';
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/adverseEvent/example1.json';
|
|
9
9
|
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
|
+
|
|
10
12
|
export default {
|
|
11
13
|
title: 'AdverseEvent',
|
|
14
|
+
component: AdverseEvent,
|
|
15
|
+
argTypes: {
|
|
16
|
+
...defaultArgTypes,
|
|
17
|
+
},
|
|
12
18
|
};
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
const Template = args => <AdverseEvent {...args} />;
|
|
21
|
+
|
|
22
|
+
export const DefaultVisualizationSTU3 = Template.bind({});
|
|
23
|
+
DefaultVisualizationSTU3.args = {
|
|
24
|
+
fhirVersion: fhirVersions.STU3,
|
|
25
|
+
fhirResource: stu3Example1,
|
|
26
|
+
fhirIcons: fhirIcons,
|
|
19
27
|
};
|
|
20
28
|
|
|
21
|
-
export const Example1ofR4 = ()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
export const Example1ofR4 = Template.bind({});
|
|
30
|
+
Example1ofR4.args = {
|
|
31
|
+
fhirVersion: fhirVersions.R4,
|
|
32
|
+
fhirResource: r4Example1,
|
|
33
|
+
fhirIcons: false,
|
|
26
34
|
};
|
|
@@ -1,12 +1,84 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import AdverseEvent from './AdverseEvent';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
6
6
|
import stu3Example1 from '../../../fixtures/stu3/resources/adverseEvent/example1.json';
|
|
7
7
|
import r4Example1 from '../../../fixtures/r4/resources/adverseEvent/example1.json';
|
|
8
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
8
9
|
|
|
9
10
|
describe('should render component correctly', () => {
|
|
11
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
fhirVersion: fhirVersions.STU3,
|
|
14
|
+
fhirResource: stu3Example1,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
|
|
18
|
+
const headerIcon = getByAltText('adverse event');
|
|
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
|
+
fhirVersion: fhirVersions.STU3,
|
|
26
|
+
fhirResource: stu3Example1,
|
|
27
|
+
fhirIcons: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const { getByTestId } = render(<AdverseEvent {...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
|
+
fhirVersion: fhirVersions.STU3,
|
|
39
|
+
fhirResource: stu3Example1,
|
|
40
|
+
fhirIcons: (
|
|
41
|
+
<img
|
|
42
|
+
src={require('../assets/containers/AdverseEvent/adverse-event.svg')}
|
|
43
|
+
alt="adverse event"
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
|
|
49
|
+
const headerIcon = getByAltText('adverse event');
|
|
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
|
+
fhirVersion: fhirVersions.STU3,
|
|
57
|
+
fhirResource: stu3Example1,
|
|
58
|
+
fhirIcons: fhirIcons,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
|
|
62
|
+
const headerIcon = getByAltText('adverse event');
|
|
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
|
+
fhirVersion: fhirVersions.STU3,
|
|
72
|
+
fhirResource: stu3Example1,
|
|
73
|
+
fhirIcons: avatarSrc,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
|
|
77
|
+
const headerIcon = getByAltText('header icon');
|
|
78
|
+
|
|
79
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
80
|
+
});
|
|
81
|
+
|
|
10
82
|
it('should render with STU3 source data', () => {
|
|
11
83
|
const defaultProps = {
|
|
12
84
|
fhirResource: stu3Example1,
|
|
@@ -18,7 +90,7 @@ describe('should render component correctly', () => {
|
|
|
18
90
|
|
|
19
91
|
expect(getByTestId('date').textContent).toEqual('1/29/2017');
|
|
20
92
|
|
|
21
|
-
expect(getByTestId('
|
|
93
|
+
expect(getByTestId('event').textContent).toContain('304386008');
|
|
22
94
|
|
|
23
95
|
expect(getByTestId('description').textContent).toContain(
|
|
24
96
|
'This was a mild rash',
|
|
@@ -44,4 +116,39 @@ describe('should render component correctly', () => {
|
|
|
44
116
|
|
|
45
117
|
expect(getByTestId('actuality').textContent).toEqual('actual');
|
|
46
118
|
});
|
|
119
|
+
|
|
120
|
+
it('should fire custom onClick function', () => {
|
|
121
|
+
const defaultProps = {
|
|
122
|
+
fhirResource: r4Example1,
|
|
123
|
+
fhirVersion: fhirVersions.R4,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const onClick = jest.fn();
|
|
127
|
+
const { getByRole } = render(
|
|
128
|
+
<AdverseEvent {...defaultProps} onClick={onClick} />,
|
|
129
|
+
);
|
|
130
|
+
const accordion = getByRole('button');
|
|
131
|
+
fireEvent.click(accordion);
|
|
132
|
+
|
|
133
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
134
|
+
expect(attribute).not.toEqual('collapse');
|
|
135
|
+
expect(onClick).toHaveBeenCalled();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should not fire custom onClick function', () => {
|
|
139
|
+
const defaultProps = {
|
|
140
|
+
fhirResource: r4Example1,
|
|
141
|
+
fhirVersion: fhirVersions.R4,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const onClick = 'test';
|
|
145
|
+
const { getByRole } = render(
|
|
146
|
+
<AdverseEvent {...defaultProps} onClick={onClick} />,
|
|
147
|
+
);
|
|
148
|
+
const accordion = getByRole('button');
|
|
149
|
+
fireEvent.click(accordion);
|
|
150
|
+
|
|
151
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
152
|
+
expect(attribute).toEqual('collapse');
|
|
153
|
+
});
|
|
47
154
|
});
|
|
@@ -123,7 +123,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
const AllergyIntolerance = ({
|
|
126
|
+
const AllergyIntolerance = ({
|
|
127
|
+
fhirResource,
|
|
128
|
+
fhirVersion,
|
|
129
|
+
fhirIcons,
|
|
130
|
+
onClick,
|
|
131
|
+
rawOnClick,
|
|
132
|
+
}) => {
|
|
127
133
|
let fhirResourceData = {};
|
|
128
134
|
try {
|
|
129
135
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -231,6 +237,8 @@ const AllergyIntolerance = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
231
237
|
/>
|
|
232
238
|
}
|
|
233
239
|
bodyContent={<Body tableData={tableData} />}
|
|
240
|
+
onClick={onClick}
|
|
241
|
+
rawOnClick={rawOnClick}
|
|
234
242
|
/>
|
|
235
243
|
</Root>
|
|
236
244
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import AllergyIntolerance from './AllergyIntolerance';
|
|
5
5
|
|
|
@@ -14,88 +14,64 @@ import fhirIcons from '../../../fixtures/example-icons';
|
|
|
14
14
|
import fhirVersions from '../fhirResourceVersions';
|
|
15
15
|
import AllergyIntoleranceIcon from '../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg';
|
|
16
16
|
|
|
17
|
-
export default {
|
|
17
|
+
export default {
|
|
18
|
+
title: 'AllergyIntolerance',
|
|
19
|
+
component: AllergyIntolerance,
|
|
20
|
+
argTypes: {
|
|
21
|
+
...defaultArgTypes,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Template = args => <AllergyIntolerance {...args} />;
|
|
18
26
|
|
|
19
|
-
export const DefaultVisualizationDSTU2 = ()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fhirResource={fhirResource}
|
|
25
|
-
fhirIcons={require('../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg')}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
27
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
28
|
+
DefaultVisualizationDSTU2.args = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: exampleAllergyIntoleranceDSTU2,
|
|
31
|
+
fhirIcons: require('../../../assets/containers/AllergyIntolerance/allergy-intolerance.svg'),
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
export const Example2ofDSTU2 = ()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fhirResource={fhirResource}
|
|
36
|
-
fhirIcons={AllergyIntoleranceIcon}
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
34
|
+
export const Example2ofDSTU2 = Template.bind({});
|
|
35
|
+
Example2ofDSTU2.args = {
|
|
36
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
37
|
+
fhirResource: example2AllergyIntoleranceDSTU2,
|
|
38
|
+
fhirIcons: AllergyIntoleranceIcon,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const ExampleDiagnosticReportSTU3 = ()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
fhirResource={fhirResource}
|
|
47
|
-
fhirIcons={fhirIcons}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
41
|
+
export const ExampleDiagnosticReportSTU3 = Template.bind({});
|
|
42
|
+
ExampleDiagnosticReportSTU3.args = {
|
|
43
|
+
fhirVersion: fhirVersions.STU3,
|
|
44
|
+
fhirResource: exampleAllergyIntoleranceSTU3,
|
|
45
|
+
fhirIcons: fhirIcons,
|
|
50
46
|
};
|
|
51
47
|
|
|
52
|
-
export const Example2DiagnosticReportSTU3 = ()
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
fhirResource={fhirResource}
|
|
58
|
-
fhirIcons={false}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
48
|
+
export const Example2DiagnosticReportSTU3 = Template.bind({});
|
|
49
|
+
Example2DiagnosticReportSTU3.args = {
|
|
50
|
+
fhirVersion: fhirVersions.STU3,
|
|
51
|
+
fhirResource: example2AllergyIntoleranceSTU3,
|
|
52
|
+
fhirIcons: false,
|
|
61
53
|
};
|
|
62
54
|
|
|
63
|
-
export const Example1R4 = ()
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
fhirResource={fhirResource}
|
|
69
|
-
fhirIcons={'random text'}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
55
|
+
export const Example1R4 = Template.bind({});
|
|
56
|
+
Example1R4.args = {
|
|
57
|
+
fhirVersion: fhirVersions.R4,
|
|
58
|
+
fhirResource: example1AllergyIntoleranceR4,
|
|
59
|
+
fhirIcons: 'random text',
|
|
72
60
|
};
|
|
73
61
|
|
|
74
|
-
export const Example2R4 = ()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
fhirVersion={fhirVersions.R4}
|
|
79
|
-
fhirResource={fhirResource}
|
|
80
|
-
fhirIcons={fhirIcons}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
62
|
+
export const Example2R4 = Template.bind({});
|
|
63
|
+
Example2R4.args = {
|
|
64
|
+
fhirVersion: fhirVersions.R4,
|
|
65
|
+
fhirResource: example2AllergyIntoleranceR4,
|
|
83
66
|
};
|
|
84
67
|
|
|
85
|
-
export const Example3R4 = ()
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
fhirVersion={fhirVersions.R4}
|
|
90
|
-
fhirResource={fhirResource}
|
|
91
|
-
fhirIcons={fhirIcons}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
68
|
+
export const Example3R4 = Template.bind({});
|
|
69
|
+
Example3R4.args = {
|
|
70
|
+
fhirVersion: fhirVersions.R4,
|
|
71
|
+
fhirResource: example3AllergyIntoleranceR4,
|
|
94
72
|
};
|
|
95
73
|
|
|
96
|
-
export const ExampleWithoutFhirVersionProperty = ()
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<AllergyIntolerance fhirResource={fhirResource} fhirIcons={fhirIcons} />
|
|
100
|
-
);
|
|
74
|
+
export const ExampleWithoutFhirVersionProperty = Template.bind({});
|
|
75
|
+
ExampleWithoutFhirVersionProperty.args = {
|
|
76
|
+
fhirResource: example2AllergyIntoleranceSTU3,
|
|
101
77
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import AllergyIntolerance from './AllergyIntolerance';
|
|
4
4
|
|
|
5
5
|
import exampleAllergyIntoleranceDSTU2 from '../../../fixtures/dstu2/resources/allergyIntolerance/example1.json';
|
|
@@ -201,4 +201,39 @@ describe('should render component correctly', () => {
|
|
|
201
201
|
|
|
202
202
|
expect(queryByTestId('asserter')).toBeNull();
|
|
203
203
|
});
|
|
204
|
+
|
|
205
|
+
it('should fire custom onClick function', () => {
|
|
206
|
+
const defaultProps = {
|
|
207
|
+
fhirResource: example2AllergyIntoleranceR4,
|
|
208
|
+
fhirVersion: fhirVersions.R4,
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const onClick = jest.fn();
|
|
212
|
+
const { getByRole } = render(
|
|
213
|
+
<AllergyIntolerance {...defaultProps} onClick={onClick} />,
|
|
214
|
+
);
|
|
215
|
+
const accordion = getByRole('button');
|
|
216
|
+
fireEvent.click(accordion);
|
|
217
|
+
|
|
218
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
219
|
+
expect(attribute).not.toEqual('collapse');
|
|
220
|
+
expect(onClick).toHaveBeenCalled();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('should not fire custom onClick function', () => {
|
|
224
|
+
const defaultProps = {
|
|
225
|
+
fhirResource: example2AllergyIntoleranceR4,
|
|
226
|
+
fhirVersion: fhirVersions.R4,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const onClick = 'test';
|
|
230
|
+
const { getByRole } = render(
|
|
231
|
+
<AllergyIntolerance {...defaultProps} onClick={onClick} />,
|
|
232
|
+
);
|
|
233
|
+
const accordion = getByRole('button');
|
|
234
|
+
fireEvent.click(accordion);
|
|
235
|
+
|
|
236
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
237
|
+
expect(attribute).toEqual('collapse');
|
|
238
|
+
});
|
|
204
239
|
});
|