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 Patient from './Patient';
|
|
5
5
|
|
|
@@ -15,44 +15,52 @@ import example3PatientR4 from '../../../fixtures/r4/resources/patient/example3.j
|
|
|
15
15
|
import PatientIcon from '../../../assets/containers/Patient/patient.svg';
|
|
16
16
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
17
17
|
|
|
18
|
-
export default {
|
|
18
|
+
export default {
|
|
19
|
+
title: 'Patient',
|
|
20
|
+
component: Patient,
|
|
21
|
+
argTypes: {
|
|
22
|
+
...defaultArgTypes,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Template = args => <Patient {...args} />;
|
|
19
27
|
|
|
20
|
-
export const DefaultVisualizationDSTU2 = ()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fhirResource={fhirResource}
|
|
25
|
-
fhirIcons={require('../../../assets/containers/Patient/patient.svg')}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
29
|
+
DefaultVisualizationDSTU2.args = {
|
|
30
|
+
fhirResource: examplePatient,
|
|
31
|
+
fhirIcons: require('../../../assets/containers/Patient/patient.svg'),
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
export const Example2OfDSTU2 = ()
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
35
|
+
Example2OfDSTU2.args = {
|
|
36
|
+
fhirResource: example2PatientDSTU2,
|
|
37
|
+
fhirIcons: PatientIcon,
|
|
33
38
|
};
|
|
34
39
|
|
|
35
|
-
export const ExampleSTU3 = ()
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
export const ExampleSTU3 = Template.bind({});
|
|
41
|
+
ExampleSTU3.args = {
|
|
42
|
+
fhirResource: examplePatientSTU3,
|
|
43
|
+
fhirIcons: fhirIcons,
|
|
38
44
|
};
|
|
39
45
|
|
|
40
|
-
export const Example2STU3 = ()
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
export const Example2STU3 = Template.bind({});
|
|
47
|
+
Example2STU3.args = {
|
|
48
|
+
fhirResource: example2PatientSTU3,
|
|
49
|
+
fhirIcons: false,
|
|
43
50
|
};
|
|
44
51
|
|
|
45
|
-
export const Example1R4 = ()
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
export const Example1R4 = Template.bind({});
|
|
53
|
+
Example1R4.args = {
|
|
54
|
+
fhirResource: example1PatientR4,
|
|
55
|
+
fhirIcons: 'random text',
|
|
48
56
|
};
|
|
49
57
|
|
|
50
|
-
export const Example2R4 = ()
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
export const Example2R4 = Template.bind({});
|
|
59
|
+
Example2R4.args = {
|
|
60
|
+
fhirResource: example2PatientR4,
|
|
53
61
|
};
|
|
54
62
|
|
|
55
|
-
export const Example3R4 = ()
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
export const Example3R4 = Template.bind({});
|
|
64
|
+
Example3R4.args = {
|
|
65
|
+
fhirResource: example3PatientR4,
|
|
58
66
|
};
|
|
@@ -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 Patient from './Patient';
|
|
4
4
|
|
|
5
5
|
import examplePatient from '../../../fixtures/dstu2/resources/patient/example.json';
|
|
@@ -38,7 +38,7 @@ describe('should render component correctly', () => {
|
|
|
38
38
|
fhirResource: examplePatient,
|
|
39
39
|
fhirIcons: (
|
|
40
40
|
<img
|
|
41
|
-
src={require('../assets/containers/
|
|
41
|
+
src={require('../assets/containers/Patient/patient.svg')}
|
|
42
42
|
alt="patient"
|
|
43
43
|
/>
|
|
44
44
|
),
|
|
@@ -156,4 +156,33 @@ describe('should render component correctly', () => {
|
|
|
156
156
|
const { getByTestId } = render(<Patient {...defaultProps} />);
|
|
157
157
|
expect(getByTestId('deceasedInfo').textContent).toEqual('2/14/2015');
|
|
158
158
|
});
|
|
159
|
+
|
|
160
|
+
it('should fire custom onClick function', () => {
|
|
161
|
+
const defaultProps = { fhirResource: example3PatientR4 };
|
|
162
|
+
|
|
163
|
+
const onClick = jest.fn();
|
|
164
|
+
const { getByRole } = render(
|
|
165
|
+
<Patient {...defaultProps} onClick={onClick} />,
|
|
166
|
+
);
|
|
167
|
+
const accordion = getByRole('button');
|
|
168
|
+
fireEvent.click(accordion);
|
|
169
|
+
|
|
170
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
171
|
+
expect(attribute).not.toEqual('collapse');
|
|
172
|
+
expect(onClick).toHaveBeenCalled();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should not fire custom onClick function', () => {
|
|
176
|
+
const defaultProps = { fhirResource: example3PatientR4 };
|
|
177
|
+
|
|
178
|
+
const onClick = 'test';
|
|
179
|
+
const { getByRole } = render(
|
|
180
|
+
<Patient {...defaultProps} onClick={onClick} />,
|
|
181
|
+
);
|
|
182
|
+
const accordion = getByRole('button');
|
|
183
|
+
fireEvent.click(accordion);
|
|
184
|
+
|
|
185
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
186
|
+
expect(attribute).toEqual('collapse');
|
|
187
|
+
});
|
|
159
188
|
});
|
|
@@ -82,7 +82,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const Practitioner = ({
|
|
85
|
+
const Practitioner = ({
|
|
86
|
+
fhirResource,
|
|
87
|
+
fhirVersion,
|
|
88
|
+
fhirIcons,
|
|
89
|
+
onClick,
|
|
90
|
+
rawOnClick,
|
|
91
|
+
}) => {
|
|
86
92
|
let fhirResourceData = {};
|
|
87
93
|
try {
|
|
88
94
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -160,6 +166,8 @@ const Practitioner = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
160
166
|
/>
|
|
161
167
|
}
|
|
162
168
|
bodyContent={<Body tableData={tableData} />}
|
|
169
|
+
onClick={onClick}
|
|
170
|
+
rawOnClick={rawOnClick}
|
|
163
171
|
/>
|
|
164
172
|
</Root>
|
|
165
173
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import Practitioner from './Practitioner';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -14,66 +14,53 @@ import r4Example3 from '../../../fixtures/r4/resources/practitioner/example3.jso
|
|
|
14
14
|
import PractitionerIcon from '../../../assets/containers/Practitioner/practitioner.svg';
|
|
15
15
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
16
16
|
|
|
17
|
-
export default {
|
|
17
|
+
export default {
|
|
18
|
+
title: 'Practitioner',
|
|
19
|
+
component: Practitioner,
|
|
20
|
+
argTypes: {
|
|
21
|
+
...defaultArgTypes,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Template = args => <Practitioner {...args} />;
|
|
18
26
|
|
|
19
|
-
export const DefaultVisualizationDSTU2 = ()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fhirResource={fhirResource}
|
|
25
|
-
fhirIcons={require('../../../assets/containers/Practitioner/practitioner.svg')}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
27
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
28
|
+
DefaultVisualizationDSTU2.args = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: require('../../../assets/containers/Practitioner/practitioner.svg'),
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
export const Example2OfDSTU2 = ()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fhirResource={fhirResource}
|
|
36
|
-
fhirIcons={PractitionerIcon}
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
34
|
+
export const Example2OfDSTU2 = Template.bind({});
|
|
35
|
+
Example2OfDSTU2.args = {
|
|
36
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
37
|
+
fhirResource: dstu2Example2,
|
|
38
|
+
fhirIcons: PractitionerIcon,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const ExampleOfSTU3 = ()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
fhirResource={fhirResource}
|
|
47
|
-
fhirIcons={fhirIcons}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
41
|
+
export const ExampleOfSTU3 = Template.bind({});
|
|
42
|
+
ExampleOfSTU3.args = {
|
|
43
|
+
fhirVersion: fhirVersions.STU3,
|
|
44
|
+
fhirResource: stu3Example1,
|
|
45
|
+
fhirIcons: fhirIcons,
|
|
50
46
|
};
|
|
51
47
|
|
|
52
|
-
export const Example1OfR4 = ()
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
fhirResource={fhirResource}
|
|
58
|
-
fhirIcons={false}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
48
|
+
export const Example1OfR4 = Template.bind({});
|
|
49
|
+
Example1OfR4.args = {
|
|
50
|
+
fhirVersion: fhirVersions.R4,
|
|
51
|
+
fhirResource: r4Example1,
|
|
52
|
+
fhirIcons: false,
|
|
61
53
|
};
|
|
62
54
|
|
|
63
|
-
export const Example2OfR4 = ()
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
fhirResource={fhirResource}
|
|
69
|
-
fhirIcons={'random text'}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
55
|
+
export const Example2OfR4 = Template.bind({});
|
|
56
|
+
Example2OfR4.args = {
|
|
57
|
+
fhirVersion: fhirVersions.R4,
|
|
58
|
+
fhirResource: r4Example2,
|
|
59
|
+
fhirIcons: 'random text',
|
|
72
60
|
};
|
|
73
61
|
|
|
74
|
-
export const Example3OfR4 = ()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
);
|
|
62
|
+
export const Example3OfR4 = Template.bind({});
|
|
63
|
+
Example3OfR4.args = {
|
|
64
|
+
fhirVersion: fhirVersions.R4,
|
|
65
|
+
fhirResource: r4Example3,
|
|
79
66
|
};
|
|
@@ -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 Practitioner from './Practitioner';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -170,4 +170,39 @@ describe('Practitioner should render component correctly', () => {
|
|
|
170
170
|
);
|
|
171
171
|
jest.restoreAllMocks();
|
|
172
172
|
});
|
|
173
|
+
|
|
174
|
+
it('should fire custom onClick function', () => {
|
|
175
|
+
const defaultProps = {
|
|
176
|
+
fhirVersion: fhirVersions.R4,
|
|
177
|
+
fhirResource: stu3Example1,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const onClick = jest.fn();
|
|
181
|
+
const { getByRole } = render(
|
|
182
|
+
<Practitioner {...defaultProps} onClick={onClick} />,
|
|
183
|
+
);
|
|
184
|
+
const accordion = getByRole('button');
|
|
185
|
+
fireEvent.click(accordion);
|
|
186
|
+
|
|
187
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
188
|
+
expect(attribute).not.toEqual('collapse');
|
|
189
|
+
expect(onClick).toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should not fire custom onClick function', () => {
|
|
193
|
+
const defaultProps = {
|
|
194
|
+
fhirVersion: fhirVersions.R4,
|
|
195
|
+
fhirResource: stu3Example1,
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const onClick = 'test';
|
|
199
|
+
const { getByRole } = render(
|
|
200
|
+
<Practitioner {...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).toEqual('collapse');
|
|
207
|
+
});
|
|
173
208
|
});
|
|
@@ -5,8 +5,9 @@ import _get from 'lodash/get';
|
|
|
5
5
|
import Reference from '../../datatypes/Reference';
|
|
6
6
|
import fhirVersions from '../fhirResourceVersions';
|
|
7
7
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
8
|
-
import { Root, Header,
|
|
8
|
+
import { Root, Header, Body, Badge } from '../../ui';
|
|
9
9
|
import CodeableConcept from '../../datatypes/CodeableConcept/CodeableConcept';
|
|
10
|
+
import Accordion from '../../containers/Accordion';
|
|
10
11
|
|
|
11
12
|
const commonDTO = fhirResource => {
|
|
12
13
|
const status = _get(fhirResource, 'active') === true ? 'active' : '';
|
|
@@ -42,8 +43,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
const PractitionerRole =
|
|
46
|
-
|
|
46
|
+
const PractitionerRole = ({
|
|
47
|
+
fhirResource,
|
|
48
|
+
fhirVersion,
|
|
49
|
+
fhirIcons,
|
|
50
|
+
onClick,
|
|
51
|
+
rawOnClick,
|
|
52
|
+
}) => {
|
|
47
53
|
let fhirResourceData = {};
|
|
48
54
|
try {
|
|
49
55
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -58,34 +64,51 @@ const PractitionerRole = props => {
|
|
|
58
64
|
organization,
|
|
59
65
|
practitioner,
|
|
60
66
|
} = fhirResourceData;
|
|
67
|
+
|
|
68
|
+
const tableData = [
|
|
69
|
+
{
|
|
70
|
+
label: 'Practitioner',
|
|
71
|
+
testId: 'practitioner',
|
|
72
|
+
data: practitioner && <Reference fhirData={practitioner} />,
|
|
73
|
+
status: practitioner,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: 'Organization',
|
|
77
|
+
testId: 'organization',
|
|
78
|
+
data: organization && <Reference fhirData={organization} />,
|
|
79
|
+
status: organization,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: 'Specialties',
|
|
83
|
+
testId: 'specialties',
|
|
84
|
+
data: specialties.length > 0 && (
|
|
85
|
+
<CodeableConcept fhirData={specialties} isCursive />
|
|
86
|
+
),
|
|
87
|
+
status: specialties.length > 0,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: 'Roles',
|
|
91
|
+
testId: 'roles',
|
|
92
|
+
data: codes.length > 0 && <CodeableConcept fhirData={codes} isCursive />,
|
|
93
|
+
status: codes.length > 0,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
61
97
|
return (
|
|
62
98
|
<Root name="PractitionerRole">
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</Value>
|
|
77
|
-
)}
|
|
78
|
-
{specialties.length > 0 && (
|
|
79
|
-
<Value label="Specialties" data-testid="specialties">
|
|
80
|
-
<CodeableConcept fhirData={specialties} />
|
|
81
|
-
</Value>
|
|
82
|
-
)}
|
|
83
|
-
{codes.length > 0 && (
|
|
84
|
-
<Value label="Roles" data-testid="roles">
|
|
85
|
-
<CodeableConcept fhirData={codes} />
|
|
86
|
-
</Value>
|
|
87
|
-
)}
|
|
88
|
-
</Body>
|
|
99
|
+
<Accordion
|
|
100
|
+
headerContent={
|
|
101
|
+
<Header
|
|
102
|
+
resourceName="PractitionerRole"
|
|
103
|
+
title="Practitioner roles and specialties"
|
|
104
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
105
|
+
icon={fhirIcons}
|
|
106
|
+
/>
|
|
107
|
+
}
|
|
108
|
+
bodyContent={<Body tableData={tableData} />}
|
|
109
|
+
onClick={onClick}
|
|
110
|
+
rawOnClick={rawOnClick}
|
|
111
|
+
/>
|
|
89
112
|
</Root>
|
|
90
113
|
);
|
|
91
114
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import PractitionerRole from './PractitionerRole';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -12,75 +12,62 @@ import r4Example1 from '../../../fixtures/r4/resources/practitionerRole/example1
|
|
|
12
12
|
import r4Example2 from '../../../fixtures/r4/resources/practitionerRole/example2.json';
|
|
13
13
|
import r4Example3 from '../../../fixtures/r4/resources/practitionerRole/example3.json';
|
|
14
14
|
import r4Example4 from '../../../fixtures/r4/resources/practitionerRole/example4.json';
|
|
15
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
16
|
+
import PractitionerRoleIcon from '../../../assets/containers/PractitionerRole/practitioner-role.svg';
|
|
15
17
|
|
|
16
|
-
export default {
|
|
18
|
+
export default {
|
|
19
|
+
title: 'PractitionerRole',
|
|
20
|
+
component: PractitionerRole,
|
|
21
|
+
argTypes: {
|
|
22
|
+
...defaultArgTypes,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Template = args => <PractitionerRole {...args} />;
|
|
17
27
|
|
|
18
|
-
export const ExampleOfSTU3 = ()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fhirResource={fhirResource}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
28
|
+
export const ExampleOfSTU3 = Template.bind({});
|
|
29
|
+
ExampleOfSTU3.args = {
|
|
30
|
+
fhirVersion: fhirVersions.STU3,
|
|
31
|
+
fhirResource: stu3Example1,
|
|
32
|
+
fhirIcons: require('../../../assets/containers/PractitionerRole/practitioner-role.svg'),
|
|
26
33
|
};
|
|
27
34
|
|
|
28
|
-
export const Example2OfSTU3 = ()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
fhirResource={fhirResource}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
35
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
36
|
+
Example2OfSTU3.args = {
|
|
37
|
+
fhirVersion: fhirVersions.STU3,
|
|
38
|
+
fhirResource: stu3Example2,
|
|
39
|
+
fhirIcons: PractitionerRoleIcon,
|
|
36
40
|
};
|
|
37
41
|
|
|
38
|
-
export const Example3OfSTU3 = ()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fhirResource={fhirResource}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
42
|
+
export const Example3OfSTU3 = Template.bind({});
|
|
43
|
+
Example3OfSTU3.args = {
|
|
44
|
+
fhirVersion: fhirVersions.STU3,
|
|
45
|
+
fhirResource: stu3Example3,
|
|
46
|
+
fhirIcons: fhirIcons,
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
export const Example1OfR4 = ()
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
fhirResource={fhirResource}
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
49
|
+
export const Example1OfR4 = Template.bind({});
|
|
50
|
+
Example1OfR4.args = {
|
|
51
|
+
fhirVersion: fhirVersions.R4,
|
|
52
|
+
fhirResource: r4Example1,
|
|
53
|
+
fhirIcons: false,
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
export const Example2OfR4 = ()
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fhirResource={fhirResource}
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
56
|
+
export const Example2OfR4 = Template.bind({});
|
|
57
|
+
Example2OfR4.args = {
|
|
58
|
+
fhirVersion: fhirVersions.R4,
|
|
59
|
+
fhirResource: r4Example2,
|
|
60
|
+
fhirIcons: 'random text',
|
|
66
61
|
};
|
|
67
62
|
|
|
68
|
-
export const Example3OfR4 = ()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
fhirVersion={fhirVersions.R4}
|
|
73
|
-
fhirResource={fhirResource}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
63
|
+
export const Example3OfR4 = Template.bind({});
|
|
64
|
+
Example3OfR4.args = {
|
|
65
|
+
fhirVersion: fhirVersions.R4,
|
|
66
|
+
fhirResource: r4Example3,
|
|
76
67
|
};
|
|
77
68
|
|
|
78
|
-
export const Example4OfR4 = ()
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
fhirVersion={fhirVersions.R4}
|
|
83
|
-
fhirResource={fhirResource}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
69
|
+
export const Example4OfR4 = Template.bind({});
|
|
70
|
+
Example4OfR4.args = {
|
|
71
|
+
fhirVersion: fhirVersions.R4,
|
|
72
|
+
fhirResource: r4Example4,
|
|
86
73
|
};
|
|
@@ -1,13 +1,85 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import PractitionerRole from './PractitionerRole';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
6
6
|
import stu3Example1 from '../../../fixtures/stu3/resources/practitionerRole/example1.json';
|
|
7
7
|
import r4Example1 from '../../../fixtures/r4/resources/practitionerRole/example1.json';
|
|
8
8
|
import r4Example2 from '../../../fixtures/r4/resources/practitionerRole/example3.json';
|
|
9
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
10
|
|
|
10
11
|
describe('PractitionerRole should render component correctly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirVersion: fhirVersions.STU3,
|
|
15
|
+
fhirResource: stu3Example1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('practitioner role');
|
|
20
|
+
|
|
21
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
25
|
+
const defaultProps = {
|
|
26
|
+
fhirVersion: fhirVersions.STU3,
|
|
27
|
+
fhirResource: stu3Example1,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<PractitionerRole {...defaultProps} />);
|
|
32
|
+
const headerIcon = getByTestId('placeholder');
|
|
33
|
+
|
|
34
|
+
expect(headerIcon).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
38
|
+
const defaultProps = {
|
|
39
|
+
fhirVersion: fhirVersions.STU3,
|
|
40
|
+
fhirResource: stu3Example1,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/PractitionerRole/practitioner-role.svg')}
|
|
44
|
+
alt="practitioner role"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('practitioner role');
|
|
51
|
+
|
|
52
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
56
|
+
const defaultProps = {
|
|
57
|
+
fhirVersion: fhirVersions.STU3,
|
|
58
|
+
fhirResource: stu3Example1,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('practitioner role');
|
|
64
|
+
|
|
65
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
69
|
+
const avatarSrc =
|
|
70
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
71
|
+
const defaultProps = {
|
|
72
|
+
fhirVersion: fhirVersions.STU3,
|
|
73
|
+
fhirResource: stu3Example1,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<PractitionerRole {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
11
83
|
it('should render component correctly with STU3 source data', () => {
|
|
12
84
|
const defaultProps = {
|
|
13
85
|
fhirVersion: fhirVersions.STU3,
|
|
@@ -100,4 +172,39 @@ describe('PractitionerRole should render component correctly', () => {
|
|
|
100
172
|
);
|
|
101
173
|
jest.restoreAllMocks();
|
|
102
174
|
});
|
|
175
|
+
|
|
176
|
+
it('should fire custom onClick function', () => {
|
|
177
|
+
const defaultProps = {
|
|
178
|
+
fhirVersion: fhirVersions.R4,
|
|
179
|
+
fhirResource: stu3Example1,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const onClick = jest.fn();
|
|
183
|
+
const { getByRole } = render(
|
|
184
|
+
<PractitionerRole {...defaultProps} onClick={onClick} />,
|
|
185
|
+
);
|
|
186
|
+
const accordion = getByRole('button');
|
|
187
|
+
fireEvent.click(accordion);
|
|
188
|
+
|
|
189
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
190
|
+
expect(attribute).not.toEqual('collapse');
|
|
191
|
+
expect(onClick).toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should not fire custom onClick function', () => {
|
|
195
|
+
const defaultProps = {
|
|
196
|
+
fhirVersion: fhirVersions.R4,
|
|
197
|
+
fhirResource: stu3Example1,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const onClick = 'test';
|
|
201
|
+
const { getByRole } = render(
|
|
202
|
+
<PractitionerRole {...defaultProps} onClick={onClick} />,
|
|
203
|
+
);
|
|
204
|
+
const accordion = getByRole('button');
|
|
205
|
+
fireEvent.click(accordion);
|
|
206
|
+
|
|
207
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
208
|
+
expect(attribute).toEqual('collapse');
|
|
209
|
+
});
|
|
103
210
|
});
|