fhir-react 0.3.5 → 0.3.8
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 +9 -8
- 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/{ResourceCategory/resource-placeholder.svg → Generic/generic.svg} +0 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
- package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
- package/src/assets/containers/Organization/organization.svg +5 -0
- package/src/assets/containers/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/assets/containers/ResourceCategory/resource-category.svg +3 -0
- package/src/components/containers/Accordion/Accordion.js +21 -13
- 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 +81 -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 -5
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +5 -4
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +107 -1
- package/src/components/resources/Appointment/Appointment.js +2 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +1 -2
- package/src/components/resources/Binary/Binary.stories.js +10 -4
- package/src/components/resources/Binary/Binary.test.js +67 -0
- 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 +2 -1
- package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
- package/src/components/resources/CarePlan/CarePlan.test.js +114 -6
- package/src/components/resources/CareTeam/CareTeam.js +72 -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 +158 -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 +137 -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 +3 -3
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +97 -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 +2 -1
- package/src/components/resources/Device/Device.stories.js +33 -5
- package/src/components/resources/Device/Device.test.js +108 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +5 -4
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +107 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +3 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +113 -1
- package/src/components/resources/Encounter/Encounter.js +2 -1
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +2 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +7 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +3 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +108 -1
- package/src/components/resources/Generic/Generic.js +20 -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 +3 -5
- package/src/components/resources/Goal/Goal.stories.js +5 -4
- package/src/components/resources/Goal/Goal.test.js +101 -1
- package/src/components/resources/Immunization/Immunization.js +2 -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 +135 -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 +65 -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 +91 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +113 -4
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +86 -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 +68 -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 +115 -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 -4
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +1 -2
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +102 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +3 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +11 -6
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +100 -4
- package/src/components/resources/MedicationStatement/MedicationDosage.js +2 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.js +8 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +5 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +108 -1
- package/src/components/resources/Observation/Observation.js +2 -1
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Organization/Organization.js +56 -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 +2 -0
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +2 -1
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +50 -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 +2 -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 +31 -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 +52 -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 +65 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +151 -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 +160 -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 +7 -12
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
- package/src/components/ui/index.js +32 -12
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +81 -11
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +3 -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 { nbspRegex } from '../../../testUtils';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -8,8 +8,79 @@ import DocumentReference from './DocumentReference';
|
|
|
8
8
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/documentReference/example1.json';
|
|
9
9
|
import stu3Example1 from '../../../fixtures/stu3/resources/documentReference/example1.json';
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/documentReference/example1.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
describe('should render the DocumentReference component properly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirResource: dstu2Example1,
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
21
|
+
const headerIcon = getByAltText('document reference');
|
|
22
|
+
|
|
23
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
fhirResource: dstu2Example1,
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirIcons: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const { getByTestId } = render(<DocumentReference {...defaultProps} />);
|
|
34
|
+
const headerIcon = getByTestId('placeholder');
|
|
35
|
+
|
|
36
|
+
expect(headerIcon).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
40
|
+
const defaultProps = {
|
|
41
|
+
fhirResource: dstu2Example1,
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirIcons: (
|
|
44
|
+
<img
|
|
45
|
+
src={require('../assets/containers/DocumentReference/document-reference.svg')}
|
|
46
|
+
alt="document reference"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
52
|
+
const headerIcon = getByAltText('document reference');
|
|
53
|
+
|
|
54
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
58
|
+
const defaultProps = {
|
|
59
|
+
fhirResource: dstu2Example1,
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirIcons: fhirIcons,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
65
|
+
const headerIcon = getByAltText('document reference');
|
|
66
|
+
|
|
67
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
71
|
+
const avatarSrc =
|
|
72
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
73
|
+
const defaultProps = {
|
|
74
|
+
fhirResource: dstu2Example1,
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirIcons: avatarSrc,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { getByAltText } = render(<DocumentReference {...defaultProps} />);
|
|
80
|
+
const headerIcon = getByAltText('header icon');
|
|
81
|
+
|
|
82
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
83
|
+
});
|
|
13
84
|
it('should render with DSTU2 source data', () => {
|
|
14
85
|
const { getByTestId } = render(
|
|
15
86
|
<DocumentReference
|
|
@@ -197,4 +268,45 @@ describe('should render the DocumentReference component properly', () => {
|
|
|
197
268
|
const urls = getAllByTestId('content.url').map(node => node.textContent);
|
|
198
269
|
expect(urls).toEqual(['Binary/07a6483f-732b-461e-86b6-edb665c45510']);
|
|
199
270
|
});
|
|
271
|
+
|
|
272
|
+
it('should fire custom onClick function', () => {
|
|
273
|
+
const resource = JSON.parse(JSON.stringify(r4Example1));
|
|
274
|
+
resource.content[0].attachment.url =
|
|
275
|
+
'http://example.org/xds/mhd/Binary/07a6483f-732b-461e-86b6-edb665c45510';
|
|
276
|
+
|
|
277
|
+
const onClick = jest.fn();
|
|
278
|
+
const { getByRole } = render(
|
|
279
|
+
<DocumentReference
|
|
280
|
+
fhirResource={resource}
|
|
281
|
+
fhirVersion={fhirVersions.R4}
|
|
282
|
+
onClick={onClick}
|
|
283
|
+
/>,
|
|
284
|
+
);
|
|
285
|
+
const accordion = getByRole('button');
|
|
286
|
+
fireEvent.click(accordion);
|
|
287
|
+
|
|
288
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
289
|
+
expect(attribute).not.toEqual('collapse');
|
|
290
|
+
expect(onClick).toHaveBeenCalled();
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('should not fire custom onClick function', () => {
|
|
294
|
+
const resource = JSON.parse(JSON.stringify(r4Example1));
|
|
295
|
+
resource.content[0].attachment.url =
|
|
296
|
+
'http://example.org/xds/mhd/Binary/07a6483f-732b-461e-86b6-edb665c45510';
|
|
297
|
+
|
|
298
|
+
const onClick = 'test';
|
|
299
|
+
const { getByRole } = render(
|
|
300
|
+
<DocumentReference
|
|
301
|
+
fhirResource={resource}
|
|
302
|
+
fhirVersion={fhirVersions.R4}
|
|
303
|
+
onClick={onClick}
|
|
304
|
+
/>,
|
|
305
|
+
);
|
|
306
|
+
const accordion = getByRole('button');
|
|
307
|
+
fireEvent.click(accordion);
|
|
308
|
+
|
|
309
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
310
|
+
expect(attribute).toEqual('collapse');
|
|
311
|
+
});
|
|
200
312
|
});
|
|
@@ -160,7 +160,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const Encounter = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
163
|
+
const Encounter = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
164
164
|
let fhirResourceData = {};
|
|
165
165
|
try {
|
|
166
166
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -229,6 +229,7 @@ const Encounter = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
229
229
|
)}
|
|
230
230
|
</Body>
|
|
231
231
|
}
|
|
232
|
+
onClick={onClick}
|
|
232
233
|
/>
|
|
233
234
|
</Root>
|
|
234
235
|
);
|
|
@@ -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 Encounter from './Encounter';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
import example1 from '../../../fixtures/dstu2/resources/encounter/example.json';
|
|
@@ -198,4 +198,39 @@ describe('should render component correctly', () => {
|
|
|
198
198
|
);
|
|
199
199
|
jest.restoreAllMocks();
|
|
200
200
|
});
|
|
201
|
+
|
|
202
|
+
it('should fire custom onClick function', () => {
|
|
203
|
+
const defaultProps = {
|
|
204
|
+
fhirResource: example2_STU3,
|
|
205
|
+
fhirVersion: fhirVersions.R4,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const onClick = jest.fn();
|
|
209
|
+
const { getByRole } = render(
|
|
210
|
+
<Encounter {...defaultProps} onClick={onClick} />,
|
|
211
|
+
);
|
|
212
|
+
const accordion = getByRole('button');
|
|
213
|
+
fireEvent.click(accordion);
|
|
214
|
+
|
|
215
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
216
|
+
expect(attribute).not.toEqual('collapse');
|
|
217
|
+
expect(onClick).toHaveBeenCalled();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should not fire custom onClick function', () => {
|
|
221
|
+
const defaultProps = {
|
|
222
|
+
fhirResource: example2_STU3,
|
|
223
|
+
fhirVersion: fhirVersions.R4,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const onClick = 'test';
|
|
227
|
+
const { getByRole } = render(
|
|
228
|
+
<Encounter {...defaultProps} onClick={onClick} />,
|
|
229
|
+
);
|
|
230
|
+
const accordion = getByRole('button');
|
|
231
|
+
fireEvent.click(accordion);
|
|
232
|
+
|
|
233
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
234
|
+
expect(attribute).toEqual('collapse');
|
|
235
|
+
});
|
|
201
236
|
});
|
|
@@ -233,6 +233,7 @@ const ExplanationOfBenefit = ({
|
|
|
233
233
|
fhirVersion,
|
|
234
234
|
withCarinBBProfile = false,
|
|
235
235
|
fhirIcons,
|
|
236
|
+
onClick,
|
|
236
237
|
}) => {
|
|
237
238
|
let fhirResourceData = {};
|
|
238
239
|
try {
|
|
@@ -546,6 +547,7 @@ const ExplanationOfBenefit = ({
|
|
|
546
547
|
{hasCareTeam && <CareTeam fhirData={careTeam} />}
|
|
547
548
|
</Body>
|
|
548
549
|
}
|
|
550
|
+
onClick={onClick}
|
|
549
551
|
/>
|
|
550
552
|
</Root>
|
|
551
553
|
);
|
|
@@ -8,7 +8,7 @@ import exampleC4BB from '../../../fixtures/r4/resources/explanationOfBenefit/c4b
|
|
|
8
8
|
import exampleC4BBExtendedDiagnosis from '../../../fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json';
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
10
|
import { nbspRegex } from '../../../testUtils';
|
|
11
|
-
import { render } from '@testing-library/react';
|
|
11
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
12
12
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
13
|
|
|
14
14
|
describe('should render ExplanationOfBenefit component properly', () => {
|
|
@@ -331,4 +331,41 @@ describe('should render ExplanationOfBenefit component properly', () => {
|
|
|
331
331
|
expect(getByTestId('diagnosisOnAdmission').textContent).toContain('?');
|
|
332
332
|
expect(queryByTestId('diagnosisPackageCode')).toBeNull();
|
|
333
333
|
});
|
|
334
|
+
|
|
335
|
+
it('should fire custom onClick function', () => {
|
|
336
|
+
const defaultProps = {
|
|
337
|
+
fhirResource: exampleC4BBExtendedDiagnosis,
|
|
338
|
+
fhirVersion: fhirVersions.R4,
|
|
339
|
+
withCarinBBProfile: true,
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const onClick = jest.fn();
|
|
343
|
+
const { getByRole } = render(
|
|
344
|
+
<ExplanationOfBenefit {...defaultProps} onClick={onClick} />,
|
|
345
|
+
);
|
|
346
|
+
const accordion = getByRole('button');
|
|
347
|
+
fireEvent.click(accordion);
|
|
348
|
+
|
|
349
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
350
|
+
expect(attribute).not.toEqual('collapse');
|
|
351
|
+
expect(onClick).toHaveBeenCalled();
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('should not fire custom onClick function', () => {
|
|
355
|
+
const defaultProps = {
|
|
356
|
+
fhirResource: exampleC4BBExtendedDiagnosis,
|
|
357
|
+
fhirVersion: fhirVersions.R4,
|
|
358
|
+
withCarinBBProfile: true,
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const onClick = 'test';
|
|
362
|
+
const { getByRole } = render(
|
|
363
|
+
<ExplanationOfBenefit {...defaultProps} onClick={onClick} />,
|
|
364
|
+
);
|
|
365
|
+
const accordion = getByRole('button');
|
|
366
|
+
fireEvent.click(accordion);
|
|
367
|
+
|
|
368
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
369
|
+
expect(attribute).toEqual('collapse');
|
|
370
|
+
});
|
|
334
371
|
});
|
|
@@ -70,8 +70,12 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const FamilyMemberHistory =
|
|
74
|
-
|
|
73
|
+
const FamilyMemberHistory = ({
|
|
74
|
+
fhirResource,
|
|
75
|
+
fhirVersion,
|
|
76
|
+
fhirIcons,
|
|
77
|
+
onClick,
|
|
78
|
+
}) => {
|
|
75
79
|
let fhirResourceData = {};
|
|
76
80
|
try {
|
|
77
81
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -135,6 +139,7 @@ const FamilyMemberHistory = props => {
|
|
|
135
139
|
/>
|
|
136
140
|
}
|
|
137
141
|
bodyContent={<Body tableData={tableData} />}
|
|
142
|
+
onClick={onClick}
|
|
138
143
|
/>
|
|
139
144
|
</Root>
|
|
140
145
|
);
|
|
@@ -9,6 +9,7 @@ import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory
|
|
|
9
9
|
import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
|
|
10
10
|
import example2STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example2.json';
|
|
11
11
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import FamilyMemberHistoryIcon from '../../../assets/containers/FamilyMemberHistory/family-member-history.svg';
|
|
12
13
|
|
|
13
14
|
export default {
|
|
14
15
|
title: 'FamilyMemberHistory',
|
|
@@ -20,7 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
20
21
|
<FamilyMemberHistory
|
|
21
22
|
fhirVersion={fhirVersions.DSTU2}
|
|
22
23
|
fhirResource={fhirResource}
|
|
23
|
-
fhirIcons={
|
|
24
|
+
fhirIcons={require('../../../assets/containers/FamilyMemberHistory/family-member-history.svg')}
|
|
24
25
|
/>
|
|
25
26
|
);
|
|
26
27
|
};
|
|
@@ -31,7 +32,7 @@ export const Example1OfSTU3 = () => {
|
|
|
31
32
|
<FamilyMemberHistory
|
|
32
33
|
fhirVersion={fhirVersions.STU3}
|
|
33
34
|
fhirResource={fhirResource}
|
|
34
|
-
fhirIcons={
|
|
35
|
+
fhirIcons={FamilyMemberHistoryIcon}
|
|
35
36
|
/>
|
|
36
37
|
);
|
|
37
38
|
};
|
|
@@ -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 FamilyMemberHistory from './FamilyMemberHistory';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
6
6
|
import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory/example1.json';
|
|
7
7
|
import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
|
|
8
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
8
9
|
|
|
9
10
|
describe('should render FamilyMemberHistory component correctly', () => {
|
|
11
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
fhirResource: example1DSTU2,
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
18
|
+
const headerIcon = getByAltText('family member history');
|
|
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
|
+
fhirResource: example1DSTU2,
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirIcons: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const { getByTestId } = render(<FamilyMemberHistory {...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
|
+
fhirResource: example1DSTU2,
|
|
39
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
40
|
+
fhirIcons: (
|
|
41
|
+
<img
|
|
42
|
+
src={require('../assets/containers/FamilyMemberHistory/family-member-history.svg')}
|
|
43
|
+
alt="family member history"
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
49
|
+
const headerIcon = getByAltText('family member history');
|
|
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
|
+
fhirResource: example1DSTU2,
|
|
57
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
58
|
+
fhirIcons: fhirIcons,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
62
|
+
const headerIcon = getByAltText('family member history');
|
|
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
|
+
fhirResource: example1DSTU2,
|
|
72
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
73
|
+
fhirIcons: avatarSrc,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
|
|
77
|
+
const headerIcon = getByAltText('header icon');
|
|
78
|
+
|
|
79
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
80
|
+
});
|
|
81
|
+
|
|
10
82
|
it('DSTU2', () => {
|
|
11
83
|
const defaultProps = {
|
|
12
84
|
fhirResource: example1DSTU2,
|
|
@@ -38,4 +110,39 @@ describe('should render FamilyMemberHistory component correctly', () => {
|
|
|
38
110
|
expect(getByTestId('hasRelationship').textContent).toContain('father');
|
|
39
111
|
expect(getByTestId('noteText').textContent).toContain('Was fishing at');
|
|
40
112
|
});
|
|
113
|
+
|
|
114
|
+
it('should fire custom onClick function', () => {
|
|
115
|
+
const defaultProps = {
|
|
116
|
+
fhirResource: example1STU3,
|
|
117
|
+
fhirVersion: fhirVersions.STU3,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const onClick = jest.fn();
|
|
121
|
+
const { getByRole } = render(
|
|
122
|
+
<FamilyMemberHistory {...defaultProps} onClick={onClick} />,
|
|
123
|
+
);
|
|
124
|
+
const accordion = getByRole('button');
|
|
125
|
+
fireEvent.click(accordion);
|
|
126
|
+
|
|
127
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
128
|
+
expect(attribute).not.toEqual('collapse');
|
|
129
|
+
expect(onClick).toHaveBeenCalled();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should not fire custom onClick function', () => {
|
|
133
|
+
const defaultProps = {
|
|
134
|
+
fhirResource: example1STU3,
|
|
135
|
+
fhirVersion: fhirVersions.STU3,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const onClick = 'test';
|
|
139
|
+
const { getByRole } = render(
|
|
140
|
+
<FamilyMemberHistory {...defaultProps} onClick={onClick} />,
|
|
141
|
+
);
|
|
142
|
+
const accordion = getByRole('button');
|
|
143
|
+
fireEvent.click(accordion);
|
|
144
|
+
|
|
145
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
146
|
+
expect(attribute).toEqual('collapse');
|
|
147
|
+
});
|
|
41
148
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import _get from 'lodash/get';
|
|
3
3
|
|
|
4
|
-
import { Root, Header
|
|
4
|
+
import { Root, Header } from '../../ui';
|
|
5
|
+
import Accordion from '../../containers/Accordion';
|
|
5
6
|
|
|
6
|
-
const Generic =
|
|
7
|
-
const { fhirResource } = props;
|
|
7
|
+
const Generic = ({ fhirResource, fhirIcons, onClick }) => {
|
|
8
8
|
const title = fhirResource
|
|
9
9
|
? `${fhirResource.resourceType}/${fhirResource.id}`
|
|
10
10
|
: `Unknown Resource`;
|
|
@@ -14,10 +14,23 @@ const Generic = props => {
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Root>
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
<Accordion
|
|
18
|
+
headerContent={
|
|
19
|
+
<Header
|
|
20
|
+
resourceName={'Generic'}
|
|
21
|
+
title={title}
|
|
22
|
+
icon={fhirIcons}
|
|
23
|
+
additionalContent={
|
|
24
|
+
code && (
|
|
25
|
+
<span className="text-secondary" data-testid="code">
|
|
26
|
+
{code}
|
|
27
|
+
</span>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
/>
|
|
31
|
+
}
|
|
32
|
+
onClick={onClick}
|
|
33
|
+
/>
|
|
21
34
|
</Root>
|
|
22
35
|
);
|
|
23
36
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { object } from '@storybook/addon-knobs';
|
|
3
3
|
|
|
4
4
|
import Generic from './Generic';
|
|
5
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
5
6
|
|
|
6
7
|
export default { title: 'Generic' };
|
|
7
8
|
|
|
@@ -14,5 +15,5 @@ export const DefaultVisualization = () => {
|
|
|
14
15
|
},
|
|
15
16
|
};
|
|
16
17
|
const fhirResource = object('Resource', exampleResource);
|
|
17
|
-
return <Generic fhirResource={fhirResource} />;
|
|
18
|
+
return <Generic fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
18
19
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import Generic from './Generic';
|
|
4
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
describe('should render the Generic component properly', () => {
|
|
6
7
|
const exampleResource = {
|
|
7
8
|
resourceType: 'UnknownResource',
|
|
8
9
|
id: '12345',
|
|
@@ -10,10 +11,28 @@ it('should render component correctly', () => {
|
|
|
10
11
|
text: 'Resource code text',
|
|
11
12
|
},
|
|
12
13
|
};
|
|
13
|
-
const { container, getByTestId } = render(
|
|
14
|
-
<Generic fhirResource={exampleResource} />,
|
|
15
|
-
);
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
it('should render component correctly', () => {
|
|
16
|
+
const { container, getByTestId, getByAltText } = render(
|
|
17
|
+
<Generic fhirResource={exampleResource} fhirIcons={fhirIcons} />,
|
|
18
|
+
);
|
|
19
|
+
const headerIcon = getByAltText('generic');
|
|
20
|
+
|
|
21
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
22
|
+
expect(getByTestId('title').textContent).toEqual('UnknownResource/12345');
|
|
23
|
+
expect(container.textContent).toContain('Resource code text');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should fire custom onClick function', () => {
|
|
27
|
+
const onClick = jest.fn();
|
|
28
|
+
const { getByRole } = render(
|
|
29
|
+
<Generic fhirResource={exampleResource} onClick={onClick} />,
|
|
30
|
+
);
|
|
31
|
+
const accordion = getByRole('button');
|
|
32
|
+
fireEvent.click(accordion);
|
|
33
|
+
|
|
34
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
35
|
+
expect(attribute).not.toEqual('collapse');
|
|
36
|
+
expect(onClick).toHaveBeenCalled();
|
|
37
|
+
});
|
|
19
38
|
});
|
|
@@ -99,10 +99,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const Goal =
|
|
103
|
-
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
104
|
-
const headerIcon = fhirIcons && fhirIcons['Goal'];
|
|
105
|
-
|
|
102
|
+
const Goal = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
106
103
|
let fhirResourceData = {};
|
|
107
104
|
try {
|
|
108
105
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -225,11 +222,12 @@ const Goal = props => {
|
|
|
225
222
|
)
|
|
226
223
|
}
|
|
227
224
|
badges={hasStatus && <Badge data-testid="status">{status}</Badge>}
|
|
228
|
-
icon={
|
|
225
|
+
icon={fhirIcons}
|
|
229
226
|
title={title}
|
|
230
227
|
/>
|
|
231
228
|
}
|
|
232
229
|
bodyContent={<Body tableData={tableData} />}
|
|
230
|
+
onClick={onClick}
|
|
233
231
|
/>
|
|
234
232
|
</Root>
|
|
235
233
|
);
|
|
@@ -9,6 +9,7 @@ import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
|
|
|
9
9
|
import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
|
|
10
10
|
import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
|
|
11
11
|
import fhirVersions from '../fhirResourceVersions';
|
|
12
|
+
import GoalIcon from '../../../assets/containers/Goal/goal.svg';
|
|
12
13
|
|
|
13
14
|
export default {
|
|
14
15
|
title: 'Goal',
|
|
@@ -20,7 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
20
21
|
<Goal
|
|
21
22
|
fhirVersion={fhirVersions.DSTU2}
|
|
22
23
|
fhirResource={fhirResource}
|
|
23
|
-
fhirIcons={
|
|
24
|
+
fhirIcons={require('../../../assets/containers/Goal/goal.svg')}
|
|
24
25
|
/>
|
|
25
26
|
);
|
|
26
27
|
};
|
|
@@ -31,7 +32,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
31
32
|
<Goal
|
|
32
33
|
fhirVersion={fhirVersions.DSTU2}
|
|
33
34
|
fhirResource={fhirResource}
|
|
34
|
-
fhirIcons={
|
|
35
|
+
fhirIcons={GoalIcon}
|
|
35
36
|
/>
|
|
36
37
|
);
|
|
37
38
|
};
|
|
@@ -53,7 +54,7 @@ export const Example1OfR4 = () => {
|
|
|
53
54
|
<Goal
|
|
54
55
|
fhirVersion={fhirVersions.R4}
|
|
55
56
|
fhirResource={fhirResource}
|
|
56
|
-
fhirIcons={
|
|
57
|
+
fhirIcons={false}
|
|
57
58
|
/>
|
|
58
59
|
);
|
|
59
60
|
};
|
|
@@ -64,7 +65,7 @@ export const Example2OfR4 = () => {
|
|
|
64
65
|
<Goal
|
|
65
66
|
fhirVersion={fhirVersions.R4}
|
|
66
67
|
fhirResource={fhirResource}
|
|
67
|
-
fhirIcons={
|
|
68
|
+
fhirIcons={'random text'}
|
|
68
69
|
/>
|
|
69
70
|
);
|
|
70
71
|
};
|