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
|
@@ -9,37 +9,14 @@ import fhirVersions from '../fhirResourceVersions';
|
|
|
9
9
|
import {
|
|
10
10
|
Root,
|
|
11
11
|
Header,
|
|
12
|
-
Title,
|
|
13
12
|
Body,
|
|
14
|
-
Value,
|
|
15
13
|
ValueSection,
|
|
16
14
|
Table,
|
|
17
15
|
TableHeader,
|
|
18
|
-
TableCell,
|
|
19
16
|
TableRow,
|
|
20
|
-
MissingValue,
|
|
21
17
|
} from '../../ui';
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
const DosageInstruction = props => {
|
|
25
|
-
const empty = <MissingValue />;
|
|
26
|
-
const {
|
|
27
|
-
timing = empty,
|
|
28
|
-
route = empty,
|
|
29
|
-
doseQuantity = empty,
|
|
30
|
-
additionalInstructions = empty,
|
|
31
|
-
} = props.item;
|
|
32
|
-
return (
|
|
33
|
-
<TableRow>
|
|
34
|
-
<TableCell data-testid="dosageTiming">{timing}</TableCell>
|
|
35
|
-
<TableCell data-testid="dosageRoute">{route}</TableCell>
|
|
36
|
-
<TableCell data-testid="dosageQuantity">{doseQuantity}</TableCell>
|
|
37
|
-
<TableCell data-testid="dosageAdditionalInstructions">
|
|
38
|
-
<CodeableConcept fhirData={additionalInstructions} />
|
|
39
|
-
</TableCell>
|
|
40
|
-
</TableRow>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
18
|
+
import Accordion from '../../containers/Accordion';
|
|
19
|
+
import DosageInstruction from './DosageInstruction';
|
|
43
20
|
|
|
44
21
|
const commonDTO = fhirResource => {
|
|
45
22
|
const typeCoding = _get(fhirResource, 'type.coding.0');
|
|
@@ -182,8 +159,12 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
182
159
|
}
|
|
183
160
|
};
|
|
184
161
|
|
|
185
|
-
const MedicationDispense =
|
|
186
|
-
|
|
162
|
+
const MedicationDispense = ({
|
|
163
|
+
fhirResource,
|
|
164
|
+
fhirVersion,
|
|
165
|
+
fhirIcons,
|
|
166
|
+
onClick,
|
|
167
|
+
}) => {
|
|
187
168
|
let fhirResourceData = {};
|
|
188
169
|
try {
|
|
189
170
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -201,49 +182,68 @@ const MedicationDispense = props => {
|
|
|
201
182
|
whenPrepared,
|
|
202
183
|
} = fhirResourceData;
|
|
203
184
|
|
|
185
|
+
const tableData = [
|
|
186
|
+
{
|
|
187
|
+
label: 'Medication',
|
|
188
|
+
testId: 'medicationCoding',
|
|
189
|
+
data: medicationCoding && <Coding fhirData={medicationCoding} />,
|
|
190
|
+
status: medicationCoding,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
label: 'Prepared',
|
|
194
|
+
testId: 'whenPrepared',
|
|
195
|
+
data: whenPrepared && <Date fhirData={whenPrepared} isBlack />,
|
|
196
|
+
status: whenPrepared,
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
label: 'Type',
|
|
200
|
+
testId: 'typeCoding',
|
|
201
|
+
data: typeCoding && <Coding fhirData={typeCoding} />,
|
|
202
|
+
status: typeCoding,
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
|
|
204
206
|
return (
|
|
205
207
|
<Root name="MedicationDispense">
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
)}
|
|
246
|
-
</Body>
|
|
208
|
+
<Accordion
|
|
209
|
+
headerContent={
|
|
210
|
+
<Header
|
|
211
|
+
resourceName="MedicationDispense"
|
|
212
|
+
title={medicationTitle}
|
|
213
|
+
icon={fhirIcons}
|
|
214
|
+
/>
|
|
215
|
+
}
|
|
216
|
+
bodyContent={
|
|
217
|
+
<Body tableData={tableData}>
|
|
218
|
+
{hasDosageInstruction && (
|
|
219
|
+
<ValueSection
|
|
220
|
+
label="Dosage instruction"
|
|
221
|
+
marginTop={medicationCoding || whenPrepared || typeCoding}
|
|
222
|
+
>
|
|
223
|
+
<Table>
|
|
224
|
+
<thead>
|
|
225
|
+
<TableRow>
|
|
226
|
+
<TableHeader>Timing</TableHeader>
|
|
227
|
+
<TableHeader>Route</TableHeader>
|
|
228
|
+
<TableHeader>Dose quantity</TableHeader>
|
|
229
|
+
<TableHeader>Additional instructions</TableHeader>
|
|
230
|
+
</TableRow>
|
|
231
|
+
</thead>
|
|
232
|
+
<tbody
|
|
233
|
+
data-testid="hasDosageInstruction"
|
|
234
|
+
className="border-top-0"
|
|
235
|
+
>
|
|
236
|
+
{dosageInstructionData.map((item, i) => (
|
|
237
|
+
<DosageInstruction key={`item-${i}`} item={item} />
|
|
238
|
+
))}
|
|
239
|
+
</tbody>
|
|
240
|
+
</Table>
|
|
241
|
+
</ValueSection>
|
|
242
|
+
)}
|
|
243
|
+
</Body>
|
|
244
|
+
}
|
|
245
|
+
onClick={onClick}
|
|
246
|
+
/>
|
|
247
247
|
</Root>
|
|
248
248
|
);
|
|
249
249
|
};
|
|
@@ -10,6 +10,8 @@ import stu3Example1 from '../../../fixtures/stu3/resources/medicationDispense/ex
|
|
|
10
10
|
import stu3Example2 from '../../../fixtures/stu3/resources/medicationDispense/example2.json';
|
|
11
11
|
import R4Example1 from '../../../fixtures/r4/resources/medicationDispense/example1.json';
|
|
12
12
|
import R4Example2 from '../../../fixtures/r4/resources/medicationDispense/example2.json';
|
|
13
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
|
+
import MedicationDispenseIcon from '../../../assets/containers/MedicationDispense/medication-dispense.svg';
|
|
13
15
|
|
|
14
16
|
export default {
|
|
15
17
|
title: 'MedicationDispense',
|
|
@@ -21,6 +23,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
21
23
|
<MedicationDispense
|
|
22
24
|
fhirResource={fhirResource}
|
|
23
25
|
fhirVersion={fhirVersions.DSTU2}
|
|
26
|
+
fhirIcons={require('../../../assets/containers/MedicationDispense/medication-dispense.svg')}
|
|
24
27
|
/>
|
|
25
28
|
);
|
|
26
29
|
};
|
|
@@ -31,6 +34,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
31
34
|
<MedicationDispense
|
|
32
35
|
fhirResource={fhirResource}
|
|
33
36
|
fhirVersion={fhirVersions.DSTU2}
|
|
37
|
+
fhirIcons={MedicationDispenseIcon}
|
|
34
38
|
/>
|
|
35
39
|
);
|
|
36
40
|
};
|
|
@@ -41,6 +45,7 @@ export const Example1OfSTU3 = () => {
|
|
|
41
45
|
<MedicationDispense
|
|
42
46
|
fhirResource={fhirResource}
|
|
43
47
|
fhirVersion={fhirVersions.STU3}
|
|
48
|
+
fhirIcons={fhirIcons}
|
|
44
49
|
/>
|
|
45
50
|
);
|
|
46
51
|
};
|
|
@@ -51,6 +56,7 @@ export const Example2OfSTU3 = () => {
|
|
|
51
56
|
<MedicationDispense
|
|
52
57
|
fhirResource={fhirResource}
|
|
53
58
|
fhirVersion={fhirVersions.STU3}
|
|
59
|
+
fhirIcons={false}
|
|
54
60
|
/>
|
|
55
61
|
);
|
|
56
62
|
};
|
|
@@ -61,6 +67,7 @@ export const Example1OfR4 = () => {
|
|
|
61
67
|
<MedicationDispense
|
|
62
68
|
fhirResource={fhirResource}
|
|
63
69
|
fhirVersion={fhirVersions.R4}
|
|
70
|
+
fhirIcons={'random text'}
|
|
64
71
|
/>
|
|
65
72
|
);
|
|
66
73
|
};
|
|
@@ -1,13 +1,85 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, within } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, within } from '@testing-library/react';
|
|
3
3
|
import MedicationDispense from './MedicationDispense';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
6
6
|
import dstu2Example1 from '../../../fixtures/dstu2/resources/medicationDispense/example1.json';
|
|
7
7
|
import stu3Example1 from '../../../fixtures/stu3/resources/medicationDispense/example1.json';
|
|
8
8
|
import R4Example2 from '../../../fixtures/r4/resources/medicationDispense/example2.json';
|
|
9
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
9
10
|
|
|
10
11
|
describe('should render Device component properly', () => {
|
|
12
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
15
|
+
fhirResource: dstu2Example1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { getByAltText } = render(<MedicationDispense {...defaultProps} />);
|
|
19
|
+
const headerIcon = getByAltText('medication dispense');
|
|
20
|
+
|
|
21
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
25
|
+
const defaultProps = {
|
|
26
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
27
|
+
fhirResource: dstu2Example1,
|
|
28
|
+
fhirIcons: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { getByTestId } = render(<MedicationDispense {...defaultProps} />);
|
|
32
|
+
const headerIcon = getByTestId('placeholder');
|
|
33
|
+
|
|
34
|
+
expect(headerIcon).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
38
|
+
const defaultProps = {
|
|
39
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
40
|
+
fhirResource: dstu2Example1,
|
|
41
|
+
fhirIcons: (
|
|
42
|
+
<img
|
|
43
|
+
src={require('../assets/containers/MedicationDispense/medication-dispense.svg')}
|
|
44
|
+
alt="medication dispense"
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getByAltText } = render(<MedicationDispense {...defaultProps} />);
|
|
50
|
+
const headerIcon = getByAltText('medication dispense');
|
|
51
|
+
|
|
52
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
56
|
+
const defaultProps = {
|
|
57
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
58
|
+
fhirResource: dstu2Example1,
|
|
59
|
+
fhirIcons: fhirIcons,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const { getByAltText } = render(<MedicationDispense {...defaultProps} />);
|
|
63
|
+
const headerIcon = getByAltText('medication dispense');
|
|
64
|
+
|
|
65
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
69
|
+
const avatarSrc =
|
|
70
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
71
|
+
const defaultProps = {
|
|
72
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
73
|
+
fhirResource: dstu2Example1,
|
|
74
|
+
fhirIcons: avatarSrc,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { getByAltText } = render(<MedicationDispense {...defaultProps} />);
|
|
78
|
+
const headerIcon = getByAltText('header icon');
|
|
79
|
+
|
|
80
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
81
|
+
});
|
|
82
|
+
|
|
11
83
|
it('should render with DSTU2 source data', () => {
|
|
12
84
|
const defaultProps = {
|
|
13
85
|
fhirResource: dstu2Example1,
|
|
@@ -84,4 +156,39 @@ describe('should render Device component properly', () => {
|
|
|
84
156
|
),
|
|
85
157
|
).toEqual(['Ordered(ordered)', 'Ordered(ordered)', 'Ordered(ordered)']);
|
|
86
158
|
});
|
|
159
|
+
|
|
160
|
+
it('should fire custom onClick function', () => {
|
|
161
|
+
const defaultProps = {
|
|
162
|
+
fhirResource: R4Example2,
|
|
163
|
+
fhirVersion: fhirVersions.R4,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const onClick = jest.fn();
|
|
167
|
+
const { getByRole } = render(
|
|
168
|
+
<MedicationDispense {...defaultProps} onClick={onClick} />,
|
|
169
|
+
);
|
|
170
|
+
const accordion = getByRole('button');
|
|
171
|
+
fireEvent.click(accordion);
|
|
172
|
+
|
|
173
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
174
|
+
expect(attribute).not.toEqual('collapse');
|
|
175
|
+
expect(onClick).toHaveBeenCalled();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should not fire custom onClick function', () => {
|
|
179
|
+
const defaultProps = {
|
|
180
|
+
fhirResource: R4Example2,
|
|
181
|
+
fhirVersion: fhirVersions.R4,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const onClick = 'test';
|
|
185
|
+
const { getByRole } = render(
|
|
186
|
+
<MedicationDispense {...defaultProps} onClick={onClick} />,
|
|
187
|
+
);
|
|
188
|
+
const accordion = getByRole('button');
|
|
189
|
+
fireEvent.click(accordion);
|
|
190
|
+
|
|
191
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
192
|
+
expect(attribute).toEqual('collapse');
|
|
193
|
+
});
|
|
87
194
|
});
|
|
@@ -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
|
};
|