fhir-react 0.3.5 → 0.3.8
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/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +9 -8
- package/package.json +55 -54
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Coverage/coverage.svg +4 -0
- package/src/assets/containers/{ResourceCategory/resource-placeholder.svg → Generic/generic.svg} +0 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
- package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
- package/src/assets/containers/Organization/organization.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/assets/containers/ResourceCategory/resource-category.svg +3 -0
- package/src/components/containers/Accordion/Accordion.js +21 -13
- package/src/components/datatypes/Attachment/Attachment.css +5 -0
- package/src/components/datatypes/Attachment/Attachment.js +7 -2
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Identifier/Identifier.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -1
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/resources/AdverseEvent/AdverseEvent.js +81 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -5
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +5 -4
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +107 -1
- package/src/components/resources/Appointment/Appointment.js +2 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +1 -2
- package/src/components/resources/Binary/Binary.stories.js +10 -4
- package/src/components/resources/Binary/Binary.test.js +67 -0
- 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 +12 -78
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +2 -1
- package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
- package/src/components/resources/CarePlan/CarePlan.test.js +114 -6
- package/src/components/resources/CareTeam/CareTeam.js +72 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- package/src/components/resources/Claim/CareTeam.js +55 -0
- package/src/components/resources/Claim/Claim.css +2 -11
- package/src/components/resources/Claim/Claim.js +158 -309
- package/src/components/resources/Claim/Claim.stories.js +37 -5
- package/src/components/resources/Claim/Claim.test.js +104 -1
- package/src/components/resources/Claim/Diagnosis.js +61 -0
- package/src/components/resources/Claim/Insurance.js +58 -0
- package/src/components/resources/Claim/Item.js +79 -0
- package/src/components/resources/Claim/Items.js +29 -0
- 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 +137 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
- 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 +3 -3
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +97 -69
- package/src/components/resources/Coverage/Coverage.stories.js +31 -5
- package/src/components/resources/Coverage/Coverage.test.js +111 -4
- package/src/components/resources/Device/Device.js +2 -1
- package/src/components/resources/Device/Device.stories.js +33 -5
- package/src/components/resources/Device/Device.test.js +108 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +5 -4
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +107 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +3 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +113 -1
- package/src/components/resources/Encounter/Encounter.js +2 -1
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +2 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +7 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +3 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +108 -1
- package/src/components/resources/Generic/Generic.js +20 -7
- package/src/components/resources/Generic/Generic.stories.js +2 -1
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +3 -5
- package/src/components/resources/Goal/Goal.stories.js +5 -4
- package/src/components/resources/Goal/Goal.test.js +101 -1
- package/src/components/resources/Immunization/Immunization.js +2 -2
- 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 +135 -88
- package/src/components/resources/List/List.stories.js +38 -5
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +65 -47
- package/src/components/resources/Location/Location.stories.js +11 -4
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +91 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +113 -4
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +86 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
- 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 +68 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +115 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -4
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +1 -2
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +102 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +3 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +11 -6
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +100 -4
- package/src/components/resources/MedicationStatement/MedicationDosage.js +2 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.js +8 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +5 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +108 -1
- package/src/components/resources/Observation/Observation.js +2 -1
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Organization/Organization.js +56 -37
- package/src/components/resources/Organization/Organization.stories.js +15 -2
- package/src/components/resources/Organization/Organization.test.js +109 -1
- package/src/components/resources/Patient/Patient.js +2 -0
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +2 -1
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +50 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +2 -2
- 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 +31 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
- 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 +52 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
- 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 +65 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +151 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -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 +160 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
- package/src/components/ui/index.js +32 -12
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +81 -11
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +3 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
|
|
4
4
|
import { fhirVersions } from '../../../index';
|
|
5
5
|
|
|
@@ -7,8 +7,80 @@ import MedicationKnowledge from './MedicationKnowledge';
|
|
|
7
7
|
|
|
8
8
|
import example1R4 from '../../../fixtures/r4/resources/medicationKnowledge/example1.json';
|
|
9
9
|
import example2R4 from '../../../fixtures/r4/resources/medicationKnowledge/example2.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render MedicationKnowledge component properly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirVersion: fhirVersions.R4,
|
|
16
|
+
fhirResource: example1R4,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<MedicationKnowledge {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('medication knowledge');
|
|
21
|
+
|
|
22
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fhirVersion: fhirVersions.R4,
|
|
28
|
+
fhirResource: example1R4,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<MedicationKnowledge {...defaultProps} />);
|
|
33
|
+
const headerIcon = getByTestId('placeholder');
|
|
34
|
+
|
|
35
|
+
expect(headerIcon).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
fhirVersion: fhirVersions.R4,
|
|
41
|
+
fhirResource: example1R4,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/MedicationKnowledge/medication-knowledge.svg')}
|
|
45
|
+
alt="pill database"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<MedicationKnowledge {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('pill database');
|
|
52
|
+
|
|
53
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
57
|
+
const defaultProps = {
|
|
58
|
+
fhirVersion: fhirVersions.R4,
|
|
59
|
+
fhirResource: example1R4,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<MedicationKnowledge {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('pill database');
|
|
65
|
+
|
|
66
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
70
|
+
const avatarSrc =
|
|
71
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
72
|
+
const defaultProps = {
|
|
73
|
+
fhirVersion: fhirVersions.R4,
|
|
74
|
+
fhirResource: example1R4,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<MedicationKnowledge {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
83
|
+
|
|
12
84
|
it('should render with R4 source data', () => {
|
|
13
85
|
const defaultProps = {
|
|
14
86
|
fhirResource: example1R4,
|
|
@@ -66,4 +138,41 @@ describe('should render MedicationKnowledge component properly', () => {
|
|
|
66
138
|
'(preferred-generic)',
|
|
67
139
|
);
|
|
68
140
|
});
|
|
141
|
+
|
|
142
|
+
it('should fire custom onClick function', () => {
|
|
143
|
+
const defaultProps = {
|
|
144
|
+
fhirResource: example2R4,
|
|
145
|
+
fhirVersion: fhirVersions.R4,
|
|
146
|
+
withDaVinciPDex: true,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const onClick = jest.fn();
|
|
150
|
+
const { getByRole } = render(
|
|
151
|
+
<MedicationKnowledge {...defaultProps} onClick={onClick} />,
|
|
152
|
+
);
|
|
153
|
+
const accordion = getByRole('button');
|
|
154
|
+
fireEvent.click(accordion);
|
|
155
|
+
|
|
156
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
157
|
+
expect(attribute).not.toEqual('collapse');
|
|
158
|
+
expect(onClick).toHaveBeenCalled();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should not fire custom onClick function', () => {
|
|
162
|
+
const defaultProps = {
|
|
163
|
+
fhirResource: example2R4,
|
|
164
|
+
fhirVersion: fhirVersions.R4,
|
|
165
|
+
withDaVinciPDex: true,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const onClick = 'test';
|
|
169
|
+
const { getByRole } = render(
|
|
170
|
+
<MedicationKnowledge {...defaultProps} onClick={onClick} />,
|
|
171
|
+
);
|
|
172
|
+
const accordion = getByRole('button');
|
|
173
|
+
fireEvent.click(accordion);
|
|
174
|
+
|
|
175
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
176
|
+
expect(attribute).toEqual('collapse');
|
|
177
|
+
});
|
|
69
178
|
});
|
|
@@ -8,9 +8,7 @@ import Coding from '../../datatypes/Coding';
|
|
|
8
8
|
|
|
9
9
|
import { Root, Header, Body } from '../../ui';
|
|
10
10
|
|
|
11
|
-
const MedicationOrder =
|
|
12
|
-
const { fhirResource, fhirIcons } = props;
|
|
13
|
-
const headerIcon = fhirIcons && fhirIcons['Medication'];
|
|
11
|
+
const MedicationOrder = ({ fhirResource, fhirIcons, onClick }) => {
|
|
14
12
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
15
13
|
const medicationCodeableConcept = _get(
|
|
16
14
|
fhirResource,
|
|
@@ -56,7 +54,7 @@ const MedicationOrder = props => {
|
|
|
56
54
|
<Accordion
|
|
57
55
|
headerContent={
|
|
58
56
|
<Header
|
|
59
|
-
icon={
|
|
57
|
+
icon={fhirIcons}
|
|
60
58
|
resourceName="MedicationOrder"
|
|
61
59
|
title={
|
|
62
60
|
medicationReference && (
|
|
@@ -66,6 +64,7 @@ const MedicationOrder = props => {
|
|
|
66
64
|
/>
|
|
67
65
|
}
|
|
68
66
|
bodyContent={<Body tableData={tableData} />}
|
|
67
|
+
onClick={onClick}
|
|
69
68
|
/>
|
|
70
69
|
</Root>
|
|
71
70
|
);
|
|
@@ -4,7 +4,6 @@ import { object } from '@storybook/addon-knobs';
|
|
|
4
4
|
import MedicationOrder from './MedicationOrder';
|
|
5
5
|
|
|
6
6
|
import dstu2Example from '../../../fixtures/dstu2/resources/medicationOrder/example.json';
|
|
7
|
-
import fhirIcons from '../../../fixtures/example-icons';
|
|
8
7
|
|
|
9
8
|
export default {
|
|
10
9
|
title: 'MedicationOrder',
|
|
@@ -12,5 +11,5 @@ export default {
|
|
|
12
11
|
|
|
13
12
|
export const DefaultVisualizationDSTU2 = () => {
|
|
14
13
|
const fhirResource = object('Resource', dstu2Example);
|
|
15
|
-
return <MedicationOrder fhirResource={fhirResource}
|
|
14
|
+
return <MedicationOrder fhirResource={fhirResource} />;
|
|
16
15
|
};
|
|
@@ -1,11 +1,78 @@
|
|
|
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 MedicationOrder from './MedicationOrder';
|
|
5
5
|
|
|
6
6
|
import example from '../../../fixtures/dstu2/resources/medicationOrder/example.json';
|
|
7
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
7
8
|
|
|
8
9
|
describe('should render MedicationOrder component properly', () => {
|
|
10
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
11
|
+
const defaultProps = {
|
|
12
|
+
fhirResource: example,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
16
|
+
const headerIcon = getByAltText('medication order');
|
|
17
|
+
|
|
18
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
fhirResource: example,
|
|
24
|
+
fhirIcons: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const { getByTestId } = render(<MedicationOrder {...defaultProps} />);
|
|
28
|
+
const headerIcon = getByTestId('placeholder');
|
|
29
|
+
|
|
30
|
+
expect(headerIcon).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
34
|
+
const defaultProps = {
|
|
35
|
+
fhirResource: example,
|
|
36
|
+
fhirIcons: (
|
|
37
|
+
<img
|
|
38
|
+
src={require('../assets/containers/MedicationOrder/medication-order.svg')}
|
|
39
|
+
alt="medication order"
|
|
40
|
+
/>
|
|
41
|
+
),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
45
|
+
const headerIcon = getByAltText('medication order');
|
|
46
|
+
|
|
47
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
51
|
+
const defaultProps = {
|
|
52
|
+
fhirResource: example,
|
|
53
|
+
fhirIcons: fhirIcons,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
57
|
+
const headerIcon = getByAltText('medication order');
|
|
58
|
+
|
|
59
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
63
|
+
const avatarSrc =
|
|
64
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
65
|
+
const defaultProps = {
|
|
66
|
+
fhirResource: example,
|
|
67
|
+
fhirIcons: avatarSrc,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
|
|
71
|
+
const headerIcon = getByAltText('header icon');
|
|
72
|
+
|
|
73
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
74
|
+
});
|
|
75
|
+
|
|
9
76
|
it('should render with DSTU2 source data', () => {
|
|
10
77
|
const defaultProps = {
|
|
11
78
|
fhirResource: example,
|
|
@@ -13,12 +80,43 @@ describe('should render MedicationOrder component properly', () => {
|
|
|
13
80
|
|
|
14
81
|
const { getByTestId } = render(<MedicationOrder {...defaultProps} />);
|
|
15
82
|
|
|
16
|
-
expect(getByTestId('title').textContent).toContain(
|
|
17
|
-
'Medication/MedicationExample2',
|
|
18
|
-
);
|
|
83
|
+
expect(getByTestId('title').textContent).toContain('prescribed medication');
|
|
19
84
|
expect(getByTestId('reasonCode').textContent).toContain('Otitis Media');
|
|
20
85
|
expect(getByTestId('hasDosageInstruction').textContent).toContain(
|
|
21
86
|
'Take 5ml three times daily',
|
|
22
87
|
);
|
|
23
88
|
});
|
|
89
|
+
|
|
90
|
+
it('should fire custom onClick function', () => {
|
|
91
|
+
const defaultProps = {
|
|
92
|
+
fhirResource: example,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const onClick = jest.fn();
|
|
96
|
+
const { getByRole } = render(
|
|
97
|
+
<MedicationOrder {...defaultProps} onClick={onClick} />,
|
|
98
|
+
);
|
|
99
|
+
const accordion = getByRole('button');
|
|
100
|
+
fireEvent.click(accordion);
|
|
101
|
+
|
|
102
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
103
|
+
expect(attribute).not.toEqual('collapse');
|
|
104
|
+
expect(onClick).toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should not fire custom onClick function', () => {
|
|
108
|
+
const defaultProps = {
|
|
109
|
+
fhirResource: example,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const onClick = 'test';
|
|
113
|
+
const { getByRole } = render(
|
|
114
|
+
<MedicationOrder {...defaultProps} onClick={onClick} />,
|
|
115
|
+
);
|
|
116
|
+
const accordion = getByRole('button');
|
|
117
|
+
fireEvent.click(accordion);
|
|
118
|
+
|
|
119
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
120
|
+
expect(attribute).toEqual('collapse');
|
|
121
|
+
});
|
|
24
122
|
});
|
|
@@ -9,9 +9,7 @@ import Date from '../../datatypes/Date';
|
|
|
9
9
|
|
|
10
10
|
import { Root, Header, Body } from '../../ui';
|
|
11
11
|
|
|
12
|
-
const MedicationRequest =
|
|
13
|
-
const { fhirResource, fhirIcons } = props;
|
|
14
|
-
const headerIcon = fhirIcons && fhirIcons['Medication'];
|
|
12
|
+
const MedicationRequest = ({ fhirResource, fhirIcons, onClick }) => {
|
|
15
13
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
16
14
|
const medicationCodeableConcept = _get(
|
|
17
15
|
fhirResource,
|
|
@@ -77,7 +75,7 @@ const MedicationRequest = props => {
|
|
|
77
75
|
<Accordion
|
|
78
76
|
headerContent={
|
|
79
77
|
<Header
|
|
80
|
-
icon={
|
|
78
|
+
icon={fhirIcons}
|
|
81
79
|
resourceName="MedicationRequest"
|
|
82
80
|
title={
|
|
83
81
|
medicationReference ? (
|
|
@@ -89,6 +87,7 @@ const MedicationRequest = props => {
|
|
|
89
87
|
/>
|
|
90
88
|
}
|
|
91
89
|
bodyContent={<Body tableData={tableData} />}
|
|
90
|
+
onClick={onClick}
|
|
92
91
|
/>
|
|
93
92
|
</Root>
|
|
94
93
|
);
|
|
@@ -9,6 +9,7 @@ import R4Example1 from '../../../fixtures/r4/resources/medicationRequest/example
|
|
|
9
9
|
import R4Example2 from '../../../fixtures/r4/resources/medicationRequest/example2.json';
|
|
10
10
|
import R4Example3 from '../../../fixtures/r4/resources/medicationRequest/example3.json';
|
|
11
11
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import MedicationRequestIcon from '../../../assets/containers/MedicationRequest/medication-request.svg';
|
|
12
13
|
|
|
13
14
|
export default {
|
|
14
15
|
title: 'MedicationRequest',
|
|
@@ -17,14 +18,20 @@ export default {
|
|
|
17
18
|
export const DefaultVisualizationSTU3 = () => {
|
|
18
19
|
const fhirResource = object('Resource', stu3Example1);
|
|
19
20
|
return (
|
|
20
|
-
<MedicationRequest
|
|
21
|
+
<MedicationRequest
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={require('../../../assets/containers/MedicationRequest/medication-request.svg')}
|
|
24
|
+
/>
|
|
21
25
|
);
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
export const Example2OfSTU3 = () => {
|
|
25
29
|
const fhirResource = object('Resource', stu3Example2);
|
|
26
30
|
return (
|
|
27
|
-
<MedicationRequest
|
|
31
|
+
<MedicationRequest
|
|
32
|
+
fhirResource={fhirResource}
|
|
33
|
+
fhirIcons={MedicationRequestIcon}
|
|
34
|
+
/>
|
|
28
35
|
);
|
|
29
36
|
};
|
|
30
37
|
|
|
@@ -37,14 +44,12 @@ export const Example1OfR4 = () => {
|
|
|
37
44
|
|
|
38
45
|
export const Example2OfR4 = () => {
|
|
39
46
|
const fhirResource = object('Resource', R4Example2);
|
|
40
|
-
return
|
|
41
|
-
<MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
|
|
42
|
-
);
|
|
47
|
+
return <MedicationRequest fhirResource={fhirResource} fhirIcons={false} />;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
50
|
export const Example3OfR4 = () => {
|
|
46
51
|
const fhirResource = object('Resource', R4Example3);
|
|
47
52
|
return (
|
|
48
|
-
<MedicationRequest fhirResource={fhirResource} fhirIcons={
|
|
53
|
+
<MedicationRequest fhirResource={fhirResource} fhirIcons={'random text'} />
|
|
49
54
|
);
|
|
50
55
|
};
|
|
@@ -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 MedicationRequest from './MedicationRequest';
|
|
5
5
|
|
|
@@ -8,8 +8,75 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medicationRequest/exa
|
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/medicationRequest/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/medicationRequest/example2.json';
|
|
10
10
|
import r4Example3 from '../../../fixtures/r4/resources/medicationRequest/example3.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
describe('should render MedicationRequest component properly', () => {
|
|
14
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
fhirResource: stu3Example1,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('medication request');
|
|
21
|
+
|
|
22
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fhirResource: stu3Example1,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<MedicationRequest {...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
|
+
fhirResource: stu3Example1,
|
|
40
|
+
fhirIcons: (
|
|
41
|
+
<img
|
|
42
|
+
src={require('../assets/containers/MedicationOrder/medication-request.svg')}
|
|
43
|
+
alt="medication request"
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
49
|
+
const headerIcon = getByAltText('medication request');
|
|
50
|
+
|
|
51
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
55
|
+
const defaultProps = {
|
|
56
|
+
fhirResource: stu3Example1,
|
|
57
|
+
fhirIcons: fhirIcons,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
61
|
+
const headerIcon = getByAltText('medication request');
|
|
62
|
+
|
|
63
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
67
|
+
const avatarSrc =
|
|
68
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
69
|
+
const defaultProps = {
|
|
70
|
+
fhirResource: stu3Example1,
|
|
71
|
+
fhirIcons: avatarSrc,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const { getByAltText } = render(<MedicationRequest {...defaultProps} />);
|
|
75
|
+
const headerIcon = getByAltText('header icon');
|
|
76
|
+
|
|
77
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
78
|
+
});
|
|
79
|
+
|
|
13
80
|
it('should render with STU3 source data', () => {
|
|
14
81
|
const defaultProps = {
|
|
15
82
|
fhirResource: stu3Example1,
|
|
@@ -20,7 +87,7 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
20
87
|
);
|
|
21
88
|
expect(container).not.toBeNull();
|
|
22
89
|
|
|
23
|
-
expect(getByTestId('title').textContent).toContain('
|
|
90
|
+
expect(getByTestId('title').textContent).toContain('prescribed medication');
|
|
24
91
|
expect(getByTestId('reasonCode').textContent).toContain(
|
|
25
92
|
'Essential hypertension',
|
|
26
93
|
);
|
|
@@ -51,7 +118,7 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
51
118
|
);
|
|
52
119
|
expect(container).not.toBeNull();
|
|
53
120
|
|
|
54
|
-
expect(getByTestId('title').textContent).toContain('
|
|
121
|
+
expect(getByTestId('title').textContent).toContain('prescribed medication');
|
|
55
122
|
expect(getByTestId('reasonCode').textContent).toContain(
|
|
56
123
|
'Essential hypertension',
|
|
57
124
|
);
|
|
@@ -93,7 +160,7 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
93
160
|
);
|
|
94
161
|
expect(container).not.toBeNull();
|
|
95
162
|
|
|
96
|
-
expect(getByTestId('title').textContent).toContain('
|
|
163
|
+
expect(getByTestId('title').textContent).toContain('Myleran 2mg tablet');
|
|
97
164
|
expect(getByTestId('reasonCode').textContent).toContain(
|
|
98
165
|
'Chronic myeloid Leukemia',
|
|
99
166
|
);
|
|
@@ -104,4 +171,33 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
104
171
|
expect(getByTestId('created').textContent).toEqual('1/15/2015');
|
|
105
172
|
expect(getByTestId('intent').textContent).toEqual('order');
|
|
106
173
|
});
|
|
174
|
+
|
|
175
|
+
it('should fire custom onClick function', () => {
|
|
176
|
+
const defaultProps = { fhirResource: r4Example3 };
|
|
177
|
+
|
|
178
|
+
const onClick = jest.fn();
|
|
179
|
+
const { getByRole } = render(
|
|
180
|
+
<MedicationRequest {...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).not.toEqual('collapse');
|
|
187
|
+
expect(onClick).toHaveBeenCalled();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('should not fire custom onClick function', () => {
|
|
191
|
+
const defaultProps = { fhirResource: r4Example3 };
|
|
192
|
+
|
|
193
|
+
const onClick = 'test';
|
|
194
|
+
const { getByRole } = render(
|
|
195
|
+
<MedicationRequest {...defaultProps} onClick={onClick} />,
|
|
196
|
+
);
|
|
197
|
+
const accordion = getByRole('button');
|
|
198
|
+
fireEvent.click(accordion);
|
|
199
|
+
|
|
200
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
201
|
+
expect(attribute).toEqual('collapse');
|
|
202
|
+
});
|
|
107
203
|
});
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
4
|
|
|
5
5
|
const MedicationDosage = props => {
|
|
6
|
-
const { dosage, hasNote, note,
|
|
6
|
+
const { dosage, hasNote, note, itemNumber } = props;
|
|
7
7
|
|
|
8
8
|
const instructions = _get(dosage, 'text');
|
|
9
9
|
const additionalInstructionText = _get(
|
|
@@ -16,7 +16,7 @@ const MedicationDosage = props => {
|
|
|
16
16
|
const hasRoute = route.trim() !== '';
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
<ValueSection label="Dosage" key={
|
|
19
|
+
<ValueSection label="Dosage" key={itemNumber}>
|
|
20
20
|
<ValueSectionItem label="Instructions" data-testid="dosageInstruction">
|
|
21
21
|
{instructions}
|
|
22
22
|
</ValueSectionItem>
|
|
@@ -107,8 +107,12 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
const MedicationStatement =
|
|
111
|
-
|
|
110
|
+
const MedicationStatement = ({
|
|
111
|
+
fhirResource,
|
|
112
|
+
fhirVersion,
|
|
113
|
+
fhirIcons,
|
|
114
|
+
onClick,
|
|
115
|
+
}) => {
|
|
112
116
|
let fhirResourceData = {};
|
|
113
117
|
try {
|
|
114
118
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -172,6 +176,7 @@ const MedicationStatement = props => {
|
|
|
172
176
|
return (
|
|
173
177
|
<MedicationDetails
|
|
174
178
|
key={`item-${i}`}
|
|
179
|
+
itemNumber={`item-${i}`}
|
|
175
180
|
medication={_get(medication, 'code.coding[0].display')}
|
|
176
181
|
expiration={_get(
|
|
177
182
|
medication,
|
|
@@ -199,6 +204,7 @@ const MedicationStatement = props => {
|
|
|
199
204
|
})}
|
|
200
205
|
</Body>
|
|
201
206
|
}
|
|
207
|
+
onClick={onClick}
|
|
202
208
|
/>
|
|
203
209
|
</Root>
|
|
204
210
|
);
|
|
@@ -10,6 +10,7 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medicationStatement/e
|
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/medicationStatement/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/medicationStatement/example2.json';
|
|
12
12
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import MedicationStatementIcon from '../../../assets/containers/MedicationStatement/medication-statement.svg';
|
|
13
14
|
|
|
14
15
|
export default {
|
|
15
16
|
title: 'MedicationStatement',
|
|
@@ -21,7 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
21
22
|
<MedicationStatement
|
|
22
23
|
fhirVersion={fhirVersions.DSTU2}
|
|
23
24
|
fhirResource={fhirResource}
|
|
24
|
-
fhirIcons={
|
|
25
|
+
fhirIcons={require('../../../assets/containers/MedicationStatement/medication-statement.svg')}
|
|
25
26
|
/>
|
|
26
27
|
);
|
|
27
28
|
};
|
|
@@ -32,7 +33,7 @@ export const ExampleOfSTU3 = () => {
|
|
|
32
33
|
<MedicationStatement
|
|
33
34
|
fhirVersion={fhirVersions.STU3}
|
|
34
35
|
fhirResource={fhirResource}
|
|
35
|
-
fhirIcons={
|
|
36
|
+
fhirIcons={MedicationStatementIcon}
|
|
36
37
|
/>
|
|
37
38
|
);
|
|
38
39
|
};
|
|
@@ -54,7 +55,7 @@ export const Example1OfR4 = () => {
|
|
|
54
55
|
<MedicationStatement
|
|
55
56
|
fhirVersion={fhirVersions.R4}
|
|
56
57
|
fhirResource={fhirResource}
|
|
57
|
-
fhirIcons={
|
|
58
|
+
fhirIcons={false}
|
|
58
59
|
/>
|
|
59
60
|
);
|
|
60
61
|
};
|
|
@@ -65,7 +66,7 @@ export const Example2OfR4 = () => {
|
|
|
65
66
|
<MedicationStatement
|
|
66
67
|
fhirVersion={fhirVersions.R4}
|
|
67
68
|
fhirResource={fhirResource}
|
|
68
|
-
fhirIcons={
|
|
69
|
+
fhirIcons={'random text'}
|
|
69
70
|
/>
|
|
70
71
|
);
|
|
71
72
|
};
|