fhir-react 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +1 -1
- package/.eslintrc +10 -1
- package/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +7 -7
- package/package.json +55 -54
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Generic/generic.svg +3 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
- package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
- package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +21 -13
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -5
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/resources/AdverseEvent/AdverseEvent.js +81 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +7 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +2 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Bundle/Bundle.css +7 -0
- package/src/components/resources/Bundle/Bundle.js +15 -11
- package/src/components/resources/Bundle/Bundle.stories.js +12 -78
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +2 -1
- package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
- package/src/components/resources/CareTeam/CareTeam.js +72 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- package/src/components/resources/Claim/Claim.js +2 -1
- package/src/components/resources/Claim/Claim.test.js +32 -1
- package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
- package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
- package/src/components/resources/ClaimResponse/ClaimResponse.js +137 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
- package/src/components/resources/ClaimResponse/Item.js +44 -9
- package/src/components/resources/ClaimResponse/Items.js +5 -4
- package/src/components/resources/Condition/Condition.js +3 -3
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +2 -1
- package/src/components/resources/Coverage/Coverage.test.js +36 -1
- package/src/components/resources/Device/Device.js +2 -1
- package/src/components/resources/Device/Device.test.js +36 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
- package/src/components/resources/Encounter/Encounter.js +2 -1
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +2 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +7 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
- package/src/components/resources/Generic/Generic.js +20 -7
- package/src/components/resources/Generic/Generic.stories.js +2 -1
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +2 -3
- package/src/components/resources/Goal/Goal.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +2 -2
- package/src/components/resources/Immunization/Immunization.test.js +36 -1
- package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
- package/src/components/resources/List/Entries.js +3 -3
- package/src/components/resources/List/List.js +135 -88
- package/src/components/resources/List/List.stories.js +38 -5
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +65 -47
- package/src/components/resources/Location/Location.stories.js +11 -4
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +2 -1
- package/src/components/resources/Medication/Medication.test.js +36 -1
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +86 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
- package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.js +68 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +115 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +2 -3
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +2 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +7 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
- package/src/components/resources/Observation/Observation.js +2 -1
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Organization/Organization.js +3 -2
- package/src/components/resources/Organization/Organization.test.js +36 -1
- package/src/components/resources/Patient/Patient.js +2 -0
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +2 -1
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +50 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +2 -2
- package/src/components/resources/Procedure/Procedure.test.js +30 -1
- package/src/components/resources/Questionnaire/Group.js +53 -0
- package/src/components/resources/Questionnaire/Items.js +45 -0
- package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
- package/src/components/resources/Questionnaire/Questionnaire.js +31 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
- package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
- package/src/components/resources/Questionnaire/Questions.js +40 -0
- package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
- package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
- package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
- package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +52 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
- package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
- package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
- package/src/components/resources/ReferralRequest/ReferralRequest.js +65 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +151 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
- package/src/components/resources/RelatedPerson/index.js +3 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.js +160 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/ui/index.js +22 -9
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +42 -0
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +3 -1
|
@@ -102,7 +102,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
const Device = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
105
|
+
const Device = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
106
106
|
let fhirResourceData = {};
|
|
107
107
|
try {
|
|
108
108
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -178,6 +178,7 @@ const Device = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
178
178
|
))}
|
|
179
179
|
</Body>
|
|
180
180
|
}
|
|
181
|
+
onClick={onClick}
|
|
181
182
|
/>
|
|
182
183
|
</Root>
|
|
183
184
|
);
|
|
@@ -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 Device from './Device';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -137,4 +137,39 @@ describe('should render Device component properly', () => {
|
|
|
137
137
|
|
|
138
138
|
expect(getByTestId('uniqueId').textContent).toEqual('-');
|
|
139
139
|
});
|
|
140
|
+
|
|
141
|
+
it('should fire custom onClick function', () => {
|
|
142
|
+
const defaultProps = {
|
|
143
|
+
fhirResource: r4Example2,
|
|
144
|
+
fhirVersion: fhirVersions.R4,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const onClick = jest.fn();
|
|
148
|
+
const { getByRole } = render(
|
|
149
|
+
<Device {...defaultProps} onClick={onClick} />,
|
|
150
|
+
);
|
|
151
|
+
const accordion = getByRole('button');
|
|
152
|
+
fireEvent.click(accordion);
|
|
153
|
+
|
|
154
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
155
|
+
expect(attribute).not.toEqual('collapse');
|
|
156
|
+
expect(onClick).toHaveBeenCalled();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should fire custom onClick function', () => {
|
|
160
|
+
const defaultProps = {
|
|
161
|
+
fhirResource: r4Example2,
|
|
162
|
+
fhirVersion: fhirVersions.R4,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const onClick = 'test';
|
|
166
|
+
const { getByRole } = render(
|
|
167
|
+
<Device {...defaultProps} onClick={onClick} />,
|
|
168
|
+
);
|
|
169
|
+
const accordion = getByRole('button');
|
|
170
|
+
fireEvent.click(accordion);
|
|
171
|
+
|
|
172
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
173
|
+
expect(attribute).toEqual('collapse');
|
|
174
|
+
});
|
|
140
175
|
});
|
|
@@ -93,8 +93,12 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
const DiagnosticReport =
|
|
97
|
-
|
|
96
|
+
const DiagnosticReport = ({
|
|
97
|
+
fhirResource,
|
|
98
|
+
fhirVersion,
|
|
99
|
+
fhirIcons,
|
|
100
|
+
onClick,
|
|
101
|
+
}) => {
|
|
98
102
|
let fhirResourceData = {};
|
|
99
103
|
try {
|
|
100
104
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -165,6 +169,7 @@ const DiagnosticReport = props => {
|
|
|
165
169
|
/>
|
|
166
170
|
}
|
|
167
171
|
bodyContent={<Body tableData={tableData} />}
|
|
172
|
+
onClick={onClick}
|
|
168
173
|
/>
|
|
169
174
|
</Root>
|
|
170
175
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import DiagnosticReport from './DiagnosticReport';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -152,4 +152,39 @@ describe('should render component correctly', () => {
|
|
|
152
152
|
|
|
153
153
|
expect(getByTestId('performer').textContent).toContain('Todd Ashby');
|
|
154
154
|
});
|
|
155
|
+
|
|
156
|
+
it('should fire custom onClick function', () => {
|
|
157
|
+
const defaultProps = {
|
|
158
|
+
fhirResource: example2DiagnosticReportR4,
|
|
159
|
+
fhirVersion: fhirVersions.R4,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const onClick = jest.fn();
|
|
163
|
+
const { getByRole } = render(
|
|
164
|
+
<DiagnosticReport {...defaultProps} onClick={onClick} />,
|
|
165
|
+
);
|
|
166
|
+
const accordion = getByRole('button');
|
|
167
|
+
fireEvent.click(accordion);
|
|
168
|
+
|
|
169
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
170
|
+
expect(attribute).not.toEqual('collapse');
|
|
171
|
+
expect(onClick).toHaveBeenCalled();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should not fire custom onClick function', () => {
|
|
175
|
+
const defaultProps = {
|
|
176
|
+
fhirResource: example2DiagnosticReportR4,
|
|
177
|
+
fhirVersion: fhirVersions.R4,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const onClick = 'test';
|
|
181
|
+
const { getByRole } = render(
|
|
182
|
+
<DiagnosticReport {...defaultProps} onClick={onClick} />,
|
|
183
|
+
);
|
|
184
|
+
const accordion = getByRole('button');
|
|
185
|
+
fireEvent.click(accordion);
|
|
186
|
+
|
|
187
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
188
|
+
expect(attribute).toEqual('collapse');
|
|
189
|
+
});
|
|
155
190
|
});
|
|
@@ -216,8 +216,12 @@ const Content = props => {
|
|
|
216
216
|
);
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
const DocumentReference =
|
|
220
|
-
|
|
219
|
+
const DocumentReference = ({
|
|
220
|
+
fhirVersion,
|
|
221
|
+
fhirResource,
|
|
222
|
+
fhirIcons,
|
|
223
|
+
onClick,
|
|
224
|
+
}) => {
|
|
221
225
|
let fhirResourceData = {};
|
|
222
226
|
try {
|
|
223
227
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -337,6 +341,7 @@ const DocumentReference = props => {
|
|
|
337
341
|
{hasContent && <Content content={content} />}
|
|
338
342
|
</Body>
|
|
339
343
|
}
|
|
344
|
+
onClick={onClick}
|
|
340
345
|
/>
|
|
341
346
|
</Root>
|
|
342
347
|
);
|
|
@@ -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 { nbspRegex } from '../../../testUtils';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -268,4 +268,45 @@ describe('should render the DocumentReference component properly', () => {
|
|
|
268
268
|
const urls = getAllByTestId('content.url').map(node => node.textContent);
|
|
269
269
|
expect(urls).toEqual(['Binary/07a6483f-732b-461e-86b6-edb665c45510']);
|
|
270
270
|
});
|
|
271
|
+
|
|
272
|
+
it('should fire custom onClick function', () => {
|
|
273
|
+
const resource = JSON.parse(JSON.stringify(r4Example1));
|
|
274
|
+
resource.content[0].attachment.url =
|
|
275
|
+
'http://example.org/xds/mhd/Binary/07a6483f-732b-461e-86b6-edb665c45510';
|
|
276
|
+
|
|
277
|
+
const onClick = jest.fn();
|
|
278
|
+
const { getByRole } = render(
|
|
279
|
+
<DocumentReference
|
|
280
|
+
fhirResource={resource}
|
|
281
|
+
fhirVersion={fhirVersions.R4}
|
|
282
|
+
onClick={onClick}
|
|
283
|
+
/>,
|
|
284
|
+
);
|
|
285
|
+
const accordion = getByRole('button');
|
|
286
|
+
fireEvent.click(accordion);
|
|
287
|
+
|
|
288
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
289
|
+
expect(attribute).not.toEqual('collapse');
|
|
290
|
+
expect(onClick).toHaveBeenCalled();
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('should not fire custom onClick function', () => {
|
|
294
|
+
const resource = JSON.parse(JSON.stringify(r4Example1));
|
|
295
|
+
resource.content[0].attachment.url =
|
|
296
|
+
'http://example.org/xds/mhd/Binary/07a6483f-732b-461e-86b6-edb665c45510';
|
|
297
|
+
|
|
298
|
+
const onClick = 'test';
|
|
299
|
+
const { getByRole } = render(
|
|
300
|
+
<DocumentReference
|
|
301
|
+
fhirResource={resource}
|
|
302
|
+
fhirVersion={fhirVersions.R4}
|
|
303
|
+
onClick={onClick}
|
|
304
|
+
/>,
|
|
305
|
+
);
|
|
306
|
+
const accordion = getByRole('button');
|
|
307
|
+
fireEvent.click(accordion);
|
|
308
|
+
|
|
309
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
310
|
+
expect(attribute).toEqual('collapse');
|
|
311
|
+
});
|
|
271
312
|
});
|
|
@@ -160,7 +160,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const Encounter = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
163
|
+
const Encounter = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
164
164
|
let fhirResourceData = {};
|
|
165
165
|
try {
|
|
166
166
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -229,6 +229,7 @@ const Encounter = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
|
229
229
|
)}
|
|
230
230
|
</Body>
|
|
231
231
|
}
|
|
232
|
+
onClick={onClick}
|
|
232
233
|
/>
|
|
233
234
|
</Root>
|
|
234
235
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import Encounter from './Encounter';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
import example1 from '../../../fixtures/dstu2/resources/encounter/example.json';
|
|
@@ -198,4 +198,39 @@ describe('should render component correctly', () => {
|
|
|
198
198
|
);
|
|
199
199
|
jest.restoreAllMocks();
|
|
200
200
|
});
|
|
201
|
+
|
|
202
|
+
it('should fire custom onClick function', () => {
|
|
203
|
+
const defaultProps = {
|
|
204
|
+
fhirResource: example2_STU3,
|
|
205
|
+
fhirVersion: fhirVersions.R4,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const onClick = jest.fn();
|
|
209
|
+
const { getByRole } = render(
|
|
210
|
+
<Encounter {...defaultProps} onClick={onClick} />,
|
|
211
|
+
);
|
|
212
|
+
const accordion = getByRole('button');
|
|
213
|
+
fireEvent.click(accordion);
|
|
214
|
+
|
|
215
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
216
|
+
expect(attribute).not.toEqual('collapse');
|
|
217
|
+
expect(onClick).toHaveBeenCalled();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should not fire custom onClick function', () => {
|
|
221
|
+
const defaultProps = {
|
|
222
|
+
fhirResource: example2_STU3,
|
|
223
|
+
fhirVersion: fhirVersions.R4,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const onClick = 'test';
|
|
227
|
+
const { getByRole } = render(
|
|
228
|
+
<Encounter {...defaultProps} onClick={onClick} />,
|
|
229
|
+
);
|
|
230
|
+
const accordion = getByRole('button');
|
|
231
|
+
fireEvent.click(accordion);
|
|
232
|
+
|
|
233
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
234
|
+
expect(attribute).toEqual('collapse');
|
|
235
|
+
});
|
|
201
236
|
});
|
|
@@ -233,6 +233,7 @@ const ExplanationOfBenefit = ({
|
|
|
233
233
|
fhirVersion,
|
|
234
234
|
withCarinBBProfile = false,
|
|
235
235
|
fhirIcons,
|
|
236
|
+
onClick,
|
|
236
237
|
}) => {
|
|
237
238
|
let fhirResourceData = {};
|
|
238
239
|
try {
|
|
@@ -546,6 +547,7 @@ const ExplanationOfBenefit = ({
|
|
|
546
547
|
{hasCareTeam && <CareTeam fhirData={careTeam} />}
|
|
547
548
|
</Body>
|
|
548
549
|
}
|
|
550
|
+
onClick={onClick}
|
|
549
551
|
/>
|
|
550
552
|
</Root>
|
|
551
553
|
);
|
|
@@ -8,7 +8,7 @@ import exampleC4BB from '../../../fixtures/r4/resources/explanationOfBenefit/c4b
|
|
|
8
8
|
import exampleC4BBExtendedDiagnosis from '../../../fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json';
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
10
|
import { nbspRegex } from '../../../testUtils';
|
|
11
|
-
import { render } from '@testing-library/react';
|
|
11
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
12
12
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
13
|
|
|
14
14
|
describe('should render ExplanationOfBenefit component properly', () => {
|
|
@@ -331,4 +331,41 @@ describe('should render ExplanationOfBenefit component properly', () => {
|
|
|
331
331
|
expect(getByTestId('diagnosisOnAdmission').textContent).toContain('?');
|
|
332
332
|
expect(queryByTestId('diagnosisPackageCode')).toBeNull();
|
|
333
333
|
});
|
|
334
|
+
|
|
335
|
+
it('should fire custom onClick function', () => {
|
|
336
|
+
const defaultProps = {
|
|
337
|
+
fhirResource: exampleC4BBExtendedDiagnosis,
|
|
338
|
+
fhirVersion: fhirVersions.R4,
|
|
339
|
+
withCarinBBProfile: true,
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const onClick = jest.fn();
|
|
343
|
+
const { getByRole } = render(
|
|
344
|
+
<ExplanationOfBenefit {...defaultProps} onClick={onClick} />,
|
|
345
|
+
);
|
|
346
|
+
const accordion = getByRole('button');
|
|
347
|
+
fireEvent.click(accordion);
|
|
348
|
+
|
|
349
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
350
|
+
expect(attribute).not.toEqual('collapse');
|
|
351
|
+
expect(onClick).toHaveBeenCalled();
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('should not fire custom onClick function', () => {
|
|
355
|
+
const defaultProps = {
|
|
356
|
+
fhirResource: exampleC4BBExtendedDiagnosis,
|
|
357
|
+
fhirVersion: fhirVersions.R4,
|
|
358
|
+
withCarinBBProfile: true,
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const onClick = 'test';
|
|
362
|
+
const { getByRole } = render(
|
|
363
|
+
<ExplanationOfBenefit {...defaultProps} onClick={onClick} />,
|
|
364
|
+
);
|
|
365
|
+
const accordion = getByRole('button');
|
|
366
|
+
fireEvent.click(accordion);
|
|
367
|
+
|
|
368
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
369
|
+
expect(attribute).toEqual('collapse');
|
|
370
|
+
});
|
|
334
371
|
});
|
|
@@ -70,8 +70,12 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const FamilyMemberHistory =
|
|
74
|
-
|
|
73
|
+
const FamilyMemberHistory = ({
|
|
74
|
+
fhirResource,
|
|
75
|
+
fhirVersion,
|
|
76
|
+
fhirIcons,
|
|
77
|
+
onClick,
|
|
78
|
+
}) => {
|
|
75
79
|
let fhirResourceData = {};
|
|
76
80
|
try {
|
|
77
81
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -135,6 +139,7 @@ const FamilyMemberHistory = props => {
|
|
|
135
139
|
/>
|
|
136
140
|
}
|
|
137
141
|
bodyContent={<Body tableData={tableData} />}
|
|
142
|
+
onClick={onClick}
|
|
138
143
|
/>
|
|
139
144
|
</Root>
|
|
140
145
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import FamilyMemberHistory from './FamilyMemberHistory';
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
|
|
@@ -110,4 +110,39 @@ describe('should render FamilyMemberHistory component correctly', () => {
|
|
|
110
110
|
expect(getByTestId('hasRelationship').textContent).toContain('father');
|
|
111
111
|
expect(getByTestId('noteText').textContent).toContain('Was fishing at');
|
|
112
112
|
});
|
|
113
|
+
|
|
114
|
+
it('should fire custom onClick function', () => {
|
|
115
|
+
const defaultProps = {
|
|
116
|
+
fhirResource: example1STU3,
|
|
117
|
+
fhirVersion: fhirVersions.STU3,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const onClick = jest.fn();
|
|
121
|
+
const { getByRole } = render(
|
|
122
|
+
<FamilyMemberHistory {...defaultProps} onClick={onClick} />,
|
|
123
|
+
);
|
|
124
|
+
const accordion = getByRole('button');
|
|
125
|
+
fireEvent.click(accordion);
|
|
126
|
+
|
|
127
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
128
|
+
expect(attribute).not.toEqual('collapse');
|
|
129
|
+
expect(onClick).toHaveBeenCalled();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should not fire custom onClick function', () => {
|
|
133
|
+
const defaultProps = {
|
|
134
|
+
fhirResource: example1STU3,
|
|
135
|
+
fhirVersion: fhirVersions.STU3,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const onClick = 'test';
|
|
139
|
+
const { getByRole } = render(
|
|
140
|
+
<FamilyMemberHistory {...defaultProps} onClick={onClick} />,
|
|
141
|
+
);
|
|
142
|
+
const accordion = getByRole('button');
|
|
143
|
+
fireEvent.click(accordion);
|
|
144
|
+
|
|
145
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
146
|
+
expect(attribute).toEqual('collapse');
|
|
147
|
+
});
|
|
113
148
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import _get from 'lodash/get';
|
|
3
3
|
|
|
4
|
-
import { Root, Header
|
|
4
|
+
import { Root, Header } from '../../ui';
|
|
5
|
+
import Accordion from '../../containers/Accordion';
|
|
5
6
|
|
|
6
|
-
const Generic =
|
|
7
|
-
const { fhirResource } = props;
|
|
7
|
+
const Generic = ({ fhirResource, fhirIcons, onClick }) => {
|
|
8
8
|
const title = fhirResource
|
|
9
9
|
? `${fhirResource.resourceType}/${fhirResource.id}`
|
|
10
10
|
: `Unknown Resource`;
|
|
@@ -14,10 +14,23 @@ const Generic = props => {
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Root>
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
<Accordion
|
|
18
|
+
headerContent={
|
|
19
|
+
<Header
|
|
20
|
+
resourceName={'Generic'}
|
|
21
|
+
title={title}
|
|
22
|
+
icon={fhirIcons}
|
|
23
|
+
additionalContent={
|
|
24
|
+
code && (
|
|
25
|
+
<span className="text-secondary" data-testid="code">
|
|
26
|
+
{code}
|
|
27
|
+
</span>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
/>
|
|
31
|
+
}
|
|
32
|
+
onClick={onClick}
|
|
33
|
+
/>
|
|
21
34
|
</Root>
|
|
22
35
|
);
|
|
23
36
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { object } from '@storybook/addon-knobs';
|
|
3
3
|
|
|
4
4
|
import Generic from './Generic';
|
|
5
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
5
6
|
|
|
6
7
|
export default { title: 'Generic' };
|
|
7
8
|
|
|
@@ -14,5 +15,5 @@ export const DefaultVisualization = () => {
|
|
|
14
15
|
},
|
|
15
16
|
};
|
|
16
17
|
const fhirResource = object('Resource', exampleResource);
|
|
17
|
-
return <Generic fhirResource={fhirResource} />;
|
|
18
|
+
return <Generic fhirResource={fhirResource} fhirIcons={fhirIcons} />;
|
|
18
19
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import Generic from './Generic';
|
|
4
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
describe('should render the Generic component properly', () => {
|
|
6
7
|
const exampleResource = {
|
|
7
8
|
resourceType: 'UnknownResource',
|
|
8
9
|
id: '12345',
|
|
@@ -10,10 +11,28 @@ it('should render component correctly', () => {
|
|
|
10
11
|
text: 'Resource code text',
|
|
11
12
|
},
|
|
12
13
|
};
|
|
13
|
-
const { container, getByTestId } = render(
|
|
14
|
-
<Generic fhirResource={exampleResource} />,
|
|
15
|
-
);
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
it('should render component correctly', () => {
|
|
16
|
+
const { container, getByTestId, getByAltText } = render(
|
|
17
|
+
<Generic fhirResource={exampleResource} fhirIcons={fhirIcons} />,
|
|
18
|
+
);
|
|
19
|
+
const headerIcon = getByAltText('generic');
|
|
20
|
+
|
|
21
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
22
|
+
expect(getByTestId('title').textContent).toEqual('UnknownResource/12345');
|
|
23
|
+
expect(container.textContent).toContain('Resource code text');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should fire custom onClick function', () => {
|
|
27
|
+
const onClick = jest.fn();
|
|
28
|
+
const { getByRole } = render(
|
|
29
|
+
<Generic fhirResource={exampleResource} onClick={onClick} />,
|
|
30
|
+
);
|
|
31
|
+
const accordion = getByRole('button');
|
|
32
|
+
fireEvent.click(accordion);
|
|
33
|
+
|
|
34
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
35
|
+
expect(attribute).not.toEqual('collapse');
|
|
36
|
+
expect(onClick).toHaveBeenCalled();
|
|
37
|
+
});
|
|
19
38
|
});
|
|
@@ -99,9 +99,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const Goal =
|
|
103
|
-
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
104
|
-
|
|
102
|
+
const Goal = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
105
103
|
let fhirResourceData = {};
|
|
106
104
|
try {
|
|
107
105
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -229,6 +227,7 @@ const Goal = props => {
|
|
|
229
227
|
/>
|
|
230
228
|
}
|
|
231
229
|
bodyContent={<Body tableData={tableData} />}
|
|
230
|
+
onClick={onClick}
|
|
232
231
|
/>
|
|
233
232
|
</Root>
|
|
234
233
|
);
|
|
@@ -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 Goal from './Goal';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -187,4 +187,35 @@ describe('should render Goal component properly', () => {
|
|
|
187
187
|
|
|
188
188
|
expect(queryByTestId('priority')).toBeNull();
|
|
189
189
|
});
|
|
190
|
+
|
|
191
|
+
it('should fire custom onClick function', () => {
|
|
192
|
+
const defaultProps = {
|
|
193
|
+
fhirResource: r4Example2,
|
|
194
|
+
fhirVersion: fhirVersions.R4,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const onClick = jest.fn();
|
|
198
|
+
const { getByRole } = render(<Goal {...defaultProps} onClick={onClick} />);
|
|
199
|
+
const accordion = getByRole('button');
|
|
200
|
+
fireEvent.click(accordion);
|
|
201
|
+
|
|
202
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
203
|
+
expect(attribute).not.toEqual('collapse');
|
|
204
|
+
expect(onClick).toHaveBeenCalled();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should not fire custom onClick function', () => {
|
|
208
|
+
const defaultProps = {
|
|
209
|
+
fhirResource: r4Example2,
|
|
210
|
+
fhirVersion: fhirVersions.R4,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const onClick = 'test';
|
|
214
|
+
const { getByRole } = render(<Goal {...defaultProps} onClick={onClick} />);
|
|
215
|
+
const accordion = getByRole('button');
|
|
216
|
+
fireEvent.click(accordion);
|
|
217
|
+
|
|
218
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
219
|
+
expect(attribute).toEqual('collapse');
|
|
220
|
+
});
|
|
190
221
|
});
|
|
@@ -103,8 +103,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
const Immunization =
|
|
107
|
-
const { fhirVersion, fhirResource, fhirIcons } = props;
|
|
106
|
+
const Immunization = ({ fhirVersion, fhirResource, fhirIcons, onClick }) => {
|
|
108
107
|
const {
|
|
109
108
|
title,
|
|
110
109
|
status,
|
|
@@ -241,6 +240,7 @@ const Immunization = props => {
|
|
|
241
240
|
/>
|
|
242
241
|
}
|
|
243
242
|
bodyContent={<Body tableData={tableData} />}
|
|
243
|
+
onClick={onClick}
|
|
244
244
|
/>
|
|
245
245
|
</Root>
|
|
246
246
|
);
|
|
@@ -4,7 +4,7 @@ import dstu2Example from '../../../fixtures/dstu2/resources/immunization/example
|
|
|
4
4
|
import fhirVersions from '../fhirResourceVersions';
|
|
5
5
|
import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.json';
|
|
6
6
|
import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
|
|
7
|
-
import { render } from '@testing-library/react';
|
|
7
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
8
8
|
import stu3Example from '../../../fixtures/stu3/resources/immunization/example1.json';
|
|
9
9
|
import fhirIcons from '../../../fixtures/example-icons';
|
|
10
10
|
|
|
@@ -222,4 +222,39 @@ describe('should render Immunization component properly', () => {
|
|
|
222
222
|
|
|
223
223
|
expect(queryByTestId('site')).toBeNull();
|
|
224
224
|
});
|
|
225
|
+
|
|
226
|
+
it('should fire custom onClick function', () => {
|
|
227
|
+
const defaultProps = {
|
|
228
|
+
fhirResource: r4Example1,
|
|
229
|
+
fhirVersion: fhirVersions.R4,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const onClick = jest.fn();
|
|
233
|
+
const { getByRole } = render(
|
|
234
|
+
<Immunization {...defaultProps} onClick={onClick} />,
|
|
235
|
+
);
|
|
236
|
+
const accordion = getByRole('button');
|
|
237
|
+
fireEvent.click(accordion);
|
|
238
|
+
|
|
239
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
240
|
+
expect(attribute).not.toEqual('collapse');
|
|
241
|
+
expect(onClick).toHaveBeenCalled();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should not fire custom onClick function', () => {
|
|
245
|
+
const defaultProps = {
|
|
246
|
+
fhirResource: r4Example1,
|
|
247
|
+
fhirVersion: fhirVersions.R4,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const onClick = 'test';
|
|
251
|
+
const { getByRole } = render(
|
|
252
|
+
<Immunization {...defaultProps} onClick={onClick} />,
|
|
253
|
+
);
|
|
254
|
+
const accordion = getByRole('button');
|
|
255
|
+
fireEvent.click(accordion);
|
|
256
|
+
|
|
257
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
258
|
+
expect(attribute).toEqual('collapse');
|
|
259
|
+
});
|
|
225
260
|
});
|