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
|
import Coverage from './Coverage';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -8,8 +8,80 @@ import exampleCoverage from '../../../fixtures/dstu2/resources/coverage/example1
|
|
|
8
8
|
import exampleCoverageStu3 from '../../../fixtures/stu3/resources/coverage/example1.json';
|
|
9
9
|
import example2CoverageStu3 from '../../../fixtures/stu3/resources/coverage/example2.json';
|
|
10
10
|
import exampleCoverageR4 from '../../../fixtures/r4/resources/coverage/example1.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
describe('should render component correctly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
fhirResource: exampleCoverage,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
21
|
+
const headerIcon = getByAltText('coverage');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirResource: exampleCoverage,
|
|
30
|
+
fhirIcons: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const { getByTestId } = render(<Coverage {...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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirResource: exampleCoverage,
|
|
43
|
+
fhirIcons: (
|
|
44
|
+
<img
|
|
45
|
+
src={require('../assets/containers/Coverage/coverage.svg')}
|
|
46
|
+
alt="coverage"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
52
|
+
const headerIcon = getByAltText('coverage');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirResource: exampleCoverage,
|
|
61
|
+
fhirIcons: fhirIcons,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
65
|
+
const headerIcon = getByAltText('coverage');
|
|
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
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirResource: exampleCoverage,
|
|
76
|
+
fhirIcons: avatarSrc,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { getByAltText } = render(<Coverage {...defaultProps} />);
|
|
80
|
+
const headerIcon = getByAltText('header icon');
|
|
81
|
+
|
|
82
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
83
|
+
});
|
|
84
|
+
|
|
13
85
|
it('should render with DSTU2 source data', () => {
|
|
14
86
|
const defaultProps = {
|
|
15
87
|
fhirResource: exampleCoverage,
|
|
@@ -18,7 +90,7 @@ describe('should render component correctly', () => {
|
|
|
18
90
|
const { getByTestId } = render(<Coverage {...defaultProps} />);
|
|
19
91
|
|
|
20
92
|
expect(getByTestId('title').textContent.replace(nbspRegex, ' ')).toContain(
|
|
21
|
-
'Coverage
|
|
93
|
+
'Coverage',
|
|
22
94
|
);
|
|
23
95
|
expect(getByTestId('issuer').textContent).toContain('Organization/2');
|
|
24
96
|
expect(getByTestId('planId').textContent).toContain('CBI35');
|
|
@@ -35,7 +107,7 @@ describe('should render component correctly', () => {
|
|
|
35
107
|
const { getByTestId } = render(<Coverage {...defaultProps} />);
|
|
36
108
|
|
|
37
109
|
expect(getByTestId('title').textContent.replace(nbspRegex, ' ')).toContain(
|
|
38
|
-
'Coverage
|
|
110
|
+
'Coverage',
|
|
39
111
|
);
|
|
40
112
|
expect(getByTestId('issuer').textContent).toContain('Organization/2');
|
|
41
113
|
expect(getByTestId('planId').textContent).toContain('B37FC');
|
|
@@ -70,7 +142,7 @@ describe('should render component correctly', () => {
|
|
|
70
142
|
);
|
|
71
143
|
|
|
72
144
|
expect(getByTestId('title').textContent.replace(nbspRegex, ' ')).toContain(
|
|
73
|
-
'Coverage
|
|
145
|
+
'Coverage',
|
|
74
146
|
);
|
|
75
147
|
expect(getByTestId('issuer').textContent).toContain('Organization/2');
|
|
76
148
|
expect(queryAllByTestId('planId').length).toEqual(0);
|
|
@@ -79,4 +151,39 @@ describe('should render component correctly', () => {
|
|
|
79
151
|
expect(getByTestId('type').textContent).toContain('extended healthcare');
|
|
80
152
|
expect(queryAllByTestId('details').length).toEqual(0);
|
|
81
153
|
});
|
|
154
|
+
|
|
155
|
+
it('should fire custom onClick function', () => {
|
|
156
|
+
const defaultProps = {
|
|
157
|
+
fhirResource: exampleCoverageR4,
|
|
158
|
+
fhirVersion: fhirVersions.R4,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const onClick = jest.fn();
|
|
162
|
+
const { getByRole } = render(
|
|
163
|
+
<Coverage {...defaultProps} onClick={onClick} />,
|
|
164
|
+
);
|
|
165
|
+
const accordion = getByRole('button');
|
|
166
|
+
fireEvent.click(accordion);
|
|
167
|
+
|
|
168
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
169
|
+
expect(attribute).not.toEqual('collapse');
|
|
170
|
+
expect(onClick).toHaveBeenCalled();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should not fire custom onClick function', () => {
|
|
174
|
+
const defaultProps = {
|
|
175
|
+
fhirResource: exampleCoverageR4,
|
|
176
|
+
fhirVersion: fhirVersions.R4,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const onClick = 'test';
|
|
180
|
+
const { getByRole } = render(
|
|
181
|
+
<Coverage {...defaultProps} onClick={onClick} />,
|
|
182
|
+
);
|
|
183
|
+
const accordion = getByRole('button');
|
|
184
|
+
fireEvent.click(accordion);
|
|
185
|
+
|
|
186
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
187
|
+
expect(attribute).toEqual('collapse');
|
|
188
|
+
});
|
|
82
189
|
});
|
|
@@ -102,7 +102,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
const Device = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
105
|
+
const Device = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
106
106
|
let fhirResourceData = {};
|
|
107
107
|
try {
|
|
108
108
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -178,6 +178,7 @@ const Device = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
178
178
|
))}
|
|
179
179
|
</Body>
|
|
180
180
|
}
|
|
181
|
+
onClick={onClick}
|
|
181
182
|
/>
|
|
182
183
|
</Root>
|
|
183
184
|
);
|
|
@@ -10,6 +10,8 @@ import stu3Example2 from '../../../fixtures/stu3/resources/device/example2.json'
|
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/device/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/device/example2.json';
|
|
12
12
|
import fhirVersions from '../fhirResourceVersions';
|
|
13
|
+
import DeviceIcon from '../../../assets/containers/Device/device.svg';
|
|
14
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
15
|
|
|
14
16
|
export default {
|
|
15
17
|
title: 'Device',
|
|
@@ -18,29 +20,55 @@ export default {
|
|
|
18
20
|
export const DefaultVisualizationDSTU2 = () => {
|
|
19
21
|
const fhirResource = object('Resource', dstu2Example1);
|
|
20
22
|
return (
|
|
21
|
-
<Device
|
|
23
|
+
<Device
|
|
24
|
+
fhirResource={fhirResource}
|
|
25
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
26
|
+
fhirIcons={require('../../../assets/containers/Device/device.svg')}
|
|
27
|
+
/>
|
|
22
28
|
);
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
export const ExampleOfDSTU2 = () => {
|
|
26
32
|
const fhirResource = object('Resource', dstu2Example2);
|
|
27
33
|
return (
|
|
28
|
-
<Device
|
|
34
|
+
<Device
|
|
35
|
+
fhirResource={fhirResource}
|
|
36
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
37
|
+
fhirIcons={DeviceIcon}
|
|
38
|
+
/>
|
|
29
39
|
);
|
|
30
40
|
};
|
|
31
41
|
|
|
32
42
|
export const Example1OfSTU3 = () => {
|
|
33
43
|
const fhirResource = object('Resource', stu3Example1);
|
|
34
|
-
return
|
|
44
|
+
return (
|
|
45
|
+
<Device
|
|
46
|
+
fhirResource={fhirResource}
|
|
47
|
+
fhirVersion={fhirVersions.STU3}
|
|
48
|
+
fhirIcons={fhirIcons}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
35
51
|
};
|
|
36
52
|
export const Example2OfSTU3 = () => {
|
|
37
53
|
const fhirResource = object('Resource', stu3Example2);
|
|
38
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
<Device
|
|
56
|
+
fhirResource={fhirResource}
|
|
57
|
+
fhirVersion={fhirVersions.STU3}
|
|
58
|
+
fhirIcons={false}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
39
61
|
};
|
|
40
62
|
|
|
41
63
|
export const Example1OfR4 = () => {
|
|
42
64
|
const fhirResource = object('Resource', r4Example1);
|
|
43
|
-
return
|
|
65
|
+
return (
|
|
66
|
+
<Device
|
|
67
|
+
fhirResource={fhirResource}
|
|
68
|
+
fhirVersion={fhirVersions.R4}
|
|
69
|
+
fhirIcons={'random text'}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
44
72
|
};
|
|
45
73
|
|
|
46
74
|
export const Example2OfR4 = () => {
|
|
@@ -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
|
|
|
4
4
|
import Device from './Device';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
6
6
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/device/example.json';
|
|
7
7
|
import stu3Example2 from '../../../fixtures/stu3/resources/device/example2.json';
|
|
8
8
|
import r4Example2 from '../../../fixtures/r4/resources/device/example2.json';
|
|
9
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
10
|
|
|
10
11
|
describe('should render Device component properly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirResource: dstu2Example1,
|
|
15
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('device');
|
|
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
|
+
fhirResource: dstu2Example1,
|
|
27
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<Device {...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
|
+
fhirResource: dstu2Example1,
|
|
40
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/Device/device.svg')}
|
|
44
|
+
alt="device"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('device');
|
|
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
|
+
fhirResource: dstu2Example1,
|
|
58
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('device');
|
|
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
|
+
fhirResource: dstu2Example1,
|
|
73
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<Device {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
11
83
|
it('should render with DSTU2 source data', () => {
|
|
12
84
|
const defaultProps = {
|
|
13
85
|
fhirResource: dstu2Example1,
|
|
@@ -65,4 +137,39 @@ describe('should render Device component properly', () => {
|
|
|
65
137
|
|
|
66
138
|
expect(getByTestId('uniqueId').textContent).toEqual('-');
|
|
67
139
|
});
|
|
140
|
+
|
|
141
|
+
it('should fire custom onClick function', () => {
|
|
142
|
+
const defaultProps = {
|
|
143
|
+
fhirResource: r4Example2,
|
|
144
|
+
fhirVersion: fhirVersions.R4,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const onClick = jest.fn();
|
|
148
|
+
const { getByRole } = render(
|
|
149
|
+
<Device {...defaultProps} onClick={onClick} />,
|
|
150
|
+
);
|
|
151
|
+
const accordion = getByRole('button');
|
|
152
|
+
fireEvent.click(accordion);
|
|
153
|
+
|
|
154
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
155
|
+
expect(attribute).not.toEqual('collapse');
|
|
156
|
+
expect(onClick).toHaveBeenCalled();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should fire custom onClick function', () => {
|
|
160
|
+
const defaultProps = {
|
|
161
|
+
fhirResource: r4Example2,
|
|
162
|
+
fhirVersion: fhirVersions.R4,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const onClick = 'test';
|
|
166
|
+
const { getByRole } = render(
|
|
167
|
+
<Device {...defaultProps} onClick={onClick} />,
|
|
168
|
+
);
|
|
169
|
+
const accordion = getByRole('button');
|
|
170
|
+
fireEvent.click(accordion);
|
|
171
|
+
|
|
172
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
173
|
+
expect(attribute).toEqual('collapse');
|
|
174
|
+
});
|
|
68
175
|
});
|
|
@@ -93,8 +93,12 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
const DiagnosticReport =
|
|
97
|
-
|
|
96
|
+
const DiagnosticReport = ({
|
|
97
|
+
fhirResource,
|
|
98
|
+
fhirVersion,
|
|
99
|
+
fhirIcons,
|
|
100
|
+
onClick,
|
|
101
|
+
}) => {
|
|
98
102
|
let fhirResourceData = {};
|
|
99
103
|
try {
|
|
100
104
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -165,6 +169,7 @@ const DiagnosticReport = props => {
|
|
|
165
169
|
/>
|
|
166
170
|
}
|
|
167
171
|
bodyContent={<Body tableData={tableData} />}
|
|
172
|
+
onClick={onClick}
|
|
168
173
|
/>
|
|
169
174
|
</Root>
|
|
170
175
|
);
|
|
@@ -10,6 +10,7 @@ import exampleDiagnosticReportR4 from '../../../fixtures/r4/resources/diagnostic
|
|
|
10
10
|
import example2DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example2.json';
|
|
11
11
|
import example3DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example3.json';
|
|
12
12
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import DiagnosticReportIcon from '../../../assets/containers/DiagnosticReport/diagnostic-report.svg';
|
|
13
14
|
|
|
14
15
|
export default { title: 'DiagnosticReport' };
|
|
15
16
|
|
|
@@ -19,7 +20,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
19
20
|
<DiagnosticReport
|
|
20
21
|
fhirVersion={fhirVersions.DSTU2}
|
|
21
22
|
fhirResource={fhirResource}
|
|
22
|
-
fhirIcons={
|
|
23
|
+
fhirIcons={require('../../../assets/containers/DiagnosticReport/diagnostic-report.svg')}
|
|
23
24
|
/>
|
|
24
25
|
);
|
|
25
26
|
};
|
|
@@ -30,7 +31,7 @@ export const ExampleDiagnosticReportSTU3 = () => {
|
|
|
30
31
|
<DiagnosticReport
|
|
31
32
|
fhirVersion={fhirVersions.STU3}
|
|
32
33
|
fhirResource={fhirResource}
|
|
33
|
-
fhirIcons={
|
|
34
|
+
fhirIcons={DiagnosticReportIcon}
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
@@ -52,7 +53,7 @@ export const Example2DiagnosticReportR4 = () => {
|
|
|
52
53
|
<DiagnosticReport
|
|
53
54
|
fhirVersion={fhirVersions.R4}
|
|
54
55
|
fhirResource={fhirResource}
|
|
55
|
-
fhirIcons={
|
|
56
|
+
fhirIcons={false}
|
|
56
57
|
/>
|
|
57
58
|
);
|
|
58
59
|
};
|
|
@@ -63,7 +64,7 @@ export const Example3DiagnosticReportR4 = () => {
|
|
|
63
64
|
<DiagnosticReport
|
|
64
65
|
fhirVersion={fhirVersions.R4}
|
|
65
66
|
fhirResource={fhirResource}
|
|
66
|
-
fhirIcons={
|
|
67
|
+
fhirIcons={'random text'}
|
|
67
68
|
/>
|
|
68
69
|
);
|
|
69
70
|
};
|
|
@@ -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 DiagnosticReport from './DiagnosticReport';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -7,8 +7,79 @@ import exampleDiagnosticReportDSTU2 from '../../../fixtures/dstu2/resources/diag
|
|
|
7
7
|
import exampleDiagnosticReportSTU3 from '../../../fixtures/stu3/resources/diagnosticReport/example1.json';
|
|
8
8
|
import exampleDiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example1.json';
|
|
9
9
|
import example2DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example2.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render component correctly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirResource: exampleDiagnosticReportDSTU2,
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('diagnostic report');
|
|
21
|
+
|
|
22
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fhirResource: exampleDiagnosticReportDSTU2,
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<DiagnosticReport {...defaultProps} />);
|
|
33
|
+
const headerIcon = getByTestId('placeholder');
|
|
34
|
+
|
|
35
|
+
expect(headerIcon).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
fhirResource: exampleDiagnosticReportDSTU2,
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/DiagnosticReport/diagnostic-report.svg')}
|
|
45
|
+
alt="diagnostic report"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('diagnostic report');
|
|
52
|
+
|
|
53
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
57
|
+
const defaultProps = {
|
|
58
|
+
fhirResource: exampleDiagnosticReportDSTU2,
|
|
59
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('diagnostic report');
|
|
65
|
+
|
|
66
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
70
|
+
const avatarSrc =
|
|
71
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
72
|
+
const defaultProps = {
|
|
73
|
+
fhirResource: exampleDiagnosticReportDSTU2,
|
|
74
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
12
83
|
it('should render with DSTU2 source data', () => {
|
|
13
84
|
const defaultProps = {
|
|
14
85
|
fhirResource: exampleDiagnosticReportDSTU2,
|
|
@@ -81,4 +152,39 @@ describe('should render component correctly', () => {
|
|
|
81
152
|
|
|
82
153
|
expect(getByTestId('performer').textContent).toContain('Todd Ashby');
|
|
83
154
|
});
|
|
155
|
+
|
|
156
|
+
it('should fire custom onClick function', () => {
|
|
157
|
+
const defaultProps = {
|
|
158
|
+
fhirResource: example2DiagnosticReportR4,
|
|
159
|
+
fhirVersion: fhirVersions.R4,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const onClick = jest.fn();
|
|
163
|
+
const { getByRole } = render(
|
|
164
|
+
<DiagnosticReport {...defaultProps} onClick={onClick} />,
|
|
165
|
+
);
|
|
166
|
+
const accordion = getByRole('button');
|
|
167
|
+
fireEvent.click(accordion);
|
|
168
|
+
|
|
169
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
170
|
+
expect(attribute).not.toEqual('collapse');
|
|
171
|
+
expect(onClick).toHaveBeenCalled();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should not fire custom onClick function', () => {
|
|
175
|
+
const defaultProps = {
|
|
176
|
+
fhirResource: example2DiagnosticReportR4,
|
|
177
|
+
fhirVersion: fhirVersions.R4,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const onClick = 'test';
|
|
181
|
+
const { getByRole } = render(
|
|
182
|
+
<DiagnosticReport {...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).toEqual('collapse');
|
|
189
|
+
});
|
|
84
190
|
});
|
|
@@ -216,8 +216,12 @@ const Content = props => {
|
|
|
216
216
|
);
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
const DocumentReference =
|
|
220
|
-
|
|
219
|
+
const DocumentReference = ({
|
|
220
|
+
fhirVersion,
|
|
221
|
+
fhirResource,
|
|
222
|
+
fhirIcons,
|
|
223
|
+
onClick,
|
|
224
|
+
}) => {
|
|
221
225
|
let fhirResourceData = {};
|
|
222
226
|
try {
|
|
223
227
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -337,6 +341,7 @@ const DocumentReference = props => {
|
|
|
337
341
|
{hasContent && <Content content={content} />}
|
|
338
342
|
</Body>
|
|
339
343
|
}
|
|
344
|
+
onClick={onClick}
|
|
340
345
|
/>
|
|
341
346
|
</Root>
|
|
342
347
|
);
|
|
@@ -8,6 +8,7 @@ import exampleDocumentReference from '../../../fixtures/dstu2/resources/document
|
|
|
8
8
|
import exampleDocumentReferenceSTU3 from '../../../fixtures/stu3/resources/documentReference/example1.json';
|
|
9
9
|
import example1DocumentReferenceR4 from '../../../fixtures/r4/resources/documentReference/example1.json';
|
|
10
10
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
|
+
import DocumentReferenceIcon from '../../../assets/containers/DocumentReference/document-reference.svg';
|
|
11
12
|
|
|
12
13
|
export default { title: 'Document Reference' };
|
|
13
14
|
|
|
@@ -17,7 +18,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
17
18
|
<DocumentReference
|
|
18
19
|
fhirResource={fhirResource}
|
|
19
20
|
fhirVersion={fhirVersions.DSTU2}
|
|
20
|
-
fhirIcons={
|
|
21
|
+
fhirIcons={require('../../../assets/containers/DocumentReference/document-reference.svg')}
|
|
21
22
|
/>
|
|
22
23
|
);
|
|
23
24
|
};
|
|
@@ -28,7 +29,7 @@ export const ExampleSTU3 = () => {
|
|
|
28
29
|
<DocumentReference
|
|
29
30
|
fhirResource={fhirResource}
|
|
30
31
|
fhirVersion={fhirVersions.STU3}
|
|
31
|
-
fhirIcons={
|
|
32
|
+
fhirIcons={DocumentReferenceIcon}
|
|
32
33
|
/>
|
|
33
34
|
);
|
|
34
35
|
};
|