fhir-react 0.3.2 → 0.3.6

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.
Files changed (95) hide show
  1. package/README.md +85 -2
  2. package/build/bootstrap-reboot.min.css +8 -2
  3. package/build/index.js +7 -14
  4. package/build/style.css +4 -5
  5. package/package.json +1 -1
  6. package/src/assets/containers/Binary/binary.svg +9 -0
  7. package/src/assets/containers/{Medication/medication.svg → MedicationOrder/medication-order.svg} +0 -0
  8. package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
  9. package/src/assets/containers/Patient/patient.svg +6 -0
  10. package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
  11. package/src/components/containers/Accordion/Accordion.js +17 -12
  12. package/src/components/datatypes/Annotation/Annotation.js +4 -4
  13. package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
  14. package/src/components/datatypes/Coding/Coding.css +0 -1
  15. package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
  16. package/src/components/datatypes/Reference/Reference.css +3 -0
  17. package/src/components/datatypes/Reference/Reference.js +2 -0
  18. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +86 -77
  19. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +12 -1
  20. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +71 -0
  21. package/src/components/resources/Appointment/Appointment.js +3 -3
  22. package/src/components/resources/Appointment/Appointment.stories.js +28 -5
  23. package/src/components/resources/Appointment/Appointment.test.js +72 -0
  24. package/src/components/resources/Binary/Binary.js +30 -20
  25. package/src/components/resources/Binary/Binary.stories.js +12 -5
  26. package/src/components/resources/Binary/Binary.test.js +67 -0
  27. package/src/components/resources/CarePlan/CarePlan.js +111 -96
  28. package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
  29. package/src/components/resources/CarePlan/CarePlan.test.js +74 -2
  30. package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
  31. package/src/components/resources/Condition/Condition.js +1 -3
  32. package/src/components/resources/Condition/Condition.stories.js +9 -19
  33. package/src/components/resources/Condition/Condition.test.js +71 -1
  34. package/src/components/resources/Device/Device.js +54 -34
  35. package/src/components/resources/Device/Device.stories.js +33 -5
  36. package/src/components/resources/Device/Device.test.js +72 -0
  37. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +53 -43
  38. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +8 -1
  39. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +71 -0
  40. package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
  41. package/src/components/resources/DocumentReference/DocumentReference.stories.js +5 -0
  42. package/src/components/resources/DocumentReference/DocumentReference.test.js +71 -0
  43. package/src/components/resources/Encounter/Encounter.js +3 -4
  44. package/src/components/resources/Encounter/Encounter.stories.js +27 -5
  45. package/src/components/resources/Encounter/Encounter.test.js +72 -0
  46. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +26 -10
  47. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
  48. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +80 -3
  49. package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +21 -6
  50. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
  51. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +5 -0
  52. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +72 -0
  53. package/src/components/resources/Goal/Goal.js +103 -85
  54. package/src/components/resources/Goal/Goal.stories.js +38 -7
  55. package/src/components/resources/Goal/Goal.test.js +70 -3
  56. package/src/components/resources/Immunization/Immunization.js +1 -2
  57. package/src/components/resources/Immunization/Immunization.stories.js +6 -9
  58. package/src/components/resources/Immunization/Immunization.test.js +71 -1
  59. package/src/components/resources/Medication/Medication.test.js +1 -1
  60. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +1 -1
  61. package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
  62. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +67 -0
  63. package/src/components/resources/MedicationRequest/MedicationRequest.js +64 -44
  64. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +21 -5
  65. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +67 -0
  66. package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
  67. package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
  68. package/src/components/resources/MedicationStatement/MedicationStatement.js +66 -118
  69. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +7 -0
  70. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +103 -6
  71. package/src/components/resources/Observation/Observation.js +3 -3
  72. package/src/components/resources/Observation/Observation.stories.js +14 -5
  73. package/src/components/resources/Observation/Observation.test.js +67 -0
  74. package/src/components/resources/Patient/Patient.js +9 -6
  75. package/src/components/resources/Patient/Patient.stories.js +12 -5
  76. package/src/components/resources/Patient/Patient.test.js +67 -0
  77. package/src/components/resources/Practitioner/Practitioner.js +3 -13
  78. package/src/components/resources/Practitioner/Practitioner.stories.js +19 -3
  79. package/src/components/resources/Practitioner/Practitioner.test.js +72 -0
  80. package/src/components/resources/Procedure/Procedure.js +1 -2
  81. package/src/components/resources/Procedure/Procedure.stories.js +11 -5
  82. package/src/components/resources/Procedure/Procedure.test.js +71 -1
  83. package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -8
  84. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
  85. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
  86. package/src/components/ui/bootstrap-reboot.min.css +8 -2
  87. package/src/components/ui/index.js +44 -25
  88. package/src/fixtures/example-icons.jsx +74 -22
  89. package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
  90. package/src/style.scss +1 -0
  91. package/src/utils/convertCamelCaseToSentence.js +9 -0
  92. package/src/utils/convertCamelCaseToSentence.test.js +9 -0
  93. package/src/utils/formatDate.js +6 -4
  94. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
  95. package/src/components/resources/CarePlan/CarePlan.css +0 -7
@@ -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 = props => {
229
- const { fhirResource, fhirVersion, withCarinBBProfile = false } = props;
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
- <MissingValue />
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 infoStatus = _get(informationItem, 'code.coding.0');
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
- <Coding fhirData={infoStatus} />
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="supportingInfo"
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="supportingInfo.category"
30
+ data-testid={`supportingInfo.${index}.category`}
29
31
  >
30
32
  <CodeableConcept fhirData={category} />
31
33
  </Value>
32
34
  )}
33
35
  {code && (
34
- <Value dirColumn label="Code" data-testid="supportingInfo.code">
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="supportingInfo.timingDate"
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="supportingInfo.timingPeriodStart"
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="supportingInfo.timingPeriodEnd"
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
- <Header>
103
- <Title>{title}</Title>
104
- {status && <Badge data-testid="status">{status}</Badge>}
105
- {date && (
106
- <BadgeSecondary>
107
- on <Date fhirData={date} />
108
- </BadgeSecondary>
109
- )}
110
- </Header>
111
- <Body>
112
- {patient && (
113
- <Value label="Patient" data-testid="patient">
114
- <Reference fhirData={patient} />
115
- </Value>
116
- )}
117
- {hasRelationship && (
118
- <Value label="Relationship" data-testid="hasRelationship">
119
- {relationship.map((item, i) => (
120
- <Coding key={`item-${i}`} fhirData={item} />
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,8 @@ 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';
12
+ import FamilyMemberHistoryIcon from '../../../assets/containers/FamilyMemberHistory/family-member-history.svg';
11
13
 
12
14
  export default {
13
15
  title: 'FamilyMemberHistory',
@@ -19,6 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
19
21
  <FamilyMemberHistory
20
22
  fhirVersion={fhirVersions.DSTU2}
21
23
  fhirResource={fhirResource}
24
+ fhirIcons={require('../../../assets/containers/FamilyMemberHistory/family-member-history.svg')}
22
25
  />
23
26
  );
24
27
  };
@@ -29,6 +32,7 @@ export const Example1OfSTU3 = () => {
29
32
  <FamilyMemberHistory
30
33
  fhirVersion={fhirVersions.STU3}
31
34
  fhirResource={fhirResource}
35
+ fhirIcons={FamilyMemberHistoryIcon}
32
36
  />
33
37
  );
34
38
  };
@@ -39,6 +43,7 @@ export const Example2OfSTU3 = () => {
39
43
  <FamilyMemberHistory
40
44
  fhirVersion={fhirVersions.STU3}
41
45
  fhirResource={fhirResource}
46
+ fhirIcons={fhirIcons}
42
47
  />
43
48
  );
44
49
  };
@@ -5,8 +5,80 @@ import fhirVersions from '../fhirResourceVersions';
5
5
 
6
6
  import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory/example1.json';
7
7
  import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
8
+ import fhirIcons from '../../../fixtures/example-icons';
8
9
 
9
10
  describe('should render FamilyMemberHistory component correctly', () => {
11
+ it('component without a fhirIcons props should render a default icon', () => {
12
+ const defaultProps = {
13
+ fhirResource: example1DSTU2,
14
+ fhirVersion: fhirVersions.DSTU2,
15
+ };
16
+
17
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
18
+ const headerIcon = getByAltText('family member history');
19
+
20
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
21
+ });
22
+
23
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
24
+ const defaultProps = {
25
+ fhirResource: example1DSTU2,
26
+ fhirVersion: fhirVersions.DSTU2,
27
+ fhirIcons: false,
28
+ };
29
+
30
+ const { getByTestId } = render(<FamilyMemberHistory {...defaultProps} />);
31
+ const headerIcon = getByTestId('placeholder');
32
+
33
+ expect(headerIcon).toBeTruthy();
34
+ });
35
+
36
+ it('component with the img as a fhirIcons props should render an img', () => {
37
+ const defaultProps = {
38
+ fhirResource: example1DSTU2,
39
+ fhirVersion: fhirVersions.DSTU2,
40
+ fhirIcons: (
41
+ <img
42
+ src={require('../assets/containers/FamilyMemberHistory/family-member-history.svg')}
43
+ alt="family member history"
44
+ />
45
+ ),
46
+ };
47
+
48
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
49
+ const headerIcon = getByAltText('family member history');
50
+
51
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
52
+ });
53
+
54
+ it('component with the resources object as a fhirIcons props should render an img', () => {
55
+ const defaultProps = {
56
+ fhirResource: example1DSTU2,
57
+ fhirVersion: fhirVersions.DSTU2,
58
+ fhirIcons: fhirIcons,
59
+ };
60
+
61
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
62
+ const headerIcon = getByAltText('family member history');
63
+
64
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
65
+ });
66
+
67
+ it('component with the url as a fhirIcons props should render an img', () => {
68
+ const avatarSrc =
69
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
70
+ const defaultProps = {
71
+ fhirResource: example1DSTU2,
72
+ fhirVersion: fhirVersions.DSTU2,
73
+ fhirIcons: avatarSrc,
74
+ };
75
+
76
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
77
+ const headerIcon = getByAltText('header icon');
78
+
79
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
80
+ });
81
+
10
82
  it('DSTU2', () => {
11
83
  const defaultProps = {
12
84
  fhirResource: example1DSTU2,