fhir-react 0.3.7 → 0.3.10
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/.storybook/main.js +5 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview.js +7 -0
- package/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +9 -9
- package/package.json +59 -57
- 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 +44 -13
- package/src/components/containers/Accordion/Accordion.stories.js +74 -58
- package/src/components/containers/ResourceContainer/ResourceContainer.css +4 -0
- package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
- package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +46 -22
- 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/defaultArgTypes.js +12 -0
- package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +19 -11
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +46 -70
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +9 -1
- package/src/components/resources/Appointment/Appointment.stories.js +51 -62
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +2 -1
- package/src/components/resources/Binary/Binary.stories.js +27 -21
- 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 +59 -115
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +9 -1
- package/src/components/resources/CarePlan/CarePlan.stories.js +44 -54
- package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
- package/src/components/resources/CareTeam/CareTeam.js +79 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +25 -14
- 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 +9 -1
- package/src/components/resources/Claim/Claim.stories.js +36 -49
- 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 +144 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +44 -41
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
- package/src/components/resources/ClaimResponse/Item.js +44 -9
- package/src/components/resources/ClaimResponse/Items.js +5 -4
- package/src/components/resources/Condition/Condition.js +10 -3
- package/src/components/resources/Condition/Condition.stories.js +47 -62
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +9 -1
- package/src/components/resources/Coverage/Coverage.stories.js +38 -50
- package/src/components/resources/Coverage/Coverage.test.js +36 -1
- package/src/components/resources/Device/Device.js +9 -1
- package/src/components/resources/Device/Device.stories.js +40 -52
- package/src/components/resources/Device/Device.test.js +36 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +9 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +38 -50
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +25 -29
- package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
- package/src/components/resources/Encounter/Encounter.js +9 -1
- package/src/components/resources/Encounter/Encounter.stories.js +43 -59
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +53 -67
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js +74 -38
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +22 -28
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
- package/src/components/resources/Generic/Generic.js +21 -7
- package/src/components/resources/Generic/Generic.stories.js +22 -12
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +9 -3
- package/src/components/resources/Goal/Goal.stories.js +35 -49
- package/src/components/resources/Goal/Goal.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +9 -2
- package/src/components/resources/Immunization/Immunization.stories.js +38 -51
- package/src/components/resources/Immunization/Immunization.test.js +36 -1
- package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
- package/src/components/resources/List/Entries.js +3 -3
- package/src/components/resources/List/List.js +137 -88
- package/src/components/resources/List/List.stories.js +69 -40
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +66 -47
- package/src/components/resources/Location/Location.stories.js +25 -13
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +9 -1
- package/src/components/resources/Medication/Medication.stories.js +42 -64
- package/src/components/resources/Medication/Medication.test.js +36 -1
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +34 -41
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
- package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.js +70 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +41 -52
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +117 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +51 -54
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -3
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +11 -4
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +27 -30
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +32 -46
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
- package/src/components/resources/Observation/Observation.js +3 -1
- package/src/components/resources/Observation/Observation.stories.js +39 -33
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Observation/ObservationGraph.js +1 -1
- package/src/components/resources/Organization/Organization.js +10 -2
- package/src/components/resources/Organization/Organization.stories.js +40 -52
- package/src/components/resources/Organization/Organization.test.js +36 -1
- package/src/components/resources/Patient/Patient.js +4 -0
- package/src/components/resources/Patient/Patient.stories.js +36 -28
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +9 -1
- package/src/components/resources/Practitioner/Practitioner.stories.js +39 -52
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +45 -58
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +3 -2
- package/src/components/resources/Procedure/Procedure.stories.js +33 -25
- package/src/components/resources/Procedure/Procedure.test.js +30 -1
- package/src/components/resources/Questionnaire/Group.js +53 -0
- package/src/components/resources/Questionnaire/Items.js +45 -0
- package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
- package/src/components/resources/Questionnaire/Questionnaire.js +38 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +50 -57
- package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
- package/src/components/resources/Questionnaire/Questions.js +40 -0
- package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
- package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
- package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
- package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +54 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +46 -58
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
- package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
- package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
- package/src/components/resources/ReferralRequest/ReferralRequest.js +72 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.stories.js +20 -20
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +42 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
- package/src/components/resources/RelatedPerson/index.js +3 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.js +167 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +18 -14
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +40 -27
- package/src/components/ui/index.js +48 -31
- 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 +14 -1
- package/.storybook/addons.js +0 -1
- package/.storybook/config.js +0 -26
- package/.storybook/presets.js +0 -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,14 @@ 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
|
+
rawOnClick,
|
|
113
|
+
}) => {
|
|
108
114
|
let fhirResourceData = {};
|
|
109
115
|
try {
|
|
110
116
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource, withDaVinciPDex);
|
|
@@ -138,72 +144,117 @@ const MedicationKnowledge = props => {
|
|
|
138
144
|
: amountDisplay;
|
|
139
145
|
}
|
|
140
146
|
|
|
147
|
+
const tableData = [
|
|
148
|
+
{
|
|
149
|
+
label: 'Code',
|
|
150
|
+
testId: 'code',
|
|
151
|
+
data: code && <CodeableConcept fhirData={code} isCursive />,
|
|
152
|
+
status: code,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: 'Manufacturer',
|
|
156
|
+
testId: 'manufacturer',
|
|
157
|
+
data: manufacturer && <Reference fhirData={manufacturer} />,
|
|
158
|
+
status: manufacturer,
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
label: 'Amount',
|
|
162
|
+
testId: 'amount',
|
|
163
|
+
data: amountDisplay,
|
|
164
|
+
status: amountDisplay,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: 'Synonym',
|
|
168
|
+
testId: 'synonym',
|
|
169
|
+
data: synonym,
|
|
170
|
+
status: synonym,
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
const usdfExtensionsData = [
|
|
175
|
+
{
|
|
176
|
+
label: 'Prior Authorization',
|
|
177
|
+
testId: 'usdfPriorAuthorization',
|
|
178
|
+
data:
|
|
179
|
+
isBoolean(usdfPriorAuthorization) && usdfPriorAuthorization === true
|
|
180
|
+
? 'yes'
|
|
181
|
+
: 'no',
|
|
182
|
+
status: isBoolean(usdfPriorAuthorization),
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: 'Step Therapy Limit',
|
|
186
|
+
testId: 'usdfStepTherapyLimit',
|
|
187
|
+
data:
|
|
188
|
+
isBoolean(usdfStepTherapyLimit) && usdfStepTherapyLimit === true
|
|
189
|
+
? 'yes'
|
|
190
|
+
: 'no',
|
|
191
|
+
status: isBoolean(usdfStepTherapyLimit),
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
label: 'Quantity Limit',
|
|
195
|
+
testId: 'usdfQuantityLimit',
|
|
196
|
+
data:
|
|
197
|
+
isBoolean(usdfQuantityLimit) && usdfQuantityLimit === true
|
|
198
|
+
? 'yes'
|
|
199
|
+
: 'no',
|
|
200
|
+
status: isBoolean(usdfQuantityLimit),
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
label: 'Plan ID',
|
|
204
|
+
testId: 'usdfPlanID',
|
|
205
|
+
data: usdfPlanID,
|
|
206
|
+
status: usdfPlanID,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
label: 'Drug Tier ID',
|
|
210
|
+
testId: 'usdfDrugTierID',
|
|
211
|
+
data: usdfDrugTierID && <CodeableConcept fhirData={usdfDrugTierID} />,
|
|
212
|
+
status: usdfDrugTierID,
|
|
213
|
+
},
|
|
214
|
+
];
|
|
215
|
+
|
|
141
216
|
return (
|
|
142
217
|
<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"
|
|
218
|
+
<Accordion
|
|
219
|
+
headerContent={
|
|
220
|
+
<Header
|
|
221
|
+
resourceName="MedicationKnowledge"
|
|
222
|
+
title={
|
|
223
|
+
id
|
|
224
|
+
? `Medication knowledge ID: ${id} `
|
|
225
|
+
: 'MedicationOrder knowledge '
|
|
226
|
+
}
|
|
227
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
228
|
+
icon={fhirIcons}
|
|
229
|
+
/>
|
|
230
|
+
}
|
|
231
|
+
bodyContent={
|
|
232
|
+
<Body tableData={tableData}>
|
|
233
|
+
{hasExtensions && (
|
|
234
|
+
<ValueSection
|
|
235
|
+
label="USDF extensions"
|
|
236
|
+
data-testid="usdfExtensions"
|
|
237
|
+
marginTop
|
|
185
238
|
>
|
|
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>
|
|
239
|
+
{usdfExtensionsData.map(
|
|
240
|
+
(item, index) =>
|
|
241
|
+
item.status && (
|
|
242
|
+
<ValueSectionItem
|
|
243
|
+
key={`usdf-extension-item-${index}`}
|
|
244
|
+
label={item.label}
|
|
245
|
+
data-testid={item.testId}
|
|
246
|
+
>
|
|
247
|
+
{item.data}
|
|
248
|
+
</ValueSectionItem>
|
|
249
|
+
),
|
|
250
|
+
)}
|
|
251
|
+
</ValueSection>
|
|
203
252
|
)}
|
|
204
|
-
</
|
|
205
|
-
|
|
206
|
-
|
|
253
|
+
</Body>
|
|
254
|
+
}
|
|
255
|
+
onClick={onClick}
|
|
256
|
+
rawOnClick={rawOnClick}
|
|
257
|
+
/>
|
|
207
258
|
</Root>
|
|
208
259
|
);
|
|
209
260
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import MedicationKnowledge from './MedicationKnowledge';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -8,71 +8,68 @@ 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',
|
|
16
|
+
component: MedicationKnowledge,
|
|
17
|
+
argTypes: {
|
|
18
|
+
...defaultArgTypes,
|
|
19
|
+
withDaVinciPDex: {
|
|
20
|
+
table: {
|
|
21
|
+
disable: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
14
25
|
};
|
|
15
26
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
27
|
+
const Template = args => <MedicationKnowledge {...args} />;
|
|
28
|
+
|
|
29
|
+
export const DefaultVisualizationR4 = Template.bind({});
|
|
30
|
+
DefaultVisualizationR4.args = {
|
|
31
|
+
fhirVersion: fhirVersions.R4,
|
|
32
|
+
fhirResource: example1R4,
|
|
33
|
+
fhirIcons: require('../../../assets/containers/MedicationKnowledge/medication-knowledge.svg'),
|
|
24
34
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
35
|
+
|
|
36
|
+
export const ExampleR4WithoutDaVinciPDex = Template.bind({});
|
|
37
|
+
ExampleR4WithoutDaVinciPDex.args = {
|
|
38
|
+
fhirVersion: fhirVersions.R4,
|
|
39
|
+
fhirResource: example2R4,
|
|
40
|
+
fhirIcons: MedicationKnowledgeIcon,
|
|
33
41
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
42
|
+
|
|
43
|
+
export const ExampleR4WithDaVinciPDex = Template.bind({});
|
|
44
|
+
ExampleR4WithDaVinciPDex.args = {
|
|
45
|
+
fhirVersion: fhirVersions.R4,
|
|
46
|
+
fhirResource: example2R4,
|
|
47
|
+
fhirIcons: fhirIcons,
|
|
48
|
+
withDaVinciPDex: true,
|
|
43
49
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
50
|
+
|
|
51
|
+
export const Example2R4 = Template.bind({});
|
|
52
|
+
Example2R4.args = {
|
|
53
|
+
fhirVersion: fhirVersions.R4,
|
|
54
|
+
fhirResource: example3R4,
|
|
55
|
+
fhirIcons: false,
|
|
52
56
|
};
|
|
53
57
|
|
|
54
|
-
export const Example3R4WithDaVinciPDex = ()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
withDaVinciPDex
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
58
|
+
export const Example3R4WithDaVinciPDex = Template.bind({});
|
|
59
|
+
Example3R4WithDaVinciPDex.args = {
|
|
60
|
+
fhirVersion: fhirVersions.R4,
|
|
61
|
+
fhirResource: example4R4,
|
|
62
|
+
fhirIcons: 'random text',
|
|
63
|
+
withDaVinciPDex: true,
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
export const ExampleWithoutFHIRVersionProperty = ()
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
export const ExampleWithoutFHIRVersionProperty = Template.bind({});
|
|
67
|
+
ExampleWithoutFHIRVersionProperty.args = {
|
|
68
|
+
fhirResource: example3R4,
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
export const ExampleWithUnsupportedFHIRVersionProperty = ()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
fhirVersion={fhirVersions.DSTU2}
|
|
75
|
-
fhirResource={fhirResource}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
71
|
+
export const ExampleWithUnsupportedFHIRVersionProperty = Template.bind({});
|
|
72
|
+
ExampleWithUnsupportedFHIRVersionProperty.args = {
|
|
73
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
74
|
+
fhirResource: example4R4,
|
|
78
75
|
};
|
|
@@ -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, rawOnClick }) => {
|
|
14
12
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
15
13
|
const medicationCodeableConcept = _get(
|
|
16
14
|
fhirResource,
|
|
@@ -66,6 +64,8 @@ const MedicationOrder = props => {
|
|
|
66
64
|
/>
|
|
67
65
|
}
|
|
68
66
|
bodyContent={<Body tableData={tableData} />}
|
|
67
|
+
onClick={onClick}
|
|
68
|
+
rawOnClick={rawOnClick}
|
|
69
69
|
/>
|
|
70
70
|
</Root>
|
|
71
71
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import MedicationOrder from './MedicationOrder';
|
|
5
5
|
|
|
@@ -7,9 +7,16 @@ import dstu2Example from '../../../fixtures/dstu2/resources/medicationOrder/exam
|
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: 'MedicationOrder',
|
|
10
|
+
component: MedicationOrder,
|
|
11
|
+
argTypes: {
|
|
12
|
+
...defaultArgTypes,
|
|
13
|
+
},
|
|
10
14
|
};
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const Template = args => <MedicationOrder {...args} />;
|
|
17
|
+
|
|
18
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
19
|
+
DefaultVisualizationDSTU2.args = {
|
|
20
|
+
fhirResource: dstu2Example,
|
|
21
|
+
fhirIcons: require('../../../assets/containers/MedicationOrder/medication-order.svg'),
|
|
15
22
|
};
|
|
@@ -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,12 @@ import Date from '../../datatypes/Date';
|
|
|
9
9
|
|
|
10
10
|
import { Root, Header, Body } from '../../ui';
|
|
11
11
|
|
|
12
|
-
const MedicationRequest = ({
|
|
12
|
+
const MedicationRequest = ({
|
|
13
|
+
fhirResource,
|
|
14
|
+
fhirIcons,
|
|
15
|
+
onClick,
|
|
16
|
+
rawOnClick,
|
|
17
|
+
}) => {
|
|
13
18
|
const medicationReference = _get(fhirResource, 'medicationReference');
|
|
14
19
|
const medicationCodeableConcept = _get(
|
|
15
20
|
fhirResource,
|
|
@@ -87,6 +92,8 @@ const MedicationRequest = ({ fhirResource, fhirIcons }) => {
|
|
|
87
92
|
/>
|
|
88
93
|
}
|
|
89
94
|
bodyContent={<Body tableData={tableData} />}
|
|
95
|
+
onClick={onClick}
|
|
96
|
+
rawOnClick={rawOnClick}
|
|
90
97
|
/>
|
|
91
98
|
</Root>
|
|
92
99
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import MedicationRequest from './MedicationRequest';
|
|
5
5
|
|
|
@@ -13,43 +13,40 @@ import MedicationRequestIcon from '../../../assets/containers/MedicationRequest/
|
|
|
13
13
|
|
|
14
14
|
export default {
|
|
15
15
|
title: 'MedicationRequest',
|
|
16
|
+
component: MedicationRequest,
|
|
17
|
+
argTypes: {
|
|
18
|
+
...defaultArgTypes,
|
|
19
|
+
},
|
|
16
20
|
};
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
22
|
+
const Template = args => <MedicationRequest {...args} />;
|
|
23
|
+
|
|
24
|
+
export const DefaultVisualizationSTU3 = Template.bind({});
|
|
25
|
+
DefaultVisualizationSTU3.args = {
|
|
26
|
+
fhirResource: stu3Example1,
|
|
27
|
+
fhirIcons: require('../../../assets/containers/MedicationRequest/medication-request.svg'),
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
export const Example2OfSTU3 = ()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
fhirResource={fhirResource}
|
|
33
|
-
fhirIcons={MedicationRequestIcon}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
30
|
+
export const Example2OfSTU3 = Template.bind({});
|
|
31
|
+
Example2OfSTU3.args = {
|
|
32
|
+
fhirResource: stu3Example2,
|
|
33
|
+
fhirIcons: MedicationRequestIcon,
|
|
36
34
|
};
|
|
37
35
|
|
|
38
|
-
export const Example1OfR4 = ()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
36
|
+
export const Example1OfR4 = Template.bind({});
|
|
37
|
+
Example1OfR4.args = {
|
|
38
|
+
fhirResource: R4Example1,
|
|
39
|
+
fhirIcons: fhirIcons,
|
|
43
40
|
};
|
|
44
41
|
|
|
45
|
-
export const Example2OfR4 = ()
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
export const Example2OfR4 = Template.bind({});
|
|
43
|
+
Example2OfR4.args = {
|
|
44
|
+
fhirResource: R4Example2,
|
|
45
|
+
fhirIcons: false,
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
export const Example3OfR4 = ()
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
48
|
+
export const Example3OfR4 = Template.bind({});
|
|
49
|
+
Example3OfR4.args = {
|
|
50
|
+
fhirResource: R4Example3,
|
|
51
|
+
fhirIcons: 'random text',
|
|
55
52
|
};
|