fhir-react 0.3.7 → 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 +7 -7
- package/package.json +55 -54
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Generic/generic.svg +3 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
- package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
- package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +21 -13
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -5
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/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 +7 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +2 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -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 +2 -1
- package/src/components/resources/CarePlan/CarePlan.test.js +42 -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/Claim.js +2 -1
- package/src/components/resources/Claim/Claim.test.js +32 -1
- package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
- package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
- package/src/components/resources/ClaimResponse/ClaimResponse.js +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 +2 -1
- package/src/components/resources/Coverage/Coverage.test.js +36 -1
- package/src/components/resources/Device/Device.js +2 -1
- package/src/components/resources/Device/Device.test.js +36 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -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.test.js +36 -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 +2 -3
- package/src/components/resources/Goal/Goal.test.js +32 -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 +2 -1
- package/src/components/resources/Medication/Medication.test.js +36 -1
- 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 +2 -3
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +2 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +7 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -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 +3 -2
- package/src/components/resources/Organization/Organization.test.js +36 -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/ui/index.js +22 -9
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +42 -0
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +3 -1
|
@@ -8,14 +8,14 @@ import { getExtension, isBoolean } from './utils';
|
|
|
8
8
|
import {
|
|
9
9
|
Root,
|
|
10
10
|
Header,
|
|
11
|
-
Title,
|
|
12
|
-
Value,
|
|
13
11
|
Body,
|
|
14
12
|
Badge,
|
|
15
13
|
ValueSection,
|
|
14
|
+
ValueSectionItem,
|
|
16
15
|
} from '../../ui';
|
|
17
16
|
import Reference from '../../datatypes/Reference';
|
|
18
17
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
18
|
+
import Accordion from '../../containers/Accordion';
|
|
19
19
|
|
|
20
20
|
const commonDTO = fhirResource => {
|
|
21
21
|
const id = _get(fhirResource, 'id');
|
|
@@ -103,8 +103,13 @@ const resourceDTO = (fhirVersion, fhirResource, withDaVinciPDex) => {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
const MedicationKnowledge =
|
|
107
|
-
|
|
106
|
+
const MedicationKnowledge = ({
|
|
107
|
+
fhirResource,
|
|
108
|
+
fhirVersion,
|
|
109
|
+
withDaVinciPDex = false,
|
|
110
|
+
fhirIcons,
|
|
111
|
+
onClick,
|
|
112
|
+
}) => {
|
|
108
113
|
let fhirResourceData = {};
|
|
109
114
|
try {
|
|
110
115
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource, withDaVinciPDex);
|
|
@@ -138,72 +143,116 @@ const MedicationKnowledge = props => {
|
|
|
138
143
|
: amountDisplay;
|
|
139
144
|
}
|
|
140
145
|
|
|
146
|
+
const tableData = [
|
|
147
|
+
{
|
|
148
|
+
label: 'Code',
|
|
149
|
+
testId: 'code',
|
|
150
|
+
data: code && <CodeableConcept fhirData={code} isCursive />,
|
|
151
|
+
status: code,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
label: 'Manufacturer',
|
|
155
|
+
testId: 'manufacturer',
|
|
156
|
+
data: manufacturer && <Reference fhirData={manufacturer} />,
|
|
157
|
+
status: manufacturer,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: 'Amount',
|
|
161
|
+
testId: 'amount',
|
|
162
|
+
data: amountDisplay,
|
|
163
|
+
status: amountDisplay,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
label: 'Synonym',
|
|
167
|
+
testId: 'synonym',
|
|
168
|
+
data: synonym,
|
|
169
|
+
status: synonym,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
const usdfExtensionsData = [
|
|
174
|
+
{
|
|
175
|
+
label: 'Prior Authorization',
|
|
176
|
+
testId: 'usdfPriorAuthorization',
|
|
177
|
+
data:
|
|
178
|
+
isBoolean(usdfPriorAuthorization) && usdfPriorAuthorization === true
|
|
179
|
+
? 'yes'
|
|
180
|
+
: 'no',
|
|
181
|
+
status: isBoolean(usdfPriorAuthorization),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: 'Step Therapy Limit',
|
|
185
|
+
testId: 'usdfStepTherapyLimit',
|
|
186
|
+
data:
|
|
187
|
+
isBoolean(usdfStepTherapyLimit) && usdfStepTherapyLimit === true
|
|
188
|
+
? 'yes'
|
|
189
|
+
: 'no',
|
|
190
|
+
status: isBoolean(usdfStepTherapyLimit),
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
label: 'Quantity Limit',
|
|
194
|
+
testId: 'usdfQuantityLimit',
|
|
195
|
+
data:
|
|
196
|
+
isBoolean(usdfQuantityLimit) && usdfQuantityLimit === true
|
|
197
|
+
? 'yes'
|
|
198
|
+
: 'no',
|
|
199
|
+
status: isBoolean(usdfQuantityLimit),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
label: 'Plan ID',
|
|
203
|
+
testId: 'usdfPlanID',
|
|
204
|
+
data: usdfPlanID,
|
|
205
|
+
status: usdfPlanID,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
label: 'Drug Tier ID',
|
|
209
|
+
testId: 'usdfDrugTierID',
|
|
210
|
+
data: usdfDrugTierID && <CodeableConcept fhirData={usdfDrugTierID} />,
|
|
211
|
+
status: usdfDrugTierID,
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
|
|
141
215
|
return (
|
|
142
216
|
<Root name="MedicationKnowledge">
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
</Value>
|
|
164
|
-
)}
|
|
165
|
-
{synonym && (
|
|
166
|
-
<Value label="Synonym" data-testid="synonym">
|
|
167
|
-
{synonym}
|
|
168
|
-
</Value>
|
|
169
|
-
)}
|
|
170
|
-
|
|
171
|
-
{hasExtensions && (
|
|
172
|
-
<ValueSection label="USDF extensions" data-testid="usdfExtensions">
|
|
173
|
-
{isBoolean(usdfPriorAuthorization) && (
|
|
174
|
-
<Value
|
|
175
|
-
label="Prior Authorization"
|
|
176
|
-
data-testid="usdfPriorAuthorization"
|
|
177
|
-
>
|
|
178
|
-
{usdfPriorAuthorization === true ? 'yes' : 'no'}
|
|
179
|
-
</Value>
|
|
180
|
-
)}
|
|
181
|
-
{isBoolean(usdfStepTherapyLimit) && (
|
|
182
|
-
<Value
|
|
183
|
-
label="Step Therapy Limit"
|
|
184
|
-
data-testid="usdfStepTherapyLimit"
|
|
217
|
+
<Accordion
|
|
218
|
+
headerContent={
|
|
219
|
+
<Header
|
|
220
|
+
resourceName="MedicationKnowledge"
|
|
221
|
+
title={
|
|
222
|
+
id
|
|
223
|
+
? `Medication knowledge ID: ${id} `
|
|
224
|
+
: 'MedicationOrder knowledge '
|
|
225
|
+
}
|
|
226
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
227
|
+
icon={fhirIcons}
|
|
228
|
+
/>
|
|
229
|
+
}
|
|
230
|
+
bodyContent={
|
|
231
|
+
<Body tableData={tableData}>
|
|
232
|
+
{hasExtensions && (
|
|
233
|
+
<ValueSection
|
|
234
|
+
label="USDF extensions"
|
|
235
|
+
data-testid="usdfExtensions"
|
|
236
|
+
marginTop
|
|
185
237
|
>
|
|
186
|
-
{
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
{usdfDrugTierID && (
|
|
200
|
-
<Value label="Drug Tier ID" data-testid="usdfDrugTierID">
|
|
201
|
-
<CodeableConcept fhirData={usdfDrugTierID} />
|
|
202
|
-
</Value>
|
|
238
|
+
{usdfExtensionsData.map(
|
|
239
|
+
(item, index) =>
|
|
240
|
+
item.status && (
|
|
241
|
+
<ValueSectionItem
|
|
242
|
+
key={`usdf-extension-item-${index}`}
|
|
243
|
+
label={item.label}
|
|
244
|
+
data-testid={item.testId}
|
|
245
|
+
>
|
|
246
|
+
{item.data}
|
|
247
|
+
</ValueSectionItem>
|
|
248
|
+
),
|
|
249
|
+
)}
|
|
250
|
+
</ValueSection>
|
|
203
251
|
)}
|
|
204
|
-
</
|
|
205
|
-
|
|
206
|
-
|
|
252
|
+
</Body>
|
|
253
|
+
}
|
|
254
|
+
onClick={onClick}
|
|
255
|
+
/>
|
|
207
256
|
</Root>
|
|
208
257
|
);
|
|
209
258
|
};
|
|
@@ -8,6 +8,8 @@ import example1R4 from '../../../fixtures/r4/resources/medicationKnowledge/examp
|
|
|
8
8
|
import example2R4 from '../../../fixtures/r4/resources/medicationKnowledge/example2.json';
|
|
9
9
|
import example3R4 from '../../../fixtures/r4/resources/medicationKnowledge/example3.json';
|
|
10
10
|
import example4R4 from '../../../fixtures/r4/resources/medicationKnowledge/example4.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
|
+
import MedicationKnowledgeIcon from '../../../assets/containers/MedicationKnowledge/medication-knowledge.svg';
|
|
11
13
|
|
|
12
14
|
export default {
|
|
13
15
|
title: 'MedicationKnowledge',
|
|
@@ -19,6 +21,7 @@ export const DefaultVisualizationR4 = () => {
|
|
|
19
21
|
<MedicationKnowledge
|
|
20
22
|
fhirVersion={fhirVersions.R4}
|
|
21
23
|
fhirResource={fhirResource}
|
|
24
|
+
fhirIcons={require('../../../assets/containers/MedicationKnowledge/medication-knowledge.svg')}
|
|
22
25
|
/>
|
|
23
26
|
);
|
|
24
27
|
};
|
|
@@ -28,6 +31,7 @@ export const ExampleR4WithoutDaVinciPDex = () => {
|
|
|
28
31
|
<MedicationKnowledge
|
|
29
32
|
fhirVersion={fhirVersions.R4}
|
|
30
33
|
fhirResource={fhirResource}
|
|
34
|
+
fhirIcons={MedicationKnowledgeIcon}
|
|
31
35
|
/>
|
|
32
36
|
);
|
|
33
37
|
};
|
|
@@ -38,6 +42,7 @@ export const ExampleR4WithDaVinciPDex = () => {
|
|
|
38
42
|
fhirVersion={fhirVersions.R4}
|
|
39
43
|
fhirResource={fhirResource}
|
|
40
44
|
withDaVinciPDex
|
|
45
|
+
fhirIcons={fhirIcons}
|
|
41
46
|
/>
|
|
42
47
|
);
|
|
43
48
|
};
|
|
@@ -58,6 +63,7 @@ export const Example3R4WithDaVinciPDex = () => {
|
|
|
58
63
|
fhirVersion={fhirVersions.R4}
|
|
59
64
|
fhirResource={fhirResource}
|
|
60
65
|
withDaVinciPDex
|
|
66
|
+
fhirIcons={false}
|
|
61
67
|
/>
|
|
62
68
|
);
|
|
63
69
|
};
|
|
@@ -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
|
-
|
|
11
|
+
const MedicationOrder = ({ fhirResource, fhirIcons, onClick }) => {
|
|
14
12
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
15
13
|
const medicationCodeableConcept = _get(
|
|
16
14
|
fhirResource,
|
|
@@ -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
|
);
|
|
@@ -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 MedicationOrder from './MedicationOrder';
|
|
5
5
|
|
|
@@ -80,12 +80,43 @@ describe('should render MedicationOrder component properly', () => {
|
|
|
80
80
|
|
|
81
81
|
const { getByTestId } = render(<MedicationOrder {...defaultProps} />);
|
|
82
82
|
|
|
83
|
-
expect(getByTestId('title').textContent).toContain(
|
|
84
|
-
'Medication/MedicationExample2',
|
|
85
|
-
);
|
|
83
|
+
expect(getByTestId('title').textContent).toContain('prescribed medication');
|
|
86
84
|
expect(getByTestId('reasonCode').textContent).toContain('Otitis Media');
|
|
87
85
|
expect(getByTestId('hasDosageInstruction').textContent).toContain(
|
|
88
86
|
'Take 5ml three times daily',
|
|
89
87
|
);
|
|
90
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
|
+
});
|
|
91
122
|
});
|
|
@@ -9,7 +9,7 @@ import Date from '../../datatypes/Date';
|
|
|
9
9
|
|
|
10
10
|
import { Root, Header, Body } from '../../ui';
|
|
11
11
|
|
|
12
|
-
const MedicationRequest = ({ fhirResource, fhirIcons }) => {
|
|
12
|
+
const MedicationRequest = ({ fhirResource, fhirIcons, onClick }) => {
|
|
13
13
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
14
14
|
const medicationCodeableConcept = _get(
|
|
15
15
|
fhirResource,
|
|
@@ -87,6 +87,7 @@ const MedicationRequest = ({ fhirResource, fhirIcons }) => {
|
|
|
87
87
|
/>
|
|
88
88
|
}
|
|
89
89
|
bodyContent={<Body tableData={tableData} />}
|
|
90
|
+
onClick={onClick}
|
|
90
91
|
/>
|
|
91
92
|
</Root>
|
|
92
93
|
);
|
|
@@ -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
|
|
|
@@ -87,7 +87,7 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
87
87
|
);
|
|
88
88
|
expect(container).not.toBeNull();
|
|
89
89
|
|
|
90
|
-
expect(getByTestId('title').textContent).toContain('
|
|
90
|
+
expect(getByTestId('title').textContent).toContain('prescribed medication');
|
|
91
91
|
expect(getByTestId('reasonCode').textContent).toContain(
|
|
92
92
|
'Essential hypertension',
|
|
93
93
|
);
|
|
@@ -118,7 +118,7 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
118
118
|
);
|
|
119
119
|
expect(container).not.toBeNull();
|
|
120
120
|
|
|
121
|
-
expect(getByTestId('title').textContent).toContain('
|
|
121
|
+
expect(getByTestId('title').textContent).toContain('prescribed medication');
|
|
122
122
|
expect(getByTestId('reasonCode').textContent).toContain(
|
|
123
123
|
'Essential hypertension',
|
|
124
124
|
);
|
|
@@ -160,7 +160,7 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
160
160
|
);
|
|
161
161
|
expect(container).not.toBeNull();
|
|
162
162
|
|
|
163
|
-
expect(getByTestId('title').textContent).toContain('
|
|
163
|
+
expect(getByTestId('title').textContent).toContain('Myleran 2mg tablet');
|
|
164
164
|
expect(getByTestId('reasonCode').textContent).toContain(
|
|
165
165
|
'Chronic myeloid Leukemia',
|
|
166
166
|
);
|
|
@@ -171,4 +171,33 @@ describe('should render MedicationRequest component properly', () => {
|
|
|
171
171
|
expect(getByTestId('created').textContent).toEqual('1/15/2015');
|
|
172
172
|
expect(getByTestId('intent').textContent).toEqual('order');
|
|
173
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
|
+
});
|
|
174
203
|
});
|
|
@@ -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);
|
|
@@ -200,6 +204,7 @@ const MedicationStatement = props => {
|
|
|
200
204
|
})}
|
|
201
205
|
</Body>
|
|
202
206
|
}
|
|
207
|
+
onClick={onClick}
|
|
203
208
|
/>
|
|
204
209
|
</Root>
|
|
205
210
|
);
|
|
@@ -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 MedicationStatement from './MedicationStatement';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
import example1MedicationStatement from '../../../fixtures/dstu2/resources/medicationStatement/example1.json';
|
|
@@ -168,4 +168,39 @@ describe('should render MedicationStatement component correctly', () => {
|
|
|
168
168
|
'#med0309',
|
|
169
169
|
);
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
it('should fire custom onClick function', () => {
|
|
173
|
+
const defaultProps = {
|
|
174
|
+
fhirResource: r4Example1,
|
|
175
|
+
fhirVersion: fhirVersions.R4,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const onClick = jest.fn();
|
|
179
|
+
const { getByRole } = render(
|
|
180
|
+
<MedicationStatement {...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 = {
|
|
192
|
+
fhirResource: r4Example1,
|
|
193
|
+
fhirVersion: fhirVersions.R4,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const onClick = 'test';
|
|
197
|
+
const { getByRole } = render(
|
|
198
|
+
<MedicationStatement {...defaultProps} onClick={onClick} />,
|
|
199
|
+
);
|
|
200
|
+
const accordion = getByRole('button');
|
|
201
|
+
fireEvent.click(accordion);
|
|
202
|
+
|
|
203
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
204
|
+
expect(attribute).toEqual('collapse');
|
|
205
|
+
});
|
|
171
206
|
});
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from '../../ui';
|
|
19
19
|
import Reference from '../../datatypes/Reference';
|
|
20
20
|
|
|
21
|
-
const Observation = ({ fhirResource, fhirIcons }) => {
|
|
21
|
+
const Observation = ({ fhirResource, fhirIcons, onClick }) => {
|
|
22
22
|
const effectiveDate = _get(fhirResource, 'effectiveDateTime');
|
|
23
23
|
const codeCodingDisplay = _get(fhirResource, 'code.coding.0.display');
|
|
24
24
|
const codeText = _get(fhirResource, 'code.text', '');
|
|
@@ -114,6 +114,7 @@ const Observation = ({ fhirResource, fhirIcons }) => {
|
|
|
114
114
|
/>
|
|
115
115
|
</Body>
|
|
116
116
|
}
|
|
117
|
+
onClick={onClick}
|
|
117
118
|
/>
|
|
118
119
|
</Root>
|
|
119
120
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required
|
|
3
3
|
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { render } from '@testing-library/react';
|
|
5
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
6
6
|
import Observation from './Observation';
|
|
7
7
|
|
|
8
8
|
import exampleObservationIssued from '../../../fixtures/dstu2/resources/observation/example-issued.json';
|
|
@@ -148,4 +148,33 @@ describe('should render component correctly', () => {
|
|
|
148
148
|
expect(getByTestId('valueQuantityUnit')).not.toBeNull();
|
|
149
149
|
expect(getByTestId('valueQuantityUnit').textContent).toEqual('mmol/l');
|
|
150
150
|
});
|
|
151
|
+
|
|
152
|
+
it('should fire custom onClick function', () => {
|
|
153
|
+
const defaultProps = { fhirResource: example1ObservationExcessR4 };
|
|
154
|
+
|
|
155
|
+
const onClick = jest.fn();
|
|
156
|
+
const { getByRole } = render(
|
|
157
|
+
<Observation {...defaultProps} onClick={onClick} />,
|
|
158
|
+
);
|
|
159
|
+
const accordion = getByRole('button');
|
|
160
|
+
fireEvent.click(accordion);
|
|
161
|
+
|
|
162
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
163
|
+
expect(attribute).not.toEqual('collapse');
|
|
164
|
+
expect(onClick).toHaveBeenCalled();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should not fire custom onClick function', () => {
|
|
168
|
+
const defaultProps = { fhirResource: example1ObservationExcessR4 };
|
|
169
|
+
|
|
170
|
+
const onClick = 'test';
|
|
171
|
+
const { getByRole } = render(
|
|
172
|
+
<Observation {...defaultProps} onClick={onClick} />,
|
|
173
|
+
);
|
|
174
|
+
const accordion = getByRole('button');
|
|
175
|
+
fireEvent.click(accordion);
|
|
176
|
+
|
|
177
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
178
|
+
expect(attribute).toEqual('collapse');
|
|
179
|
+
});
|
|
151
180
|
});
|