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
|
@@ -17,8 +17,6 @@ import r4Example3 from '../../../fixtures/r4/resources/bundle/example3.json';
|
|
|
17
17
|
import r4Example4 from '../../../fixtures/r4/resources/bundle/example4.json';
|
|
18
18
|
import fhirVersions from '../fhirResourceVersions';
|
|
19
19
|
|
|
20
|
-
import fhirIcons from '../../../fixtures/example-icons';
|
|
21
|
-
|
|
22
20
|
export default {
|
|
23
21
|
title: 'Bundle',
|
|
24
22
|
};
|
|
@@ -26,133 +24,69 @@ export default {
|
|
|
26
24
|
export const Example1OfDSTU2 = () => {
|
|
27
25
|
const fhirResource = object('Resource', dstu2Example1);
|
|
28
26
|
return (
|
|
29
|
-
<Bundle
|
|
30
|
-
fhirResource={fhirResource}
|
|
31
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
32
|
-
fhirIcons={fhirIcons}
|
|
33
|
-
/>
|
|
27
|
+
<Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
|
|
34
28
|
);
|
|
35
29
|
};
|
|
36
30
|
|
|
37
31
|
export const Example2OfDSTU2 = () => {
|
|
38
32
|
const fhirResource = object('Resource', dstu2Example2);
|
|
39
33
|
return (
|
|
40
|
-
<Bundle
|
|
41
|
-
fhirResource={fhirResource}
|
|
42
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
43
|
-
fhirIcons={fhirIcons}
|
|
44
|
-
/>
|
|
34
|
+
<Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
|
|
45
35
|
);
|
|
46
36
|
};
|
|
47
37
|
|
|
48
38
|
export const Example3OfDSTU2 = () => {
|
|
49
39
|
const fhirResource = object('Resource', dstu2Example3);
|
|
50
40
|
return (
|
|
51
|
-
<Bundle
|
|
52
|
-
fhirResource={fhirResource}
|
|
53
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
54
|
-
fhirIcons={fhirIcons}
|
|
55
|
-
/>
|
|
41
|
+
<Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
|
|
56
42
|
);
|
|
57
43
|
};
|
|
58
44
|
|
|
59
45
|
export const Example4OfDSTU2 = () => {
|
|
60
46
|
const fhirResource = object('Resource', dstu2Example4);
|
|
61
47
|
return (
|
|
62
|
-
<Bundle
|
|
63
|
-
fhirResource={fhirResource}
|
|
64
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
65
|
-
fhirIcons={fhirIcons}
|
|
66
|
-
/>
|
|
48
|
+
<Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
|
|
67
49
|
);
|
|
68
50
|
};
|
|
69
51
|
|
|
70
52
|
export const Example1OfSTU3 = () => {
|
|
71
53
|
const fhirResource = object('Resource', stu3Example1);
|
|
72
|
-
return
|
|
73
|
-
<Bundle
|
|
74
|
-
fhirResource={fhirResource}
|
|
75
|
-
fhirVersion={fhirVersions.STU3}
|
|
76
|
-
fhirIcons={fhirIcons}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
54
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />;
|
|
79
55
|
};
|
|
80
56
|
|
|
81
57
|
export const Example2OfSTU3 = () => {
|
|
82
58
|
const fhirResource = object('Resource', stu3Example2);
|
|
83
|
-
return
|
|
84
|
-
<Bundle
|
|
85
|
-
fhirResource={fhirResource}
|
|
86
|
-
fhirVersion={fhirVersions.STU3}
|
|
87
|
-
fhirIcons={fhirIcons}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
59
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />;
|
|
90
60
|
};
|
|
91
61
|
|
|
92
62
|
export const Example3OfSTU3 = () => {
|
|
93
63
|
const fhirResource = object('Resource', stu3Example3);
|
|
94
|
-
return
|
|
95
|
-
<Bundle
|
|
96
|
-
fhirResource={fhirResource}
|
|
97
|
-
fhirVersion={fhirVersions.STU3}
|
|
98
|
-
fhirIcons={fhirIcons}
|
|
99
|
-
/>
|
|
100
|
-
);
|
|
64
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />;
|
|
101
65
|
};
|
|
102
66
|
|
|
103
67
|
export const Example4OfSTU3 = () => {
|
|
104
68
|
const fhirResource = object('Resource', stu3Example4);
|
|
105
|
-
return
|
|
106
|
-
<Bundle
|
|
107
|
-
fhirResource={fhirResource}
|
|
108
|
-
fhirVersion={fhirVersions.STU3}
|
|
109
|
-
fhirIcons={fhirIcons}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
69
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />;
|
|
112
70
|
};
|
|
113
71
|
|
|
114
72
|
export const Example1OfR4 = () => {
|
|
115
73
|
const fhirResource = object('Resource', r4Example1);
|
|
116
|
-
return
|
|
117
|
-
<Bundle
|
|
118
|
-
fhirResource={fhirResource}
|
|
119
|
-
fhirVersion={fhirVersions.R4}
|
|
120
|
-
fhirIcons={fhirIcons}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
74
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />;
|
|
123
75
|
};
|
|
124
76
|
|
|
125
77
|
export const Example2OfR4 = () => {
|
|
126
78
|
const fhirResource = object('Resource', r4Example2);
|
|
127
|
-
return
|
|
128
|
-
<Bundle
|
|
129
|
-
fhirResource={fhirResource}
|
|
130
|
-
fhirVersion={fhirVersions.R4}
|
|
131
|
-
fhirIcons={fhirIcons}
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
79
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />;
|
|
134
80
|
};
|
|
135
81
|
|
|
136
82
|
export const Example3OfR4 = () => {
|
|
137
83
|
const fhirResource = object('Resource', r4Example3);
|
|
138
|
-
return
|
|
139
|
-
<Bundle
|
|
140
|
-
fhirResource={fhirResource}
|
|
141
|
-
fhirVersion={fhirVersions.R4}
|
|
142
|
-
fhirIcons={fhirIcons}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
84
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />;
|
|
145
85
|
};
|
|
146
86
|
|
|
147
87
|
export const Example4OfR4 = () => {
|
|
148
88
|
const fhirResource = object('Resource', r4Example4);
|
|
149
|
-
return
|
|
150
|
-
<Bundle
|
|
151
|
-
fhirResource={fhirResource}
|
|
152
|
-
fhirVersion={fhirVersions.R4}
|
|
153
|
-
fhirIcons={fhirIcons}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
89
|
+
return <Bundle fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />;
|
|
156
90
|
};
|
|
157
91
|
|
|
158
92
|
// export const ExampleWithoutFHIRVersionProperty = () => {
|
|
@@ -8,8 +8,6 @@ import dstu2Example2 from '../../../fixtures/dstu2/resources/bundle/example3.jso
|
|
|
8
8
|
import stu3Example1 from '../../../fixtures/stu3/resources/bundle/example1.json';
|
|
9
9
|
import r4Example1 from '../../../fixtures/r4/resources/bundle/example1.json';
|
|
10
10
|
|
|
11
|
-
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
-
|
|
13
11
|
describe('Bundle should render component correctly', () => {
|
|
14
12
|
it('should render component correctly with DSTU2 source data', () => {
|
|
15
13
|
const defaultProps = {
|
|
@@ -31,7 +29,6 @@ describe('Bundle should render component correctly', () => {
|
|
|
31
29
|
const defaultProps = {
|
|
32
30
|
fhirVersion: fhirVersions.DSTU2,
|
|
33
31
|
fhirResource: dstu2Example2,
|
|
34
|
-
fhirIcons: fhirIcons,
|
|
35
32
|
};
|
|
36
33
|
const { getByText, getAllByTestId } = render(<Bundle {...defaultProps} />);
|
|
37
34
|
expect(getAllByTestId('title').map(title => title.textContent)).toEqual([
|
|
@@ -162,7 +162,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
const CarePlan = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
165
|
+
const CarePlan = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
166
166
|
let fhirResourceData = {};
|
|
167
167
|
try {
|
|
168
168
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -304,6 +304,7 @@ const CarePlan = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
304
304
|
)}
|
|
305
305
|
</Body>
|
|
306
306
|
}
|
|
307
|
+
onClick={onClick}
|
|
307
308
|
/>
|
|
308
309
|
</Root>
|
|
309
310
|
);
|
|
@@ -10,38 +10,64 @@ import weightLossCarePlanR4 from '../../../fixtures/r4/resources/carePlan/weight
|
|
|
10
10
|
import pregnancyCarePlanR4 from '../../../fixtures/r4/resources/carePlan/pregnancyPlan.json';
|
|
11
11
|
import heartOperationCarePlanR4 from '../../../fixtures/r4/resources/carePlan/heartOperationPlan.json';
|
|
12
12
|
import fhirVersions from '../fhirResourceVersions';
|
|
13
|
+
import CarePlanIcon from '../../../assets/containers/CarePlan/care-plan.svg';
|
|
14
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
15
|
|
|
14
16
|
export default { title: 'CarePlan' };
|
|
15
17
|
|
|
16
18
|
export const DefaultVisualizationDSTU2 = () => {
|
|
17
19
|
const fhirResource = object('Resource', exampleCarePlanDSTU2);
|
|
18
20
|
return (
|
|
19
|
-
<CarePlan
|
|
21
|
+
<CarePlan
|
|
22
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
23
|
+
fhirResource={fhirResource}
|
|
24
|
+
fhirIcons={require('../../../assets/containers/CarePlan/care-plan.svg')}
|
|
25
|
+
/>
|
|
20
26
|
);
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
export const ExampleCarePlanSTU3 = () => {
|
|
24
30
|
const fhirResource = object('Resource', exampleCarePlanSTU3);
|
|
25
31
|
return (
|
|
26
|
-
<CarePlan
|
|
32
|
+
<CarePlan
|
|
33
|
+
fhirVersion={fhirVersions.STU3}
|
|
34
|
+
fhirResource={fhirResource}
|
|
35
|
+
fhirIcons={CarePlanIcon}
|
|
36
|
+
/>
|
|
27
37
|
);
|
|
28
38
|
};
|
|
29
39
|
|
|
30
40
|
export const Example2CarePlanSTU3 = () => {
|
|
31
41
|
const fhirResource = object('Resource', example2CarePlanSTU3);
|
|
32
42
|
return (
|
|
33
|
-
<CarePlan
|
|
43
|
+
<CarePlan
|
|
44
|
+
fhirVersion={fhirVersions.STU3}
|
|
45
|
+
fhirResource={fhirResource}
|
|
46
|
+
fhirIcons={fhirIcons}
|
|
47
|
+
/>
|
|
34
48
|
);
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
export const WeightLossCarePlanR4 = () => {
|
|
38
52
|
const fhirResource = object('Resource', weightLossCarePlanR4);
|
|
39
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
<CarePlan
|
|
55
|
+
fhirVersion={fhirVersions.R4}
|
|
56
|
+
fhirResource={fhirResource}
|
|
57
|
+
fhirIcons={false}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
40
60
|
};
|
|
41
61
|
|
|
42
62
|
export const PregnancyCarePlanR4 = () => {
|
|
43
63
|
const fhirResource = object('Resource', pregnancyCarePlanR4);
|
|
44
|
-
return
|
|
64
|
+
return (
|
|
65
|
+
<CarePlan
|
|
66
|
+
fhirVersion={fhirVersions.R4}
|
|
67
|
+
fhirResource={fhirResource}
|
|
68
|
+
fhirIcons={'random text'}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
45
71
|
};
|
|
46
72
|
|
|
47
73
|
export const HeartOperatioCarePlanR4 = () => {
|
|
@@ -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 CarePlan from './CarePlan';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -7,8 +7,80 @@ import examplecarePlanDSTU2 from '../../../fixtures/dstu2/resources/carePlan/exa
|
|
|
7
7
|
import exampleCarePlanSTU3 from '../../../fixtures/stu3/resources/carePlan/example1.json';
|
|
8
8
|
import example1CarePlanR4 from '../../../fixtures/r4/resources/carePlan/weightLossPlan.json';
|
|
9
9
|
import example2CarePlanR4 from '../../../fixtures/r4/resources/carePlan/pregnancyPlan.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render component correctly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirResource: examplecarePlanDSTU2,
|
|
16
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('care plan');
|
|
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: examplecarePlanDSTU2,
|
|
28
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<CarePlan {...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
|
+
fhirResource: examplecarePlanDSTU2,
|
|
41
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/CarePlan/care-plan.svg')}
|
|
45
|
+
alt="care plan"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('care plan');
|
|
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
|
+
fhirResource: examplecarePlanDSTU2,
|
|
59
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('care plan');
|
|
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
|
+
fhirResource: examplecarePlanDSTU2,
|
|
74
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<CarePlan {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
83
|
+
|
|
12
84
|
it('should render with DSTU2 source data', () => {
|
|
13
85
|
const defaultProps = {
|
|
14
86
|
fhirResource: examplecarePlanDSTU2,
|
|
@@ -39,8 +111,9 @@ describe('should render component correctly', () => {
|
|
|
39
111
|
expect(getByTestId('activity').textContent).toContain('3141-9');
|
|
40
112
|
expect(getByTestId('intent').textContent).toEqual('plan');
|
|
41
113
|
expect(getByTestId('description').textContent).toContain('Manage obesity');
|
|
42
|
-
expect(getByTestId('subject').textContent).toContain(
|
|
43
|
-
|
|
114
|
+
expect(getByTestId('subject').textContent).toContain(
|
|
115
|
+
'Peter James Chalmers',
|
|
116
|
+
);
|
|
44
117
|
expect(getByTestId('author').textContent).toContain('Dr Adam Careful');
|
|
45
118
|
expect(getByTestId('periodEnd').textContent).toEqual('6/1/2017');
|
|
46
119
|
expect(getByTestId('basedOn').textContent).toEqual(
|
|
@@ -64,8 +137,9 @@ describe('should render component correctly', () => {
|
|
|
64
137
|
expect(getByTestId('intent').textContent).toEqual('plan');
|
|
65
138
|
expect(getByTestId('goals').textContent).toEqual('Goal/example');
|
|
66
139
|
expect(getByTestId('description').textContent).toContain('Manage obesity');
|
|
67
|
-
expect(getByTestId('subject').textContent).toContain(
|
|
68
|
-
|
|
140
|
+
expect(getByTestId('subject').textContent).toContain(
|
|
141
|
+
'Peter James Chalmers',
|
|
142
|
+
);
|
|
69
143
|
expect(getByTestId('author').textContent).toContain('Dr Adam Careful');
|
|
70
144
|
expect(getByTestId('periodEnd').textContent).toEqual('6/1/2017');
|
|
71
145
|
expect(getByTestId('basedOn').textContent).toEqual(
|
|
@@ -88,8 +162,42 @@ describe('should render component correctly', () => {
|
|
|
88
162
|
expect(getByTestId('intent').textContent).toEqual('plan');
|
|
89
163
|
expect(getByTestId('goals').textContent).toEqual('#goal');
|
|
90
164
|
expect(getByTestId('subject').textContent).toContain('Eve Everywoman');
|
|
91
|
-
expect(getByTestId('subject').textContent).toContain('Patient/1');
|
|
92
165
|
expect(getByTestId('periodStart').textContent).toEqual('1/1/2013');
|
|
93
166
|
expect(getByTestId('periodEnd').textContent).toEqual('10/1/2013');
|
|
94
167
|
});
|
|
168
|
+
|
|
169
|
+
it('should fire custom onClick function', () => {
|
|
170
|
+
const defaultProps = {
|
|
171
|
+
fhirResource: example2CarePlanR4,
|
|
172
|
+
fhirVersion: fhirVersions.R4,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const onClick = jest.fn();
|
|
176
|
+
const { getByRole } = render(
|
|
177
|
+
<CarePlan {...defaultProps} onClick={onClick} />,
|
|
178
|
+
);
|
|
179
|
+
const accordion = getByRole('button');
|
|
180
|
+
fireEvent.click(accordion);
|
|
181
|
+
|
|
182
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
183
|
+
expect(attribute).not.toEqual('collapse');
|
|
184
|
+
expect(onClick).toHaveBeenCalled();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should not fire custom onClick function', () => {
|
|
188
|
+
const defaultProps = {
|
|
189
|
+
fhirResource: example2CarePlanR4,
|
|
190
|
+
fhirVersion: fhirVersions.R4,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const onClick = 'test';
|
|
194
|
+
const { getByRole } = render(
|
|
195
|
+
<CarePlan {...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
|
+
});
|
|
95
203
|
});
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
Header,
|
|
5
5
|
MissingValue,
|
|
6
6
|
Root,
|
|
7
|
-
|
|
8
|
-
Value,
|
|
7
|
+
ValueSection,
|
|
9
8
|
} from '../../ui';
|
|
10
9
|
|
|
11
10
|
import CareTeamParticipants from './CareTeamParticipants';
|
|
@@ -16,6 +15,7 @@ import React from 'react';
|
|
|
16
15
|
import Reference from '../../datatypes/Reference';
|
|
17
16
|
import _get from 'lodash/get';
|
|
18
17
|
import fhirVersions from '../fhirResourceVersions';
|
|
18
|
+
import Accordion from '../../containers/Accordion';
|
|
19
19
|
|
|
20
20
|
const commonDTO = fhirResource => {
|
|
21
21
|
// Default value for title - "Care team"
|
|
@@ -83,8 +83,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
const CareTeam =
|
|
87
|
-
const { fhirResource, fhirVersion } = props;
|
|
86
|
+
const CareTeam = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
88
87
|
const {
|
|
89
88
|
name,
|
|
90
89
|
status,
|
|
@@ -98,54 +97,77 @@ const CareTeam = props => {
|
|
|
98
97
|
} = resourceDTO(fhirVersion, fhirResource);
|
|
99
98
|
const hasParticipants = participants.length > 0;
|
|
100
99
|
|
|
100
|
+
const tableData = [
|
|
101
|
+
{
|
|
102
|
+
label: 'Category',
|
|
103
|
+
testId: 'category',
|
|
104
|
+
data: category && <CodableConcept fhirData={category} isCursive />,
|
|
105
|
+
status: category,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: 'Subject',
|
|
109
|
+
testId: 'subject',
|
|
110
|
+
data: subject && <Reference fhirData={subject} />,
|
|
111
|
+
status: subject,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: 'Encounter',
|
|
115
|
+
testId: 'encounter',
|
|
116
|
+
data: encounter && <Reference fhirData={encounter} />,
|
|
117
|
+
status: encounter,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: 'Managing organization',
|
|
121
|
+
testId: 'managingOrganization',
|
|
122
|
+
data: managingOrganization && (
|
|
123
|
+
<Reference fhirData={managingOrganization} />
|
|
124
|
+
),
|
|
125
|
+
status: managingOrganization,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
label: 'Care Period Start',
|
|
129
|
+
testId: 'periodStart',
|
|
130
|
+
data: periodStart ? (
|
|
131
|
+
<DateType fhirData={periodStart} isBlack />
|
|
132
|
+
) : (
|
|
133
|
+
<MissingValue />
|
|
134
|
+
),
|
|
135
|
+
status: periodStart,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
label: 'Care Period End',
|
|
139
|
+
testId: 'periodEnd',
|
|
140
|
+
data: periodEnd ? (
|
|
141
|
+
<DateType fhirData={periodEnd} isBlack />
|
|
142
|
+
) : (
|
|
143
|
+
<MissingValue />
|
|
144
|
+
),
|
|
145
|
+
status: periodEnd,
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
|
|
101
149
|
return (
|
|
102
150
|
<Root name="CareTeam">
|
|
103
|
-
<
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
{managingOrganization && (
|
|
124
|
-
<Value
|
|
125
|
-
label="Managing organization"
|
|
126
|
-
data-testid="managingOrganization"
|
|
127
|
-
>
|
|
128
|
-
<Reference fhirData={managingOrganization} />
|
|
129
|
-
</Value>
|
|
130
|
-
)}
|
|
131
|
-
{periodStart && (
|
|
132
|
-
<Value label="Care Period Start" data-testid="periodStart">
|
|
133
|
-
{periodStart ? (
|
|
134
|
-
<DateType fhirData={periodStart} />
|
|
135
|
-
) : (
|
|
136
|
-
<MissingValue />
|
|
137
|
-
)}
|
|
138
|
-
</Value>
|
|
139
|
-
)}
|
|
140
|
-
{periodEnd && (
|
|
141
|
-
<Value label="Care Period End" data-testid="periodEnd">
|
|
142
|
-
{periodEnd ? <DateType fhirData={periodEnd} /> : <MissingValue />}
|
|
143
|
-
</Value>
|
|
144
|
-
)}
|
|
145
|
-
{hasParticipants && (
|
|
146
|
-
<CareTeamParticipants participants={participants} />
|
|
147
|
-
)}
|
|
148
|
-
</Body>
|
|
151
|
+
<Accordion
|
|
152
|
+
headerContent={
|
|
153
|
+
<Header
|
|
154
|
+
resourceName={'CareTeam'}
|
|
155
|
+
icon={fhirIcons}
|
|
156
|
+
title={name}
|
|
157
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
158
|
+
/>
|
|
159
|
+
}
|
|
160
|
+
bodyContent={
|
|
161
|
+
<Body tableData={tableData}>
|
|
162
|
+
<ValueSection>
|
|
163
|
+
{hasParticipants && (
|
|
164
|
+
<CareTeamParticipants participants={participants} />
|
|
165
|
+
)}
|
|
166
|
+
</ValueSection>
|
|
167
|
+
</Body>
|
|
168
|
+
}
|
|
169
|
+
onClick={onClick}
|
|
170
|
+
/>
|
|
149
171
|
</Root>
|
|
150
172
|
);
|
|
151
173
|
};
|
|
@@ -7,6 +7,9 @@ import example_STU3 from '../../../fixtures/stu3/resources/careTeam/example1.jso
|
|
|
7
7
|
import example2_STU3 from '../../../fixtures/stu3/resources/careTeam/example2.json';
|
|
8
8
|
import example_R4 from '../../../fixtures/r4/resources/careTeam/example1.json';
|
|
9
9
|
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
|
+
import CareTeamIcon from '../../../assets/containers/CareTeam/care-team.svg';
|
|
12
|
+
|
|
10
13
|
export default {
|
|
11
14
|
title: 'CareTeam',
|
|
12
15
|
};
|
|
@@ -14,18 +17,32 @@ export default {
|
|
|
14
17
|
export const ExampleSTU3 = () => {
|
|
15
18
|
const fhirResource = object('Resource', example_STU3);
|
|
16
19
|
return (
|
|
17
|
-
<CareTeam
|
|
20
|
+
<CareTeam
|
|
21
|
+
fhirResource={fhirResource}
|
|
22
|
+
fhirVersion={fhirVersions.STU3}
|
|
23
|
+
fhirIcons={CareTeamIcon}
|
|
24
|
+
/>
|
|
18
25
|
);
|
|
19
26
|
};
|
|
20
27
|
|
|
21
28
|
export const Example2OfSTU3 = () => {
|
|
22
29
|
const fhirResource = object('Resource', example2_STU3);
|
|
23
30
|
return (
|
|
24
|
-
<CareTeam
|
|
31
|
+
<CareTeam
|
|
32
|
+
fhirResource={fhirResource}
|
|
33
|
+
fhirVersion={fhirVersions.STU3}
|
|
34
|
+
fhirIcons={fhirIcons}
|
|
35
|
+
/>
|
|
25
36
|
);
|
|
26
37
|
};
|
|
27
38
|
|
|
28
39
|
export const ExampleR4 = () => {
|
|
29
40
|
const fhirResource = object('Resource', example_R4);
|
|
30
|
-
return
|
|
41
|
+
return (
|
|
42
|
+
<CareTeam
|
|
43
|
+
fhirResource={fhirResource}
|
|
44
|
+
fhirVersion={fhirVersions.R4}
|
|
45
|
+
fhirIcons={false}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
31
48
|
};
|