fhir-react 0.3.6 → 0.3.9
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/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +11 -10
- package/package.json +55 -54
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Coverage/coverage.svg +4 -0
- package/src/assets/containers/Generic/generic.svg +3 -0
- package/src/assets/containers/Medication/medication.svg +5 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/Organization/organization.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/ResourceContainer/ResourceContainer.css +4 -0
- package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
- package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +23 -1
- package/src/components/datatypes/Attachment/Attachment.css +5 -0
- package/src/components/datatypes/Attachment/Attachment.js +7 -2
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Identifier/Identifier.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -1
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
- 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.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +9 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +2 -1
- 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 +12 -78
- 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.test.js +42 -6
- package/src/components/resources/CareTeam/CareTeam.js +79 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- 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 +165 -309
- package/src/components/resources/Claim/Claim.stories.js +37 -5
- package/src/components/resources/Claim/Claim.test.js +104 -1
- 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/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 +15 -2
- 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.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +104 -69
- package/src/components/resources/Coverage/Coverage.stories.js +31 -5
- package/src/components/resources/Coverage/Coverage.test.js +111 -4
- package/src/components/resources/Device/Device.js +9 -1
- 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.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
- 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.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
- 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 +2 -1
- 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.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +9 -2
- 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 +38 -5
- 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 +11 -4
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +98 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +114 -5
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
- 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 +7 -0
- 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 +6 -0
- 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.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
- 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.test.js +36 -1
- package/src/components/resources/Observation/Observation.js +3 -1
- 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 +63 -37
- package/src/components/resources/Organization/Organization.stories.js +15 -2
- package/src/components/resources/Organization/Organization.test.js +109 -1
- package/src/components/resources/Patient/Patient.js +4 -0
- 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.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
- 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.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 +8 -0
- 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 +8 -0
- 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.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -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 +2 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
- package/src/components/ui/index.js +56 -32
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +63 -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
|
@@ -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
|
};
|
|
@@ -7,6 +7,8 @@ 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',
|
|
12
14
|
};
|
|
@@ -14,13 +16,21 @@ export default {
|
|
|
14
16
|
export const DefaultVisualizationSTU3 = () => {
|
|
15
17
|
const fhirResource = object('Resource', stu3Example1);
|
|
16
18
|
return (
|
|
17
|
-
<AdverseEvent
|
|
19
|
+
<AdverseEvent
|
|
20
|
+
fhirResource={fhirResource}
|
|
21
|
+
fhirVersion={fhirVersions.STU3}
|
|
22
|
+
fhirIcons={fhirIcons}
|
|
23
|
+
/>
|
|
18
24
|
);
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
export const Example1ofR4 = () => {
|
|
22
28
|
const fhirResource = object('Resource', r4Example1);
|
|
23
29
|
return (
|
|
24
|
-
<AdverseEvent
|
|
30
|
+
<AdverseEvent
|
|
31
|
+
fhirResource={fhirResource}
|
|
32
|
+
fhirVersion={fhirVersions.R4}
|
|
33
|
+
fhirIcons={false}
|
|
34
|
+
/>
|
|
25
35
|
);
|
|
26
36
|
};
|
|
@@ -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 { 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
|
});
|
|
@@ -144,7 +144,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
const Appointment = ({
|
|
147
|
+
const Appointment = ({
|
|
148
|
+
fhirResource,
|
|
149
|
+
fhirVersion,
|
|
150
|
+
fhirIcons,
|
|
151
|
+
onClick,
|
|
152
|
+
rawOnClick,
|
|
153
|
+
}) => {
|
|
148
154
|
const {
|
|
149
155
|
description,
|
|
150
156
|
status,
|
|
@@ -253,6 +259,8 @@ const Appointment = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
253
259
|
)}
|
|
254
260
|
</Body>
|
|
255
261
|
}
|
|
262
|
+
onClick={onClick}
|
|
263
|
+
rawOnClick={rawOnClick}
|
|
256
264
|
/>
|
|
257
265
|
</Root>
|
|
258
266
|
);
|
|
@@ -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 Appointment from './Appointment';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -231,4 +231,39 @@ describe('should render component correctly', () => {
|
|
|
231
231
|
|
|
232
232
|
expect(getByTestId('reason').textContent).toContain('Clinical Review');
|
|
233
233
|
});
|
|
234
|
+
|
|
235
|
+
it('should fire custom onClick function', () => {
|
|
236
|
+
const defaultProps = {
|
|
237
|
+
fhirResource: example3AppointmentR4,
|
|
238
|
+
fhirVersion: fhirVersions.R4,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const onClick = jest.fn();
|
|
242
|
+
const { getByRole } = render(
|
|
243
|
+
<Appointment {...defaultProps} onClick={onClick} />,
|
|
244
|
+
);
|
|
245
|
+
const accordion = getByRole('button');
|
|
246
|
+
fireEvent.click(accordion);
|
|
247
|
+
|
|
248
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
249
|
+
expect(attribute).not.toEqual('collapse');
|
|
250
|
+
expect(onClick).toHaveBeenCalled();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('should not fire custom onClick function', () => {
|
|
254
|
+
const defaultProps = {
|
|
255
|
+
fhirResource: example3AppointmentR4,
|
|
256
|
+
fhirVersion: fhirVersions.R4,
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const onClick = 'test';
|
|
260
|
+
const { getByRole } = render(
|
|
261
|
+
<Appointment {...defaultProps} onClick={onClick} />,
|
|
262
|
+
);
|
|
263
|
+
const accordion = getByRole('button');
|
|
264
|
+
fireEvent.click(accordion);
|
|
265
|
+
|
|
266
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
267
|
+
expect(attribute).toEqual('collapse');
|
|
268
|
+
});
|
|
234
269
|
});
|
|
@@ -6,7 +6,7 @@ import Accordion from '../../containers/Accordion/Accordion';
|
|
|
6
6
|
import { Body, Header } from '../../ui';
|
|
7
7
|
|
|
8
8
|
const Binary = props => {
|
|
9
|
-
const { fhirResource, fhirIcons } = props;
|
|
9
|
+
const { fhirResource, fhirIcons, rawOnClick } = props;
|
|
10
10
|
|
|
11
11
|
const loadBinaryFile = () => {
|
|
12
12
|
switch (fhirResource.contentType) {
|
|
@@ -37,6 +37,7 @@ const Binary = props => {
|
|
|
37
37
|
/>
|
|
38
38
|
}
|
|
39
39
|
bodyContent={<Body>{loadBinaryFile()}</Body>}
|
|
40
|
+
rawOnClick={rawOnClick}
|
|
40
41
|
/>
|
|
41
42
|
</div>
|
|
42
43
|
);
|
|
@@ -4,12 +4,12 @@ import _get from 'lodash/get';
|
|
|
4
4
|
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
6
6
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
7
|
-
import { Root, Header,
|
|
7
|
+
import { Root, Header, Badge, Body, BadgeSecondary } from '../../ui';
|
|
8
8
|
import * as FhirResourceTypes from '../../supportedFhirResourceList';
|
|
9
9
|
|
|
10
10
|
import './Bundle.css';
|
|
11
11
|
|
|
12
|
-
export default function Bundle({ fhirResource, fhirVersion
|
|
12
|
+
export default function Bundle({ fhirResource, fhirVersion }) {
|
|
13
13
|
const commonDTO = fhirResource => {
|
|
14
14
|
const type = _get(fhirResource, 'type', null);
|
|
15
15
|
const total = _get(fhirResource, 'total');
|
|
@@ -51,11 +51,14 @@ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
|
|
|
51
51
|
.filter(Boolean);
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
|
-
<Root name="Bundle">
|
|
55
|
-
<Header
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
<Root name="Bundle" className="fhir-resource__Bundle__rootPadding">
|
|
55
|
+
<Header
|
|
56
|
+
resourceName="Bundle"
|
|
57
|
+
title={type}
|
|
58
|
+
badges={!isNaN(total) && <Badge data-testid="total">{total}</Badge>}
|
|
59
|
+
capitalize
|
|
60
|
+
isNoIcon
|
|
61
|
+
/>
|
|
59
62
|
<Body>
|
|
60
63
|
{resources.length > 0 &&
|
|
61
64
|
resources.map((resource, index) => {
|
|
@@ -71,14 +74,15 @@ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
|
|
|
71
74
|
key={`${resource.id}-${index}`}
|
|
72
75
|
>
|
|
73
76
|
{resourceType && (
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
<div className="mx-20">
|
|
78
|
+
<BadgeSecondary data-testid="resourceType">
|
|
79
|
+
{resourceType}
|
|
80
|
+
</BadgeSecondary>
|
|
81
|
+
</div>
|
|
77
82
|
)}
|
|
78
83
|
<FhirComponent
|
|
79
84
|
fhirResource={resource}
|
|
80
85
|
fhirVersion={fhirVersion}
|
|
81
|
-
fhirIcons={fhirIcons}
|
|
82
86
|
/>
|
|
83
87
|
</div>
|
|
84
88
|
);
|