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,11 +8,10 @@ import { getExtension } from './utils';
|
|
|
8
8
|
import {
|
|
9
9
|
Root,
|
|
10
10
|
Header,
|
|
11
|
-
Title,
|
|
12
|
-
Value,
|
|
13
11
|
Body,
|
|
14
12
|
ValueSection,
|
|
15
13
|
Badge,
|
|
14
|
+
ValueSectionItem,
|
|
16
15
|
} from '../../ui';
|
|
17
16
|
import Date from '../../datatypes/Date';
|
|
18
17
|
import Reference from '../../datatypes/Reference';
|
|
@@ -20,6 +19,7 @@ import Entries from './Entries';
|
|
|
20
19
|
import Identifier from '../../datatypes/Identifier/Identifier';
|
|
21
20
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
22
21
|
import DrugTierDefinitionExtension from './DrugTierDefinitionExtension';
|
|
22
|
+
import Accordion from '../../containers/Accordion';
|
|
23
23
|
|
|
24
24
|
const commonDTO = fhirResource => {
|
|
25
25
|
const id = _get(fhirResource, 'id');
|
|
@@ -125,8 +125,14 @@ const resourceDTO = (fhirVersion, fhirResource, withDaVinciPDex) => {
|
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
const List =
|
|
129
|
-
|
|
128
|
+
const List = ({
|
|
129
|
+
fhirResource,
|
|
130
|
+
fhirVersion,
|
|
131
|
+
withDaVinciPDex = false,
|
|
132
|
+
fhirIcons,
|
|
133
|
+
onClick,
|
|
134
|
+
rawOnClick,
|
|
135
|
+
}) => {
|
|
130
136
|
let fhirResourceData = {};
|
|
131
137
|
try {
|
|
132
138
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource, withDaVinciPDex);
|
|
@@ -156,95 +162,138 @@ const List = props => {
|
|
|
156
162
|
usdfPlanIDType,
|
|
157
163
|
} = fhirResourceData;
|
|
158
164
|
|
|
165
|
+
const tableData = [
|
|
166
|
+
{
|
|
167
|
+
label: 'Identifier',
|
|
168
|
+
testId: 'identifier',
|
|
169
|
+
data:
|
|
170
|
+
identifier &&
|
|
171
|
+
identifier.map((id, index) => (
|
|
172
|
+
<div key={`identifier-${index}`}>
|
|
173
|
+
<Identifier fhirData={id} />
|
|
174
|
+
</div>
|
|
175
|
+
)),
|
|
176
|
+
status: identifier,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
label: 'Mode',
|
|
180
|
+
testId: 'mode',
|
|
181
|
+
data: mode,
|
|
182
|
+
status: mode,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: 'code',
|
|
186
|
+
testId: 'code',
|
|
187
|
+
data: code && <CodeableConcept fhirData={code} />,
|
|
188
|
+
status: code,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: 'Subject',
|
|
192
|
+
testId: 'subject',
|
|
193
|
+
data: subject && <Reference fhirData={subject} />,
|
|
194
|
+
status: subject,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: 'Date',
|
|
198
|
+
testId: 'date',
|
|
199
|
+
data: date && <Date fhirData={date} isBlack />,
|
|
200
|
+
status: date,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
label: 'Source',
|
|
204
|
+
testId: 'source',
|
|
205
|
+
data: source && <Reference fhirData={source} />,
|
|
206
|
+
status: source,
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
const extensionData = [
|
|
211
|
+
{
|
|
212
|
+
label: 'Network',
|
|
213
|
+
testId: 'usdfNetwork',
|
|
214
|
+
data: usdfNetwork,
|
|
215
|
+
status: usdfNetwork,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
label: 'Summary URL',
|
|
219
|
+
testId: 'usdfSummaryURL',
|
|
220
|
+
data: usdfSummaryURL,
|
|
221
|
+
status: usdfSummaryURL,
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
label: 'Formulary URL',
|
|
225
|
+
testId: 'usdfFormularyURL',
|
|
226
|
+
data: usdfFormularyURL,
|
|
227
|
+
status: usdfFormularyURL,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
label: 'Email Plan Contact',
|
|
231
|
+
testId: 'usdfEmailPlanContact',
|
|
232
|
+
data: usdfEmailPlanContact,
|
|
233
|
+
status: usdfEmailPlanContact,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
label: 'Marketing URL',
|
|
237
|
+
testId: 'usdfMarketingURL',
|
|
238
|
+
data: usdfMarketingURL,
|
|
239
|
+
status: usdfMarketingURL,
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
label: 'Plan ID Type',
|
|
243
|
+
testId: 'usdfPlanIDType',
|
|
244
|
+
data: usdfPlanIDType,
|
|
245
|
+
status: usdfPlanIDType,
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
|
|
159
249
|
return (
|
|
160
250
|
<Root name="List">
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</div>
|
|
174
|
-
))}
|
|
175
|
-
</Value>
|
|
176
|
-
)}
|
|
177
|
-
{mode && (
|
|
178
|
-
<Value label="Mode" data-testid="mode">
|
|
179
|
-
{mode}
|
|
180
|
-
</Value>
|
|
181
|
-
)}
|
|
182
|
-
{code && (
|
|
183
|
-
<Value label="code" data-testid="code">
|
|
184
|
-
<CodeableConcept fhirData={code} />
|
|
185
|
-
</Value>
|
|
186
|
-
)}
|
|
187
|
-
{subject && (
|
|
188
|
-
<Value label="Subject" data-testid="subject">
|
|
189
|
-
<Reference fhirData={subject} />
|
|
190
|
-
</Value>
|
|
191
|
-
)}
|
|
192
|
-
{date && (
|
|
193
|
-
<Value label="Date" data-testid="date">
|
|
194
|
-
<Date fhirData={date} />
|
|
195
|
-
</Value>
|
|
196
|
-
)}
|
|
197
|
-
{source && (
|
|
198
|
-
<Value label="Source" data-testid="source">
|
|
199
|
-
<Reference fhirData={source} />
|
|
200
|
-
</Value>
|
|
201
|
-
)}
|
|
202
|
-
{entry && <Entries fhirData={entry} />}
|
|
251
|
+
<Accordion
|
|
252
|
+
headerContent={
|
|
253
|
+
<Header
|
|
254
|
+
resourceName="List"
|
|
255
|
+
title={`${title || 'List'} ${id && id} `}
|
|
256
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
257
|
+
icon={fhirIcons}
|
|
258
|
+
/>
|
|
259
|
+
}
|
|
260
|
+
bodyContent={
|
|
261
|
+
<Body tableData={tableData}>
|
|
262
|
+
{entry && <Entries fhirData={entry} />}
|
|
203
263
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
data-testid="usdfDrugTierDefinition"
|
|
210
|
-
/>
|
|
211
|
-
)}
|
|
212
|
-
{usdfNetwork && (
|
|
213
|
-
<Value label="Network" data-testid="usdfNetwork">
|
|
214
|
-
{usdfNetwork}
|
|
215
|
-
</Value>
|
|
216
|
-
)}
|
|
217
|
-
{usdfSummaryURL && (
|
|
218
|
-
<Value label="Summary URL" data-testid="usdfSummaryURL">
|
|
219
|
-
{usdfSummaryURL}
|
|
220
|
-
</Value>
|
|
221
|
-
)}
|
|
222
|
-
{usdfFormularyURL && (
|
|
223
|
-
<Value label="Formulary URL" data-testid="usdfFormularyURL">
|
|
224
|
-
{usdfFormularyURL}
|
|
225
|
-
</Value>
|
|
226
|
-
)}
|
|
227
|
-
{usdfEmailPlanContact && (
|
|
228
|
-
<Value
|
|
229
|
-
label="Email Plan Contact"
|
|
230
|
-
data-testid="usdfEmailPlanContact"
|
|
264
|
+
{hasExtensions && (
|
|
265
|
+
<ValueSection
|
|
266
|
+
label="USDF extensions"
|
|
267
|
+
data-testid="usdfExtensions"
|
|
268
|
+
marginTop
|
|
231
269
|
>
|
|
232
|
-
{
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
270
|
+
{usdfDrugTierDefinition && (
|
|
271
|
+
<DrugTierDefinitionExtension
|
|
272
|
+
drugTierDefinitionExtension={usdfDrugTierDefinition}
|
|
273
|
+
data-testid="usdfDrugTierDefinition"
|
|
274
|
+
/>
|
|
275
|
+
)}
|
|
276
|
+
<ValueSection marginTop>
|
|
277
|
+
{extensionData.map(
|
|
278
|
+
(item, index) =>
|
|
279
|
+
item.status && (
|
|
280
|
+
<ValueSectionItem
|
|
281
|
+
key={`extension-item-${index}`}
|
|
282
|
+
label={item.label}
|
|
283
|
+
data-testid={item.testId}
|
|
284
|
+
>
|
|
285
|
+
{item.data}
|
|
286
|
+
</ValueSectionItem>
|
|
287
|
+
),
|
|
288
|
+
)}
|
|
289
|
+
</ValueSection>
|
|
290
|
+
</ValueSection>
|
|
244
291
|
)}
|
|
245
|
-
</
|
|
246
|
-
|
|
247
|
-
|
|
292
|
+
</Body>
|
|
293
|
+
}
|
|
294
|
+
onClick={onClick}
|
|
295
|
+
rawOnClick={rawOnClick}
|
|
296
|
+
/>
|
|
248
297
|
</Root>
|
|
249
298
|
);
|
|
250
299
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultArgTypes } from '../../defaultArgTypes';
|
|
3
3
|
|
|
4
4
|
import List from './List';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -14,62 +14,91 @@ import example1R4 from '../../../fixtures/r4/resources/list/example1.json';
|
|
|
14
14
|
import example2R4 from '../../../fixtures/r4/resources/list/example2.json';
|
|
15
15
|
import example3R4 from '../../../fixtures/r4/resources/list/example3.json';
|
|
16
16
|
|
|
17
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
18
|
+
import ListIcon from '../../../assets/containers/List/list.svg';
|
|
19
|
+
|
|
17
20
|
export default {
|
|
18
21
|
title: 'List',
|
|
22
|
+
component: List,
|
|
23
|
+
argTypes: {
|
|
24
|
+
...defaultArgTypes,
|
|
25
|
+
withDaVinciPDex: {
|
|
26
|
+
table: {
|
|
27
|
+
disable: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
19
31
|
};
|
|
20
32
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
const Template = args => <List {...args} />;
|
|
34
|
+
|
|
35
|
+
export const DefaultVisualizationDSTU2 = Template.bind({});
|
|
36
|
+
DefaultVisualizationDSTU2.args = {
|
|
37
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
38
|
+
fhirResource: example1Dstu2,
|
|
39
|
+
fhirIcons: require('../../../assets/containers/List/list.svg'),
|
|
24
40
|
};
|
|
25
41
|
|
|
26
|
-
export const Example2DSTU2 = ()
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
export const Example2DSTU2 = Template.bind({});
|
|
43
|
+
Example2DSTU2.args = {
|
|
44
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
45
|
+
fhirResource: example2Dstu2,
|
|
46
|
+
fhirIcons: ListIcon,
|
|
29
47
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
|
|
49
|
+
export const Example3DSTU2 = Template.bind({});
|
|
50
|
+
Example3DSTU2.args = {
|
|
51
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
52
|
+
fhirResource: example3Dstu2,
|
|
53
|
+
fhirIcons: fhirIcons,
|
|
33
54
|
};
|
|
34
55
|
|
|
35
|
-
export const DefaultVisualizationSTU3 = ()
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
export const DefaultVisualizationSTU3 = Template.bind({});
|
|
57
|
+
DefaultVisualizationSTU3.args = {
|
|
58
|
+
fhirVersion: fhirVersions.STU3,
|
|
59
|
+
fhirResource: example1Stu3,
|
|
60
|
+
fhirIcons: false,
|
|
38
61
|
};
|
|
39
62
|
|
|
40
|
-
export const Example2STU3 = ()
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
export const Example2STU3 = Template.bind({});
|
|
64
|
+
Example2STU3.args = {
|
|
65
|
+
fhirVersion: fhirVersions.STU3,
|
|
66
|
+
fhirResource: example2Stu3,
|
|
67
|
+
fhirIcons: 'random text',
|
|
43
68
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
69
|
+
|
|
70
|
+
export const Example3STU3 = Template.bind({});
|
|
71
|
+
Example3STU3.args = {
|
|
72
|
+
fhirVersion: fhirVersions.STU3,
|
|
73
|
+
fhirResource: example3Stu3,
|
|
47
74
|
};
|
|
48
75
|
|
|
49
|
-
export const DefaultVisualizationR4 = ()
|
|
50
|
-
|
|
51
|
-
|
|
76
|
+
export const DefaultVisualizationR4 = Template.bind({});
|
|
77
|
+
DefaultVisualizationR4.args = {
|
|
78
|
+
fhirVersion: fhirVersions.R4,
|
|
79
|
+
fhirResource: example1R4,
|
|
52
80
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
81
|
+
|
|
82
|
+
export const ExampleR4WithoutDaVinciPDex = Template.bind({});
|
|
83
|
+
ExampleR4WithoutDaVinciPDex.args = {
|
|
84
|
+
fhirVersion: fhirVersions.R4,
|
|
85
|
+
fhirResource: example2R4,
|
|
56
86
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
withDaVinciPDex
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
87
|
+
|
|
88
|
+
export const ExampleR4WithDaVinciPDex = Template.bind({});
|
|
89
|
+
ExampleR4WithDaVinciPDex.args = {
|
|
90
|
+
fhirVersion: fhirVersions.R4,
|
|
91
|
+
fhirResource: example2R4,
|
|
92
|
+
withDaVinciPDex: true,
|
|
66
93
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
94
|
+
|
|
95
|
+
export const Example2R4 = Template.bind({});
|
|
96
|
+
Example2R4.args = {
|
|
97
|
+
fhirVersion: fhirVersions.R4,
|
|
98
|
+
fhirResource: example3R4,
|
|
70
99
|
};
|
|
71
100
|
|
|
72
|
-
export const ExampleWithoutFHIRVersionProperty = ()
|
|
73
|
-
|
|
74
|
-
|
|
101
|
+
export const ExampleWithoutFHIRVersionProperty = Template.bind({});
|
|
102
|
+
ExampleWithoutFHIRVersionProperty.args = {
|
|
103
|
+
fhirResource: example3R4,
|
|
75
104
|
};
|
|
@@ -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,79 @@ import List from './List';
|
|
|
7
7
|
|
|
8
8
|
import example1Dstu2 from '../../../fixtures/dstu2/resources/list/example1.json';
|
|
9
9
|
import example2R4 from '../../../fixtures/r4/resources/list/example2.json';
|
|
10
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
11
|
|
|
11
12
|
describe('should render List component properly', () => {
|
|
13
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
16
|
+
fhirResource: example1Dstu2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { getByAltText } = render(<List {...defaultProps} />);
|
|
20
|
+
const headerIcon = getByAltText('list');
|
|
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.DSTU2,
|
|
28
|
+
fhirResource: example1Dstu2,
|
|
29
|
+
fhirIcons: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const { getByTestId } = render(<List {...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.DSTU2,
|
|
41
|
+
fhirResource: example1Dstu2,
|
|
42
|
+
fhirIcons: (
|
|
43
|
+
<img
|
|
44
|
+
src={require('../assets/containers/List/list.svg')}
|
|
45
|
+
alt="checklist"
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const { getByAltText } = render(<List {...defaultProps} />);
|
|
51
|
+
const headerIcon = getByAltText('checklist');
|
|
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.DSTU2,
|
|
59
|
+
fhirResource: example1Dstu2,
|
|
60
|
+
fhirIcons: fhirIcons,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByAltText } = render(<List {...defaultProps} />);
|
|
64
|
+
const headerIcon = getByAltText('checklist');
|
|
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.DSTU2,
|
|
74
|
+
fhirResource: example1Dstu2,
|
|
75
|
+
fhirIcons: avatarSrc,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { getByAltText } = render(<List {...defaultProps} />);
|
|
79
|
+
const headerIcon = getByAltText('header icon');
|
|
80
|
+
|
|
81
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
82
|
+
});
|
|
12
83
|
it('should render with DSTU2 source data', () => {
|
|
13
84
|
const defaultProps = {
|
|
14
85
|
fhirResource: example1Dstu2,
|
|
@@ -92,4 +163,37 @@ describe('should render List component properly', () => {
|
|
|
92
163
|
);
|
|
93
164
|
expect(getByTestId('usdfPlanIDType').textContent).toContain('HIOS-PLAN-ID');
|
|
94
165
|
});
|
|
166
|
+
|
|
167
|
+
it('should fire custom onClick function', () => {
|
|
168
|
+
const defaultProps = {
|
|
169
|
+
fhirResource: example2R4,
|
|
170
|
+
fhirVersion: fhirVersions.R4,
|
|
171
|
+
withDaVinciPDex: true,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const onClick = jest.fn();
|
|
175
|
+
const { getByRole } = render(<List {...defaultProps} onClick={onClick} />);
|
|
176
|
+
const accordion = getByRole('button');
|
|
177
|
+
fireEvent.click(accordion);
|
|
178
|
+
|
|
179
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
180
|
+
expect(attribute).not.toEqual('collapse');
|
|
181
|
+
expect(onClick).toHaveBeenCalled();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should not fire custom onClick function', () => {
|
|
185
|
+
const defaultProps = {
|
|
186
|
+
fhirResource: example2R4,
|
|
187
|
+
fhirVersion: fhirVersions.R4,
|
|
188
|
+
withDaVinciPDex: true,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const onClick = 'test';
|
|
192
|
+
const { getByRole } = render(<List {...defaultProps} onClick={onClick} />);
|
|
193
|
+
const accordion = getByRole('button');
|
|
194
|
+
fireEvent.click(accordion);
|
|
195
|
+
|
|
196
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
197
|
+
expect(attribute).toEqual('collapse');
|
|
198
|
+
});
|
|
95
199
|
});
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
4
|
|
|
5
|
-
import { Root, Header,
|
|
5
|
+
import { Root, Header, Badge, Body } from '../../ui';
|
|
6
6
|
import Address from '../../datatypes/Address';
|
|
7
7
|
import Telecom from '../../datatypes/Telecom';
|
|
8
8
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
9
9
|
import Reference from '../../datatypes/Reference';
|
|
10
|
+
import Accordion from '../../containers/Accordion';
|
|
10
11
|
|
|
11
|
-
const Location =
|
|
12
|
-
const { fhirResource } = props;
|
|
12
|
+
const Location = ({ fhirResource, fhirIcons, onClick, rawOnClick }) => {
|
|
13
13
|
const name = _get(fhirResource, 'name');
|
|
14
14
|
const status = _get(fhirResource, 'status');
|
|
15
15
|
const description = _get(fhirResource, 'description');
|
|
@@ -19,52 +19,71 @@ const Location = props => {
|
|
|
19
19
|
const physicalType = _get(fhirResource, 'physicalType');
|
|
20
20
|
const mode = _get(fhirResource, 'mode');
|
|
21
21
|
const managingOrganization = _get(fhirResource, 'managingOrganization');
|
|
22
|
+
|
|
23
|
+
const tableData = [
|
|
24
|
+
{
|
|
25
|
+
label: 'Type',
|
|
26
|
+
testId: 'type',
|
|
27
|
+
data: type && <CodeableConcept fhirData={type} isCursive />,
|
|
28
|
+
status: type,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Physical type',
|
|
32
|
+
testId: 'physicalType',
|
|
33
|
+
data: physicalType && (
|
|
34
|
+
<CodeableConcept fhirData={physicalType} isCursive />
|
|
35
|
+
),
|
|
36
|
+
status: physicalType,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: 'Location mode',
|
|
40
|
+
testId: 'mode',
|
|
41
|
+
data: mode,
|
|
42
|
+
status: mode,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: 'Description',
|
|
46
|
+
testId: 'description',
|
|
47
|
+
data: description,
|
|
48
|
+
status: description,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: 'Address',
|
|
52
|
+
testId: 'address',
|
|
53
|
+
data: address && <Address fhirData={address} />,
|
|
54
|
+
status: address,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Telecom',
|
|
58
|
+
testId: 'telecom',
|
|
59
|
+
data: telecom && <Telecom fhirData={telecom} noSystemData />,
|
|
60
|
+
status: telecom,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: 'Managing organization',
|
|
64
|
+
testId: 'managingOrganization',
|
|
65
|
+
data: managingOrganization && (
|
|
66
|
+
<Reference fhirData={managingOrganization} />
|
|
67
|
+
),
|
|
68
|
+
status: managingOrganization,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
22
72
|
return (
|
|
23
73
|
<Root name="Location">
|
|
24
|
-
<
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</Value>
|
|
38
|
-
)}
|
|
39
|
-
{mode && (
|
|
40
|
-
<Value label="Location mode" data-testid="mode">
|
|
41
|
-
{mode}
|
|
42
|
-
</Value>
|
|
43
|
-
)}
|
|
44
|
-
{description && (
|
|
45
|
-
<Value label="Description" data-testid="description">
|
|
46
|
-
{description}
|
|
47
|
-
</Value>
|
|
48
|
-
)}
|
|
49
|
-
{address && (
|
|
50
|
-
<Value label="Address" data-testid="address">
|
|
51
|
-
<Address fhirData={address} />
|
|
52
|
-
</Value>
|
|
53
|
-
)}
|
|
54
|
-
{telecom && (
|
|
55
|
-
<Value label="Telecom" data-testid="telecom">
|
|
56
|
-
<Telecom fhirData={telecom} />
|
|
57
|
-
</Value>
|
|
58
|
-
)}
|
|
59
|
-
{managingOrganization && (
|
|
60
|
-
<Value
|
|
61
|
-
label="Managing organization"
|
|
62
|
-
data-testid="managingOrganization"
|
|
63
|
-
>
|
|
64
|
-
<Reference fhirData={managingOrganization} />
|
|
65
|
-
</Value>
|
|
66
|
-
)}
|
|
67
|
-
</Body>
|
|
74
|
+
<Accordion
|
|
75
|
+
headerContent={
|
|
76
|
+
<Header
|
|
77
|
+
resourceName="Location"
|
|
78
|
+
title={name}
|
|
79
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
80
|
+
icon={fhirIcons}
|
|
81
|
+
/>
|
|
82
|
+
}
|
|
83
|
+
bodyContent={<Body tableData={tableData} />}
|
|
84
|
+
onClick={onClick}
|
|
85
|
+
rawOnClick={rawOnClick}
|
|
86
|
+
/>
|
|
68
87
|
</Root>
|
|
69
88
|
);
|
|
70
89
|
};
|