fhir-react 0.3.5 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +1 -1
- package/.eslintrc +10 -1
- package/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +9 -8
- package/package.json +55 -54
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Coverage/coverage.svg +4 -0
- package/src/assets/containers/{ResourceCategory/resource-placeholder.svg → Generic/generic.svg} +0 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
- package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
- package/src/assets/containers/Organization/organization.svg +5 -0
- package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
- package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
- package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
- package/src/assets/containers/ResourceCategory/resource-category.svg +3 -0
- package/src/components/containers/Accordion/Accordion.js +21 -13
- package/src/components/datatypes/Attachment/Attachment.css +5 -0
- package/src/components/datatypes/Attachment/Attachment.js +7 -2
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Identifier/Identifier.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -1
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/resources/AdverseEvent/AdverseEvent.js +81 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -5
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +5 -4
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +107 -1
- package/src/components/resources/Appointment/Appointment.js +2 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +1 -2
- package/src/components/resources/Binary/Binary.stories.js +10 -4
- package/src/components/resources/Binary/Binary.test.js +67 -0
- package/src/components/resources/Bundle/Bundle.css +7 -0
- package/src/components/resources/Bundle/Bundle.js +15 -11
- package/src/components/resources/Bundle/Bundle.stories.js +12 -78
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +2 -1
- package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
- package/src/components/resources/CarePlan/CarePlan.test.js +114 -6
- package/src/components/resources/CareTeam/CareTeam.js +72 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- package/src/components/resources/Claim/CareTeam.js +55 -0
- package/src/components/resources/Claim/Claim.css +2 -11
- package/src/components/resources/Claim/Claim.js +158 -309
- package/src/components/resources/Claim/Claim.stories.js +37 -5
- package/src/components/resources/Claim/Claim.test.js +104 -1
- package/src/components/resources/Claim/Diagnosis.js +61 -0
- package/src/components/resources/Claim/Insurance.js +58 -0
- package/src/components/resources/Claim/Item.js +79 -0
- package/src/components/resources/Claim/Items.js +29 -0
- package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
- package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
- package/src/components/resources/ClaimResponse/ClaimResponse.js +137 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
- package/src/components/resources/ClaimResponse/Item.js +44 -9
- package/src/components/resources/ClaimResponse/Items.js +5 -4
- package/src/components/resources/Condition/Condition.js +3 -3
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +97 -69
- package/src/components/resources/Coverage/Coverage.stories.js +31 -5
- package/src/components/resources/Coverage/Coverage.test.js +111 -4
- package/src/components/resources/Device/Device.js +2 -1
- package/src/components/resources/Device/Device.stories.js +33 -5
- package/src/components/resources/Device/Device.test.js +108 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +5 -4
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +107 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +3 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +113 -1
- package/src/components/resources/Encounter/Encounter.js +2 -1
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +2 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +7 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +3 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +108 -1
- package/src/components/resources/Generic/Generic.js +20 -7
- package/src/components/resources/Generic/Generic.stories.js +2 -1
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +3 -5
- package/src/components/resources/Goal/Goal.stories.js +5 -4
- package/src/components/resources/Goal/Goal.test.js +101 -1
- package/src/components/resources/Immunization/Immunization.js +2 -2
- package/src/components/resources/Immunization/Immunization.test.js +36 -1
- package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
- package/src/components/resources/List/Entries.js +3 -3
- package/src/components/resources/List/List.js +135 -88
- package/src/components/resources/List/List.stories.js +38 -5
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +65 -47
- package/src/components/resources/Location/Location.stories.js +11 -4
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +91 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +113 -4
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +86 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
- package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.js +68 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +115 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -4
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +1 -2
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +102 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +3 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +11 -6
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +100 -4
- package/src/components/resources/MedicationStatement/MedicationDosage.js +2 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.js +8 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +5 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +108 -1
- package/src/components/resources/Observation/Observation.js +2 -1
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Organization/Organization.js +56 -37
- package/src/components/resources/Organization/Organization.stories.js +15 -2
- package/src/components/resources/Organization/Organization.test.js +109 -1
- package/src/components/resources/Patient/Patient.js +2 -0
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +2 -1
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +50 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +2 -2
- package/src/components/resources/Procedure/Procedure.test.js +30 -1
- package/src/components/resources/Questionnaire/Group.js +53 -0
- package/src/components/resources/Questionnaire/Items.js +45 -0
- package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
- package/src/components/resources/Questionnaire/Questionnaire.js +31 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
- package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
- package/src/components/resources/Questionnaire/Questions.js +40 -0
- package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
- package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
- package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
- package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +52 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
- package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
- package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
- package/src/components/resources/ReferralRequest/ReferralRequest.js +65 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +151 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
- package/src/components/resources/RelatedPerson/index.js +3 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.js +160 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
- package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
- package/src/components/ui/index.js +32 -12
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +81 -11
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +3 -1
|
@@ -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 ClaimResponse from './ClaimResponse';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -10,8 +10,84 @@ import stu3Example2 from '../../../fixtures/stu3/resources/claimResponse/example
|
|
|
10
10
|
import r4Example1 from '../../../fixtures/r4/resources/claimResponse/example1.json';
|
|
11
11
|
import r4Example2 from '../../../fixtures/r4/resources/claimResponse/example2.json';
|
|
12
12
|
import r4Example3 from '../../../fixtures/r4/resources/claimResponse/example3.json';
|
|
13
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
14
|
|
|
14
15
|
describe('should render the ClaimResponse component properly', () => {
|
|
16
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
17
|
+
const defaultProps = {
|
|
18
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
19
|
+
fhirResource: dstu2Example1,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const { getByAltText } = render(<ClaimResponse {...defaultProps} />);
|
|
23
|
+
const headerIcon = getByAltText('claim response');
|
|
24
|
+
|
|
25
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
29
|
+
const defaultProps = {
|
|
30
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
31
|
+
fhirResource: dstu2Example1,
|
|
32
|
+
fhirIcons: false,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const { getByTestId } = render(<ClaimResponse {...defaultProps} />);
|
|
36
|
+
const headerIcon = getByTestId('placeholder');
|
|
37
|
+
|
|
38
|
+
expect(headerIcon).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
42
|
+
const defaultProps = {
|
|
43
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
44
|
+
fhirResource: dstu2Example1,
|
|
45
|
+
fhirIcons: (
|
|
46
|
+
<img
|
|
47
|
+
src={require('../assets/containers/ClaimResponse/claim-response.svg')}
|
|
48
|
+
alt="clipboard with a symmetrical cross and a return arrow"
|
|
49
|
+
/>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const { getByAltText } = render(<ClaimResponse {...defaultProps} />);
|
|
54
|
+
const headerIcon = getByAltText(
|
|
55
|
+
'clipboard with a symmetrical cross and a return arrow',
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
62
|
+
const defaultProps = {
|
|
63
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
64
|
+
fhirResource: dstu2Example1,
|
|
65
|
+
fhirIcons: fhirIcons,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const { getByAltText } = render(<ClaimResponse {...defaultProps} />);
|
|
69
|
+
const headerIcon = getByAltText(
|
|
70
|
+
'clipboard with a symmetrical cross and a return arrow',
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
77
|
+
const avatarSrc =
|
|
78
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
79
|
+
const defaultProps = {
|
|
80
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
81
|
+
fhirResource: dstu2Example1,
|
|
82
|
+
fhirIcons: avatarSrc,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const { getByAltText } = render(<ClaimResponse {...defaultProps} />);
|
|
86
|
+
const headerIcon = getByAltText('header icon');
|
|
87
|
+
|
|
88
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
89
|
+
});
|
|
90
|
+
|
|
15
91
|
it('with DSTU2 source data', () => {
|
|
16
92
|
const defaultProps = {
|
|
17
93
|
fhirResource: dstu2Example1,
|
|
@@ -262,4 +338,39 @@ describe('should render the ClaimResponse component properly', () => {
|
|
|
262
338
|
' (expense)',
|
|
263
339
|
]);
|
|
264
340
|
});
|
|
341
|
+
|
|
342
|
+
it('should fire custom onClick function', () => {
|
|
343
|
+
const defaultProps = {
|
|
344
|
+
fhirResource: r4Example3,
|
|
345
|
+
fhirVersion: fhirVersions.R4,
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const onClick = jest.fn();
|
|
349
|
+
const { getAllByRole } = render(
|
|
350
|
+
<ClaimResponse {...defaultProps} onClick={onClick} />,
|
|
351
|
+
);
|
|
352
|
+
const accordion = getAllByRole('button')[0];
|
|
353
|
+
fireEvent.click(accordion);
|
|
354
|
+
|
|
355
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
356
|
+
expect(attribute).not.toEqual('collapse');
|
|
357
|
+
expect(onClick).toHaveBeenCalled();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('should not fire custom onClick function', () => {
|
|
361
|
+
const defaultProps = {
|
|
362
|
+
fhirResource: r4Example3,
|
|
363
|
+
fhirVersion: fhirVersions.R4,
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const onClick = 'test';
|
|
367
|
+
const { getAllByRole } = render(
|
|
368
|
+
<ClaimResponse {...defaultProps} onClick={onClick} />,
|
|
369
|
+
);
|
|
370
|
+
const accordion = getAllByRole('button')[0];
|
|
371
|
+
fireEvent.click(accordion);
|
|
372
|
+
|
|
373
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
374
|
+
expect(attribute).toEqual('collapse');
|
|
375
|
+
});
|
|
265
376
|
});
|
|
@@ -1,20 +1,40 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { TableCell, TableRow } from '../../ui';
|
|
3
|
+
import { Chevron, TableCell, TableRow } from '../../ui';
|
|
4
4
|
import Coding from '../../datatypes/Coding';
|
|
5
5
|
import Money from '../../datatypes/Money';
|
|
6
6
|
|
|
7
|
-
const Item =
|
|
8
|
-
const { item, parentSequences, level } = props;
|
|
9
|
-
|
|
7
|
+
const Item = ({ item, parentSequences, parentId, isCollapse = false }) => {
|
|
10
8
|
const itemSequences = [...parentSequences, item.sequenceLinkId];
|
|
11
9
|
const id = itemSequences.join('.');
|
|
10
|
+
const collapseId = parentSequences.length ? parentId : item.sequence;
|
|
11
|
+
|
|
12
|
+
const [rotate, setRotate] = useState(false);
|
|
13
|
+
const handleTableExpand = () => setRotate(!rotate);
|
|
14
|
+
|
|
15
|
+
const isExpandable =
|
|
16
|
+
parentSequences.length === 0 && item.subItems.length !== 0;
|
|
12
17
|
|
|
13
18
|
return (
|
|
14
19
|
<>
|
|
15
|
-
<TableRow
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
<TableRow
|
|
21
|
+
className={`${isCollapse ? `collapse item-${parentId}` : ''} ${
|
|
22
|
+
isExpandable ? 'fw-bold table-expandable-row border-top' : ''
|
|
23
|
+
}`}
|
|
24
|
+
data-bs-target={`.item-${collapseId}`}
|
|
25
|
+
data-bs-toggle={'collapse'}
|
|
26
|
+
aria-controls={id}
|
|
27
|
+
aria-expanded="false"
|
|
28
|
+
onClick={handleTableExpand}
|
|
29
|
+
>
|
|
30
|
+
<TableCell
|
|
31
|
+
data-testid="items.sequence"
|
|
32
|
+
className="col-md-2 align-self-start"
|
|
33
|
+
isAlignTop
|
|
34
|
+
>
|
|
35
|
+
{id}
|
|
36
|
+
</TableCell>
|
|
37
|
+
<TableCell data-testid="items.adjudication" className="col-md-8">
|
|
18
38
|
{item.adjudication.map((adjudication, idx) => (
|
|
19
39
|
<div
|
|
20
40
|
key={idx}
|
|
@@ -29,13 +49,28 @@ const Item = props => {
|
|
|
29
49
|
</div>
|
|
30
50
|
))}
|
|
31
51
|
</TableCell>
|
|
52
|
+
{isExpandable ? (
|
|
53
|
+
<TableCell className="col-md-2" isAlignTop>
|
|
54
|
+
<button
|
|
55
|
+
className="fhir-container__Accordion__header-button w-100 p-0 border-0 rounded-1 collapsed text-dark bg-transparent shadow-none "
|
|
56
|
+
type="button"
|
|
57
|
+
>
|
|
58
|
+
<div className={` ${rotate ? ' header-rotate' : ''}`}>
|
|
59
|
+
<Chevron strokeColor={rotate ? '#2a6fd7' : '#6f83a9'} />
|
|
60
|
+
</div>
|
|
61
|
+
</button>
|
|
62
|
+
</TableCell>
|
|
63
|
+
) : (
|
|
64
|
+
<TableCell style={{ width: '64px' }} className="col-md-2" />
|
|
65
|
+
)}
|
|
32
66
|
</TableRow>
|
|
33
67
|
{item.subItems.map((subItem, idx) => (
|
|
34
68
|
<Item
|
|
35
69
|
key={idx}
|
|
36
70
|
item={subItem}
|
|
37
|
-
level={level + 1}
|
|
38
71
|
parentSequences={itemSequences}
|
|
72
|
+
parentId={collapseId}
|
|
73
|
+
isCollapse
|
|
39
74
|
/>
|
|
40
75
|
))}
|
|
41
76
|
</>
|
|
@@ -7,17 +7,18 @@ const Items = props => {
|
|
|
7
7
|
const { items } = props;
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
|
-
<ValueSection label="Items" data-testid="items">
|
|
10
|
+
<ValueSection label="Items" data-testid="items" marginTop>
|
|
11
11
|
<Table>
|
|
12
12
|
<thead>
|
|
13
13
|
<TableRow>
|
|
14
14
|
<TableHeader>ID</TableHeader>
|
|
15
|
-
<TableHeader
|
|
15
|
+
<TableHeader>Adjudication</TableHeader>
|
|
16
|
+
<TableHeader></TableHeader>
|
|
16
17
|
</TableRow>
|
|
17
18
|
</thead>
|
|
18
|
-
<tbody>
|
|
19
|
+
<tbody className="border-top-0">
|
|
19
20
|
{items.map((item, idx) => (
|
|
20
|
-
<Item key={idx} item={item}
|
|
21
|
+
<Item key={idx} item={item} parentSequences={[]} />
|
|
21
22
|
))}
|
|
22
23
|
</tbody>
|
|
23
24
|
</Table>
|
|
@@ -86,9 +86,8 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
86
86
|
throw Error('Unrecognized the fhir version property type.');
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
-
function Condition(props) {
|
|
90
|
-
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
91
89
|
|
|
90
|
+
const Condition = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
92
91
|
const {
|
|
93
92
|
codeText,
|
|
94
93
|
severityText,
|
|
@@ -157,10 +156,11 @@ function Condition(props) {
|
|
|
157
156
|
/>
|
|
158
157
|
}
|
|
159
158
|
bodyContent={<Body tableData={tableData} />}
|
|
159
|
+
onClick={onClick}
|
|
160
160
|
/>
|
|
161
161
|
</Root>
|
|
162
162
|
);
|
|
163
|
-
}
|
|
163
|
+
};
|
|
164
164
|
|
|
165
165
|
Condition.propTypes = {
|
|
166
166
|
fhirResource: PropTypes.shape({}).isRequired,
|
|
@@ -8,7 +8,7 @@ import exampleConditionSTU3 from '../../../fixtures/stu3/resources/condition/exa
|
|
|
8
8
|
import exampleConditionSeverity from '../../../fixtures/dstu2/resources/condition/example-severity.json';
|
|
9
9
|
import exampleConditionSeveritySTU3 from '../../../fixtures/stu3/resources/condition/example-severity.json';
|
|
10
10
|
import fhirVersions from '../fhirResourceVersions';
|
|
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 component correctly', () => {
|
|
@@ -108,9 +108,7 @@ describe('should render component correctly', () => {
|
|
|
108
108
|
expect(getByTestId('clinicalStatus').textContent).toEqual('active');
|
|
109
109
|
expect(getByTestId('severity').textContent).toEqual('Medium severity');
|
|
110
110
|
expect(getByTestId('onsetDate').textContent).toEqual('8/24/2015');
|
|
111
|
-
expect(getByTestId('asserter').textContent).toEqual(
|
|
112
|
-
'MOORE, NICKPractitioner/f8fedcd9e6e565a21f457909',
|
|
113
|
-
);
|
|
111
|
+
expect(getByTestId('asserter').textContent).toEqual('MOORE, NICK');
|
|
114
112
|
});
|
|
115
113
|
|
|
116
114
|
it('STU3 - without severity field', () => {
|
|
@@ -191,4 +189,39 @@ describe('should render component correctly', () => {
|
|
|
191
189
|
expect(getByTestId('asserter').textContent).toEqual('Practitioner/f201');
|
|
192
190
|
expect(getByTestId('dateRecorded').textContent).toEqual('4/4/2013');
|
|
193
191
|
});
|
|
192
|
+
|
|
193
|
+
it('should fire custom onClick function', () => {
|
|
194
|
+
const defaultProps = {
|
|
195
|
+
fhirResource: example3ConditionSeverityR4,
|
|
196
|
+
fhirVersion: fhirVersions.R4,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const onClick = jest.fn();
|
|
200
|
+
const { getByRole } = render(
|
|
201
|
+
<Condition {...defaultProps} onClick={onClick} />,
|
|
202
|
+
);
|
|
203
|
+
const accordion = getByRole('button');
|
|
204
|
+
fireEvent.click(accordion);
|
|
205
|
+
|
|
206
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
207
|
+
expect(attribute).not.toEqual('collapse');
|
|
208
|
+
expect(onClick).toHaveBeenCalled();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should not fire custom onClick function', () => {
|
|
212
|
+
const defaultProps = {
|
|
213
|
+
fhirResource: example3ConditionSeverityR4,
|
|
214
|
+
fhirVersion: fhirVersions.R4,
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const onClick = 'test';
|
|
218
|
+
const { getByRole } = render(
|
|
219
|
+
<Condition {...defaultProps} onClick={onClick} />,
|
|
220
|
+
);
|
|
221
|
+
const accordion = getByRole('button');
|
|
222
|
+
fireEvent.click(accordion);
|
|
223
|
+
|
|
224
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
225
|
+
expect(attribute).toEqual('collapse');
|
|
226
|
+
});
|
|
194
227
|
});
|
|
@@ -6,8 +6,9 @@ import Reference from '../../datatypes/Reference';
|
|
|
6
6
|
import Coding from '../../datatypes/Coding';
|
|
7
7
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
8
8
|
import fhirVersions from '../fhirResourceVersions';
|
|
9
|
-
import { Root, Header,
|
|
9
|
+
import { Root, Header, Body, Value } from '../../ui';
|
|
10
10
|
import Identifier from '../../datatypes/Identifier';
|
|
11
|
+
import Accordion from '../../containers/Accordion';
|
|
11
12
|
|
|
12
13
|
const commonDTO = fhirResource => {
|
|
13
14
|
const identifier = _get(fhirResource, 'identifier.0');
|
|
@@ -113,8 +114,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
|
|
116
|
-
const Coverage =
|
|
117
|
-
const { fhirResource, fhirVersion } = props;
|
|
117
|
+
const Coverage = ({ fhirResource, fhirVersion, fhirIcons, onClick }) => {
|
|
118
118
|
let fhirResourceData = {};
|
|
119
119
|
try {
|
|
120
120
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -138,74 +138,102 @@ const Coverage = props => {
|
|
|
138
138
|
} = fhirResourceData;
|
|
139
139
|
const issuerReferenceType = _get(issuer, 'reference');
|
|
140
140
|
const issuerIdentifierType = _get(issuer, 'identifier');
|
|
141
|
+
|
|
142
|
+
const tableData = [
|
|
143
|
+
{
|
|
144
|
+
label: 'Issuer',
|
|
145
|
+
testId: 'issuer',
|
|
146
|
+
data: issuerReferenceType && <Reference fhirData={issuer} />,
|
|
147
|
+
status: issuerReferenceType,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
label: 'Issuer',
|
|
151
|
+
testId: 'issuer',
|
|
152
|
+
data: issuerIdentifierType && <Identifier fhirData={issuer.identifier} />,
|
|
153
|
+
status: issuerIdentifierType,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
label: 'PlanId',
|
|
157
|
+
testId: 'planId',
|
|
158
|
+
data: planId,
|
|
159
|
+
status: planId,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: 'Coverage',
|
|
163
|
+
testId: '',
|
|
164
|
+
data: period && (
|
|
165
|
+
<>
|
|
166
|
+
{coverageFrom && (
|
|
167
|
+
<span data-testid="coverageFrom">from: {coverageFrom}</span>
|
|
168
|
+
)}{' '}
|
|
169
|
+
{coverageTo && <span data-testid="coverageTo">to: {coverageTo}</span>}
|
|
170
|
+
</>
|
|
171
|
+
),
|
|
172
|
+
status: period,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: 'Type of coverage',
|
|
176
|
+
testId: 'type',
|
|
177
|
+
data: type && <Coding fhirData={type} />,
|
|
178
|
+
status: type,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: 'Details',
|
|
182
|
+
testId: 'details',
|
|
183
|
+
data: hasDetails && (
|
|
184
|
+
<>
|
|
185
|
+
<span>{details.planDescription}</span>
|
|
186
|
+
{details.classDescription && (
|
|
187
|
+
<>
|
|
188
|
+
{' | '}
|
|
189
|
+
<span>{details.classDescription}</span>
|
|
190
|
+
</>
|
|
191
|
+
)}
|
|
192
|
+
</>
|
|
193
|
+
),
|
|
194
|
+
status: hasDetails,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: 'Extension',
|
|
198
|
+
testId: 'extensions',
|
|
199
|
+
data:
|
|
200
|
+
hasExtension &&
|
|
201
|
+
extension.map((item, i) => {
|
|
202
|
+
const coding = Array.isArray(item.coding) ? item.coding : [];
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<span key={`item-${i}`}>
|
|
206
|
+
{item.name && <span>{item.name}</span>}
|
|
207
|
+
{coding.map((code, j) => (
|
|
208
|
+
<Coding key={`item-${j}`} fhirData={code} />
|
|
209
|
+
))}
|
|
210
|
+
</span>
|
|
211
|
+
);
|
|
212
|
+
}),
|
|
213
|
+
status: hasExtension,
|
|
214
|
+
},
|
|
215
|
+
];
|
|
216
|
+
|
|
141
217
|
return (
|
|
142
218
|
<Root name="coverage">
|
|
143
|
-
<
|
|
144
|
-
{
|
|
145
|
-
<
|
|
146
|
-
Coverage
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{planId && (
|
|
162
|
-
<Value label="PlanId" data-testid="planId">
|
|
163
|
-
{planId}
|
|
164
|
-
</Value>
|
|
165
|
-
)}
|
|
166
|
-
{period && (
|
|
167
|
-
<Value label="Coverage">
|
|
168
|
-
{coverageFrom && (
|
|
169
|
-
<span data-testid="coverageFrom">from: {coverageFrom}</span>
|
|
170
|
-
)}{' '}
|
|
171
|
-
{coverageTo && (
|
|
172
|
-
<span data-testid="coverageTo">to: {coverageTo}</span>
|
|
173
|
-
)}
|
|
174
|
-
</Value>
|
|
175
|
-
)}
|
|
176
|
-
{type && (
|
|
177
|
-
<Value label="Type of coverage" data-testid="type">
|
|
178
|
-
<Coding fhirData={type} />
|
|
179
|
-
</Value>
|
|
180
|
-
)}
|
|
181
|
-
{hasDetails && (
|
|
182
|
-
<Value label="Details" data-testid="details">
|
|
183
|
-
<span>{details.planDescription}</span>
|
|
184
|
-
{details.classDescription && (
|
|
185
|
-
<>
|
|
186
|
-
{' | '}
|
|
187
|
-
<span>{details.classDescription}</span>
|
|
188
|
-
</>
|
|
189
|
-
)}
|
|
190
|
-
</Value>
|
|
191
|
-
)}
|
|
192
|
-
{hasExtension && (
|
|
193
|
-
<Value label="Extension" data-testid="extensions">
|
|
194
|
-
{extension.map((item, i) => {
|
|
195
|
-
const coding = Array.isArray(item.coding) ? item.coding : [];
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<span key={`item-${i}`}>
|
|
199
|
-
{item.name && <span>{item.name}</span>}
|
|
200
|
-
{coding.map((code, j) => (
|
|
201
|
-
<Coding key={`item-${j}`} fhirData={code} />
|
|
202
|
-
))}
|
|
203
|
-
</span>
|
|
204
|
-
);
|
|
205
|
-
})}
|
|
206
|
-
</Value>
|
|
207
|
-
)}
|
|
208
|
-
</Body>
|
|
219
|
+
<Accordion
|
|
220
|
+
headerContent={
|
|
221
|
+
<Header
|
|
222
|
+
resourceName="Coverage"
|
|
223
|
+
additionalContent={
|
|
224
|
+
identifier && (
|
|
225
|
+
<Value label="Identifier">
|
|
226
|
+
<Identifier fhirData={identifier} valueOnly noCursive />
|
|
227
|
+
</Value>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
title="Coverage"
|
|
231
|
+
icon={fhirIcons}
|
|
232
|
+
/>
|
|
233
|
+
}
|
|
234
|
+
bodyContent={<Body tableData={tableData} />}
|
|
235
|
+
onClick={onClick}
|
|
236
|
+
/>
|
|
209
237
|
</Root>
|
|
210
238
|
);
|
|
211
239
|
};
|
|
@@ -9,38 +9,64 @@ import exampleCoverageStu3 from '../../../fixtures/stu3/resources/coverage/examp
|
|
|
9
9
|
import example2CoverageStu3 from '../../../fixtures/stu3/resources/coverage/example2.json';
|
|
10
10
|
import exampleCoverageR4 from '../../../fixtures/r4/resources/coverage/example1.json';
|
|
11
11
|
import example2CoverageR4 from '../../../fixtures/r4/resources/coverage/example2.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
13
|
+
import CoverageIcon from '../../../assets/containers/Coverage/coverage.svg';
|
|
12
14
|
|
|
13
15
|
export default { title: 'Coverage' };
|
|
14
16
|
|
|
15
17
|
export const DefaultVisualizationDSTU2 = () => {
|
|
16
18
|
const fhirResource = object('Resource', exampleCoverageDstu2);
|
|
17
19
|
return (
|
|
18
|
-
<Coverage
|
|
20
|
+
<Coverage
|
|
21
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
22
|
+
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={require('../../../assets/containers/Coverage/coverage.svg')}
|
|
24
|
+
/>
|
|
19
25
|
);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
export const ExampleOfSTU3 = () => {
|
|
23
29
|
const fhirResource = object('Resource', exampleCoverageStu3);
|
|
24
30
|
return (
|
|
25
|
-
<Coverage
|
|
31
|
+
<Coverage
|
|
32
|
+
fhirVersion={fhirVersions.STU3}
|
|
33
|
+
fhirResource={fhirResource}
|
|
34
|
+
fhirIcons={CoverageIcon}
|
|
35
|
+
/>
|
|
26
36
|
);
|
|
27
37
|
};
|
|
28
38
|
|
|
29
39
|
export const Example2OfSTU3 = () => {
|
|
30
40
|
const fhirResource = object('Resource', example2CoverageStu3);
|
|
31
41
|
return (
|
|
32
|
-
<Coverage
|
|
42
|
+
<Coverage
|
|
43
|
+
fhirVersion={fhirVersions.STU3}
|
|
44
|
+
fhirResource={fhirResource}
|
|
45
|
+
fhirIcons={fhirIcons}
|
|
46
|
+
/>
|
|
33
47
|
);
|
|
34
48
|
};
|
|
35
49
|
|
|
36
50
|
export const ExampleOfR4 = () => {
|
|
37
51
|
const fhirResource = object('Resource', exampleCoverageR4);
|
|
38
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
<Coverage
|
|
54
|
+
fhirResource={fhirResource}
|
|
55
|
+
fhirVersion={fhirVersions.R4}
|
|
56
|
+
fhirIcons={false}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
39
59
|
};
|
|
40
60
|
|
|
41
61
|
export const Example2OfR4 = () => {
|
|
42
62
|
const fhirResource = object('Resource', example2CoverageR4);
|
|
43
|
-
return
|
|
63
|
+
return (
|
|
64
|
+
<Coverage
|
|
65
|
+
fhirResource={fhirResource}
|
|
66
|
+
fhirVersion={fhirVersions.R4}
|
|
67
|
+
fhirIcons={'random text'}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
44
70
|
};
|
|
45
71
|
|
|
46
72
|
export const ExampleWithoutFhirVersionProperty = () => {
|