fhir-react 0.3.7 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +1 -1
- package/.eslintrc +10 -1
- package/.storybook/main.js +5 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview.js +7 -0
- package/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +9 -9
- package/package.json +59 -57
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Generic/generic.svg +3 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
- package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
- package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +44 -13
- package/src/components/containers/Accordion/Accordion.stories.js +74 -58
- package/src/components/containers/ResourceContainer/ResourceContainer.css +4 -0
- package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
- package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +46 -22
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -5
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/defaultArgTypes.js +12 -0
- package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +19 -11
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +46 -70
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +9 -1
- package/src/components/resources/Appointment/Appointment.stories.js +51 -62
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +2 -1
- package/src/components/resources/Binary/Binary.stories.js +27 -21
- package/src/components/resources/Bundle/Bundle.css +7 -0
- package/src/components/resources/Bundle/Bundle.js +15 -11
- package/src/components/resources/Bundle/Bundle.stories.js +59 -115
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +9 -1
- package/src/components/resources/CarePlan/CarePlan.stories.js +44 -54
- package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
- package/src/components/resources/CareTeam/CareTeam.js +79 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +25 -14
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- package/src/components/resources/Claim/Claim.js +9 -1
- package/src/components/resources/Claim/Claim.stories.js +36 -49
- package/src/components/resources/Claim/Claim.test.js +32 -1
- package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
- package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
- package/src/components/resources/ClaimResponse/ClaimResponse.js +144 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +44 -41
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
- package/src/components/resources/ClaimResponse/Item.js +44 -9
- package/src/components/resources/ClaimResponse/Items.js +5 -4
- package/src/components/resources/Condition/Condition.js +10 -3
- package/src/components/resources/Condition/Condition.stories.js +47 -62
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +9 -1
- package/src/components/resources/Coverage/Coverage.stories.js +38 -50
- package/src/components/resources/Coverage/Coverage.test.js +36 -1
- package/src/components/resources/Device/Device.js +9 -1
- package/src/components/resources/Device/Device.stories.js +40 -52
- package/src/components/resources/Device/Device.test.js +36 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +9 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +38 -50
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +25 -29
- package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
- package/src/components/resources/Encounter/Encounter.js +9 -1
- package/src/components/resources/Encounter/Encounter.stories.js +43 -59
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +53 -67
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js +74 -38
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +22 -28
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
- package/src/components/resources/Generic/Generic.js +21 -7
- package/src/components/resources/Generic/Generic.stories.js +22 -12
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +9 -3
- package/src/components/resources/Goal/Goal.stories.js +35 -49
- package/src/components/resources/Goal/Goal.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +9 -2
- package/src/components/resources/Immunization/Immunization.stories.js +38 -51
- package/src/components/resources/Immunization/Immunization.test.js +36 -1
- package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
- package/src/components/resources/List/Entries.js +3 -3
- package/src/components/resources/List/List.js +137 -88
- package/src/components/resources/List/List.stories.js +69 -40
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +66 -47
- package/src/components/resources/Location/Location.stories.js +25 -13
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +9 -1
- package/src/components/resources/Medication/Medication.stories.js +42 -64
- package/src/components/resources/Medication/Medication.test.js +36 -1
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +34 -41
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
- package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.js +70 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +41 -52
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +117 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +51 -54
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -3
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +11 -4
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +27 -30
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +32 -46
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
- package/src/components/resources/Observation/Observation.js +3 -1
- package/src/components/resources/Observation/Observation.stories.js +39 -33
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Observation/ObservationGraph.js +1 -1
- package/src/components/resources/Organization/Organization.js +10 -2
- package/src/components/resources/Organization/Organization.stories.js +40 -52
- package/src/components/resources/Organization/Organization.test.js +36 -1
- package/src/components/resources/Patient/Patient.js +4 -0
- package/src/components/resources/Patient/Patient.stories.js +36 -28
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +9 -1
- package/src/components/resources/Practitioner/Practitioner.stories.js +39 -52
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +45 -58
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +3 -2
- package/src/components/resources/Procedure/Procedure.stories.js +33 -25
- package/src/components/resources/Procedure/Procedure.test.js +30 -1
- package/src/components/resources/Questionnaire/Group.js +53 -0
- package/src/components/resources/Questionnaire/Items.js +45 -0
- package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
- package/src/components/resources/Questionnaire/Questionnaire.js +38 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +50 -57
- package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
- package/src/components/resources/Questionnaire/Questions.js +40 -0
- package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
- package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
- package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
- package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +54 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +46 -58
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
- package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
- package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
- package/src/components/resources/ReferralRequest/ReferralRequest.js +72 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.stories.js +20 -20
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +42 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
- package/src/components/resources/RelatedPerson/index.js +3 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.js +167 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +18 -14
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +40 -27
- package/src/components/ui/index.js +48 -31
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +42 -0
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +14 -1
- package/.storybook/addons.js +0 -1
- package/.storybook/config.js +0 -26
- package/.storybook/presets.js +0 -1
|
@@ -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,8 @@ const ExplanationOfBenefit = ({
|
|
|
233
233
|
fhirVersion,
|
|
234
234
|
withCarinBBProfile = false,
|
|
235
235
|
fhirIcons,
|
|
236
|
+
onClick,
|
|
237
|
+
rawOnClick,
|
|
236
238
|
}) => {
|
|
237
239
|
let fhirResourceData = {};
|
|
238
240
|
try {
|
|
@@ -546,6 +548,8 @@ const ExplanationOfBenefit = ({
|
|
|
546
548
|
{hasCareTeam && <CareTeam fhirData={careTeam} />}
|
|
547
549
|
</Body>
|
|
548
550
|
}
|
|
551
|
+
onClick={onClick}
|
|
552
|
+
rawOnClick={rawOnClick}
|
|
549
553
|
/>
|
|
550
554
|
</Root>
|
|
551
555
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import ExplanationOfBenefit from './ExplanationOfBenefit';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -17,83 +17,69 @@ import ExplanationOfBenefitIcon from '../../../assets/containers/ExplanationOfBe
|
|
|
17
17
|
|
|
18
18
|
export default {
|
|
19
19
|
title: 'ExplanationOfBenefit',
|
|
20
|
+
component: ExplanationOfBenefit,
|
|
21
|
+
argTypes: {
|
|
22
|
+
...defaultArgTypes,
|
|
23
|
+
withCarinBBProfile: {
|
|
24
|
+
table: {
|
|
25
|
+
disable: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
20
29
|
};
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
+
const Template = args => <ExplanationOfBenefit {...args} />;
|
|
32
|
+
|
|
33
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
34
|
+
DefaultVisualizationDSTU2.args = {
|
|
35
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
36
|
+
fhirResource: example1Dstu2,
|
|
37
|
+
fhirIcons: require('../../../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg'),
|
|
31
38
|
};
|
|
32
39
|
|
|
33
|
-
export const ExampleSTU3 = ()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fhirResource={fhirResource}
|
|
39
|
-
fhirIcons={ExplanationOfBenefitIcon}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
40
|
+
export const ExampleSTU3 = Template.bind({});
|
|
41
|
+
ExampleSTU3.args = {
|
|
42
|
+
fhirVersion: fhirVersions.STU3,
|
|
43
|
+
fhirResource: example1Stu3,
|
|
44
|
+
fhirIcons: ExplanationOfBenefitIcon,
|
|
42
45
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
fhirIcons={fhirIcons}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
46
|
+
|
|
47
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
48
|
+
Example2OfSTU3.args = {
|
|
49
|
+
fhirVersion: fhirVersions.STU3,
|
|
50
|
+
fhirResource: example2Stu3,
|
|
51
|
+
fhirIcons: fhirIcons,
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fhirIcons={false}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
53
|
+
|
|
54
|
+
export const PersonPrimaryCoverageR4 = Template.bind({});
|
|
55
|
+
PersonPrimaryCoverageR4.args = {
|
|
56
|
+
fhirVersion: fhirVersions.R4,
|
|
57
|
+
fhirResource: example1R4,
|
|
58
|
+
fhirIcons: false,
|
|
62
59
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fhirIcons={'random text'}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
60
|
+
|
|
61
|
+
export const EOBForClaimWithErrorsR4 = Template.bind({});
|
|
62
|
+
EOBForClaimWithErrorsR4.args = {
|
|
63
|
+
fhirVersion: fhirVersions.R4,
|
|
64
|
+
fhirResource: example2R4,
|
|
65
|
+
fhirIcons: 'random text',
|
|
72
66
|
};
|
|
73
67
|
|
|
74
|
-
export const ExampleWithoutFHIRVersionProperty = ()
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
export const ExampleWithoutFHIRVersionProperty = Template.bind({});
|
|
69
|
+
ExampleWithoutFHIRVersionProperty.args = {
|
|
70
|
+
fhirResource: example1Stu3,
|
|
77
71
|
};
|
|
78
72
|
|
|
79
|
-
export const EOBCarinBlueButtonExample = ()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
fhirResource={fhirResource}
|
|
85
|
-
withCarinBBProfile
|
|
86
|
-
/>
|
|
87
|
-
);
|
|
73
|
+
export const EOBCarinBlueButtonExample = Template.bind({});
|
|
74
|
+
EOBCarinBlueButtonExample.args = {
|
|
75
|
+
fhirVersion: fhirVersions.R4,
|
|
76
|
+
fhirResource: exampleC4BB,
|
|
77
|
+
withCarinBBProfile: true,
|
|
88
78
|
};
|
|
89
79
|
|
|
90
|
-
export const EOBCarinBlueButtonExtendedDiagnosis = ()
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
fhirResource={fhirResource}
|
|
96
|
-
withCarinBBProfile
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
80
|
+
export const EOBCarinBlueButtonExtendedDiagnosis = Template.bind({});
|
|
81
|
+
EOBCarinBlueButtonExtendedDiagnosis.args = {
|
|
82
|
+
fhirVersion: fhirVersions.R4,
|
|
83
|
+
fhirResource: exampleC4BBExtendedDiagnosis,
|
|
84
|
+
withCarinBBProfile: true,
|
|
99
85
|
};
|
|
@@ -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
|
});
|
package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js
CHANGED
|
@@ -2,8 +2,6 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import ExplanationOfBenefitGraph from './ExplanationOfBenefitGraph';
|
|
4
4
|
|
|
5
|
-
export default { title: 'ExplanationOfBenefitGraph' };
|
|
6
|
-
|
|
7
5
|
const CHART_DATA = [
|
|
8
6
|
{
|
|
9
7
|
id: 'a',
|
|
@@ -31,48 +29,86 @@ const CHART_DATA = [
|
|
|
31
29
|
},
|
|
32
30
|
];
|
|
33
31
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
export default {
|
|
33
|
+
title: 'ExplanationOfBenefitGraph',
|
|
34
|
+
component: ExplanationOfBenefitGraph,
|
|
35
|
+
argTypes: {
|
|
36
|
+
data: {
|
|
37
|
+
table: {
|
|
38
|
+
disable: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
margin: {
|
|
42
|
+
table: {
|
|
43
|
+
disable: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
totalLabel: {
|
|
47
|
+
table: {
|
|
48
|
+
disable: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
height: {
|
|
52
|
+
table: {
|
|
53
|
+
disable: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
enableLinkLabels: {
|
|
57
|
+
table: {
|
|
58
|
+
disable: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
enableValueLabels: {
|
|
62
|
+
table: {
|
|
63
|
+
disable: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
pieChartProperties: {
|
|
67
|
+
table: {
|
|
68
|
+
disable: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const Template = args => <ExplanationOfBenefitGraph {...args} />;
|
|
75
|
+
|
|
76
|
+
export const DefaultExplanationOfBenefitGraph = Template.bind({});
|
|
77
|
+
DefaultExplanationOfBenefitGraph.args = {
|
|
78
|
+
data: CHART_DATA,
|
|
79
|
+
margin: { top: 10, bottom: 10 },
|
|
41
80
|
};
|
|
42
81
|
|
|
43
|
-
export const ExplanationOfBenefitGraphWithCustomCenteredMetric = (
|
|
44
|
-
|
|
82
|
+
export const ExplanationOfBenefitGraphWithCustomCenteredMetric = Template.bind(
|
|
83
|
+
{},
|
|
84
|
+
);
|
|
85
|
+
ExplanationOfBenefitGraphWithCustomCenteredMetric.args = {
|
|
86
|
+
data: CHART_DATA,
|
|
87
|
+
totalLabel: 'Custom',
|
|
45
88
|
};
|
|
46
89
|
|
|
47
|
-
export const ExplanationOfBenefitGraphWithHeightAndMargin = ()
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
height={250}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
90
|
+
export const ExplanationOfBenefitGraphWithHeightAndMargin = Template.bind({});
|
|
91
|
+
ExplanationOfBenefitGraphWithHeightAndMargin.args = {
|
|
92
|
+
data: CHART_DATA,
|
|
93
|
+
margin: { top: 40, bottom: 40 },
|
|
94
|
+
height: 250,
|
|
55
95
|
};
|
|
56
96
|
|
|
57
|
-
export const ExplanationOfBenefitGraphWithLabels = ()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
enableValueLabels
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
97
|
+
export const ExplanationOfBenefitGraphWithLabels = Template.bind({});
|
|
98
|
+
ExplanationOfBenefitGraphWithLabels.args = {
|
|
99
|
+
data: CHART_DATA,
|
|
100
|
+
margin: { top: 20, bottom: 20 },
|
|
101
|
+
enableLinkLabels: true,
|
|
102
|
+
enableValueLabels: true,
|
|
66
103
|
};
|
|
67
104
|
|
|
68
|
-
export const ExplanationOfBenefitGraphWithPieChartProperties = (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
105
|
+
export const ExplanationOfBenefitGraphWithPieChartProperties = Template.bind(
|
|
106
|
+
{},
|
|
107
|
+
);
|
|
108
|
+
ExplanationOfBenefitGraphWithPieChartProperties.args = {
|
|
109
|
+
data: CHART_DATA,
|
|
110
|
+
margin: { top: 20, bottom: 20 },
|
|
111
|
+
enableLinkLabels: true,
|
|
112
|
+
enableValueLabels: true,
|
|
113
|
+
pieChartProperties: { startAngle: 90, cornerRadius: 15, borderWidth: 4 },
|
|
78
114
|
};
|
|
@@ -70,8 +70,13 @@ 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
|
+
rawOnClick,
|
|
79
|
+
}) => {
|
|
75
80
|
let fhirResourceData = {};
|
|
76
81
|
try {
|
|
77
82
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -135,6 +140,8 @@ const FamilyMemberHistory = props => {
|
|
|
135
140
|
/>
|
|
136
141
|
}
|
|
137
142
|
bodyContent={<Body tableData={tableData} />}
|
|
143
|
+
onClick={onClick}
|
|
144
|
+
rawOnClick={rawOnClick}
|
|
138
145
|
/>
|
|
139
146
|
</Root>
|
|
140
147
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import FamilyMemberHistory from './FamilyMemberHistory';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -13,37 +13,31 @@ import FamilyMemberHistoryIcon from '../../../assets/containers/FamilyMemberHist
|
|
|
13
13
|
|
|
14
14
|
export default {
|
|
15
15
|
title: 'FamilyMemberHistory',
|
|
16
|
+
component: FamilyMemberHistory,
|
|
17
|
+
argTypes: {
|
|
18
|
+
...defaultArgTypes,
|
|
19
|
+
},
|
|
16
20
|
};
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
22
|
+
const Template = args => <FamilyMemberHistory {...args} />;
|
|
23
|
+
|
|
24
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
25
|
+
DefaultVisualizationDSTU2.args = {
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirResource: example1DSTU2,
|
|
28
|
+
fhirIcons: require('../../../assets/containers/FamilyMemberHistory/family-member-history.svg'),
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
export const Example1OfSTU3 = ()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fhirResource={fhirResource}
|
|
35
|
-
fhirIcons={FamilyMemberHistoryIcon}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
31
|
+
export const Example1OfSTU3 = Template.bind({});
|
|
32
|
+
Example1OfSTU3.args = {
|
|
33
|
+
fhirVersion: fhirVersions.STU3,
|
|
34
|
+
fhirResource: example1STU3,
|
|
35
|
+
fhirIcons: FamilyMemberHistoryIcon,
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
export const Example2OfSTU3 = ()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fhirResource={fhirResource}
|
|
46
|
-
fhirIcons={fhirIcons}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
38
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
39
|
+
Example2OfSTU3.args = {
|
|
40
|
+
fhirVersion: fhirVersions.STU3,
|
|
41
|
+
fhirResource: example2STU3,
|
|
42
|
+
fhirIcons: fhirIcons,
|
|
49
43
|
};
|
|
@@ -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 FamilyMemberHistory from './FamilyMemberHistory';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -110,4 +110,39 @@ describe('should render FamilyMemberHistory component correctly', () => {
|
|
|
110
110
|
expect(getByTestId('hasRelationship').textContent).toContain('father');
|
|
111
111
|
expect(getByTestId('noteText').textContent).toContain('Was fishing at');
|
|
112
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
|
+
});
|
|
113
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, rawOnClick }) => {
|
|
8
8
|
const title = fhirResource
|
|
9
9
|
? `${fhirResource.resourceType}/${fhirResource.id}`
|
|
10
10
|
: `Unknown Resource`;
|
|
@@ -14,10 +14,24 @@ 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
|
+
rawOnClick={rawOnClick}
|
|
34
|
+
/>
|
|
21
35
|
</Root>
|
|
22
36
|
);
|
|
23
37
|
};
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Generic from './Generic';
|
|
5
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
5
6
|
|
|
6
|
-
export default {
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Generic',
|
|
9
|
+
component: Generic,
|
|
10
|
+
argTypes: {
|
|
11
|
+
...defaultArgTypes,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Template = args => <Generic {...args} />;
|
|
7
16
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const exampleResource = {
|
|
18
|
+
resourceType: 'UnknownResource',
|
|
19
|
+
id: '12345',
|
|
20
|
+
code: {
|
|
21
|
+
text: 'Resource code text',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const DefaultVisualization = Template.bind({});
|
|
25
|
+
DefaultVisualization.args = {
|
|
26
|
+
fhirResource: exampleResource,
|
|
27
|
+
fhirIcons: fhirIcons,
|
|
18
28
|
};
|
|
@@ -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
|
});
|