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 {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Location from './Location';
|
|
5
5
|
|
|
@@ -7,27 +7,39 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/location/example1.j
|
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/location/example1.json';
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/location/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/location/example2.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
|
+
import LocationIcon from '../../../assets/containers/Location/location.svg';
|
|
10
12
|
|
|
11
13
|
export default {
|
|
12
14
|
title: 'Location',
|
|
15
|
+
component: Location,
|
|
16
|
+
argTypes: {
|
|
17
|
+
...defaultArgTypes,
|
|
18
|
+
},
|
|
13
19
|
};
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const Template = args => <Location {...args} />;
|
|
22
|
+
|
|
23
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
24
|
+
DefaultVisualizationDSTU2.args = {
|
|
25
|
+
fhirResource: dstu2Example1,
|
|
26
|
+
fhirIcons: require('../../../assets/containers/Location/location.svg'),
|
|
18
27
|
};
|
|
19
28
|
|
|
20
|
-
export const ExampleOfSTU3 = ()
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
export const ExampleOfSTU3 = Template.bind({});
|
|
30
|
+
ExampleOfSTU3.args = {
|
|
31
|
+
fhirResource: stu3Example1,
|
|
32
|
+
fhirIcons: LocationIcon,
|
|
23
33
|
};
|
|
24
34
|
|
|
25
|
-
export const Example1OfR4 = ()
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
export const Example1OfR4 = Template.bind({});
|
|
36
|
+
Example1OfR4.args = {
|
|
37
|
+
fhirResource: r4Example1,
|
|
38
|
+
fhirIcons: fhirIcons,
|
|
28
39
|
};
|
|
29
40
|
|
|
30
|
-
export const Example2OfR4 = ()
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
export const Example2OfR4 = Template.bind({});
|
|
42
|
+
Example2OfR4.args = {
|
|
43
|
+
fhirResource: r4Example2,
|
|
44
|
+
fhirIcons: false,
|
|
33
45
|
};
|
|
@@ -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 Location from './Location';
|
|
5
5
|
|
|
@@ -7,8 +7,81 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/location/example1.j
|
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/location/example1.json';
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/location/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/location/example2.json';
|
|
10
|
+
import fhirVersions from '../fhirResourceVersions';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
12
|
|
|
11
13
|
describe('should render Location component properly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
fhirResource: dstu2Example1,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { getByAltText } = render(<Location {...defaultProps} />);
|
|
21
|
+
const headerIcon = getByAltText('location');
|
|
22
|
+
|
|
23
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirResource: dstu2Example1,
|
|
30
|
+
fhirIcons: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const { getByTestId } = render(<Location {...defaultProps} />);
|
|
34
|
+
const headerIcon = getByTestId('placeholder');
|
|
35
|
+
|
|
36
|
+
expect(headerIcon).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
40
|
+
const defaultProps = {
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirResource: dstu2Example1,
|
|
43
|
+
fhirIcons: (
|
|
44
|
+
<img
|
|
45
|
+
src={require('../assets/containers/Location/location.svg')}
|
|
46
|
+
alt="location marker"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { getByAltText } = render(<Location {...defaultProps} />);
|
|
52
|
+
const headerIcon = getByAltText('location marker');
|
|
53
|
+
|
|
54
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
58
|
+
const defaultProps = {
|
|
59
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirResource: dstu2Example1,
|
|
61
|
+
fhirIcons: fhirIcons,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const { getByAltText } = render(<Location {...defaultProps} />);
|
|
65
|
+
const headerIcon = getByAltText('location marker');
|
|
66
|
+
|
|
67
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
71
|
+
const avatarSrc =
|
|
72
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
73
|
+
const defaultProps = {
|
|
74
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirResource: dstu2Example1,
|
|
76
|
+
fhirIcons: avatarSrc,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { getByAltText } = render(<Location {...defaultProps} />);
|
|
80
|
+
const headerIcon = getByAltText('header icon');
|
|
81
|
+
|
|
82
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
83
|
+
});
|
|
84
|
+
|
|
12
85
|
it('should render with DSTU2 source data', () => {
|
|
13
86
|
const defaultProps = {
|
|
14
87
|
fhirResource: dstu2Example1,
|
|
@@ -31,7 +104,7 @@ describe('should render Location component properly', () => {
|
|
|
31
104
|
|
|
32
105
|
expect(getByTestId('address').textContent).toContain('Galapagosweg 91');
|
|
33
106
|
|
|
34
|
-
expect(getByTestId('telecom').textContent).toContain('
|
|
107
|
+
expect(getByTestId('telecom').textContent).toContain('2329');
|
|
35
108
|
|
|
36
109
|
expect(queryByTestId('type')).toBeNull();
|
|
37
110
|
|
|
@@ -66,7 +139,7 @@ describe('should render Location component properly', () => {
|
|
|
66
139
|
|
|
67
140
|
expect(getByTestId('address').textContent).toContain('Galapagosweg 91');
|
|
68
141
|
|
|
69
|
-
expect(getByTestId('telecom').textContent).toContain('
|
|
142
|
+
expect(getByTestId('telecom').textContent).toContain('2329');
|
|
70
143
|
|
|
71
144
|
expect(queryByTestId('type')).toBeNull();
|
|
72
145
|
|
|
@@ -101,7 +174,7 @@ describe('should render Location component properly', () => {
|
|
|
101
174
|
|
|
102
175
|
expect(getByTestId('address').textContent).toContain('Galapagosweg 91');
|
|
103
176
|
|
|
104
|
-
expect(getByTestId('telecom').textContent).toContain('
|
|
177
|
+
expect(getByTestId('telecom').textContent).toContain('2329');
|
|
105
178
|
|
|
106
179
|
expect(queryByTestId('type')).toBeNull();
|
|
107
180
|
|
|
@@ -146,4 +219,33 @@ describe('should render Location component properly', () => {
|
|
|
146
219
|
'Organization/f001',
|
|
147
220
|
);
|
|
148
221
|
});
|
|
222
|
+
|
|
223
|
+
it('should fire custom onClick function', () => {
|
|
224
|
+
const defaultProps = { fhirResource: r4Example1 };
|
|
225
|
+
|
|
226
|
+
const onClick = jest.fn();
|
|
227
|
+
const { getByRole } = render(
|
|
228
|
+
<Location {...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).not.toEqual('collapse');
|
|
235
|
+
expect(onClick).toHaveBeenCalled();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should not fire custom onClick function', () => {
|
|
239
|
+
const defaultProps = { fhirResource: r4Example1 };
|
|
240
|
+
|
|
241
|
+
const onClick = 'test';
|
|
242
|
+
const { getByRole } = render(
|
|
243
|
+
<Location {...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).toEqual('collapse');
|
|
250
|
+
});
|
|
149
251
|
});
|
|
@@ -162,7 +162,13 @@ const Ingredient = props => {
|
|
|
162
162
|
);
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
const Medication = ({
|
|
165
|
+
const Medication = ({
|
|
166
|
+
fhirResource,
|
|
167
|
+
fhirVersion,
|
|
168
|
+
fhirIcons,
|
|
169
|
+
onClick,
|
|
170
|
+
rawOnClick,
|
|
171
|
+
}) => {
|
|
166
172
|
let fhirResourceData = {};
|
|
167
173
|
try {
|
|
168
174
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -273,6 +279,8 @@ const Medication = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
273
279
|
)}
|
|
274
280
|
</Body>
|
|
275
281
|
}
|
|
282
|
+
onClick={onClick}
|
|
283
|
+
rawOnClick={rawOnClick}
|
|
276
284
|
/>
|
|
277
285
|
</Root>
|
|
278
286
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Medication from './Medication';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -16,79 +16,57 @@ import MedicationIcon from '../../../assets/containers/Medication/medication.svg
|
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
title: 'Medication',
|
|
19
|
+
component: Medication,
|
|
20
|
+
argTypes: {
|
|
21
|
+
...defaultArgTypes,
|
|
22
|
+
},
|
|
19
23
|
};
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
25
|
+
const Template = args => <Medication {...args} />;
|
|
26
|
+
|
|
27
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
28
|
+
DefaultVisualizationDSTU2.args = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: require('../../../assets/containers/Medication/medication.svg'),
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
export const Example2OfDSTU2 = ()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fhirResource={fhirResource}
|
|
38
|
-
fhirIcons={MedicationIcon}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
34
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
35
|
+
Example2OfDSTU2.args = {
|
|
36
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
37
|
+
fhirResource: dstu2Example2,
|
|
38
|
+
fhirIcons: MedicationIcon,
|
|
41
39
|
};
|
|
42
40
|
|
|
43
|
-
export const Example1OfSTU3 = ()
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
fhirResource={fhirResource}
|
|
49
|
-
fhirIcons={fhirIcons}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
41
|
+
export const Example1OfSTU3 = Template.bind({});
|
|
42
|
+
Example1OfSTU3.args = {
|
|
43
|
+
fhirVersion: fhirVersions.STU3,
|
|
44
|
+
fhirResource: stu3Example1,
|
|
45
|
+
fhirIcons: fhirIcons,
|
|
52
46
|
};
|
|
53
47
|
|
|
54
|
-
export const Example2OfSTU3 = ()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fhirResource={fhirResource}
|
|
60
|
-
fhirIcons={false}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
48
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
49
|
+
Example2OfSTU3.args = {
|
|
50
|
+
fhirVersion: fhirVersions.STU3,
|
|
51
|
+
fhirResource: stu3Example2,
|
|
52
|
+
fhirIcons: false,
|
|
63
53
|
};
|
|
64
54
|
|
|
65
|
-
export const Example1OfR4 = ()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
fhirResource={fhirResource}
|
|
71
|
-
fhirIcons={'random text'}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
55
|
+
export const Example1OfR4 = Template.bind({});
|
|
56
|
+
Example1OfR4.args = {
|
|
57
|
+
fhirVersion: fhirVersions.R4,
|
|
58
|
+
fhirResource: r4Example1,
|
|
59
|
+
fhirIcons: 'random text',
|
|
74
60
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
fhirResource={fhirResource}
|
|
81
|
-
fhirIcons={fhirIcons}
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
61
|
+
|
|
62
|
+
export const Example2OfR4 = Template.bind({});
|
|
63
|
+
Example2OfR4.args = {
|
|
64
|
+
fhirVersion: fhirVersions.R4,
|
|
65
|
+
fhirResource: r4Example2,
|
|
84
66
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
fhirResource={fhirResource}
|
|
91
|
-
fhirIcons={fhirIcons}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
67
|
+
|
|
68
|
+
export const Example3OfR4 = Template.bind({});
|
|
69
|
+
Example3OfR4.args = {
|
|
70
|
+
fhirVersion: fhirVersions.R4,
|
|
71
|
+
fhirResource: r4Example3,
|
|
94
72
|
};
|
|
@@ -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 Medication from './Medication';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -188,4 +188,39 @@ describe('should render Medication component properly', () => {
|
|
|
188
188
|
expect(queryByTestId('product-images')).toBeNull();
|
|
189
189
|
expect(getByTestId('product-ingredient').textContent).toContain('#sub04');
|
|
190
190
|
});
|
|
191
|
+
|
|
192
|
+
it('should fire custom onClick function', () => {
|
|
193
|
+
const defaultProps = {
|
|
194
|
+
fhirResource: r4Example2,
|
|
195
|
+
fhirVersion: fhirVersions.R4,
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const onClick = jest.fn();
|
|
199
|
+
const { getByRole } = render(
|
|
200
|
+
<Medication {...defaultProps} onClick={onClick} />,
|
|
201
|
+
);
|
|
202
|
+
const accordion = getByRole('button');
|
|
203
|
+
fireEvent.click(accordion);
|
|
204
|
+
|
|
205
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
206
|
+
expect(attribute).not.toEqual('collapse');
|
|
207
|
+
expect(onClick).toHaveBeenCalled();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should not fire custom onClick function', () => {
|
|
211
|
+
const defaultProps = {
|
|
212
|
+
fhirResource: r4Example2,
|
|
213
|
+
fhirVersion: fhirVersions.R4,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const onClick = 'test';
|
|
217
|
+
const { getByRole } = render(
|
|
218
|
+
<Medication {...defaultProps} onClick={onClick} />,
|
|
219
|
+
);
|
|
220
|
+
const accordion = getByRole('button');
|
|
221
|
+
fireEvent.click(accordion);
|
|
222
|
+
|
|
223
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
224
|
+
expect(attribute).toEqual('collapse');
|
|
225
|
+
});
|
|
191
226
|
});
|
|
@@ -9,16 +9,16 @@ import fhirVersions from '../fhirResourceVersions';
|
|
|
9
9
|
import {
|
|
10
10
|
Root,
|
|
11
11
|
Header,
|
|
12
|
-
Title,
|
|
13
12
|
Badge,
|
|
14
13
|
Body,
|
|
15
|
-
Value,
|
|
16
14
|
MissingValue,
|
|
17
15
|
TableHeader,
|
|
18
16
|
Table,
|
|
19
17
|
TableCell,
|
|
20
18
|
TableRow,
|
|
19
|
+
ValueSection,
|
|
21
20
|
} from '../../ui';
|
|
21
|
+
import Accordion from '../../containers/Accordion';
|
|
22
22
|
|
|
23
23
|
const commonDTO = fhirResource => {
|
|
24
24
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
@@ -110,8 +110,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
const MedicationAdministration =
|
|
114
|
-
|
|
113
|
+
const MedicationAdministration = ({
|
|
114
|
+
fhirResource,
|
|
115
|
+
fhirVersion,
|
|
116
|
+
fhirIcons,
|
|
117
|
+
onClick,
|
|
118
|
+
rawOnClick,
|
|
119
|
+
}) => {
|
|
115
120
|
let fhirResourceData = {};
|
|
116
121
|
try {
|
|
117
122
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -130,66 +135,87 @@ const MedicationAdministration = props => {
|
|
|
130
135
|
status,
|
|
131
136
|
} = fhirResourceData;
|
|
132
137
|
|
|
138
|
+
const tableData = [
|
|
139
|
+
{
|
|
140
|
+
label: 'Patient',
|
|
141
|
+
testId: 'patient',
|
|
142
|
+
data: subject && <Reference fhirData={subject} />,
|
|
143
|
+
status: subject,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: 'Practitioner',
|
|
147
|
+
testId: 'practitioner',
|
|
148
|
+
data: practitioner && <Reference fhirData={practitioner} />,
|
|
149
|
+
status: practitioner,
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
const tableContentData = [
|
|
154
|
+
{
|
|
155
|
+
testId: 'periodTimeStart',
|
|
156
|
+
data: periodTimeStart ? (
|
|
157
|
+
<Date fhirData={periodTimeStart} />
|
|
158
|
+
) : (
|
|
159
|
+
<MissingValue />
|
|
160
|
+
),
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
testId: 'periodTimeEnd',
|
|
164
|
+
data: periodTimeEnd ? (
|
|
165
|
+
<Date fhirData={periodTimeEnd} />
|
|
166
|
+
) : (
|
|
167
|
+
<MissingValue />
|
|
168
|
+
),
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
testId: 'dosageRoute',
|
|
172
|
+
data: dosageRoute ? <Coding fhirData={dosageRoute} /> : <MissingValue />,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
testId: 'dosageQuantity',
|
|
176
|
+
data: dosageQuantity ? dosageQuantity : <MissingValue />,
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
|
|
133
180
|
return (
|
|
134
181
|
<Root name="MedicationAdministration">
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
{periodTimeEnd ? (
|
|
173
|
-
<Date fhirData={periodTimeEnd} />
|
|
174
|
-
) : (
|
|
175
|
-
<MissingValue />
|
|
176
|
-
)}
|
|
177
|
-
</TableCell>
|
|
178
|
-
<TableCell data-testid="dosageRoute">
|
|
179
|
-
{dosageRoute ? (
|
|
180
|
-
<Coding fhirData={dosageRoute} />
|
|
181
|
-
) : (
|
|
182
|
-
<MissingValue />
|
|
183
|
-
)}
|
|
184
|
-
</TableCell>
|
|
185
|
-
<TableCell data-testid="dosageQuantity">
|
|
186
|
-
{dosageQuantity ? dosageQuantity : <MissingValue />}
|
|
187
|
-
</TableCell>
|
|
188
|
-
</TableRow>
|
|
189
|
-
</tbody>
|
|
190
|
-
</Table>
|
|
191
|
-
</div>
|
|
192
|
-
</Body>
|
|
182
|
+
<Accordion
|
|
183
|
+
headerContent={
|
|
184
|
+
<Header
|
|
185
|
+
resourceName="MedicationAdministration"
|
|
186
|
+
title={<Reference fhirData={medicationReference} />}
|
|
187
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
188
|
+
icon={fhirIcons}
|
|
189
|
+
/>
|
|
190
|
+
}
|
|
191
|
+
bodyContent={
|
|
192
|
+
<Body tableData={tableData}>
|
|
193
|
+
<ValueSection className="overflow-auto">
|
|
194
|
+
<Table>
|
|
195
|
+
<thead>
|
|
196
|
+
<TableRow>
|
|
197
|
+
<TableHeader>Period start</TableHeader>
|
|
198
|
+
<TableHeader>Period end</TableHeader>
|
|
199
|
+
<TableHeader>Dosage route</TableHeader>
|
|
200
|
+
<TableHeader>Dosage quantity</TableHeader>
|
|
201
|
+
</TableRow>
|
|
202
|
+
</thead>
|
|
203
|
+
<tbody className="border-top-0">
|
|
204
|
+
<TableRow>
|
|
205
|
+
{tableContentData.map((element, index) => (
|
|
206
|
+
<TableCell key={index} data-testid={element.testId}>
|
|
207
|
+
{element.data}
|
|
208
|
+
</TableCell>
|
|
209
|
+
))}
|
|
210
|
+
</TableRow>
|
|
211
|
+
</tbody>
|
|
212
|
+
</Table>
|
|
213
|
+
</ValueSection>
|
|
214
|
+
</Body>
|
|
215
|
+
}
|
|
216
|
+
onClick={onClick}
|
|
217
|
+
rawOnClick={rawOnClick}
|
|
218
|
+
/>
|
|
193
219
|
</Root>
|
|
194
220
|
);
|
|
195
221
|
};
|