fhir-react 0.3.6 → 0.3.9
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 +11 -10
- 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/Generic/generic.svg +3 -0
- package/src/assets/containers/Medication/medication.svg +5 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.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/components/containers/Accordion/Accordion.js +44 -13
- 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 +23 -1
- 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 +88 -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 -1
- 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.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +2 -1
- 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 +9 -1
- 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 +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 +165 -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 +144 -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 +10 -3
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +104 -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 +9 -1
- 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.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
- 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.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
- 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 +2 -1
- 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.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +9 -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 +137 -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 +66 -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 +98 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +114 -5
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -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 +70 -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 +117 -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 -3
- 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.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
- 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.test.js +30 -1
- package/src/components/resources/Observation/ObservationGraph.js +1 -1
- package/src/components/resources/Organization/Organization.js +63 -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 +4 -0
- 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.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -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 +3 -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 +38 -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 +54 -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 +72 -40
- 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 +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 +167 -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 +1 -1
- package/src/components/ui/index.js +56 -32
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +63 -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
|
@@ -11,6 +11,8 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medication/example2.j
|
|
|
11
11
|
import r4Example1 from '../../../fixtures/r4/resources/medication/example1.json';
|
|
12
12
|
import r4Example2 from '../../../fixtures/r4/resources/medication/example2.json';
|
|
13
13
|
import r4Example3 from '../../../fixtures/r4/resources/medication/example3.json';
|
|
14
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
15
|
+
import MedicationIcon from '../../../assets/containers/Medication/medication.svg';
|
|
14
16
|
|
|
15
17
|
export default {
|
|
16
18
|
title: 'Medication',
|
|
@@ -19,46 +21,74 @@ export default {
|
|
|
19
21
|
export const DefaultVisualizationDSTU2 = () => {
|
|
20
22
|
const fhirResource = object('Resource', dstu2Example1);
|
|
21
23
|
return (
|
|
22
|
-
<Medication
|
|
24
|
+
<Medication
|
|
25
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
26
|
+
fhirResource={fhirResource}
|
|
27
|
+
fhirIcons={require('../../../assets/containers/Medication/medication.svg')}
|
|
28
|
+
/>
|
|
23
29
|
);
|
|
24
30
|
};
|
|
25
31
|
|
|
26
32
|
export const Example2OfDSTU2 = () => {
|
|
27
33
|
const fhirResource = object('Resource', dstu2Example2);
|
|
28
34
|
return (
|
|
29
|
-
<Medication
|
|
35
|
+
<Medication
|
|
36
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
37
|
+
fhirResource={fhirResource}
|
|
38
|
+
fhirIcons={MedicationIcon}
|
|
39
|
+
/>
|
|
30
40
|
);
|
|
31
41
|
};
|
|
32
42
|
|
|
33
43
|
export const Example1OfSTU3 = () => {
|
|
34
44
|
const fhirResource = object('Resource', stu3Example1);
|
|
35
45
|
return (
|
|
36
|
-
<Medication
|
|
46
|
+
<Medication
|
|
47
|
+
fhirVersion={fhirVersions.STU3}
|
|
48
|
+
fhirResource={fhirResource}
|
|
49
|
+
fhirIcons={fhirIcons}
|
|
50
|
+
/>
|
|
37
51
|
);
|
|
38
52
|
};
|
|
39
53
|
|
|
40
54
|
export const Example2OfSTU3 = () => {
|
|
41
55
|
const fhirResource = object('Resource', stu3Example2);
|
|
42
56
|
return (
|
|
43
|
-
<Medication
|
|
57
|
+
<Medication
|
|
58
|
+
fhirVersion={fhirVersions.STU3}
|
|
59
|
+
fhirResource={fhirResource}
|
|
60
|
+
fhirIcons={false}
|
|
61
|
+
/>
|
|
44
62
|
);
|
|
45
63
|
};
|
|
46
64
|
|
|
47
65
|
export const Example1OfR4 = () => {
|
|
48
66
|
const fhirResource = object('Resource', r4Example1);
|
|
49
67
|
return (
|
|
50
|
-
<Medication
|
|
68
|
+
<Medication
|
|
69
|
+
fhirVersion={fhirVersions.R4}
|
|
70
|
+
fhirResource={fhirResource}
|
|
71
|
+
fhirIcons={'random text'}
|
|
72
|
+
/>
|
|
51
73
|
);
|
|
52
74
|
};
|
|
53
75
|
export const Example2OfR4 = () => {
|
|
54
76
|
const fhirResource = object('Resource', r4Example2);
|
|
55
77
|
return (
|
|
56
|
-
<Medication
|
|
78
|
+
<Medication
|
|
79
|
+
fhirVersion={fhirVersions.R4}
|
|
80
|
+
fhirResource={fhirResource}
|
|
81
|
+
fhirIcons={fhirIcons}
|
|
82
|
+
/>
|
|
57
83
|
);
|
|
58
84
|
};
|
|
59
85
|
export const Example3OfR4 = () => {
|
|
60
86
|
const fhirResource = object('Resource', r4Example3);
|
|
61
87
|
return (
|
|
62
|
-
<Medication
|
|
88
|
+
<Medication
|
|
89
|
+
fhirVersion={fhirVersions.R4}
|
|
90
|
+
fhirResource={fhirResource}
|
|
91
|
+
fhirIcons={fhirIcons}
|
|
92
|
+
/>
|
|
63
93
|
);
|
|
64
94
|
};
|
|
@@ -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';
|
|
@@ -9,8 +9,80 @@ import stu3Example1 from '../../../fixtures/stu3/resources/medication/example1.j
|
|
|
9
9
|
import stu3Example2 from '../../../fixtures/stu3/resources/medication/example2.json';
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/medication/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/medication/example2.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
|
|
14
|
+
describe('should render Medication component properly', () => {
|
|
15
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
fhirResource: dstu2Example1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { getByAltText } = render(<Medication {...defaultProps} />);
|
|
22
|
+
const headerIcon = getByAltText('medication');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<Medication {...defaultProps} />);
|
|
35
|
+
const headerIcon = getByTestId('placeholder');
|
|
36
|
+
|
|
37
|
+
expect(headerIcon).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirResource: dstu2Example1,
|
|
44
|
+
fhirIcons: (
|
|
45
|
+
<img
|
|
46
|
+
src={require('../assets/containers/Medication/medication.svg')}
|
|
47
|
+
alt="medication"
|
|
48
|
+
/>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { getByAltText } = render(<Medication {...defaultProps} />);
|
|
53
|
+
const headerIcon = getByAltText('medication');
|
|
54
|
+
|
|
55
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
59
|
+
const defaultProps = {
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirResource: dstu2Example1,
|
|
62
|
+
fhirIcons: fhirIcons,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { getByAltText } = render(<Medication {...defaultProps} />);
|
|
66
|
+
const headerIcon = getByAltText('medication');
|
|
67
|
+
|
|
68
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
72
|
+
const avatarSrc =
|
|
73
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirResource: dstu2Example1,
|
|
77
|
+
fhirIcons: avatarSrc,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { getByAltText } = render(<Medication {...defaultProps} />);
|
|
81
|
+
const headerIcon = getByAltText('header icon');
|
|
82
|
+
|
|
83
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
84
|
+
});
|
|
12
85
|
|
|
13
|
-
describe('should render MedicationOrder component properly', () => {
|
|
14
86
|
it('should render with DSTU2 source data', () => {
|
|
15
87
|
const defaultProps = {
|
|
16
88
|
fhirResource: dstu2Example1,
|
|
@@ -41,7 +113,9 @@ describe('should render MedicationOrder component properly', () => {
|
|
|
41
113
|
fhirVersion: fhirVersions.STU3,
|
|
42
114
|
};
|
|
43
115
|
|
|
44
|
-
const { container, getByTestId } = render(
|
|
116
|
+
const { container, getByTestId, getByAltText } = render(
|
|
117
|
+
<Medication {...defaultProps} />,
|
|
118
|
+
);
|
|
45
119
|
expect(container).not.toBeNull();
|
|
46
120
|
|
|
47
121
|
expect(getByTestId('title').textContent).toContain(
|
|
@@ -56,8 +130,8 @@ describe('should render MedicationOrder component properly', () => {
|
|
|
56
130
|
);
|
|
57
131
|
expect(getByTestId('package-container').textContent).toContain('Vial');
|
|
58
132
|
|
|
59
|
-
expect(
|
|
60
|
-
'
|
|
133
|
+
expect(getByAltText('Vancomycin Image').src).toContain(
|
|
134
|
+
'https://www.drugs.com/images/pills/fio/AKN07410.JPG',
|
|
61
135
|
);
|
|
62
136
|
});
|
|
63
137
|
|
|
@@ -114,4 +188,39 @@ describe('should render MedicationOrder component properly', () => {
|
|
|
114
188
|
expect(queryByTestId('product-images')).toBeNull();
|
|
115
189
|
expect(getByTestId('product-ingredient').textContent).toContain('#sub04');
|
|
116
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
|
+
});
|
|
117
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
|
};
|
package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js
CHANGED
|
@@ -9,6 +9,8 @@ import r4Example1 from '../../../fixtures/r4/resources/medicationAdministration/
|
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/medicationAdministration/example2.json';
|
|
10
10
|
import r4Example3 from '../../../fixtures/r4/resources/medicationAdministration/example3.json';
|
|
11
11
|
import fhirVersions from '../fhirResourceVersions';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import MedicationAdministrationIcon from '../../../assets/containers/MedicationAdministration/medication-administration.svg';
|
|
12
14
|
|
|
13
15
|
export default {
|
|
14
16
|
title: 'MedicationAdministration',
|
|
@@ -20,6 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
20
22
|
<MedicationAdministration
|
|
21
23
|
fhirVersion={fhirVersions.DSTU2}
|
|
22
24
|
fhirResource={fhirResource}
|
|
25
|
+
fhirIcons={require('../../../assets/containers/MedicationAdministration/medication-administration.svg')}
|
|
23
26
|
/>
|
|
24
27
|
);
|
|
25
28
|
};
|
|
@@ -30,6 +33,7 @@ export const ExampleOfSTU3 = () => {
|
|
|
30
33
|
<MedicationAdministration
|
|
31
34
|
fhirVersion={fhirVersions.STU3}
|
|
32
35
|
fhirResource={fhirResource}
|
|
36
|
+
fhirIcons={MedicationAdministrationIcon}
|
|
33
37
|
/>
|
|
34
38
|
);
|
|
35
39
|
};
|
|
@@ -40,6 +44,7 @@ export const Example1OfR4 = () => {
|
|
|
40
44
|
<MedicationAdministration
|
|
41
45
|
fhirVersion={fhirVersions.R4}
|
|
42
46
|
fhirResource={fhirResource}
|
|
47
|
+
fhirIcons={fhirIcons}
|
|
43
48
|
/>
|
|
44
49
|
);
|
|
45
50
|
};
|
|
@@ -50,6 +55,7 @@ export const Example2OfR4 = () => {
|
|
|
50
55
|
<MedicationAdministration
|
|
51
56
|
fhirVersion={fhirVersions.R4}
|
|
52
57
|
fhirResource={fhirResource}
|
|
58
|
+
fhirIcons={false}
|
|
53
59
|
/>
|
|
54
60
|
);
|
|
55
61
|
};
|
|
@@ -60,6 +66,7 @@ export const Example3OfR4 = () => {
|
|
|
60
66
|
<MedicationAdministration
|
|
61
67
|
fhirVersion={fhirVersions.R4}
|
|
62
68
|
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={'random text'}
|
|
63
70
|
/>
|
|
64
71
|
);
|
|
65
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 MedicationAdministration from './MedicationAdministration';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -7,8 +7,89 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/medicationAdministr
|
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/medicationAdministration/example1.json';
|
|
8
8
|
import r4Example1 from '../../../fixtures/r4/resources/medicationAdministration/example1.json';
|
|
9
9
|
import r4Example2 from '../../../fixtures/r4/resources/medicationAdministration/example3.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render MedicationAdministration component properly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
16
|
+
fhirResource: dstu2Example1,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(
|
|
20
|
+
<MedicationAdministration {...defaultProps} />,
|
|
21
|
+
);
|
|
22
|
+
const headerIcon = getByAltText('medication administration');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(
|
|
35
|
+
<MedicationAdministration {...defaultProps} />,
|
|
36
|
+
);
|
|
37
|
+
const headerIcon = getByTestId('placeholder');
|
|
38
|
+
|
|
39
|
+
expect(headerIcon).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
43
|
+
const defaultProps = {
|
|
44
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
45
|
+
fhirResource: dstu2Example1,
|
|
46
|
+
fhirIcons: (
|
|
47
|
+
<img
|
|
48
|
+
src={require('../assets/containers/MedicationAdministration/medication-administration.svg')}
|
|
49
|
+
alt="pill gets swallowed"
|
|
50
|
+
/>
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const { getByAltText } = render(
|
|
55
|
+
<MedicationAdministration {...defaultProps} />,
|
|
56
|
+
);
|
|
57
|
+
const headerIcon = getByAltText('pill gets swallowed');
|
|
58
|
+
|
|
59
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
63
|
+
const defaultProps = {
|
|
64
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
65
|
+
fhirResource: dstu2Example1,
|
|
66
|
+
fhirIcons: fhirIcons,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const { getByAltText } = render(
|
|
70
|
+
<MedicationAdministration {...defaultProps} />,
|
|
71
|
+
);
|
|
72
|
+
const headerIcon = getByAltText('pill gets swallowed');
|
|
73
|
+
|
|
74
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
78
|
+
const avatarSrc =
|
|
79
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
80
|
+
const defaultProps = {
|
|
81
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
82
|
+
fhirResource: dstu2Example1,
|
|
83
|
+
fhirIcons: avatarSrc,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const { getByAltText } = render(
|
|
87
|
+
<MedicationAdministration {...defaultProps} />,
|
|
88
|
+
);
|
|
89
|
+
const headerIcon = getByAltText('header icon');
|
|
90
|
+
|
|
91
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
92
|
+
});
|
|
12
93
|
it('should render with DSTU2 source data', () => {
|
|
13
94
|
const defaultProps = {
|
|
14
95
|
fhirResource: dstu2Example1,
|
|
@@ -108,4 +189,39 @@ describe('should render MedicationAdministration component properly', () => {
|
|
|
108
189
|
expect(getByTestId('dosageRoute').textContent).toContain('Oral Route');
|
|
109
190
|
expect(getByTestId('dosageQuantity').textContent).toEqual('2 TAB');
|
|
110
191
|
});
|
|
192
|
+
|
|
193
|
+
it('should fire custom onClick function', () => {
|
|
194
|
+
const defaultProps = {
|
|
195
|
+
fhirResource: r4Example2,
|
|
196
|
+
fhirVersion: fhirVersions.R4,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const onClick = jest.fn();
|
|
200
|
+
const { getByRole } = render(
|
|
201
|
+
<MedicationAdministration {...defaultProps} onClick={onClick} />,
|
|
202
|
+
);
|
|
203
|
+
const accordion = getByRole('button');
|
|
204
|
+
fireEvent.click(accordion);
|
|
205
|
+
|
|
206
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
207
|
+
expect(attribute).not.toEqual('collapse');
|
|
208
|
+
expect(onClick).toHaveBeenCalled();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should not fire custom onClick function', () => {
|
|
212
|
+
const defaultProps = {
|
|
213
|
+
fhirResource: r4Example2,
|
|
214
|
+
fhirVersion: fhirVersions.R4,
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const onClick = 'test';
|
|
218
|
+
const { getByRole } = render(
|
|
219
|
+
<MedicationAdministration {...defaultProps} onClick={onClick} />,
|
|
220
|
+
);
|
|
221
|
+
const accordion = getByRole('button');
|
|
222
|
+
fireEvent.click(accordion);
|
|
223
|
+
|
|
224
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
225
|
+
expect(attribute).toEqual('collapse');
|
|
226
|
+
});
|
|
111
227
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MissingValue, TableCell, TableRow } from '../../ui';
|
|
2
|
+
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
const DosageInstruction = props => {
|
|
6
|
+
const empty = <MissingValue />;
|
|
7
|
+
const {
|
|
8
|
+
timing = empty,
|
|
9
|
+
route = empty,
|
|
10
|
+
doseQuantity = empty,
|
|
11
|
+
additionalInstructions = empty,
|
|
12
|
+
} = props.item;
|
|
13
|
+
return (
|
|
14
|
+
<TableRow>
|
|
15
|
+
<TableCell data-testid="dosageTiming">{timing}</TableCell>
|
|
16
|
+
<TableCell data-testid="dosageRoute">{route}</TableCell>
|
|
17
|
+
<TableCell data-testid="dosageQuantity">{doseQuantity}</TableCell>
|
|
18
|
+
<TableCell data-testid="dosageAdditionalInstructions">
|
|
19
|
+
<CodeableConcept fhirData={additionalInstructions} />
|
|
20
|
+
</TableCell>
|
|
21
|
+
</TableRow>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default DosageInstruction;
|