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
|
@@ -99,9 +99,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const Goal =
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const Goal = ({
|
|
103
|
+
fhirResource,
|
|
104
|
+
fhirVersion,
|
|
105
|
+
fhirIcons,
|
|
106
|
+
onClick,
|
|
107
|
+
rawOnClick,
|
|
108
|
+
}) => {
|
|
105
109
|
let fhirResourceData = {};
|
|
106
110
|
try {
|
|
107
111
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -229,6 +233,8 @@ const Goal = props => {
|
|
|
229
233
|
/>
|
|
230
234
|
}
|
|
231
235
|
bodyContent={<Body tableData={tableData} />}
|
|
236
|
+
onClick={onClick}
|
|
237
|
+
rawOnClick={rawOnClick}
|
|
232
238
|
/>
|
|
233
239
|
</Root>
|
|
234
240
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Goal from './Goal';
|
|
5
5
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
@@ -13,64 +13,50 @@ import GoalIcon from '../../../assets/containers/Goal/goal.svg';
|
|
|
13
13
|
|
|
14
14
|
export default {
|
|
15
15
|
title: 'Goal',
|
|
16
|
+
component: Goal,
|
|
17
|
+
argTypes: {
|
|
18
|
+
...defaultArgTypes,
|
|
19
|
+
},
|
|
16
20
|
};
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
22
|
+
const Template = args => <Goal {...args} />;
|
|
23
|
+
|
|
24
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
25
|
+
DefaultVisualizationDSTU2.args = {
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirResource: dstu2Example1,
|
|
28
|
+
fhirIcons: require('../../../assets/containers/Goal/goal.svg'),
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
export const Example2OfDSTU2 = ()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fhirResource={fhirResource}
|
|
35
|
-
fhirIcons={GoalIcon}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
31
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
32
|
+
Example2OfDSTU2.args = {
|
|
33
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
34
|
+
fhirResource: dstu2Example2,
|
|
35
|
+
fhirIcons: GoalIcon,
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
export const ExampleOfSTU3 = ()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fhirResource={fhirResource}
|
|
46
|
-
fhirIcons={fhirIcons}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
38
|
+
export const ExampleOfSTU3 = Template.bind({});
|
|
39
|
+
ExampleOfSTU3.args = {
|
|
40
|
+
fhirVersion: fhirVersions.STU3,
|
|
41
|
+
fhirResource: stu3Example1,
|
|
42
|
+
fhirIcons: fhirIcons,
|
|
49
43
|
};
|
|
50
44
|
|
|
51
|
-
export const Example1OfR4 = ()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
fhirResource={fhirResource}
|
|
57
|
-
fhirIcons={false}
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
45
|
+
export const Example1OfR4 = Template.bind({});
|
|
46
|
+
Example1OfR4.args = {
|
|
47
|
+
fhirVersion: fhirVersions.R4,
|
|
48
|
+
fhirResource: r4Example1,
|
|
49
|
+
fhirIcons: false,
|
|
60
50
|
};
|
|
61
51
|
|
|
62
|
-
export const Example2OfR4 = ()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
fhirResource={fhirResource}
|
|
68
|
-
fhirIcons={'random text'}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
52
|
+
export const Example2OfR4 = Template.bind({});
|
|
53
|
+
Example2OfR4.args = {
|
|
54
|
+
fhirVersion: fhirVersions.R4,
|
|
55
|
+
fhirResource: r4Example2,
|
|
56
|
+
fhirIcons: 'random text',
|
|
71
57
|
};
|
|
72
58
|
|
|
73
|
-
export const ExampleWithoutFhirVersionProperty = ()
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
export const ExampleWithoutFhirVersionProperty = Template.bind({});
|
|
60
|
+
ExampleWithoutFhirVersionProperty.args = {
|
|
61
|
+
fhirResource: stu3Example1,
|
|
76
62
|
};
|
|
@@ -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 Goal from './Goal';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -187,4 +187,35 @@ describe('should render Goal component properly', () => {
|
|
|
187
187
|
|
|
188
188
|
expect(queryByTestId('priority')).toBeNull();
|
|
189
189
|
});
|
|
190
|
+
|
|
191
|
+
it('should fire custom onClick function', () => {
|
|
192
|
+
const defaultProps = {
|
|
193
|
+
fhirResource: r4Example2,
|
|
194
|
+
fhirVersion: fhirVersions.R4,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const onClick = jest.fn();
|
|
198
|
+
const { getByRole } = render(<Goal {...defaultProps} onClick={onClick} />);
|
|
199
|
+
const accordion = getByRole('button');
|
|
200
|
+
fireEvent.click(accordion);
|
|
201
|
+
|
|
202
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
203
|
+
expect(attribute).not.toEqual('collapse');
|
|
204
|
+
expect(onClick).toHaveBeenCalled();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should not fire custom onClick function', () => {
|
|
208
|
+
const defaultProps = {
|
|
209
|
+
fhirResource: r4Example2,
|
|
210
|
+
fhirVersion: fhirVersions.R4,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const onClick = 'test';
|
|
214
|
+
const { getByRole } = render(<Goal {...defaultProps} onClick={onClick} />);
|
|
215
|
+
const accordion = getByRole('button');
|
|
216
|
+
fireEvent.click(accordion);
|
|
217
|
+
|
|
218
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
219
|
+
expect(attribute).toEqual('collapse');
|
|
220
|
+
});
|
|
190
221
|
});
|
|
@@ -103,8 +103,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
const Immunization =
|
|
107
|
-
|
|
106
|
+
const Immunization = ({
|
|
107
|
+
fhirVersion,
|
|
108
|
+
fhirResource,
|
|
109
|
+
fhirIcons,
|
|
110
|
+
onClick,
|
|
111
|
+
rawOnClick,
|
|
112
|
+
}) => {
|
|
108
113
|
const {
|
|
109
114
|
title,
|
|
110
115
|
status,
|
|
@@ -241,6 +246,8 @@ const Immunization = props => {
|
|
|
241
246
|
/>
|
|
242
247
|
}
|
|
243
248
|
bodyContent={<Body tableData={tableData} />}
|
|
249
|
+
onClick={onClick}
|
|
250
|
+
rawOnClick={rawOnClick}
|
|
244
251
|
/>
|
|
245
252
|
</Root>
|
|
246
253
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Immunization from './Immunization';
|
|
5
5
|
|
|
@@ -15,64 +15,51 @@ import ImmunizationIcon from '../../../assets/containers/Immunization/immunizati
|
|
|
15
15
|
|
|
16
16
|
export default {
|
|
17
17
|
title: 'Immunization',
|
|
18
|
+
component: Immunization,
|
|
19
|
+
argTypes: {
|
|
20
|
+
...defaultArgTypes,
|
|
21
|
+
},
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
24
|
+
const Template = args => <Immunization {...args} />;
|
|
25
|
+
|
|
26
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
27
|
+
DefaultVisualizationDSTU2.args = {
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirResource: example1,
|
|
30
|
+
fhirIcons: require('../../../assets/containers/Immunization/immunization.svg'),
|
|
29
31
|
};
|
|
30
32
|
|
|
31
|
-
export const Example2OfDSTU2 = ()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
37
|
-
fhirIcons={ImmunizationIcon}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
33
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
34
|
+
Example2OfDSTU2.args = {
|
|
35
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
36
|
+
fhirResource: example2,
|
|
37
|
+
fhirIcons: ImmunizationIcon,
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
export const ExampleSTU3 = ()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
fhirVersion={fhirVersions.STU3}
|
|
48
|
-
fhirIcons={fhirIcons}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
40
|
+
export const ExampleSTU3 = Template.bind({});
|
|
41
|
+
ExampleSTU3.args = {
|
|
42
|
+
fhirVersion: fhirVersions.STU3,
|
|
43
|
+
fhirResource: stu3Example,
|
|
44
|
+
fhirIcons: fhirIcons,
|
|
51
45
|
};
|
|
52
46
|
|
|
53
|
-
export const Example1R4 = ()
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
fhirVersion={fhirVersions.R4}
|
|
59
|
-
fhirIcons={false}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
47
|
+
export const Example1R4 = Template.bind({});
|
|
48
|
+
Example1R4.args = {
|
|
49
|
+
fhirVersion: fhirVersions.R4,
|
|
50
|
+
fhirResource: r4Example1,
|
|
51
|
+
fhirIcons: false,
|
|
62
52
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fhirIcons={'random text'}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
53
|
+
|
|
54
|
+
export const Example2R4 = Template.bind({});
|
|
55
|
+
Example2R4.args = {
|
|
56
|
+
fhirVersion: fhirVersions.R4,
|
|
57
|
+
fhirResource: r4Example2,
|
|
58
|
+
fhirIcons: 'random text',
|
|
72
59
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
|
|
61
|
+
export const Example3R4 = Template.bind({});
|
|
62
|
+
Example3R4.args = {
|
|
63
|
+
fhirVersion: fhirVersions.R4,
|
|
64
|
+
fhirResource: r4Example3,
|
|
78
65
|
};
|
|
@@ -4,7 +4,7 @@ import dstu2Example from '../../../fixtures/dstu2/resources/immunization/example
|
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.json';
|
|
6
6
|
import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
|
|
7
|
-
import { render } from '@testing-library/react';
|
|
7
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
8
8
|
import stu3Example from '../../../fixtures/stu3/resources/immunization/example1.json';
|
|
9
9
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
10
|
|
|
@@ -222,4 +222,39 @@ describe('should render Immunization component properly', () => {
|
|
|
222
222
|
|
|
223
223
|
expect(queryByTestId('site')).toBeNull();
|
|
224
224
|
});
|
|
225
|
+
|
|
226
|
+
it('should fire custom onClick function', () => {
|
|
227
|
+
const defaultProps = {
|
|
228
|
+
fhirResource: r4Example1,
|
|
229
|
+
fhirVersion: fhirVersions.R4,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const onClick = jest.fn();
|
|
233
|
+
const { getByRole } = render(
|
|
234
|
+
<Immunization {...defaultProps} onClick={onClick} />,
|
|
235
|
+
);
|
|
236
|
+
const accordion = getByRole('button');
|
|
237
|
+
fireEvent.click(accordion);
|
|
238
|
+
|
|
239
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
240
|
+
expect(attribute).not.toEqual('collapse');
|
|
241
|
+
expect(onClick).toHaveBeenCalled();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should not fire custom onClick function', () => {
|
|
245
|
+
const defaultProps = {
|
|
246
|
+
fhirResource: r4Example1,
|
|
247
|
+
fhirVersion: fhirVersions.R4,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const onClick = 'test';
|
|
251
|
+
const { getByRole } = render(
|
|
252
|
+
<Immunization {...defaultProps} onClick={onClick} />,
|
|
253
|
+
);
|
|
254
|
+
const accordion = getByRole('button');
|
|
255
|
+
fireEvent.click(accordion);
|
|
256
|
+
|
|
257
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
258
|
+
expect(attribute).toEqual('collapse');
|
|
259
|
+
});
|
|
225
260
|
});
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
4
|
import { getExtension } from './utils';
|
|
5
|
-
import { ValueSection,
|
|
5
|
+
import { ValueSection, ValueSectionItem } from '../../ui';
|
|
6
6
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
7
7
|
import Money from '../../datatypes/Money';
|
|
8
8
|
|
|
@@ -82,48 +82,92 @@ const DrugTierDefinitionExtension = props => {
|
|
|
82
82
|
coinsuranceOption,
|
|
83
83
|
} = dto(drugTierDefinitionExtension);
|
|
84
84
|
|
|
85
|
+
const drugData = [
|
|
86
|
+
{
|
|
87
|
+
label: 'Drug Tier ID',
|
|
88
|
+
testId: 'drugTierID',
|
|
89
|
+
data: drugTierID && <CodeableConcept fhirData={drugTierID} />,
|
|
90
|
+
status: drugTierID,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
label: 'Mail order',
|
|
94
|
+
testId: 'mailOrder',
|
|
95
|
+
data: mailOrder ? 'yes' : 'no',
|
|
96
|
+
status: mailOrder,
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const costData = [
|
|
101
|
+
{
|
|
102
|
+
label: 'Pharmacy Type',
|
|
103
|
+
testId: 'pharmacyType',
|
|
104
|
+
data: pharmacyType && <CodeableConcept fhirData={pharmacyType} />,
|
|
105
|
+
status: pharmacyType,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: 'Copay Amount',
|
|
109
|
+
testId: 'copayAmount',
|
|
110
|
+
data: copayAmount && <Money fhirData={copayAmount} />,
|
|
111
|
+
status: copayAmount,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: 'Copay Option',
|
|
115
|
+
testId: 'copayOption',
|
|
116
|
+
data: copayOption && <CodeableConcept fhirData={copayOption} />,
|
|
117
|
+
status: copayOption,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: 'Coinsurance Rate',
|
|
121
|
+
testId: 'coinsuranceRate',
|
|
122
|
+
data: coinsuranceRate,
|
|
123
|
+
status: coinsuranceRate === 0 || coinsuranceRate,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: 'Coinsurance Option',
|
|
127
|
+
testId: 'coinsuranceOption',
|
|
128
|
+
data: coinsuranceOption && (
|
|
129
|
+
<CodeableConcept fhirData={coinsuranceOption} />
|
|
130
|
+
),
|
|
131
|
+
status: coinsuranceOption,
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
85
135
|
return (
|
|
86
136
|
hasExtensions && (
|
|
87
137
|
<ValueSection
|
|
88
138
|
label="Drug Tier Definition"
|
|
89
139
|
data-testid="drugTierDefinition"
|
|
140
|
+
marginTop
|
|
90
141
|
>
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
142
|
+
{drugData.map(
|
|
143
|
+
(item, index) =>
|
|
144
|
+
item.status && (
|
|
145
|
+
<ValueSectionItem
|
|
146
|
+
key={`drug-item-${index}`}
|
|
147
|
+
label={item.label}
|
|
148
|
+
data-testid={item.testId}
|
|
149
|
+
>
|
|
150
|
+
{item.data}
|
|
151
|
+
</ValueSectionItem>
|
|
152
|
+
),
|
|
100
153
|
)}
|
|
101
154
|
{hasConstSharing && (
|
|
102
|
-
<ValueSection
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{(coinsuranceRate === 0 || coinsuranceRate) && (
|
|
119
|
-
<Value label="Coinsurance Rate" data-testid="coinsuranceRate">
|
|
120
|
-
{coinsuranceRate}
|
|
121
|
-
</Value>
|
|
122
|
-
)}
|
|
123
|
-
{coinsuranceOption && (
|
|
124
|
-
<Value label="Coinsurance Option" data-testid="coinsuranceOption">
|
|
125
|
-
<CodeableConcept fhirData={coinsuranceOption} />
|
|
126
|
-
</Value>
|
|
155
|
+
<ValueSection
|
|
156
|
+
label="Cost sharing"
|
|
157
|
+
data-testid="costSharing"
|
|
158
|
+
marginTop
|
|
159
|
+
>
|
|
160
|
+
{costData.map(
|
|
161
|
+
(item, index) =>
|
|
162
|
+
item.status && (
|
|
163
|
+
<ValueSectionItem
|
|
164
|
+
key={`cost-item-${index}`}
|
|
165
|
+
label={item.label}
|
|
166
|
+
data-testid={item.testId}
|
|
167
|
+
>
|
|
168
|
+
{item.data}
|
|
169
|
+
</ValueSectionItem>
|
|
170
|
+
),
|
|
127
171
|
)}
|
|
128
172
|
</ValueSection>
|
|
129
173
|
)}
|
|
@@ -16,7 +16,7 @@ import Reference from '../../datatypes/Reference';
|
|
|
16
16
|
const Entries = ({ fhirData: items = [] }) => {
|
|
17
17
|
if (items.length === 0) return null;
|
|
18
18
|
return (
|
|
19
|
-
<ValueSection label="Entries" data-testid="entries">
|
|
19
|
+
<ValueSection label="Entries" data-testid="entries" marginTop>
|
|
20
20
|
<Table>
|
|
21
21
|
<thead>
|
|
22
22
|
<TableRow>
|
|
@@ -26,7 +26,7 @@ const Entries = ({ fhirData: items = [] }) => {
|
|
|
26
26
|
<TableHeader>Status</TableHeader>
|
|
27
27
|
</TableRow>
|
|
28
28
|
</thead>
|
|
29
|
-
<tbody>
|
|
29
|
+
<tbody className="border-top-0">
|
|
30
30
|
{items.map((item, idx) => (
|
|
31
31
|
<Entry key={idx} item={item} />
|
|
32
32
|
))}
|
|
@@ -50,7 +50,7 @@ const Entry = props => {
|
|
|
50
50
|
<Reference fhirData={entry} />
|
|
51
51
|
</TableCell>
|
|
52
52
|
<TableCell data-testid="items.date">
|
|
53
|
-
{date ? <Date fhirData={date} /> : <MissingValue />}
|
|
53
|
+
{date ? <Date fhirData={date} isBlack /> : <MissingValue />}
|
|
54
54
|
</TableCell>
|
|
55
55
|
<TableCell data-testid="items.isDeleted">
|
|
56
56
|
{deleted === true ? 'yes' : 'no'}
|