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
|
@@ -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
|
|
|
4
4
|
import Organization from './Organization';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -14,7 +14,80 @@ import r4Example1 from '../../../fixtures/r4/resources/organization/example1.jso
|
|
|
14
14
|
import r4Example2 from '../../../fixtures/r4/resources/organization/example2.json';
|
|
15
15
|
import r4Example3 from '../../../fixtures/r4/resources/organization/example3.json';
|
|
16
16
|
|
|
17
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
18
|
+
|
|
17
19
|
describe('should render Organization component properly', () => {
|
|
20
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
21
|
+
const defaultProps = {
|
|
22
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
23
|
+
fhirResource: dstu2Example1,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
27
|
+
const headerIcon = getByAltText('organization');
|
|
28
|
+
|
|
29
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
33
|
+
const defaultProps = {
|
|
34
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
35
|
+
fhirResource: dstu2Example1,
|
|
36
|
+
fhirIcons: false,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const { getByTestId } = render(<Organization {...defaultProps} />);
|
|
40
|
+
const headerIcon = getByTestId('placeholder');
|
|
41
|
+
|
|
42
|
+
expect(headerIcon).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
46
|
+
const defaultProps = {
|
|
47
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
48
|
+
fhirResource: dstu2Example1,
|
|
49
|
+
fhirIcons: (
|
|
50
|
+
<img
|
|
51
|
+
src={require('../assets/containers/Organization/organization.svg')}
|
|
52
|
+
alt="organization"
|
|
53
|
+
/>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
58
|
+
const headerIcon = getByAltText('organization');
|
|
59
|
+
|
|
60
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
64
|
+
const defaultProps = {
|
|
65
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
66
|
+
fhirResource: dstu2Example1,
|
|
67
|
+
fhirIcons: fhirIcons,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
71
|
+
const headerIcon = getByAltText('organization');
|
|
72
|
+
|
|
73
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
77
|
+
const avatarSrc =
|
|
78
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
79
|
+
const defaultProps = {
|
|
80
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
81
|
+
fhirResource: dstu2Example1,
|
|
82
|
+
fhirIcons: avatarSrc,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const { getByAltText } = render(<Organization {...defaultProps} />);
|
|
86
|
+
const headerIcon = getByAltText('header icon');
|
|
87
|
+
|
|
88
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
89
|
+
});
|
|
90
|
+
|
|
18
91
|
it('should render with DSTU2 source data', () => {
|
|
19
92
|
const defaultProps = {
|
|
20
93
|
fhirResource: dstu2Example1,
|
|
@@ -128,4 +201,39 @@ describe('should render Organization component properly', () => {
|
|
|
128
201
|
'No additional data',
|
|
129
202
|
);
|
|
130
203
|
});
|
|
204
|
+
|
|
205
|
+
it('should fire custom onClick function', () => {
|
|
206
|
+
const defaultProps = {
|
|
207
|
+
fhirResource: r4Example3,
|
|
208
|
+
fhirVersion: fhirVersions.R4,
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const onClick = jest.fn();
|
|
212
|
+
const { getByRole } = render(
|
|
213
|
+
<Organization {...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: r4Example3,
|
|
226
|
+
fhirVersion: fhirVersions.R4,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const onClick = 'test';
|
|
230
|
+
const { getByRole } = render(
|
|
231
|
+
<Organization {...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
|
+
});
|
|
131
239
|
});
|
|
@@ -46,6 +46,8 @@ function Patient(props) {
|
|
|
46
46
|
renderName,
|
|
47
47
|
patientSimple,
|
|
48
48
|
fhirIcons,
|
|
49
|
+
onClick,
|
|
50
|
+
rawOnClick,
|
|
49
51
|
} = props;
|
|
50
52
|
|
|
51
53
|
const id = getId(fhirResource);
|
|
@@ -146,6 +148,8 @@ function Patient(props) {
|
|
|
146
148
|
/>
|
|
147
149
|
}
|
|
148
150
|
bodyContent={<Body tableData={tableData} />}
|
|
151
|
+
onClick={onClick}
|
|
152
|
+
rawOnClick={rawOnClick}
|
|
149
153
|
/>
|
|
150
154
|
</Root>
|
|
151
155
|
);
|
|
@@ -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 Patient from './Patient';
|
|
4
4
|
|
|
5
5
|
import examplePatient from '../../../fixtures/dstu2/resources/patient/example.json';
|
|
@@ -38,7 +38,7 @@ describe('should render component correctly', () => {
|
|
|
38
38
|
fhirResource: examplePatient,
|
|
39
39
|
fhirIcons: (
|
|
40
40
|
<img
|
|
41
|
-
src={require('../assets/containers/
|
|
41
|
+
src={require('../assets/containers/Patient/patient.svg')}
|
|
42
42
|
alt="patient"
|
|
43
43
|
/>
|
|
44
44
|
),
|
|
@@ -156,4 +156,33 @@ describe('should render component correctly', () => {
|
|
|
156
156
|
const { getByTestId } = render(<Patient {...defaultProps} />);
|
|
157
157
|
expect(getByTestId('deceasedInfo').textContent).toEqual('2/14/2015');
|
|
158
158
|
});
|
|
159
|
+
|
|
160
|
+
it('should fire custom onClick function', () => {
|
|
161
|
+
const defaultProps = { fhirResource: example3PatientR4 };
|
|
162
|
+
|
|
163
|
+
const onClick = jest.fn();
|
|
164
|
+
const { getByRole } = render(
|
|
165
|
+
<Patient {...defaultProps} onClick={onClick} />,
|
|
166
|
+
);
|
|
167
|
+
const accordion = getByRole('button');
|
|
168
|
+
fireEvent.click(accordion);
|
|
169
|
+
|
|
170
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
171
|
+
expect(attribute).not.toEqual('collapse');
|
|
172
|
+
expect(onClick).toHaveBeenCalled();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should not fire custom onClick function', () => {
|
|
176
|
+
const defaultProps = { fhirResource: example3PatientR4 };
|
|
177
|
+
|
|
178
|
+
const onClick = 'test';
|
|
179
|
+
const { getByRole } = render(
|
|
180
|
+
<Patient {...defaultProps} onClick={onClick} />,
|
|
181
|
+
);
|
|
182
|
+
const accordion = getByRole('button');
|
|
183
|
+
fireEvent.click(accordion);
|
|
184
|
+
|
|
185
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
186
|
+
expect(attribute).toEqual('collapse');
|
|
187
|
+
});
|
|
159
188
|
});
|
|
@@ -82,7 +82,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const Practitioner = ({
|
|
85
|
+
const Practitioner = ({
|
|
86
|
+
fhirResource,
|
|
87
|
+
fhirVersion,
|
|
88
|
+
fhirIcons,
|
|
89
|
+
onClick,
|
|
90
|
+
rawOnClick,
|
|
91
|
+
}) => {
|
|
86
92
|
let fhirResourceData = {};
|
|
87
93
|
try {
|
|
88
94
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -160,6 +166,8 @@ const Practitioner = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
160
166
|
/>
|
|
161
167
|
}
|
|
162
168
|
bodyContent={<Body tableData={tableData} />}
|
|
169
|
+
onClick={onClick}
|
|
170
|
+
rawOnClick={rawOnClick}
|
|
163
171
|
/>
|
|
164
172
|
</Root>
|
|
165
173
|
);
|
|
@@ -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 Practitioner from './Practitioner';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -170,4 +170,39 @@ describe('Practitioner should render component correctly', () => {
|
|
|
170
170
|
);
|
|
171
171
|
jest.restoreAllMocks();
|
|
172
172
|
});
|
|
173
|
+
|
|
174
|
+
it('should fire custom onClick function', () => {
|
|
175
|
+
const defaultProps = {
|
|
176
|
+
fhirVersion: fhirVersions.R4,
|
|
177
|
+
fhirResource: stu3Example1,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const onClick = jest.fn();
|
|
181
|
+
const { getByRole } = render(
|
|
182
|
+
<Practitioner {...defaultProps} onClick={onClick} />,
|
|
183
|
+
);
|
|
184
|
+
const accordion = getByRole('button');
|
|
185
|
+
fireEvent.click(accordion);
|
|
186
|
+
|
|
187
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
188
|
+
expect(attribute).not.toEqual('collapse');
|
|
189
|
+
expect(onClick).toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should not fire custom onClick function', () => {
|
|
193
|
+
const defaultProps = {
|
|
194
|
+
fhirVersion: fhirVersions.R4,
|
|
195
|
+
fhirResource: stu3Example1,
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const onClick = 'test';
|
|
199
|
+
const { getByRole } = render(
|
|
200
|
+
<Practitioner {...defaultProps} onClick={onClick} />,
|
|
201
|
+
);
|
|
202
|
+
const accordion = getByRole('button');
|
|
203
|
+
fireEvent.click(accordion);
|
|
204
|
+
|
|
205
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
206
|
+
expect(attribute).toEqual('collapse');
|
|
207
|
+
});
|
|
173
208
|
});
|
|
@@ -5,8 +5,9 @@ import _get from 'lodash/get';
|
|
|
5
5
|
import Reference from '../../datatypes/Reference';
|
|
6
6
|
import fhirVersions from '../fhirResourceVersions';
|
|
7
7
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
8
|
-
import { Root, Header,
|
|
8
|
+
import { Root, Header, Body, Badge } from '../../ui';
|
|
9
9
|
import CodeableConcept from '../../datatypes/CodeableConcept/CodeableConcept';
|
|
10
|
+
import Accordion from '../../containers/Accordion';
|
|
10
11
|
|
|
11
12
|
const commonDTO = fhirResource => {
|
|
12
13
|
const status = _get(fhirResource, 'active') === true ? 'active' : '';
|
|
@@ -42,8 +43,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
const PractitionerRole =
|
|
46
|
-
|
|
46
|
+
const PractitionerRole = ({
|
|
47
|
+
fhirResource,
|
|
48
|
+
fhirVersion,
|
|
49
|
+
fhirIcons,
|
|
50
|
+
onClick,
|
|
51
|
+
rawOnClick,
|
|
52
|
+
}) => {
|
|
47
53
|
let fhirResourceData = {};
|
|
48
54
|
try {
|
|
49
55
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -58,34 +64,51 @@ const PractitionerRole = props => {
|
|
|
58
64
|
organization,
|
|
59
65
|
practitioner,
|
|
60
66
|
} = fhirResourceData;
|
|
67
|
+
|
|
68
|
+
const tableData = [
|
|
69
|
+
{
|
|
70
|
+
label: 'Practitioner',
|
|
71
|
+
testId: 'practitioner',
|
|
72
|
+
data: practitioner && <Reference fhirData={practitioner} />,
|
|
73
|
+
status: practitioner,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: 'Organization',
|
|
77
|
+
testId: 'organization',
|
|
78
|
+
data: organization && <Reference fhirData={organization} />,
|
|
79
|
+
status: organization,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: 'Specialties',
|
|
83
|
+
testId: 'specialties',
|
|
84
|
+
data: specialties.length > 0 && (
|
|
85
|
+
<CodeableConcept fhirData={specialties} isCursive />
|
|
86
|
+
),
|
|
87
|
+
status: specialties.length > 0,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: 'Roles',
|
|
91
|
+
testId: 'roles',
|
|
92
|
+
data: codes.length > 0 && <CodeableConcept fhirData={codes} isCursive />,
|
|
93
|
+
status: codes.length > 0,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
61
97
|
return (
|
|
62
98
|
<Root name="PractitionerRole">
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</Value>
|
|
77
|
-
)}
|
|
78
|
-
{specialties.length > 0 && (
|
|
79
|
-
<Value label="Specialties" data-testid="specialties">
|
|
80
|
-
<CodeableConcept fhirData={specialties} />
|
|
81
|
-
</Value>
|
|
82
|
-
)}
|
|
83
|
-
{codes.length > 0 && (
|
|
84
|
-
<Value label="Roles" data-testid="roles">
|
|
85
|
-
<CodeableConcept fhirData={codes} />
|
|
86
|
-
</Value>
|
|
87
|
-
)}
|
|
88
|
-
</Body>
|
|
99
|
+
<Accordion
|
|
100
|
+
headerContent={
|
|
101
|
+
<Header
|
|
102
|
+
resourceName="PractitionerRole"
|
|
103
|
+
title="Practitioner roles and specialties"
|
|
104
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
105
|
+
icon={fhirIcons}
|
|
106
|
+
/>
|
|
107
|
+
}
|
|
108
|
+
bodyContent={<Body tableData={tableData} />}
|
|
109
|
+
onClick={onClick}
|
|
110
|
+
rawOnClick={rawOnClick}
|
|
111
|
+
/>
|
|
89
112
|
</Root>
|
|
90
113
|
);
|
|
91
114
|
};
|
|
@@ -12,6 +12,8 @@ import r4Example1 from '../../../fixtures/r4/resources/practitionerRole/example1
|
|
|
12
12
|
import r4Example2 from '../../../fixtures/r4/resources/practitionerRole/example2.json';
|
|
13
13
|
import r4Example3 from '../../../fixtures/r4/resources/practitionerRole/example3.json';
|
|
14
14
|
import r4Example4 from '../../../fixtures/r4/resources/practitionerRole/example4.json';
|
|
15
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
16
|
+
import PractitionerRoleIcon from '../../../assets/containers/PractitionerRole/practitioner-role.svg';
|
|
15
17
|
|
|
16
18
|
export default { title: 'PractitionerRole' };
|
|
17
19
|
|
|
@@ -21,6 +23,7 @@ export const ExampleOfSTU3 = () => {
|
|
|
21
23
|
<PractitionerRole
|
|
22
24
|
fhirVersion={fhirVersions.STU3}
|
|
23
25
|
fhirResource={fhirResource}
|
|
26
|
+
fhirIcons={require('../../../assets/containers/PractitionerRole/practitioner-role.svg')}
|
|
24
27
|
/>
|
|
25
28
|
);
|
|
26
29
|
};
|
|
@@ -31,6 +34,7 @@ export const Example2OfSTU3 = () => {
|
|
|
31
34
|
<PractitionerRole
|
|
32
35
|
fhirVersion={fhirVersions.STU3}
|
|
33
36
|
fhirResource={fhirResource}
|
|
37
|
+
fhirIcons={PractitionerRoleIcon}
|
|
34
38
|
/>
|
|
35
39
|
);
|
|
36
40
|
};
|
|
@@ -41,6 +45,7 @@ export const Example3OfSTU3 = () => {
|
|
|
41
45
|
<PractitionerRole
|
|
42
46
|
fhirVersion={fhirVersions.STU3}
|
|
43
47
|
fhirResource={fhirResource}
|
|
48
|
+
fhirIcons={fhirIcons}
|
|
44
49
|
/>
|
|
45
50
|
);
|
|
46
51
|
};
|
|
@@ -61,6 +66,7 @@ export const Example2OfR4 = () => {
|
|
|
61
66
|
<PractitionerRole
|
|
62
67
|
fhirVersion={fhirVersions.R4}
|
|
63
68
|
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={false}
|
|
64
70
|
/>
|
|
65
71
|
);
|
|
66
72
|
};
|
|
@@ -71,6 +77,7 @@ export const Example3OfR4 = () => {
|
|
|
71
77
|
<PractitionerRole
|
|
72
78
|
fhirVersion={fhirVersions.R4}
|
|
73
79
|
fhirResource={fhirResource}
|
|
80
|
+
fhirIcons={'random text'}
|
|
74
81
|
/>
|
|
75
82
|
);
|
|
76
83
|
};
|
|
@@ -1,13 +1,85 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import PractitionerRole from './PractitionerRole';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
6
6
|
import stu3Example1 from '../../../fixtures/stu3/resources/practitionerRole/example1.json';
|
|
7
7
|
import r4Example1 from '../../../fixtures/r4/resources/practitionerRole/example1.json';
|
|
8
8
|
import r4Example2 from '../../../fixtures/r4/resources/practitionerRole/example3.json';
|
|
9
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
10
|
|
|
10
11
|
describe('PractitionerRole should render component correctly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirVersion: fhirVersions.STU3,
|
|
15
|
+
fhirResource: stu3Example1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('practitioner role');
|
|
20
|
+
|
|
21
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
25
|
+
const defaultProps = {
|
|
26
|
+
fhirVersion: fhirVersions.STU3,
|
|
27
|
+
fhirResource: stu3Example1,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<PractitionerRole {...defaultProps} />);
|
|
32
|
+
const headerIcon = getByTestId('placeholder');
|
|
33
|
+
|
|
34
|
+
expect(headerIcon).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
38
|
+
const defaultProps = {
|
|
39
|
+
fhirVersion: fhirVersions.STU3,
|
|
40
|
+
fhirResource: stu3Example1,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/PractitionerRole/practitioner-role.svg')}
|
|
44
|
+
alt="practitioner role"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('practitioner role');
|
|
51
|
+
|
|
52
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
56
|
+
const defaultProps = {
|
|
57
|
+
fhirVersion: fhirVersions.STU3,
|
|
58
|
+
fhirResource: stu3Example1,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('practitioner role');
|
|
64
|
+
|
|
65
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
69
|
+
const avatarSrc =
|
|
70
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
71
|
+
const defaultProps = {
|
|
72
|
+
fhirVersion: fhirVersions.STU3,
|
|
73
|
+
fhirResource: stu3Example1,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
11
83
|
it('should render component correctly with STU3 source data', () => {
|
|
12
84
|
const defaultProps = {
|
|
13
85
|
fhirVersion: fhirVersions.STU3,
|
|
@@ -100,4 +172,39 @@ describe('PractitionerRole should render component correctly', () => {
|
|
|
100
172
|
);
|
|
101
173
|
jest.restoreAllMocks();
|
|
102
174
|
});
|
|
175
|
+
|
|
176
|
+
it('should fire custom onClick function', () => {
|
|
177
|
+
const defaultProps = {
|
|
178
|
+
fhirVersion: fhirVersions.R4,
|
|
179
|
+
fhirResource: stu3Example1,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const onClick = jest.fn();
|
|
183
|
+
const { getByRole } = render(
|
|
184
|
+
<PractitionerRole {...defaultProps} onClick={onClick} />,
|
|
185
|
+
);
|
|
186
|
+
const accordion = getByRole('button');
|
|
187
|
+
fireEvent.click(accordion);
|
|
188
|
+
|
|
189
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
190
|
+
expect(attribute).not.toEqual('collapse');
|
|
191
|
+
expect(onClick).toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should not fire custom onClick function', () => {
|
|
195
|
+
const defaultProps = {
|
|
196
|
+
fhirVersion: fhirVersions.R4,
|
|
197
|
+
fhirResource: stu3Example1,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const onClick = 'test';
|
|
201
|
+
const { getByRole } = render(
|
|
202
|
+
<PractitionerRole {...defaultProps} onClick={onClick} />,
|
|
203
|
+
);
|
|
204
|
+
const accordion = getByRole('button');
|
|
205
|
+
fireEvent.click(accordion);
|
|
206
|
+
|
|
207
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
208
|
+
expect(attribute).toEqual('collapse');
|
|
209
|
+
});
|
|
103
210
|
});
|
|
@@ -14,8 +14,7 @@ import _has from 'lodash/has';
|
|
|
14
14
|
import { isNotEmptyArray } from '../../../utils';
|
|
15
15
|
import { Value } from '../../ui';
|
|
16
16
|
|
|
17
|
-
const Procedure =
|
|
18
|
-
const { fhirResource, fhirIcons } = props;
|
|
17
|
+
const Procedure = ({ fhirResource, fhirIcons, onClick, rawOnClick }) => {
|
|
19
18
|
const display =
|
|
20
19
|
_get(fhirResource, 'code.coding[0].display') ||
|
|
21
20
|
_get(fhirResource, 'code.text');
|
|
@@ -125,6 +124,8 @@ const Procedure = props => {
|
|
|
125
124
|
/>
|
|
126
125
|
}
|
|
127
126
|
bodyContent={<Body tableData={tableData} />}
|
|
127
|
+
onClick={onClick}
|
|
128
|
+
rawOnClick={rawOnClick}
|
|
128
129
|
/>
|
|
129
130
|
</Root>
|
|
130
131
|
);
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/procedure/example1.json';
|
|
4
4
|
import r4Example2 from '../../../fixtures/r4/resources/procedure/example2.json';
|
|
5
5
|
import r4Example3 from '../../../fixtures/r4/resources/procedure/example3.json';
|
|
6
|
-
import { render } from '@testing-library/react';
|
|
6
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/procedure/example1.json';
|
|
8
8
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -168,4 +168,33 @@ describe('Procedure should render component correctly', () => {
|
|
|
168
168
|
'Eerste neo-adjuvante',
|
|
169
169
|
);
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
it('should fire custom onClick function', () => {
|
|
173
|
+
const defaultProps = { fhirResource: r4Example3 };
|
|
174
|
+
|
|
175
|
+
const onClick = jest.fn();
|
|
176
|
+
const { getByRole } = render(
|
|
177
|
+
<Procedure {...defaultProps} onClick={onClick} />,
|
|
178
|
+
);
|
|
179
|
+
const accordion = getByRole('button');
|
|
180
|
+
fireEvent.click(accordion);
|
|
181
|
+
|
|
182
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
183
|
+
expect(attribute).not.toEqual('collapse');
|
|
184
|
+
expect(onClick).toHaveBeenCalled();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should not fire custom onClick function', () => {
|
|
188
|
+
const defaultProps = { fhirResource: r4Example3 };
|
|
189
|
+
|
|
190
|
+
const onClick = 'test';
|
|
191
|
+
const { getByRole } = render(
|
|
192
|
+
<Procedure {...defaultProps} onClick={onClick} />,
|
|
193
|
+
);
|
|
194
|
+
const accordion = getByRole('button');
|
|
195
|
+
fireEvent.click(accordion);
|
|
196
|
+
|
|
197
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
198
|
+
expect(attribute).toEqual('collapse');
|
|
199
|
+
});
|
|
171
200
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _get from 'lodash/get';
|
|
2
|
+
import { MissingValue } from '../../ui';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import Questions from './Questions';
|
|
6
|
+
import { getQuestionText } from './getQuestionText';
|
|
7
|
+
|
|
8
|
+
const Group = ({ data, prepareItems, isChild = false }) => {
|
|
9
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return data.map(prepareItems).map((item, i) => {
|
|
14
|
+
const text = getQuestionText(item);
|
|
15
|
+
let nestedItems = _get(item, 'item', []);
|
|
16
|
+
nestedItems = nestedItems.map(prepareItems);
|
|
17
|
+
const isGroup = _get(item, 'isGroup');
|
|
18
|
+
return (
|
|
19
|
+
<ul
|
|
20
|
+
key={`questionnaire-item-${i}`}
|
|
21
|
+
className="fhir-resource__Questionnaire-list"
|
|
22
|
+
>
|
|
23
|
+
<li
|
|
24
|
+
className={
|
|
25
|
+
isChild
|
|
26
|
+
? 'fhir-resource__Questionnaire-list-title-question'
|
|
27
|
+
: 'fhir-resource__Questionnaire-list-title'
|
|
28
|
+
}
|
|
29
|
+
data-testid={`linkId-${item.linkId}`}
|
|
30
|
+
>
|
|
31
|
+
{text ? text : <MissingValue />}
|
|
32
|
+
</li>
|
|
33
|
+
{!isGroup && (
|
|
34
|
+
<li>
|
|
35
|
+
<Questions questions={nestedItems} prepareItems={prepareItems} />
|
|
36
|
+
</li>
|
|
37
|
+
)}
|
|
38
|
+
{isGroup && (
|
|
39
|
+
<li>
|
|
40
|
+
<Group data={nestedItems} prepareItems={prepareItems} isChild />
|
|
41
|
+
</li>
|
|
42
|
+
)}
|
|
43
|
+
</ul>
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Group.propTypes = {
|
|
49
|
+
data: PropTypes.array,
|
|
50
|
+
prepareItems: PropTypes.func.isRequired,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default Group;
|