fhir-react 0.3.1 → 0.3.5
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/README.md +85 -2
- package/build/bootstrap-reboot.min.css +8 -2
- package/build/index.js +7 -14
- package/build/style.css +26 -239
- package/package.json +3 -2
- package/src/assets/containers/Binary/binary.svg +9 -0
- package/src/assets/containers/Patient/patient.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +17 -12
- package/src/components/datatypes/Annotation/Annotation.js +4 -4
- package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
- package/src/components/datatypes/Coding/Coding.css +0 -1
- package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
- package/src/components/datatypes/Reference/Reference.css +3 -0
- package/src/components/datatypes/Reference/Reference.js +2 -0
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +87 -76
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +11 -1
- package/src/components/resources/Appointment/Appointment.js +3 -3
- package/src/components/resources/Appointment/Appointment.stories.js +28 -5
- package/src/components/resources/Appointment/Appointment.test.js +72 -0
- package/src/components/resources/Binary/Binary.js +31 -20
- package/src/components/resources/Binary/Binary.stories.js +6 -5
- package/src/components/resources/CarePlan/CarePlan.js +111 -96
- package/src/components/resources/CarePlan/CarePlan.test.js +2 -2
- package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
- package/src/components/resources/Condition/Condition.js +1 -2
- package/src/components/resources/Condition/Condition.stories.js +9 -19
- package/src/components/resources/Condition/Condition.test.js +71 -1
- package/src/components/resources/Device/Device.js +54 -34
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +53 -43
- package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +7 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
- package/src/components/resources/DocumentReference/DocumentReference.stories.js +4 -0
- package/src/components/resources/Encounter/Encounter.js +3 -4
- package/src/components/resources/Encounter/Encounter.stories.js +27 -5
- package/src/components/resources/Encounter/Encounter.test.js +72 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +26 -10
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +80 -3
- package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +21 -6
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +4 -0
- package/src/components/resources/Goal/Goal.js +104 -85
- package/src/components/resources/Goal/Goal.stories.js +37 -7
- package/src/components/resources/Goal/Goal.test.js +1 -3
- package/src/components/resources/Immunization/Immunization.js +1 -2
- package/src/components/resources/Immunization/Immunization.stories.js +6 -9
- package/src/components/resources/Immunization/Immunization.test.js +71 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
- package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +2 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.js +65 -43
- package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +16 -5
- package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
- package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
- package/src/components/resources/MedicationStatement/MedicationStatement.js +65 -118
- package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +6 -0
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +31 -6
- package/src/components/resources/Observation/Observation.js +3 -3
- package/src/components/resources/Observation/Observation.stories.js +14 -5
- package/src/components/resources/Observation/Observation.test.js +67 -0
- package/src/components/resources/Patient/Patient.js +9 -6
- package/src/components/resources/Patient/Patient.stories.js +12 -5
- package/src/components/resources/Patient/Patient.test.js +67 -0
- package/src/components/resources/Practitioner/Practitioner.js +3 -13
- package/src/components/resources/Practitioner/Practitioner.stories.js +19 -3
- package/src/components/resources/Practitioner/Practitioner.test.js +72 -0
- package/src/components/resources/Procedure/Procedure.js +1 -2
- package/src/components/resources/Procedure/Procedure.stories.js +11 -5
- package/src/components/resources/Procedure/Procedure.test.js +71 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +6 -3
- package/src/components/resources/ResourceCategory/ResourceCategory.test.js +1 -1
- package/src/components/supportedFhirResourceList.js +2 -0
- package/src/components/ui/bootstrap-reboot.min.css +8 -2
- package/src/components/ui/index.js +44 -25
- package/src/fixtures/example-icons.jsx +55 -10
- package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
- package/src/index.js +1 -0
- package/src/style.scss +1 -0
- package/src/utils/convertCamelCaseToSentence.js +9 -0
- package/src/utils/convertCamelCaseToSentence.test.js +9 -0
- package/src/utils/formatDate.js +6 -4
- package/webpack.config.js +10 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
- package/src/components/resources/CarePlan/CarePlan.css +0 -7
|
@@ -9,8 +9,80 @@ import example2_STU3 from '../../../fixtures/stu3/resources/encounter/example-2.
|
|
|
9
9
|
import example1_R4 from '../../../fixtures/r4/resources/encounter/example1.json';
|
|
10
10
|
import example2_R4 from '../../../fixtures/r4/resources/encounter/example2.json';
|
|
11
11
|
import example3_R4 from '../../../fixtures/r4/resources/encounter/example3.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
13
|
|
|
13
14
|
describe('should render component correctly', () => {
|
|
15
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
fhirResource: example1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
22
|
+
const headerIcon = getByAltText('encounter');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<Encounter {...defaultProps} />);
|
|
35
|
+
const headerIcon = getByTestId('placeholder');
|
|
36
|
+
|
|
37
|
+
expect(headerIcon).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirResource: example1,
|
|
44
|
+
fhirIcons: (
|
|
45
|
+
<img
|
|
46
|
+
src={require('../assets/containers/Encounter/encounter.svg')}
|
|
47
|
+
alt="encounter"
|
|
48
|
+
/>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
53
|
+
const headerIcon = getByAltText('encounter');
|
|
54
|
+
|
|
55
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
59
|
+
const defaultProps = {
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirResource: example1,
|
|
62
|
+
fhirIcons: fhirIcons,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
66
|
+
const headerIcon = getByAltText('encounter');
|
|
67
|
+
|
|
68
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
72
|
+
const avatarSrc =
|
|
73
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirResource: example1,
|
|
77
|
+
fhirIcons: avatarSrc,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { getByAltText } = render(<Encounter {...defaultProps} />);
|
|
81
|
+
const headerIcon = getByAltText('header icon');
|
|
82
|
+
|
|
83
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
84
|
+
});
|
|
85
|
+
|
|
14
86
|
it('DSTU2 - with PARTICIPANTS table', () => {
|
|
15
87
|
const defaultProps = {
|
|
16
88
|
fhirVersion: fhirVersions.DSTU2,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import CareTeam from './CareTeam';
|
|
15
15
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
16
16
|
import Coding from '../../datatypes/Coding';
|
|
17
|
+
import Quantity from '../../datatypes/Quantity';
|
|
17
18
|
import Date from '../../datatypes/Date';
|
|
18
19
|
import Diagnosis from './Diagnosis';
|
|
19
20
|
import Identifier from '../../datatypes/Identifier/Identifier';
|
|
@@ -80,9 +81,10 @@ const stu3DTO = fhirResource => {
|
|
|
80
81
|
services.map(serviceItem => {
|
|
81
82
|
const coding = _get(serviceItem, 'service.coding.0');
|
|
82
83
|
const servicedDate = _get(serviceItem, 'servicedDate');
|
|
84
|
+
const servicedPeriod = _get(serviceItem, 'servicedPeriod');
|
|
83
85
|
const quantity = _get(serviceItem, 'quantity.value');
|
|
84
86
|
const itemCost = _get(serviceItem, 'net');
|
|
85
|
-
return { coding, servicedDate, quantity, itemCost };
|
|
87
|
+
return { coding, servicedDate, servicedPeriod, quantity, itemCost };
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
return {
|
|
@@ -126,9 +128,10 @@ const r4DTO = fhirResource => {
|
|
|
126
128
|
services.map(serviceItem => {
|
|
127
129
|
const coding = _get(serviceItem, 'productOrService.coding.0');
|
|
128
130
|
const servicedDate = _get(serviceItem, 'servicedDate');
|
|
131
|
+
const servicedPeriod = _get(serviceItem, 'servicedPeriod');
|
|
129
132
|
const quantity = _get(serviceItem, 'quantity.value');
|
|
130
133
|
const itemCost = _get(serviceItem, 'net');
|
|
131
|
-
return { coding, servicedDate, quantity, itemCost };
|
|
134
|
+
return { coding, servicedDate, servicedPeriod, quantity, itemCost };
|
|
132
135
|
});
|
|
133
136
|
|
|
134
137
|
return {
|
|
@@ -225,8 +228,12 @@ const resourceDTO = (fhirVersion, fhirResource, withCarinBBProfile) => {
|
|
|
225
228
|
}
|
|
226
229
|
};
|
|
227
230
|
|
|
228
|
-
const ExplanationOfBenefit =
|
|
229
|
-
|
|
231
|
+
const ExplanationOfBenefit = ({
|
|
232
|
+
fhirResource,
|
|
233
|
+
fhirVersion,
|
|
234
|
+
withCarinBBProfile = false,
|
|
235
|
+
fhirIcons,
|
|
236
|
+
}) => {
|
|
230
237
|
let fhirResourceData = {};
|
|
231
238
|
try {
|
|
232
239
|
fhirResourceData = resourceDTO(
|
|
@@ -411,6 +418,7 @@ const ExplanationOfBenefit = props => {
|
|
|
411
418
|
</Value>
|
|
412
419
|
)
|
|
413
420
|
}
|
|
421
|
+
icon={fhirIcons}
|
|
414
422
|
/>
|
|
415
423
|
}
|
|
416
424
|
bodyContent={
|
|
@@ -453,11 +461,12 @@ const ExplanationOfBenefit = props => {
|
|
|
453
461
|
<Coding fhirData={serviceItem.coding} />
|
|
454
462
|
</TableCell>
|
|
455
463
|
<TableCell data-testid="explanation.servicedDate">
|
|
456
|
-
{serviceItem.servicedDate
|
|
464
|
+
{(serviceItem.servicedDate && (
|
|
457
465
|
<Date fhirData={serviceItem.servicedDate} />
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
|
|
466
|
+
)) ||
|
|
467
|
+
(serviceItem.servicedPeriod && (
|
|
468
|
+
<Period fhirData={serviceItem.servicedPeriod} />
|
|
469
|
+
)) || <MissingValue />}
|
|
461
470
|
</TableCell>
|
|
462
471
|
<TableCell data-testid="explanation.quantity">
|
|
463
472
|
{Number.isFinite(Number(serviceItem.quantity)) ? (
|
|
@@ -501,7 +510,14 @@ const ExplanationOfBenefit = props => {
|
|
|
501
510
|
informationItem,
|
|
502
511
|
'category.coding.0',
|
|
503
512
|
);
|
|
504
|
-
const
|
|
513
|
+
const infoKey = Object.keys(informationItem).filter(
|
|
514
|
+
key => {
|
|
515
|
+
return key !== 'sequence' && key !== 'category';
|
|
516
|
+
},
|
|
517
|
+
);
|
|
518
|
+
const infoStatus = _get(informationItem, infoKey);
|
|
519
|
+
const StatusComponent =
|
|
520
|
+
infoKey.toString() === 'timingDate' ? Date : Quantity;
|
|
505
521
|
|
|
506
522
|
return (
|
|
507
523
|
<TableRow key={`serviceItem-${i}`}>
|
|
@@ -514,7 +530,7 @@ const ExplanationOfBenefit = props => {
|
|
|
514
530
|
</TableCell>
|
|
515
531
|
<TableCell>
|
|
516
532
|
{infoStatus ? (
|
|
517
|
-
<
|
|
533
|
+
<StatusComponent fhirData={infoStatus} />
|
|
518
534
|
) : (
|
|
519
535
|
<MissingValue />
|
|
520
536
|
)}
|
|
@@ -12,6 +12,9 @@ import example2R4 from '../../../fixtures/r4/resources/explanationOfBenefit/eobF
|
|
|
12
12
|
import exampleC4BB from '../../../fixtures/r4/resources/explanationOfBenefit/c4bbExample.json';
|
|
13
13
|
import exampleC4BBExtendedDiagnosis from '../../../fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json';
|
|
14
14
|
|
|
15
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
16
|
+
import ExplanationOfBenefitIcon from '../../../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg';
|
|
17
|
+
|
|
15
18
|
export default {
|
|
16
19
|
title: 'ExplanationOfBenefit',
|
|
17
20
|
};
|
|
@@ -22,6 +25,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
22
25
|
<ExplanationOfBenefit
|
|
23
26
|
fhirVersion={fhirVersions.DSTU2}
|
|
24
27
|
fhirResource={fhirResource}
|
|
28
|
+
fhirIcons={require('../../../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg')}
|
|
25
29
|
/>
|
|
26
30
|
);
|
|
27
31
|
};
|
|
@@ -32,6 +36,7 @@ export const ExampleSTU3 = () => {
|
|
|
32
36
|
<ExplanationOfBenefit
|
|
33
37
|
fhirVersion={fhirVersions.STU3}
|
|
34
38
|
fhirResource={fhirResource}
|
|
39
|
+
fhirIcons={ExplanationOfBenefitIcon}
|
|
35
40
|
/>
|
|
36
41
|
);
|
|
37
42
|
};
|
|
@@ -41,6 +46,7 @@ export const Example2OfSTU3 = () => {
|
|
|
41
46
|
<ExplanationOfBenefit
|
|
42
47
|
fhirVersion={fhirVersions.STU3}
|
|
43
48
|
fhirResource={fhirResource}
|
|
49
|
+
fhirIcons={fhirIcons}
|
|
44
50
|
/>
|
|
45
51
|
);
|
|
46
52
|
};
|
|
@@ -50,6 +56,7 @@ export const PersonPrimaryCoverageR4 = () => {
|
|
|
50
56
|
<ExplanationOfBenefit
|
|
51
57
|
fhirVersion={fhirVersions.R4}
|
|
52
58
|
fhirResource={fhirResource}
|
|
59
|
+
fhirIcons={false}
|
|
53
60
|
/>
|
|
54
61
|
);
|
|
55
62
|
};
|
|
@@ -59,6 +66,7 @@ export const EOBForClaimWithErrorsR4 = () => {
|
|
|
59
66
|
<ExplanationOfBenefit
|
|
60
67
|
fhirVersion={fhirVersions.R4}
|
|
61
68
|
fhirResource={fhirResource}
|
|
69
|
+
fhirIcons={'random text'}
|
|
62
70
|
/>
|
|
63
71
|
);
|
|
64
72
|
};
|
|
@@ -9,8 +9,80 @@ import exampleC4BBExtendedDiagnosis from '../../../fixtures/r4/resources/explana
|
|
|
9
9
|
import fhirVersions from '../fhirResourceVersions';
|
|
10
10
|
import { nbspRegex } from '../../../testUtils';
|
|
11
11
|
import { render } from '@testing-library/react';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
13
|
|
|
13
14
|
describe('should render ExplanationOfBenefit component properly', () => {
|
|
15
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
fhirResource: dstu2Example1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
22
|
+
const headerIcon = getByAltText('explanation of benefit');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
35
|
+
const headerIcon = getByTestId('placeholder');
|
|
36
|
+
|
|
37
|
+
expect(headerIcon).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirResource: dstu2Example1,
|
|
44
|
+
fhirIcons: (
|
|
45
|
+
<img
|
|
46
|
+
src={require('../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg.svg')}
|
|
47
|
+
alt="explanation of benefit"
|
|
48
|
+
/>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
53
|
+
const headerIcon = getByAltText('explanation of benefit');
|
|
54
|
+
|
|
55
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
59
|
+
const defaultProps = {
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirResource: dstu2Example1,
|
|
62
|
+
fhirIcons: fhirIcons,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
66
|
+
const headerIcon = getByAltText('explanation of benefit');
|
|
67
|
+
|
|
68
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
72
|
+
const avatarSrc =
|
|
73
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirResource: dstu2Example1,
|
|
77
|
+
fhirIcons: avatarSrc,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { getByAltText } = render(<ExplanationOfBenefit {...defaultProps} />);
|
|
81
|
+
const headerIcon = getByAltText('header icon');
|
|
82
|
+
|
|
83
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
84
|
+
});
|
|
85
|
+
|
|
14
86
|
it('should render with DSTU2 source data', () => {
|
|
15
87
|
const defaultProps = {
|
|
16
88
|
fhirResource: dstu2Example1,
|
|
@@ -200,13 +272,18 @@ describe('should render ExplanationOfBenefit component properly', () => {
|
|
|
200
272
|
'Condition/88bd5ac6-175b-5906-a4ee-6eedd667b0cc',
|
|
201
273
|
);
|
|
202
274
|
expect(getByTestId('diagnosisType').textContent).toContain('principal');
|
|
203
|
-
expect(getByTestId('supportingInfo.category').textContent).toContain(
|
|
275
|
+
expect(getByTestId('supportingInfo.0.category').textContent).toContain(
|
|
204
276
|
'clmrecvddate',
|
|
205
277
|
);
|
|
206
|
-
expect(getByTestId('supportingInfo.timingDate').textContent).toEqual(
|
|
278
|
+
expect(getByTestId('supportingInfo.0.timingDate').textContent).toEqual(
|
|
207
279
|
'1/5/2017',
|
|
208
280
|
);
|
|
209
|
-
|
|
281
|
+
expect(getByTestId('supportingInfo.1.category').textContent).toContain(
|
|
282
|
+
'dayssupply',
|
|
283
|
+
);
|
|
284
|
+
expect(getByTestId('supportingInfo.1.valueQuantity').textContent).toContain(
|
|
285
|
+
'30',
|
|
286
|
+
);
|
|
210
287
|
// checking if text content of each header cell is equal to mocked data
|
|
211
288
|
const headerCells = getAllByRole('columnheader')
|
|
212
289
|
.slice(0, 4)
|
|
@@ -4,6 +4,7 @@ import _get from 'lodash/get';
|
|
|
4
4
|
import { ValueSection, Value } from '../../ui/index';
|
|
5
5
|
import CodeableConcept from '../../datatypes/CodeableConcept';
|
|
6
6
|
import Date from '../../datatypes/Date';
|
|
7
|
+
import Quantity from '../../datatypes/Quantity';
|
|
7
8
|
|
|
8
9
|
const SupportingInfo = ({ fhirData }) => {
|
|
9
10
|
return fhirData.map((supportingInfo, index) => {
|
|
@@ -11,6 +12,7 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
11
12
|
const category = _get(supportingInfo, 'category');
|
|
12
13
|
const code = _get(supportingInfo, 'code ');
|
|
13
14
|
const timingDate = _get(supportingInfo, 'timingDate');
|
|
15
|
+
const valueQuantity = _get(supportingInfo, 'valueQuantity');
|
|
14
16
|
const timingPeriodStart = _get(supportingInfo, 'timingPeriod.start');
|
|
15
17
|
const timingPeriodEnd = _get(supportingInfo, 'timingPeriod.end');
|
|
16
18
|
|
|
@@ -18,20 +20,24 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
18
20
|
<div key={`total-${index}`}>
|
|
19
21
|
<ValueSection
|
|
20
22
|
label={`Supporting information ${sequence}.`}
|
|
21
|
-
data-testid=
|
|
23
|
+
data-testid={`supportingInfo.${index}`}
|
|
22
24
|
marginTop
|
|
23
25
|
>
|
|
24
26
|
{category && (
|
|
25
27
|
<Value
|
|
26
28
|
dirColumn
|
|
27
29
|
label="Category"
|
|
28
|
-
data-testid=
|
|
30
|
+
data-testid={`supportingInfo.${index}.category`}
|
|
29
31
|
>
|
|
30
32
|
<CodeableConcept fhirData={category} />
|
|
31
33
|
</Value>
|
|
32
34
|
)}
|
|
33
35
|
{code && (
|
|
34
|
-
<Value
|
|
36
|
+
<Value
|
|
37
|
+
dirColumn
|
|
38
|
+
label="Code"
|
|
39
|
+
data-testid={`supportingInfo.${index}.category`}
|
|
40
|
+
>
|
|
35
41
|
<CodeableConcept fhirData={code} />
|
|
36
42
|
</Value>
|
|
37
43
|
)}
|
|
@@ -39,16 +45,25 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
39
45
|
<Value
|
|
40
46
|
dirColumn
|
|
41
47
|
label="Date"
|
|
42
|
-
data-testid=
|
|
48
|
+
data-testid={`supportingInfo.${index}.timingDate`}
|
|
43
49
|
>
|
|
44
50
|
<Date fhirData={timingDate} />
|
|
45
51
|
</Value>
|
|
46
52
|
)}
|
|
53
|
+
{valueQuantity && (
|
|
54
|
+
<Value
|
|
55
|
+
dirColumn
|
|
56
|
+
label="Quantity"
|
|
57
|
+
data-testid={`supportingInfo.${index}.valueQuantity`}
|
|
58
|
+
>
|
|
59
|
+
<Quantity fhirData={valueQuantity} />
|
|
60
|
+
</Value>
|
|
61
|
+
)}
|
|
47
62
|
{timingPeriodStart && (
|
|
48
63
|
<Value
|
|
49
64
|
dirColumn
|
|
50
65
|
label="Start date"
|
|
51
|
-
data-testid=
|
|
66
|
+
data-testid={`supportingInfo.${index}.timingPeriodStart`}
|
|
52
67
|
>
|
|
53
68
|
<Date fhirData={timingPeriodStart} />
|
|
54
69
|
</Value>
|
|
@@ -57,7 +72,7 @@ const SupportingInfo = ({ fhirData }) => {
|
|
|
57
72
|
<Value
|
|
58
73
|
dirColumn
|
|
59
74
|
label="End date"
|
|
60
|
-
data-testid=
|
|
75
|
+
data-testid={`supportingInfo.${index}.timingPeriodEnd`}
|
|
61
76
|
>
|
|
62
77
|
<Date fhirData={timingPeriodEnd} />
|
|
63
78
|
</Value>
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
+
import Accordion from '../../containers/Accordion/Accordion';
|
|
4
5
|
import Coding from '../../datatypes/Coding';
|
|
5
6
|
import Reference from '../../datatypes/Reference';
|
|
6
7
|
import Annotation from '../../datatypes/Annotation';
|
|
7
8
|
|
|
8
9
|
import _get from 'lodash/get';
|
|
9
|
-
import {
|
|
10
|
-
Root,
|
|
11
|
-
Header,
|
|
12
|
-
Title,
|
|
13
|
-
BadgeSecondary,
|
|
14
|
-
Badge,
|
|
15
|
-
Body,
|
|
16
|
-
Value,
|
|
17
|
-
} from '../../ui';
|
|
10
|
+
import { Root, Header, Badge, Body } from '../../ui';
|
|
18
11
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
19
12
|
import fhirVersions from '../fhirResourceVersions';
|
|
20
13
|
import Date from '../../datatypes/Date';
|
|
@@ -78,7 +71,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
78
71
|
};
|
|
79
72
|
|
|
80
73
|
const FamilyMemberHistory = props => {
|
|
81
|
-
const { fhirResource, fhirVersion } = props;
|
|
74
|
+
const { fhirResource, fhirVersion, fhirIcons } = props;
|
|
82
75
|
let fhirResourceData = {};
|
|
83
76
|
try {
|
|
84
77
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -97,36 +90,52 @@ const FamilyMemberHistory = props => {
|
|
|
97
90
|
notes,
|
|
98
91
|
} = fhirResourceData;
|
|
99
92
|
|
|
93
|
+
const tableData = [
|
|
94
|
+
{
|
|
95
|
+
label: 'Patient',
|
|
96
|
+
testId: 'patient',
|
|
97
|
+
data: patient && <Reference fhirData={patient} />,
|
|
98
|
+
status: patient,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: 'Relationship',
|
|
102
|
+
testId: 'hasRelationship',
|
|
103
|
+
data:
|
|
104
|
+
hasRelationship &&
|
|
105
|
+
relationship.map((item, i) => (
|
|
106
|
+
<Coding key={`relationship-item-${i}`} fhirData={item} />
|
|
107
|
+
)),
|
|
108
|
+
status: hasRelationship,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: 'Note',
|
|
112
|
+
testId: 'noteText',
|
|
113
|
+
data: hasNotes && <Annotation fhirData={notes} />,
|
|
114
|
+
status: hasNotes,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
|
|
100
118
|
return (
|
|
101
119
|
<Root name="FamilyMemberHistory">
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
))}
|
|
122
|
-
</Value>
|
|
123
|
-
)}
|
|
124
|
-
{hasNotes && (
|
|
125
|
-
<Value label="Note" data-testid="noteText">
|
|
126
|
-
<Annotation fhirData={notes} />
|
|
127
|
-
</Value>
|
|
128
|
-
)}
|
|
129
|
-
</Body>
|
|
120
|
+
<Accordion
|
|
121
|
+
headerContent={
|
|
122
|
+
<Header
|
|
123
|
+
resourceName="FamilyMemberHistory"
|
|
124
|
+
additionalContent={
|
|
125
|
+
date && (
|
|
126
|
+
<>
|
|
127
|
+
<span className="me-2">On</span>
|
|
128
|
+
<Date fhirData={date} />
|
|
129
|
+
</>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
133
|
+
icon={fhirIcons}
|
|
134
|
+
title={title}
|
|
135
|
+
/>
|
|
136
|
+
}
|
|
137
|
+
bodyContent={<Body tableData={tableData} />}
|
|
138
|
+
/>
|
|
130
139
|
</Root>
|
|
131
140
|
);
|
|
132
141
|
};
|
|
@@ -8,6 +8,7 @@ import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory
|
|
|
8
8
|
|
|
9
9
|
import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
|
|
10
10
|
import example2STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example2.json';
|
|
11
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
title: 'FamilyMemberHistory',
|
|
@@ -19,6 +20,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
19
20
|
<FamilyMemberHistory
|
|
20
21
|
fhirVersion={fhirVersions.DSTU2}
|
|
21
22
|
fhirResource={fhirResource}
|
|
23
|
+
fhirIcons={fhirIcons}
|
|
22
24
|
/>
|
|
23
25
|
);
|
|
24
26
|
};
|
|
@@ -29,6 +31,7 @@ export const Example1OfSTU3 = () => {
|
|
|
29
31
|
<FamilyMemberHistory
|
|
30
32
|
fhirVersion={fhirVersions.STU3}
|
|
31
33
|
fhirResource={fhirResource}
|
|
34
|
+
fhirIcons={fhirIcons}
|
|
32
35
|
/>
|
|
33
36
|
);
|
|
34
37
|
};
|
|
@@ -39,6 +42,7 @@ export const Example2OfSTU3 = () => {
|
|
|
39
42
|
<FamilyMemberHistory
|
|
40
43
|
fhirVersion={fhirVersions.STU3}
|
|
41
44
|
fhirResource={fhirResource}
|
|
45
|
+
fhirIcons={fhirIcons}
|
|
42
46
|
/>
|
|
43
47
|
);
|
|
44
48
|
};
|