fhir-react 0.2.1 → 0.3.0
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/.github/workflows/publish_npmjs.yml +18 -0
- package/.storybook/config.js +9 -3
- package/.storybook/presets.js +1 -0
- package/.storybook/preview-head.html +4 -0
- package/README.md +86 -55
- package/package.json +13 -4
- package/src/assets/common/chevron-right.svg +3 -0
- package/src/assets/containers/AllergyIntolerance/allergy-intolerance.svg +9 -0
- package/src/assets/containers/Appointment/appointment.svg +14 -0
- package/src/assets/containers/CarePlan/care-plan.svg +10 -0
- package/src/assets/containers/CareTeam/care-team.svg +10 -0
- package/src/assets/containers/Claim/claim.svg +6 -0
- package/src/assets/containers/ClaimResponse/claim-response.svg +7 -0
- package/src/assets/containers/Condition/condition.svg +11 -0
- package/src/assets/containers/Device/device.svg +8 -0
- package/src/assets/containers/DiagnosticReport/diagnostic-report.svg +14 -0
- package/src/assets/containers/DocumentReference/document-reference.svg +10 -0
- package/src/assets/containers/Encounter/encounter.svg +10 -0
- package/src/assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg +3 -0
- package/src/assets/containers/FamilyMemberHistory/family-member-history.svg +7 -0
- package/src/assets/containers/Goal/goal.svg +11 -0
- package/src/assets/containers/Immunization/immunization.svg +7 -0
- package/src/assets/containers/List/list.svg +3 -0
- package/src/assets/containers/Location/location.svg +4 -0
- package/src/assets/containers/Medication/medication.svg +5 -0
- package/src/assets/containers/MedicationAdministration/medication-administration.svg +6 -0
- package/src/assets/containers/MedicationKnowledge/medication-knowledge.svg +11 -0
- package/src/assets/containers/MedicationStatement/medication-statement.svg +5 -0
- package/src/assets/containers/Observation/observation.svg +12 -0
- package/src/assets/containers/Practitioner/practitioner.svg +5 -0
- package/src/assets/containers/Procedure/procedure.svg +9 -0
- package/src/assets/containers/Questionnaire/questionnaire.svg +6 -0
- package/src/assets/containers/QuestionnaireResponse/questionnaire-response.svg +6 -0
- package/src/assets/containers/QustionnaireResponse/questionnaire-response.svg +6 -0
- package/src/assets/containers/ResearchStudy/research-study.svg +9 -0
- package/src/assets/containers/ResourceCategory/resource-placeholder.svg +3 -0
- package/src/components/containers/Accordion/Accordion.js +80 -0
- package/src/components/containers/Accordion/Accordion.stories.js +76 -0
- package/src/components/containers/Accordion/index.js +3 -0
- package/src/components/containers/ResourceContainer/ResourceContainer.css +0 -1
- package/src/components/containers/ResourceContainer/ResourceContainer.js +1 -1
- package/src/components/datatypes/AccountBalance/AccountBalance.js +33 -0
- package/src/components/datatypes/AccountBalance/index.js +3 -0
- package/src/components/datatypes/Annotation/Annotation.js +1 -1
- package/src/components/datatypes/Coding/Coding.js +1 -1
- package/src/components/datatypes/Date/Date.js +14 -4
- package/src/components/datatypes/DatePeriod/DatePeriod.js +38 -0
- package/src/components/datatypes/DatePeriod/index.js +3 -0
- package/src/components/datatypes/HeaderIcon/HeaderIcon.js +31 -0
- package/src/components/datatypes/HeaderIcon/index.js +3 -0
- package/src/components/datatypes/HumanName/HumanName.js +6 -21
- package/src/components/datatypes/Reference/Reference.js +3 -6
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +2 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +4 -4
- package/src/components/resources/Appointment/Appointment.js +91 -65
- package/src/components/resources/Appointment/Appointment.test.js +3 -3
- package/src/components/resources/Bundle/Bundle.js +2 -2
- package/src/components/resources/Bundle/Bundle.stories.js +78 -12
- package/src/components/resources/Bundle/Bundle.test.js +3 -0
- package/src/components/resources/CarePlan/CarePlan.test.js +4 -4
- package/src/components/resources/CareTeam/CareTeam.js +13 -14
- package/src/components/resources/CareTeam/CareTeam.test.js +4 -4
- package/src/components/resources/Claim/Claim.test.js +6 -6
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +6 -6
- package/src/components/resources/Condition/Condition.js +63 -47
- package/src/components/resources/Condition/Condition.stories.js +41 -8
- package/src/components/resources/Condition/Condition.test.js +20 -14
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +5 -7
- package/src/components/resources/DocumentReference/DocumentReference.js +1 -1
- package/src/components/resources/DocumentReference/DocumentReference.test.js +3 -3
- package/src/components/resources/Encounter/Encounter.js +66 -36
- package/src/components/resources/Encounter/EncounterParticipants.js +2 -2
- package/src/components/resources/ExplanationOfBenefit/CareTeam.js +2 -2
- package/src/components/resources/ExplanationOfBenefit/Diagnosis.js +31 -5
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +272 -201
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +12 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +96 -62
- package/src/components/resources/ExplanationOfBenefit/Items.js +2 -2
- package/src/components/resources/ExplanationOfBenefit/PriceLabel.js +20 -0
- package/src/components/resources/ExplanationOfBenefit/Related.js +3 -3
- package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +14 -3
- package/src/components/resources/ExplanationOfBenefit/TotalGraph.js +68 -0
- package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.js +89 -0
- package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js +78 -0
- package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.test.js +51 -0
- package/src/components/resources/ExplanationOfBenefitGraph/index.js +3 -0
- package/src/components/resources/Goal/Goal.test.js +1 -1
- package/src/components/resources/Immunization/Immunization.js +125 -94
- package/src/components/resources/Immunization/Immunization.stories.js +23 -4
- package/src/components/resources/Immunization/Immunization.test.js +17 -12
- package/src/components/resources/List/DrugTierDefinitionExtension.js +139 -0
- package/src/components/resources/List/Entries.js +66 -0
- package/src/components/resources/List/List.js +262 -0
- package/src/components/resources/List/List.stories.js +75 -0
- package/src/components/resources/List/List.test.js +95 -0
- package/src/components/resources/List/index.js +3 -0
- package/src/components/resources/List/utils.js +6 -0
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +7 -7
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +2 -2
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +217 -0
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +78 -0
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +69 -0
- package/src/components/resources/MedicationKnowledge/index.js +3 -0
- package/src/components/resources/MedicationKnowledge/utils.js +8 -0
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +4 -4
- package/src/components/resources/Observation/Observation.js +72 -54
- package/src/components/resources/Observation/Observation.test.js +6 -18
- package/src/components/resources/Observation/ObservationGraph.js +159 -55
- package/src/components/resources/Observation/ObservationGraph.test.js +47 -26
- package/src/components/resources/Patient/Patient.js +79 -97
- package/src/components/resources/Patient/Patient.test.js +10 -10
- package/src/components/resources/Practitioner/Practitioner.js +80 -60
- package/src/components/resources/Practitioner/Practitioner.test.js +4 -4
- package/src/components/resources/Procedure/Procedure.js +99 -87
- package/src/components/resources/Procedure/Procedure.stories.js +8 -6
- package/src/components/resources/Procedure/Procedure.test.js +11 -8
- package/src/components/resources/Questionnaire/Questionnaire.test.js +3 -3
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +5 -5
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +2 -2
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +1 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +56 -0
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +29 -0
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +101 -0
- package/src/components/resources/ResourceCategory/index.js +3 -0
- package/src/components/supportedFhirResourceList.js +4 -0
- package/src/components/ui/_header.scss +3 -0
- package/src/components/ui/bootstrap-reboot.min.css +2 -22
- package/src/components/ui/index.js +191 -29
- package/src/constants/badge-status.jsx +98 -0
- package/src/fixtures/dstu2/resources/condition/condition.svg +35 -0
- package/src/fixtures/dstu2/resources/immunization/immunization.svg +10 -0
- package/src/fixtures/dstu2/resources/list/example1.json +49 -0
- package/src/fixtures/dstu2/resources/list/example2.json +116 -0
- package/src/fixtures/dstu2/resources/list/example3.json +380 -0
- package/src/fixtures/example-icons.jsx +169 -0
- package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json +446 -0
- package/src/fixtures/r4/resources/list/example1.json +45 -0
- package/src/fixtures/r4/resources/list/example2.json +282 -0
- package/src/fixtures/r4/resources/list/example3.json +298 -0
- package/src/fixtures/r4/resources/medicationKnowledge/example1.json +42 -0
- package/src/fixtures/r4/resources/medicationKnowledge/example2.json +59 -0
- package/src/fixtures/r4/resources/medicationKnowledge/example3.json +59 -0
- package/src/fixtures/r4/resources/medicationKnowledge/example4.json +59 -0
- package/src/fixtures/stu3/resources/list/example1.json +46 -0
- package/src/fixtures/stu3/resources/list/example2.json +298 -0
- package/src/fixtures/stu3/resources/list/example3.json +115 -0
- package/src/index.js +6 -1
- package/src/style.scss +176 -0
- package/src/utils/formatDate.js +21 -0
- package/src/utils/formatDate.test.js +22 -0
- package/src/utils/getBadgeColor.js +6 -0
- package/src/utils/getBadgeColor.test.js +14 -0
- package/src/utils/isUrl.js +9 -0
- package/src/utils/isUrl.test.js +12 -0
- package/src/utils.js +7 -0
- package/build/bootstrap-reboot.min.css +0 -414
- package/build/index.js +0 -15
- package/build/style.css +0 -459
- package/src/components/datatypes/HumanName/HumanName.css +0 -15
- package/src/components/datatypes/Reference/Reference.css +0 -8
- package/src/components/resources/Observation/ObservationGraph.css +0 -51
- package/src/components/resources/Patient/Patient.css +0 -19
- package/src/components/ui/index.css +0 -123
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import _get from 'lodash/get';
|
|
4
|
+
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
5
|
+
import fhirVersions from '../fhirResourceVersions';
|
|
6
|
+
import { getExtension } from './utils';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Root,
|
|
10
|
+
Header,
|
|
11
|
+
Title,
|
|
12
|
+
Value,
|
|
13
|
+
Body,
|
|
14
|
+
ValueSection,
|
|
15
|
+
Badge,
|
|
16
|
+
} from '../../ui';
|
|
17
|
+
import Date from '../../datatypes/Date';
|
|
18
|
+
import Reference from '../../datatypes/Reference';
|
|
19
|
+
import Entries from './Entries';
|
|
20
|
+
import Identifier from '../../datatypes/Identifier/Identifier';
|
|
21
|
+
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
22
|
+
import DrugTierDefinitionExtension from './DrugTierDefinitionExtension';
|
|
23
|
+
|
|
24
|
+
const commonDTO = fhirResource => {
|
|
25
|
+
const id = _get(fhirResource, 'id');
|
|
26
|
+
const identifier = _get(fhirResource, 'identifier');
|
|
27
|
+
const status = String(_get(fhirResource, 'status'));
|
|
28
|
+
const mode = _get(fhirResource, 'mode');
|
|
29
|
+
const title = _get(fhirResource, 'title');
|
|
30
|
+
const code = _get(fhirResource, 'code');
|
|
31
|
+
const subject = _get(fhirResource, 'subject');
|
|
32
|
+
const date = _get(fhirResource, 'date');
|
|
33
|
+
const source = _get(fhirResource, 'source');
|
|
34
|
+
const entry = _get(fhirResource, 'entry');
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id,
|
|
38
|
+
identifier,
|
|
39
|
+
status,
|
|
40
|
+
mode,
|
|
41
|
+
title,
|
|
42
|
+
code,
|
|
43
|
+
subject,
|
|
44
|
+
date,
|
|
45
|
+
source,
|
|
46
|
+
entry,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const daVinciPDex = fhirResource => {
|
|
51
|
+
const extension = _get(fhirResource, 'extension', []);
|
|
52
|
+
const hasExtensions = extension.length > 0;
|
|
53
|
+
|
|
54
|
+
if (hasExtensions) {
|
|
55
|
+
const usdfDrugTierDefinition = getExtension(
|
|
56
|
+
'usdf-DrugTierDefinition-extension',
|
|
57
|
+
extension,
|
|
58
|
+
);
|
|
59
|
+
const usdfNetwork = _get(
|
|
60
|
+
getExtension('usdf-Network-extension', extension),
|
|
61
|
+
'valueString',
|
|
62
|
+
);
|
|
63
|
+
const usdfSummaryURL = _get(
|
|
64
|
+
getExtension('usdf-SummaryURL-extension', extension),
|
|
65
|
+
'valueString',
|
|
66
|
+
);
|
|
67
|
+
const usdfFormularyURL = _get(
|
|
68
|
+
getExtension('usdf-FormularyURL-extension', extension),
|
|
69
|
+
'valueString',
|
|
70
|
+
);
|
|
71
|
+
const usdfEmailPlanContact = _get(
|
|
72
|
+
getExtension('usdf-EmailPlanContact-extension', extension),
|
|
73
|
+
'valueString',
|
|
74
|
+
);
|
|
75
|
+
const usdfMarketingURL = _get(
|
|
76
|
+
getExtension('usdf-MarketingURL-extension', extension),
|
|
77
|
+
'valueString',
|
|
78
|
+
);
|
|
79
|
+
const usdfPlanIDType = _get(
|
|
80
|
+
getExtension('usdf-PlanIDType-extension', extension),
|
|
81
|
+
'valueString',
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
hasExtensions,
|
|
86
|
+
usdfDrugTierDefinition,
|
|
87
|
+
usdfNetwork,
|
|
88
|
+
usdfSummaryURL,
|
|
89
|
+
usdfFormularyURL,
|
|
90
|
+
usdfEmailPlanContact,
|
|
91
|
+
usdfMarketingURL,
|
|
92
|
+
usdfPlanIDType,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
hasExtensions,
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const resourceDTO = (fhirVersion, fhirResource, withDaVinciPDex) => {
|
|
102
|
+
switch (fhirVersion) {
|
|
103
|
+
case fhirVersions.DSTU2:
|
|
104
|
+
case fhirVersions.STU3: {
|
|
105
|
+
return {
|
|
106
|
+
...commonDTO(fhirResource),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
case fhirVersions.R4: {
|
|
110
|
+
const dto = {
|
|
111
|
+
...commonDTO(fhirResource),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (withDaVinciPDex) {
|
|
115
|
+
return {
|
|
116
|
+
...dto,
|
|
117
|
+
...daVinciPDex(fhirResource),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return dto;
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
throw Error('Unrecognized the fhir version property type.');
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const List = props => {
|
|
129
|
+
const { fhirResource, fhirVersion, withDaVinciPDex = false } = props;
|
|
130
|
+
let fhirResourceData = {};
|
|
131
|
+
try {
|
|
132
|
+
fhirResourceData = resourceDTO(fhirVersion, fhirResource, withDaVinciPDex);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.warn(error.message);
|
|
135
|
+
return <UnhandledResourceDataStructure resourceName="List" />;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const {
|
|
139
|
+
id,
|
|
140
|
+
identifier,
|
|
141
|
+
status,
|
|
142
|
+
mode,
|
|
143
|
+
title,
|
|
144
|
+
code,
|
|
145
|
+
subject,
|
|
146
|
+
date,
|
|
147
|
+
source,
|
|
148
|
+
entry,
|
|
149
|
+
hasExtensions,
|
|
150
|
+
usdfDrugTierDefinition,
|
|
151
|
+
usdfNetwork,
|
|
152
|
+
usdfSummaryURL,
|
|
153
|
+
usdfFormularyURL,
|
|
154
|
+
usdfEmailPlanContact,
|
|
155
|
+
usdfMarketingURL,
|
|
156
|
+
usdfPlanIDType,
|
|
157
|
+
} = fhirResourceData;
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Root name="List">
|
|
161
|
+
<Header>
|
|
162
|
+
<Title>
|
|
163
|
+
{title || 'List'} {id && id}{' '}
|
|
164
|
+
{status && <Badge data-testid="status">{status}</Badge>}
|
|
165
|
+
</Title>
|
|
166
|
+
</Header>
|
|
167
|
+
<Body>
|
|
168
|
+
{identifier && (
|
|
169
|
+
<Value label="Identifier" data-testid="identifier">
|
|
170
|
+
{identifier.map((id, index) => (
|
|
171
|
+
<div key={`identifier-${index}`}>
|
|
172
|
+
<Identifier fhirData={id} />
|
|
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} />}
|
|
203
|
+
|
|
204
|
+
{hasExtensions && (
|
|
205
|
+
<ValueSection label="USDF extensions" data-testid="usdfExtensions">
|
|
206
|
+
{usdfDrugTierDefinition && (
|
|
207
|
+
<DrugTierDefinitionExtension
|
|
208
|
+
drugTierDefinitionExtension={usdfDrugTierDefinition}
|
|
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"
|
|
231
|
+
>
|
|
232
|
+
{usdfEmailPlanContact}
|
|
233
|
+
</Value>
|
|
234
|
+
)}
|
|
235
|
+
{usdfMarketingURL && (
|
|
236
|
+
<Value label="Marketing URL" data-testid="usdfMarketingURL">
|
|
237
|
+
{usdfMarketingURL}
|
|
238
|
+
</Value>
|
|
239
|
+
)}
|
|
240
|
+
{usdfPlanIDType && (
|
|
241
|
+
<Value label="Plan ID Type" data-testid="usdfPlanIDType">
|
|
242
|
+
{usdfPlanIDType}
|
|
243
|
+
</Value>
|
|
244
|
+
)}
|
|
245
|
+
</ValueSection>
|
|
246
|
+
)}
|
|
247
|
+
</Body>
|
|
248
|
+
</Root>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
List.propTypes = {
|
|
253
|
+
fhirResource: PropTypes.shape({}).isRequired,
|
|
254
|
+
fhirVersion: PropTypes.oneOf([
|
|
255
|
+
fhirVersions.DSTU2,
|
|
256
|
+
fhirVersions.STU3,
|
|
257
|
+
fhirVersions.R4,
|
|
258
|
+
]).isRequired,
|
|
259
|
+
withDaVinciPDex: PropTypes.bool,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export default List;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { object } from '@storybook/addon-knobs';
|
|
3
|
+
|
|
4
|
+
import List from './List';
|
|
5
|
+
import fhirVersions from '../fhirResourceVersions';
|
|
6
|
+
|
|
7
|
+
import example1Dstu2 from '../../../fixtures/dstu2/resources/list/example1.json';
|
|
8
|
+
import example2Dstu2 from '../../../fixtures/dstu2/resources/list/example2.json';
|
|
9
|
+
import example3Dstu2 from '../../../fixtures/dstu2/resources/list/example3.json';
|
|
10
|
+
import example1Stu3 from '../../../fixtures/stu3/resources/list/example1.json';
|
|
11
|
+
import example2Stu3 from '../../../fixtures/stu3/resources/list/example2.json';
|
|
12
|
+
import example3Stu3 from '../../../fixtures/stu3/resources/list/example3.json';
|
|
13
|
+
import example1R4 from '../../../fixtures/r4/resources/list/example1.json';
|
|
14
|
+
import example2R4 from '../../../fixtures/r4/resources/list/example2.json';
|
|
15
|
+
import example3R4 from '../../../fixtures/r4/resources/list/example3.json';
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
title: 'List',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const DefaultVisualizationDSTU2 = () => {
|
|
22
|
+
const fhirResource = object('Resource', example1Dstu2);
|
|
23
|
+
return <List fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Example2DSTU2 = () => {
|
|
27
|
+
const fhirResource = object('Resource', example2Dstu2);
|
|
28
|
+
return <List fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
|
|
29
|
+
};
|
|
30
|
+
export const Example3DSTU2 = () => {
|
|
31
|
+
const fhirResource = object('Resource', example3Dstu2);
|
|
32
|
+
return <List fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const DefaultVisualizationSTU3 = () => {
|
|
36
|
+
const fhirResource = object('Resource', example1Stu3);
|
|
37
|
+
return <List fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Example2STU3 = () => {
|
|
41
|
+
const fhirResource = object('Resource', example2Stu3);
|
|
42
|
+
return <List fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />;
|
|
43
|
+
};
|
|
44
|
+
export const Example3STU3 = () => {
|
|
45
|
+
const fhirResource = object('Resource', example3Stu3);
|
|
46
|
+
return <List fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const DefaultVisualizationR4 = () => {
|
|
50
|
+
const fhirResource = object('Resource', example1R4);
|
|
51
|
+
return <List fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />;
|
|
52
|
+
};
|
|
53
|
+
export const ExampleR4WithoutDaVinciPDex = () => {
|
|
54
|
+
const fhirResource = object('Resource', example2R4);
|
|
55
|
+
return <List fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />;
|
|
56
|
+
};
|
|
57
|
+
export const ExampleR4WithDaVinciPDex = () => {
|
|
58
|
+
const fhirResource = object('Resource', example2R4);
|
|
59
|
+
return (
|
|
60
|
+
<List
|
|
61
|
+
fhirVersion={fhirVersions.R4}
|
|
62
|
+
fhirResource={fhirResource}
|
|
63
|
+
withDaVinciPDex
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
export const Example2R4 = () => {
|
|
68
|
+
const fhirResource = object('Resource', example3R4);
|
|
69
|
+
return <List fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const ExampleWithoutFHIRVersionProperty = () => {
|
|
73
|
+
const fhirResource = object('Resource', example3R4);
|
|
74
|
+
return <List fhirResource={fhirResource} />;
|
|
75
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import { fhirVersions } from '../../../index';
|
|
5
|
+
|
|
6
|
+
import List from './List';
|
|
7
|
+
|
|
8
|
+
import example1Dstu2 from '../../../fixtures/dstu2/resources/list/example1.json';
|
|
9
|
+
import example2R4 from '../../../fixtures/r4/resources/list/example2.json';
|
|
10
|
+
|
|
11
|
+
describe('should render List component properly', () => {
|
|
12
|
+
it('should render with DSTU2 source data', () => {
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
fhirResource: example1Dstu2,
|
|
15
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { container, getByTestId, queryByTestId } = render(
|
|
19
|
+
<List {...defaultProps} />,
|
|
20
|
+
);
|
|
21
|
+
expect(container).not.toBeNull();
|
|
22
|
+
|
|
23
|
+
expect(getByTestId('title').textContent).toContain('List example');
|
|
24
|
+
expect(getByTestId('status').textContent).toContain('current');
|
|
25
|
+
expect(getByTestId('identifier').textContent).toContain('23974652');
|
|
26
|
+
expect(getByTestId('mode').textContent).toContain('changes');
|
|
27
|
+
expect(getByTestId('subject').textContent).toContain('Patient/example');
|
|
28
|
+
expect(getByTestId('date').textContent).toContain('11/25/2012');
|
|
29
|
+
expect(queryByTestId('code')).toBeNull();
|
|
30
|
+
expect(getByTestId('source').textContent).toContain('Patient/example');
|
|
31
|
+
expect(getByTestId('entries')).not.toBeNull();
|
|
32
|
+
expect(queryByTestId('usdfExtensions')).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should render R4 without daVinci PDex profile', () => {
|
|
36
|
+
const defaultProps = {
|
|
37
|
+
fhirResource: example2R4,
|
|
38
|
+
fhirVersion: fhirVersions.R4,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const { container, getByTestId, queryByTestId } = render(
|
|
42
|
+
<List {...defaultProps} />,
|
|
43
|
+
);
|
|
44
|
+
expect(container).not.toBeNull();
|
|
45
|
+
|
|
46
|
+
expect(getByTestId('identifier').textContent).toContain('test');
|
|
47
|
+
expect(getByTestId('mode').textContent).toContain('snapshot');
|
|
48
|
+
expect(getByTestId('date').textContent).toContain('6/12/20');
|
|
49
|
+
expect(getByTestId('entries')).not.toBeNull();
|
|
50
|
+
expect(queryByTestId('usdfExtensions')).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should render R4 with daVinci PDex profile', () => {
|
|
54
|
+
const defaultProps = {
|
|
55
|
+
fhirResource: example2R4,
|
|
56
|
+
fhirVersion: fhirVersions.R4,
|
|
57
|
+
withDaVinciPDex: true,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const { container, getByTestId, queryByTestId } = render(
|
|
61
|
+
<List {...defaultProps} />,
|
|
62
|
+
);
|
|
63
|
+
expect(container).not.toBeNull();
|
|
64
|
+
|
|
65
|
+
expect(getByTestId('identifier').textContent).toContain('test');
|
|
66
|
+
expect(getByTestId('mode').textContent).toContain('snapshot');
|
|
67
|
+
expect(getByTestId('date').textContent).toContain('6/12/2015');
|
|
68
|
+
expect(getByTestId('entries')).not.toBeNull();
|
|
69
|
+
|
|
70
|
+
expect(queryByTestId('usdfExtensions')).not.toBeNull();
|
|
71
|
+
expect(getByTestId('drugTierDefinition')).not.toBeNull();
|
|
72
|
+
expect(getByTestId('drugTierID').textContent).toContain('Generic:');
|
|
73
|
+
expect(getByTestId('mailOrder').textContent).toContain('yes');
|
|
74
|
+
expect(getByTestId('costSharing')).not.toBeNull();
|
|
75
|
+
expect(getByTestId('pharmacyType').textContent).toContain(
|
|
76
|
+
'(1-month-in-retail)',
|
|
77
|
+
);
|
|
78
|
+
expect(getByTestId('copayAmount').textContent).toContain('0');
|
|
79
|
+
|
|
80
|
+
expect(getByTestId('usdfNetwork').textContent).toContain('PREFERRED');
|
|
81
|
+
expect(getByTestId('usdfSummaryURL').textContent).toContain(
|
|
82
|
+
'http://url/to/health/plan/information',
|
|
83
|
+
);
|
|
84
|
+
expect(getByTestId('usdfFormularyURL').textContent).toContain(
|
|
85
|
+
'http://url/to/formulary/information',
|
|
86
|
+
);
|
|
87
|
+
expect(getByTestId('usdfEmailPlanContact').textContent).toContain(
|
|
88
|
+
'Patrick.Breen@carefirst.com',
|
|
89
|
+
);
|
|
90
|
+
expect(getByTestId('usdfMarketingURL').textContent).toContain(
|
|
91
|
+
'https://content.carefirst.com/sbc/D,$0/ D,$0/ D,$0/ D,$0/ D,$0B+',
|
|
92
|
+
);
|
|
93
|
+
expect(getByTestId('usdfPlanIDType').textContent).toContain('HIOS-PLAN-ID');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -30,9 +30,9 @@ describe('should render MedicationAdministration component properly', () => {
|
|
|
30
30
|
'Practitioner/example',
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
expect(getByTestId('periodTimeStart').textContent).toEqual('2015
|
|
33
|
+
expect(getByTestId('periodTimeStart').textContent).toEqual('1/15/2015');
|
|
34
34
|
|
|
35
|
-
expect(getByTestId('periodTimeEnd').textContent).toEqual('2015
|
|
35
|
+
expect(getByTestId('periodTimeEnd').textContent).toEqual('1/15/2015');
|
|
36
36
|
|
|
37
37
|
expect(getByTestId('dosageRoute').textContent).toContain(
|
|
38
38
|
'Intravenous route',
|
|
@@ -58,7 +58,7 @@ describe('should render MedicationAdministration component properly', () => {
|
|
|
58
58
|
|
|
59
59
|
expect(getByTestId('practitioner').textContent).toContain('Patrick Pump');
|
|
60
60
|
|
|
61
|
-
expect(getByTestId('periodTimeStart').textContent).toEqual('2015
|
|
61
|
+
expect(getByTestId('periodTimeStart').textContent).toEqual('1/15/2015');
|
|
62
62
|
|
|
63
63
|
expect(getByTestId('periodTimeEnd').textContent).toEqual('-');
|
|
64
64
|
|
|
@@ -83,8 +83,8 @@ describe('should render MedicationAdministration component properly', () => {
|
|
|
83
83
|
expect(getByTestId('status').textContent).toContain('on-hold');
|
|
84
84
|
expect(getByTestId('patient').textContent).toContain('Donald Duck');
|
|
85
85
|
expect(queryByTestId('practitioner')).toBeNull();
|
|
86
|
-
expect(getByTestId('periodTimeStart').textContent).toEqual('2015
|
|
87
|
-
expect(getByTestId('periodTimeEnd').textContent).toEqual('2015
|
|
86
|
+
expect(getByTestId('periodTimeStart').textContent).toEqual('1/15/2015');
|
|
87
|
+
expect(getByTestId('periodTimeEnd').textContent).toEqual('1/15/2015');
|
|
88
88
|
expect(getByTestId('dosageRoute').textContent).toContain('-');
|
|
89
89
|
expect(getByTestId('dosageQuantity').textContent).toEqual('-');
|
|
90
90
|
});
|
|
@@ -103,8 +103,8 @@ describe('should render MedicationAdministration component properly', () => {
|
|
|
103
103
|
expect(getByTestId('status').textContent).toContain('completed');
|
|
104
104
|
expect(getByTestId('patient').textContent).toContain('Donald Duck');
|
|
105
105
|
expect(getByTestId('practitioner').textContent).toContain('Patrick Pump');
|
|
106
|
-
expect(getByTestId('periodTimeStart').textContent).toEqual('2015
|
|
107
|
-
expect(getByTestId('periodTimeEnd').textContent).toEqual('2015
|
|
106
|
+
expect(getByTestId('periodTimeStart').textContent).toEqual('1/15/2015');
|
|
107
|
+
expect(getByTestId('periodTimeEnd').textContent).toEqual('1/15/2015');
|
|
108
108
|
expect(getByTestId('dosageRoute').textContent).toContain('Oral Route');
|
|
109
109
|
expect(getByTestId('dosageQuantity').textContent).toEqual('2 TAB');
|
|
110
110
|
});
|
|
@@ -21,7 +21,7 @@ describe('should render Device component properly', () => {
|
|
|
21
21
|
|
|
22
22
|
expect(getByTestId('title').textContent).toEqual('prescribed medication');
|
|
23
23
|
expect(getByTestId('typeCoding').textContent).toContain('Part Fill');
|
|
24
|
-
expect(getByTestId('whenPrepared').textContent).toContain('2015
|
|
24
|
+
expect(getByTestId('whenPrepared').textContent).toContain('3/1/2015');
|
|
25
25
|
expect(getByTestId('hasDosageInstruction').textContent).toContain(
|
|
26
26
|
'or after food',
|
|
27
27
|
);
|
|
@@ -60,7 +60,7 @@ describe('should render Device component properly', () => {
|
|
|
60
60
|
expect(container).not.toBeNull();
|
|
61
61
|
|
|
62
62
|
expect(getByTestId('title').textContent).toContain('Novolog 100u/ml');
|
|
63
|
-
expect(getByTestId('whenPrepared').textContent).toEqual('2015
|
|
63
|
+
expect(getByTestId('whenPrepared').textContent).toEqual('1/15/2015');
|
|
64
64
|
expect(
|
|
65
65
|
within(getByTestId('hasDosageInstruction'))
|
|
66
66
|
.queryAllByTestId('dosageTiming')
|