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
|
@@ -144,7 +144,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
const Appointment = ({
|
|
147
|
+
const Appointment = ({
|
|
148
|
+
fhirResource,
|
|
149
|
+
fhirVersion,
|
|
150
|
+
fhirIcons,
|
|
151
|
+
onClick,
|
|
152
|
+
rawOnClick,
|
|
153
|
+
}) => {
|
|
148
154
|
const {
|
|
149
155
|
description,
|
|
150
156
|
status,
|
|
@@ -253,6 +259,8 @@ const Appointment = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
253
259
|
)}
|
|
254
260
|
</Body>
|
|
255
261
|
}
|
|
262
|
+
onClick={onClick}
|
|
263
|
+
rawOnClick={rawOnClick}
|
|
256
264
|
/>
|
|
257
265
|
</Root>
|
|
258
266
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
import fhirVersions from '../fhirResourceVersions';
|
|
4
4
|
|
|
5
5
|
import Appointment from './Appointment';
|
|
@@ -16,76 +16,65 @@ import example3AppointmentR4 from '../../../fixtures/r4/resources/appointment/ex
|
|
|
16
16
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
17
17
|
import AppointmentIcon from '../../../assets/containers/Appointment/appointment.svg';
|
|
18
18
|
|
|
19
|
-
export default {
|
|
19
|
+
export default {
|
|
20
|
+
title: 'Appointment',
|
|
21
|
+
component: Appointment,
|
|
22
|
+
argTypes: {
|
|
23
|
+
...defaultArgTypes,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const Template = args => <Appointment {...args} />;
|
|
20
28
|
|
|
21
|
-
export const DefaultVisualizationDSTU2 = ()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
27
|
-
fhirIcons={require('../../../assets/containers/Appointment/appointment.svg')}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
29
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
30
|
+
DefaultVisualizationDSTU2.args = {
|
|
31
|
+
fhirResource: exampleAppointmentDSTU2,
|
|
32
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
33
|
+
fhirIcons: require('../../../assets/containers/Appointment/appointment.svg'),
|
|
30
34
|
};
|
|
31
35
|
|
|
32
|
-
export const Example2OfDSTU2 = ()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
38
|
-
fhirIcons={AppointmentIcon}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
36
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
37
|
+
Example2OfDSTU2.args = {
|
|
38
|
+
fhirResource: example2AppointmentDSTU2,
|
|
39
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
40
|
+
fhirIcons: AppointmentIcon,
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export const Example1OfSTU3 = ()
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
fhirVersion={fhirVersions.STU3}
|
|
49
|
-
fhirIcons={fhirIcons}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
43
|
+
export const Example1OfSTU3 = Template.bind({});
|
|
44
|
+
Example1OfSTU3.args = {
|
|
45
|
+
fhirResource: example1AppointmentSTU3,
|
|
46
|
+
fhirVersion: fhirVersions.STU3,
|
|
47
|
+
fhirIcons: fhirIcons,
|
|
52
48
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fhirIcons={false}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
49
|
+
|
|
50
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
51
|
+
Example2OfSTU3.args = {
|
|
52
|
+
fhirResource: example2AppointmentSTU3,
|
|
53
|
+
fhirVersion: fhirVersions.STU3,
|
|
54
|
+
fhirIcons: false,
|
|
62
55
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fhirIcons={'random text'}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
56
|
+
|
|
57
|
+
export const Example3OfSTU3 = Template.bind({});
|
|
58
|
+
Example3OfSTU3.args = {
|
|
59
|
+
fhirResource: example3AppointmentSTU3,
|
|
60
|
+
fhirVersion: fhirVersions.STU3,
|
|
61
|
+
fhirIcons: 'random text',
|
|
72
62
|
};
|
|
73
63
|
|
|
74
|
-
export const Example1OfR4 = ()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
);
|
|
64
|
+
export const Example1OfR4 = Template.bind({});
|
|
65
|
+
Example1OfR4.args = {
|
|
66
|
+
fhirResource: example1AppointmentR4,
|
|
67
|
+
fhirVersion: fhirVersions.R4,
|
|
79
68
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
|
|
70
|
+
export const Example2OfR4 = Template.bind({});
|
|
71
|
+
Example2OfR4.args = {
|
|
72
|
+
fhirResource: example2AppointmentR4,
|
|
73
|
+
fhirVersion: fhirVersions.R4,
|
|
85
74
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
|
|
76
|
+
export const Example3OfR4 = Template.bind({});
|
|
77
|
+
Example3OfR4.args = {
|
|
78
|
+
fhirResource: example3AppointmentR4,
|
|
79
|
+
fhirVersion: fhirVersions.R4,
|
|
91
80
|
};
|
|
@@ -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 Appointment from './Appointment';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -231,4 +231,39 @@ describe('should render component correctly', () => {
|
|
|
231
231
|
|
|
232
232
|
expect(getByTestId('reason').textContent).toContain('Clinical Review');
|
|
233
233
|
});
|
|
234
|
+
|
|
235
|
+
it('should fire custom onClick function', () => {
|
|
236
|
+
const defaultProps = {
|
|
237
|
+
fhirResource: example3AppointmentR4,
|
|
238
|
+
fhirVersion: fhirVersions.R4,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const onClick = jest.fn();
|
|
242
|
+
const { getByRole } = render(
|
|
243
|
+
<Appointment {...defaultProps} onClick={onClick} />,
|
|
244
|
+
);
|
|
245
|
+
const accordion = getByRole('button');
|
|
246
|
+
fireEvent.click(accordion);
|
|
247
|
+
|
|
248
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
249
|
+
expect(attribute).not.toEqual('collapse');
|
|
250
|
+
expect(onClick).toHaveBeenCalled();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('should not fire custom onClick function', () => {
|
|
254
|
+
const defaultProps = {
|
|
255
|
+
fhirResource: example3AppointmentR4,
|
|
256
|
+
fhirVersion: fhirVersions.R4,
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const onClick = 'test';
|
|
260
|
+
const { getByRole } = render(
|
|
261
|
+
<Appointment {...defaultProps} onClick={onClick} />,
|
|
262
|
+
);
|
|
263
|
+
const accordion = getByRole('button');
|
|
264
|
+
fireEvent.click(accordion);
|
|
265
|
+
|
|
266
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
267
|
+
expect(attribute).toEqual('collapse');
|
|
268
|
+
});
|
|
234
269
|
});
|
|
@@ -6,7 +6,7 @@ import Accordion from '../../containers/Accordion/Accordion';
|
|
|
6
6
|
import { Body, Header } from '../../ui';
|
|
7
7
|
|
|
8
8
|
const Binary = props => {
|
|
9
|
-
const { fhirResource, fhirIcons } = props;
|
|
9
|
+
const { fhirResource, fhirIcons, rawOnClick } = props;
|
|
10
10
|
|
|
11
11
|
const loadBinaryFile = () => {
|
|
12
12
|
switch (fhirResource.contentType) {
|
|
@@ -37,6 +37,7 @@ const Binary = props => {
|
|
|
37
37
|
/>
|
|
38
38
|
}
|
|
39
39
|
bodyContent={<Body>{loadBinaryFile()}</Body>}
|
|
40
|
+
rawOnClick={rawOnClick}
|
|
40
41
|
/>
|
|
41
42
|
</div>
|
|
42
43
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Binary from './Binary';
|
|
5
5
|
|
|
@@ -13,34 +13,40 @@ import BinaryIcon from '../../../assets/containers/Binary/binary.svg';
|
|
|
13
13
|
|
|
14
14
|
export default {
|
|
15
15
|
title: 'Binary',
|
|
16
|
+
component: Binary,
|
|
17
|
+
argTypes: {
|
|
18
|
+
...defaultArgTypes,
|
|
19
|
+
},
|
|
16
20
|
};
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
22
|
+
const Template = args => <Binary {...args} />;
|
|
23
|
+
|
|
24
|
+
export const PdfDSTU2 = Template.bind({});
|
|
25
|
+
PdfDSTU2.args = {
|
|
26
|
+
fhirResource: dstu2ExamplePdf,
|
|
27
|
+
fhirIcons: require('../../../assets/containers/Binary/binary.svg'),
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
export const JpegDSTU2 = ()
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
export const JpegDSTU2 = Template.bind({});
|
|
31
|
+
JpegDSTU2.args = {
|
|
32
|
+
fhirResource: dstu2ExampleJpeg,
|
|
33
|
+
fhirIcons: BinaryIcon,
|
|
31
34
|
};
|
|
32
35
|
|
|
33
|
-
export const PdfSTU3 = ()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
export const PdfSTU3 = Template.bind({});
|
|
37
|
+
PdfSTU3.args = {
|
|
38
|
+
fhirResource: stu3ExamplePdf,
|
|
39
|
+
fhirIcons: false,
|
|
36
40
|
};
|
|
37
41
|
|
|
38
|
-
export const JpegSTU3 = ()
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
export const JpegSTU3 = Template.bind({});
|
|
43
|
+
JpegSTU3.args = {
|
|
44
|
+
fhirResource: stu3ExampleJpeg,
|
|
45
|
+
fhirIcons: 'random text',
|
|
41
46
|
};
|
|
42
47
|
|
|
43
|
-
export const JsonSTU3 = ()
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
export const JsonSTU3 = Template.bind({});
|
|
49
|
+
JsonSTU3.args = {
|
|
50
|
+
fhirResource: stu3ExampleJson,
|
|
51
|
+
fhirIcons: fhirIcons,
|
|
46
52
|
};
|
|
@@ -4,12 +4,12 @@ import _get from 'lodash/get';
|
|
|
4
4
|
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
6
6
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
7
|
-
import { Root, Header,
|
|
7
|
+
import { Root, Header, Badge, Body, BadgeSecondary } from '../../ui';
|
|
8
8
|
import * as FhirResourceTypes from '../../supportedFhirResourceList';
|
|
9
9
|
|
|
10
10
|
import './Bundle.css';
|
|
11
11
|
|
|
12
|
-
export default function Bundle({ fhirResource, fhirVersion
|
|
12
|
+
export default function Bundle({ fhirResource, fhirVersion }) {
|
|
13
13
|
const commonDTO = fhirResource => {
|
|
14
14
|
const type = _get(fhirResource, 'type', null);
|
|
15
15
|
const total = _get(fhirResource, 'total');
|
|
@@ -51,11 +51,14 @@ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
|
|
|
51
51
|
.filter(Boolean);
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
|
-
<Root name="Bundle">
|
|
55
|
-
<Header
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
<Root name="Bundle" className="fhir-resource__Bundle__rootPadding">
|
|
55
|
+
<Header
|
|
56
|
+
resourceName="Bundle"
|
|
57
|
+
title={type}
|
|
58
|
+
badges={!isNaN(total) && <Badge data-testid="total">{total}</Badge>}
|
|
59
|
+
capitalize
|
|
60
|
+
isNoIcon
|
|
61
|
+
/>
|
|
59
62
|
<Body>
|
|
60
63
|
{resources.length > 0 &&
|
|
61
64
|
resources.map((resource, index) => {
|
|
@@ -71,14 +74,15 @@ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
|
|
|
71
74
|
key={`${resource.id}-${index}`}
|
|
72
75
|
>
|
|
73
76
|
{resourceType && (
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
<div className="mx-20">
|
|
78
|
+
<BadgeSecondary data-testid="resourceType">
|
|
79
|
+
{resourceType}
|
|
80
|
+
</BadgeSecondary>
|
|
81
|
+
</div>
|
|
77
82
|
)}
|
|
78
83
|
<FhirComponent
|
|
79
84
|
fhirResource={resource}
|
|
80
85
|
fhirVersion={fhirVersion}
|
|
81
|
-
fhirIcons={fhirIcons}
|
|
82
86
|
/>
|
|
83
87
|
</div>
|
|
84
88
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Bundle from './Bundle';
|
|
5
5
|
|
|
@@ -17,145 +17,89 @@ import r4Example3 from '../../../fixtures/r4/resources/bundle/example3.json';
|
|
|
17
17
|
import r4Example4 from '../../../fixtures/r4/resources/bundle/example4.json';
|
|
18
18
|
import fhirVersions from '../fhirResourceVersions';
|
|
19
19
|
|
|
20
|
-
import fhirIcons from '../../../fixtures/example-icons';
|
|
21
|
-
|
|
22
20
|
export default {
|
|
23
21
|
title: 'Bundle',
|
|
22
|
+
component: Bundle,
|
|
23
|
+
argTypes: {
|
|
24
|
+
...defaultArgTypes,
|
|
25
|
+
},
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
fhirIcons={fhirIcons}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
28
|
+
const Template = args => <Bundle {...args} />;
|
|
29
|
+
|
|
30
|
+
export const Example1OfDSTU2 = Template.bind({});
|
|
31
|
+
Example1OfDSTU2.args = {
|
|
32
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
33
|
+
fhirResource: dstu2Example1,
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
export const Example2OfDSTU2 = ()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
fhirResource={fhirResource}
|
|
42
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
43
|
-
fhirIcons={fhirIcons}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
36
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
37
|
+
Example2OfDSTU2.args = {
|
|
38
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
39
|
+
fhirResource: dstu2Example2,
|
|
46
40
|
};
|
|
47
41
|
|
|
48
|
-
export const Example3OfDSTU2 = ()
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
fhirResource={fhirResource}
|
|
53
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
54
|
-
fhirIcons={fhirIcons}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
42
|
+
export const Example3OfDSTU2 = Template.bind({});
|
|
43
|
+
Example3OfDSTU2.args = {
|
|
44
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
45
|
+
fhirResource: dstu2Example3,
|
|
57
46
|
};
|
|
58
47
|
|
|
59
|
-
export const Example4OfDSTU2 = ()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fhirResource={fhirResource}
|
|
64
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
65
|
-
fhirIcons={fhirIcons}
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
48
|
+
export const Example4OfDSTU2 = Template.bind({});
|
|
49
|
+
Example4OfDSTU2.args = {
|
|
50
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
51
|
+
fhirResource: dstu2Example4,
|
|
68
52
|
};
|
|
69
53
|
|
|
70
|
-
export const Example1OfSTU3 = ()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
fhirResource={fhirResource}
|
|
75
|
-
fhirVersion={fhirVersions.STU3}
|
|
76
|
-
fhirIcons={fhirIcons}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
54
|
+
export const Example1OfSTU3 = Template.bind({});
|
|
55
|
+
Example1OfSTU3.args = {
|
|
56
|
+
fhirVersion: fhirVersions.STU3,
|
|
57
|
+
fhirResource: stu3Example1,
|
|
79
58
|
};
|
|
80
59
|
|
|
81
|
-
export const Example2OfSTU3 = ()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fhirResource={fhirResource}
|
|
86
|
-
fhirVersion={fhirVersions.STU3}
|
|
87
|
-
fhirIcons={fhirIcons}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
60
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
61
|
+
Example2OfSTU3.args = {
|
|
62
|
+
fhirVersion: fhirVersions.STU3,
|
|
63
|
+
fhirResource: stu3Example2,
|
|
90
64
|
};
|
|
91
65
|
|
|
92
|
-
export const Example3OfSTU3 = ()
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
fhirResource={fhirResource}
|
|
97
|
-
fhirVersion={fhirVersions.STU3}
|
|
98
|
-
fhirIcons={fhirIcons}
|
|
99
|
-
/>
|
|
100
|
-
);
|
|
66
|
+
export const Example3OfSTU3 = Template.bind({});
|
|
67
|
+
Example3OfSTU3.args = {
|
|
68
|
+
fhirVersion: fhirVersions.STU3,
|
|
69
|
+
fhirResource: stu3Example3,
|
|
101
70
|
};
|
|
102
71
|
|
|
103
|
-
export const Example4OfSTU3 = ()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
fhirResource={fhirResource}
|
|
108
|
-
fhirVersion={fhirVersions.STU3}
|
|
109
|
-
fhirIcons={fhirIcons}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
72
|
+
export const Example4OfSTU3 = Template.bind({});
|
|
73
|
+
Example4OfSTU3.args = {
|
|
74
|
+
fhirVersion: fhirVersions.STU3,
|
|
75
|
+
fhirResource: stu3Example4,
|
|
112
76
|
};
|
|
113
77
|
|
|
114
|
-
export const Example1OfR4 = ()
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
fhirResource={fhirResource}
|
|
119
|
-
fhirVersion={fhirVersions.R4}
|
|
120
|
-
fhirIcons={fhirIcons}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
78
|
+
export const Example1OfR4 = Template.bind({});
|
|
79
|
+
Example1OfR4.args = {
|
|
80
|
+
fhirVersion: fhirVersions.R4,
|
|
81
|
+
fhirResource: r4Example1,
|
|
123
82
|
};
|
|
124
83
|
|
|
125
|
-
export const Example2OfR4 = ()
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
fhirResource={fhirResource}
|
|
130
|
-
fhirVersion={fhirVersions.R4}
|
|
131
|
-
fhirIcons={fhirIcons}
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
84
|
+
export const Example2OfR4 = Template.bind({});
|
|
85
|
+
Example2OfR4.args = {
|
|
86
|
+
fhirVersion: fhirVersions.R4,
|
|
87
|
+
fhirResource: r4Example2,
|
|
134
88
|
};
|
|
135
89
|
|
|
136
|
-
export const Example3OfR4 = ()
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
fhirResource={fhirResource}
|
|
141
|
-
fhirVersion={fhirVersions.R4}
|
|
142
|
-
fhirIcons={fhirIcons}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
90
|
+
export const Example3OfR4 = Template.bind({});
|
|
91
|
+
Example3OfR4.args = {
|
|
92
|
+
fhirVersion: fhirVersions.R4,
|
|
93
|
+
fhirResource: r4Example3,
|
|
145
94
|
};
|
|
146
95
|
|
|
147
|
-
export const Example4OfR4 = ()
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
fhirResource={fhirResource}
|
|
152
|
-
fhirVersion={fhirVersions.R4}
|
|
153
|
-
fhirIcons={fhirIcons}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
96
|
+
export const Example4OfR4 = Template.bind({});
|
|
97
|
+
Example4OfR4.args = {
|
|
98
|
+
fhirVersion: fhirVersions.R4,
|
|
99
|
+
fhirResource: r4Example4,
|
|
156
100
|
};
|
|
157
101
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
102
|
+
export const ExampleWithoutFHIRVersionProperty = Template.bind({});
|
|
103
|
+
ExampleWithoutFHIRVersionProperty.args = {
|
|
104
|
+
fhirResource: stu3Example2,
|
|
105
|
+
};
|
|
@@ -8,8 +8,6 @@ import dstu2Example2 from '../../../fixtures/dstu2/resources/bundle/example3.jso
|
|
|
8
8
|
import stu3Example1 from '../../../fixtures/stu3/resources/bundle/example1.json';
|
|
9
9
|
import r4Example1 from '../../../fixtures/r4/resources/bundle/example1.json';
|
|
10
10
|
|
|
11
|
-
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
-
|
|
13
11
|
describe('Bundle should render component correctly', () => {
|
|
14
12
|
it('should render component correctly with DSTU2 source data', () => {
|
|
15
13
|
const defaultProps = {
|
|
@@ -31,7 +29,6 @@ describe('Bundle should render component correctly', () => {
|
|
|
31
29
|
const defaultProps = {
|
|
32
30
|
fhirVersion: fhirVersions.DSTU2,
|
|
33
31
|
fhirResource: dstu2Example2,
|
|
34
|
-
fhirIcons: fhirIcons,
|
|
35
32
|
};
|
|
36
33
|
const { getByText, getAllByTestId } = render(<Bundle {...defaultProps} />);
|
|
37
34
|
expect(getAllByTestId('title').map(title => title.textContent)).toEqual([
|
|
@@ -162,7 +162,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
const CarePlan = ({
|
|
165
|
+
const CarePlan = ({
|
|
166
|
+
fhirResource,
|
|
167
|
+
fhirVersion,
|
|
168
|
+
fhirIcons,
|
|
169
|
+
onClick,
|
|
170
|
+
rawOnClick,
|
|
171
|
+
}) => {
|
|
166
172
|
let fhirResourceData = {};
|
|
167
173
|
try {
|
|
168
174
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -304,6 +310,8 @@ const CarePlan = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
304
310
|
)}
|
|
305
311
|
</Body>
|
|
306
312
|
}
|
|
313
|
+
onClick={onClick}
|
|
314
|
+
rawOnClick={rawOnClick}
|
|
307
315
|
/>
|
|
308
316
|
</Root>
|
|
309
317
|
);
|