fhir-react 0.3.4 → 0.3.7

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 (84) hide show
  1. package/README.md +1 -1
  2. package/build/bootstrap-reboot.min.css +8 -2
  3. package/build/index.js +7 -7
  4. package/build/style.css +6 -6
  5. package/package.json +1 -1
  6. package/src/assets/containers/Binary/binary.svg +9 -0
  7. package/src/assets/containers/Coverage/coverage.svg +4 -0
  8. package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
  9. package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
  10. package/src/assets/containers/Organization/organization.svg +5 -0
  11. package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
  12. package/src/components/containers/Accordion/Accordion.js +10 -9
  13. package/src/components/datatypes/Annotation/Annotation.js +4 -4
  14. package/src/components/datatypes/Attachment/Attachment.css +5 -0
  15. package/src/components/datatypes/Attachment/Attachment.js +7 -2
  16. package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
  17. package/src/components/datatypes/Coding/Coding.css +0 -1
  18. package/src/components/datatypes/Identifier/Identifier.js +7 -3
  19. package/src/components/datatypes/Reference/Reference.css +3 -0
  20. package/src/components/datatypes/Reference/Reference.js +7 -1
  21. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +86 -77
  22. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +12 -1
  23. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +71 -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/Claim/CareTeam.js +55 -0
  32. package/src/components/resources/Claim/Claim.css +2 -11
  33. package/src/components/resources/Claim/Claim.js +157 -309
  34. package/src/components/resources/Claim/Claim.stories.js +37 -5
  35. package/src/components/resources/Claim/Claim.test.js +72 -0
  36. package/src/components/resources/Claim/Diagnosis.js +61 -0
  37. package/src/components/resources/Claim/Insurance.js +58 -0
  38. package/src/components/resources/Claim/Item.js +79 -0
  39. package/src/components/resources/Claim/Items.js +29 -0
  40. package/src/components/resources/Coverage/Coverage.js +96 -69
  41. package/src/components/resources/Coverage/Coverage.stories.js +31 -5
  42. package/src/components/resources/Coverage/Coverage.test.js +75 -3
  43. package/src/components/resources/Device/Device.js +54 -34
  44. package/src/components/resources/Device/Device.stories.js +33 -5
  45. package/src/components/resources/Device/Device.test.js +72 -0
  46. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +53 -43
  47. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +8 -1
  48. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +71 -0
  49. package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
  50. package/src/components/resources/DocumentReference/DocumentReference.stories.js +5 -0
  51. package/src/components/resources/DocumentReference/DocumentReference.test.js +71 -0
  52. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
  53. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +5 -0
  54. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +72 -0
  55. package/src/components/resources/Goal/Goal.js +103 -85
  56. package/src/components/resources/Goal/Goal.stories.js +38 -7
  57. package/src/components/resources/Goal/Goal.test.js +70 -3
  58. package/src/components/resources/Medication/Medication.js +90 -51
  59. package/src/components/resources/Medication/Medication.stories.js +37 -7
  60. package/src/components/resources/Medication/Medication.test.js +77 -3
  61. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +1 -1
  62. package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
  63. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +67 -0
  64. package/src/components/resources/MedicationRequest/MedicationRequest.js +64 -44
  65. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +21 -5
  66. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +67 -0
  67. package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
  68. package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
  69. package/src/components/resources/MedicationStatement/MedicationStatement.js +66 -118
  70. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +7 -0
  71. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +103 -6
  72. package/src/components/resources/Organization/Organization.js +55 -37
  73. package/src/components/resources/Organization/Organization.stories.js +15 -2
  74. package/src/components/resources/Organization/Organization.test.js +73 -0
  75. package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
  76. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
  77. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
  78. package/src/components/ui/bootstrap-reboot.min.css +8 -2
  79. package/src/components/ui/index.js +22 -4
  80. package/src/fixtures/example-icons.jsx +46 -11
  81. package/src/style.scss +1 -0
  82. package/src/utils/formatDate.js +6 -4
  83. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
  84. package/src/components/resources/CarePlan/CarePlan.css +0 -7
@@ -11,13 +11,12 @@ import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
11
11
  import {
12
12
  Root,
13
13
  Header,
14
- Title,
15
14
  Badge,
16
- BadgeSecondary,
17
15
  Body,
18
- Value,
19
16
  MissingValue,
17
+ ValueSectionItem,
20
18
  } from '../../ui';
19
+ import Accordion from '../../containers/Accordion';
21
20
 
22
21
  const commonDTO = fhirResource => {
23
22
  const model = _get(fhirResource, 'model', 'Device');
@@ -103,8 +102,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
103
102
  }
104
103
  };
105
104
 
106
- const Device = props => {
107
- const { fhirResource, fhirVersion } = props;
105
+ const Device = ({ fhirResource, fhirVersion, fhirIcons }) => {
108
106
  let fhirResourceData = {};
109
107
  try {
110
108
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -130,35 +128,57 @@ const Device = props => {
130
128
  const safetyArr = hasSafety && !Array.isArray(safety) ? [safety] : safety;
131
129
  return (
132
130
  <Root name="Device">
133
- <Header>
134
- {model && <Title>{model}</Title>}
135
- {status && <Badge data-testid="status">{status}</Badge>}
136
- {hasExpiry && (
137
- <BadgeSecondary data-testid="expiry">
138
- expires on <Date fhirData={getExpiry} />
139
- </BadgeSecondary>
140
- )}
141
- </Header>
142
- <Body>
143
- {hasTypeCoding && (
144
- <Value data-testid="typeCoding" label="Type">
145
- {getTypeCoding.map((coding, i) => (
146
- <Coding key={`item-${i}`} fhirData={coding} />
147
- ))}
148
- </Value>
149
- )}
150
- <Value label="Unique device identifier" data-testid="uniqueId">
151
- {getUdi ? getUdi : <MissingValue />}
152
- </Value>
153
- {udiCarrierAIDC && <Value label="AIDC barcode">{udiCarrierAIDC}</Value>}
154
- {udiCarrierHRF && <Value label="HRF barcode">{udiCarrierHRF}</Value>}
155
- {hasSafety &&
156
- safetyArr.map((item, i) => (
157
- <Value label="HRF barcode" key={`safety-${i}`}>
158
- <CodeableConcept fhirData={item} />
159
- </Value>
160
- ))}
161
- </Body>
131
+ <Accordion
132
+ headerContent={
133
+ <Header
134
+ icon={fhirIcons}
135
+ resourceName="Device"
136
+ badges={status && <Badge data-testid="status">{status}</Badge>}
137
+ title={model}
138
+ additionalContent={
139
+ hasExpiry && (
140
+ <div data-testid="expiry">
141
+ <span className="text-secondary">expires on</span>{' '}
142
+ <Date fhirData={getExpiry} isBlack />
143
+ </div>
144
+ )
145
+ }
146
+ />
147
+ }
148
+ bodyContent={
149
+ <Body>
150
+ {hasTypeCoding && (
151
+ <ValueSectionItem data-testid="typeCoding" label="Type">
152
+ {getTypeCoding.map((coding, i) => (
153
+ <Coding key={`item-${i}`} fhirData={coding} />
154
+ ))}
155
+ </ValueSectionItem>
156
+ )}
157
+ <ValueSectionItem
158
+ label="Unique device identifier"
159
+ data-testid="uniqueId"
160
+ >
161
+ {getUdi ? getUdi : <MissingValue />}
162
+ </ValueSectionItem>
163
+ {udiCarrierAIDC && (
164
+ <ValueSectionItem label="AIDC barcode">
165
+ {udiCarrierAIDC}
166
+ </ValueSectionItem>
167
+ )}
168
+ {udiCarrierHRF && (
169
+ <ValueSectionItem label="HRF barcode">
170
+ {udiCarrierHRF}
171
+ </ValueSectionItem>
172
+ )}
173
+ {hasSafety &&
174
+ safetyArr.map((item, i) => (
175
+ <ValueSectionItem label="HRF barcode" key={`safety-${i}`}>
176
+ <CodeableConcept fhirData={item} />
177
+ </ValueSectionItem>
178
+ ))}
179
+ </Body>
180
+ }
181
+ />
162
182
  </Root>
163
183
  );
164
184
  };
@@ -10,6 +10,8 @@ import stu3Example2 from '../../../fixtures/stu3/resources/device/example2.json'
10
10
  import r4Example1 from '../../../fixtures/r4/resources/device/example1.json';
11
11
  import r4Example2 from '../../../fixtures/r4/resources/device/example2.json';
12
12
  import fhirVersions from '../fhirResourceVersions';
13
+ import DeviceIcon from '../../../assets/containers/Device/device.svg';
14
+ import fhirIcons from '../../../fixtures/example-icons';
13
15
 
14
16
  export default {
15
17
  title: 'Device',
@@ -18,29 +20,55 @@ export default {
18
20
  export const DefaultVisualizationDSTU2 = () => {
19
21
  const fhirResource = object('Resource', dstu2Example1);
20
22
  return (
21
- <Device fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
23
+ <Device
24
+ fhirResource={fhirResource}
25
+ fhirVersion={fhirVersions.DSTU2}
26
+ fhirIcons={require('../../../assets/containers/Device/device.svg')}
27
+ />
22
28
  );
23
29
  };
24
30
 
25
31
  export const ExampleOfDSTU2 = () => {
26
32
  const fhirResource = object('Resource', dstu2Example2);
27
33
  return (
28
- <Device fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
34
+ <Device
35
+ fhirResource={fhirResource}
36
+ fhirVersion={fhirVersions.DSTU2}
37
+ fhirIcons={DeviceIcon}
38
+ />
29
39
  );
30
40
  };
31
41
 
32
42
  export const Example1OfSTU3 = () => {
33
43
  const fhirResource = object('Resource', stu3Example1);
34
- return <Device fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />;
44
+ return (
45
+ <Device
46
+ fhirResource={fhirResource}
47
+ fhirVersion={fhirVersions.STU3}
48
+ fhirIcons={fhirIcons}
49
+ />
50
+ );
35
51
  };
36
52
  export const Example2OfSTU3 = () => {
37
53
  const fhirResource = object('Resource', stu3Example2);
38
- return <Device fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />;
54
+ return (
55
+ <Device
56
+ fhirResource={fhirResource}
57
+ fhirVersion={fhirVersions.STU3}
58
+ fhirIcons={false}
59
+ />
60
+ );
39
61
  };
40
62
 
41
63
  export const Example1OfR4 = () => {
42
64
  const fhirResource = object('Resource', r4Example1);
43
- return <Device fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />;
65
+ return (
66
+ <Device
67
+ fhirResource={fhirResource}
68
+ fhirVersion={fhirVersions.R4}
69
+ fhirIcons={'random text'}
70
+ />
71
+ );
44
72
  };
45
73
 
46
74
  export const Example2OfR4 = () => {
@@ -6,8 +6,80 @@ import fhirVersions from '../fhirResourceVersions';
6
6
  import dstu2Example1 from '../../../fixtures/dstu2/resources/device/example.json';
7
7
  import stu3Example2 from '../../../fixtures/stu3/resources/device/example2.json';
8
8
  import r4Example2 from '../../../fixtures/r4/resources/device/example2.json';
9
+ import fhirIcons from '../../../fixtures/example-icons';
9
10
 
10
11
  describe('should render Device component properly', () => {
12
+ it('component without a fhirIcons props should render a default icon', () => {
13
+ const defaultProps = {
14
+ fhirResource: dstu2Example1,
15
+ fhirVersion: fhirVersions.DSTU2,
16
+ };
17
+
18
+ const { getByAltText } = render(<Device {...defaultProps} />);
19
+ const headerIcon = getByAltText('device');
20
+
21
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
22
+ });
23
+
24
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
25
+ const defaultProps = {
26
+ fhirResource: dstu2Example1,
27
+ fhirVersion: fhirVersions.DSTU2,
28
+ fhirIcons: false,
29
+ };
30
+
31
+ const { getByTestId } = render(<Device {...defaultProps} />);
32
+ const headerIcon = getByTestId('placeholder');
33
+
34
+ expect(headerIcon).toBeTruthy();
35
+ });
36
+
37
+ it('component with the img as a fhirIcons props should render an img', () => {
38
+ const defaultProps = {
39
+ fhirResource: dstu2Example1,
40
+ fhirVersion: fhirVersions.DSTU2,
41
+ fhirIcons: (
42
+ <img
43
+ src={require('../assets/containers/Device/device.svg')}
44
+ alt="device"
45
+ />
46
+ ),
47
+ };
48
+
49
+ const { getByAltText } = render(<Device {...defaultProps} />);
50
+ const headerIcon = getByAltText('device');
51
+
52
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
53
+ });
54
+
55
+ it('component with the resources object as a fhirIcons props should render an img', () => {
56
+ const defaultProps = {
57
+ fhirResource: dstu2Example1,
58
+ fhirVersion: fhirVersions.DSTU2,
59
+ fhirIcons: fhirIcons,
60
+ };
61
+
62
+ const { getByAltText } = render(<Device {...defaultProps} />);
63
+ const headerIcon = getByAltText('device');
64
+
65
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
66
+ });
67
+
68
+ it('component with the url as a fhirIcons props should render an img', () => {
69
+ const avatarSrc =
70
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
71
+ const defaultProps = {
72
+ fhirResource: dstu2Example1,
73
+ fhirVersion: fhirVersions.DSTU2,
74
+ fhirIcons: avatarSrc,
75
+ };
76
+
77
+ const { getByAltText } = render(<Device {...defaultProps} />);
78
+ const headerIcon = getByAltText('header icon');
79
+
80
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
81
+ });
82
+
11
83
  it('should render with DSTU2 source data', () => {
12
84
  const defaultProps = {
13
85
  fhirResource: dstu2Example1,
@@ -7,16 +7,9 @@ import _get from 'lodash/get';
7
7
  import _has from 'lodash/has';
8
8
  import fhirVersions from '../fhirResourceVersions';
9
9
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
10
+ import Accordion from '../../containers/Accordion';
10
11
 
11
- import {
12
- Root,
13
- Header,
14
- Title,
15
- Badge,
16
- BadgeSecondary,
17
- Body,
18
- Value,
19
- } from '../../ui';
12
+ import { Root, Header, Badge, Body, Value } from '../../ui';
20
13
 
21
14
  const commonDTO = fhirResource => {
22
15
  const title =
@@ -101,7 +94,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
101
94
  };
102
95
 
103
96
  const DiagnosticReport = props => {
104
- const { fhirResource, fhirVersion } = props;
97
+ const { fhirResource, fhirVersion, fhirIcons } = props;
105
98
  let fhirResourceData = {};
106
99
  try {
107
100
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -121,41 +114,58 @@ const DiagnosticReport = props => {
121
114
  performer,
122
115
  issued,
123
116
  } = fhirResourceData;
117
+
118
+ const tableData = [
119
+ {
120
+ label: 'Issued',
121
+ testId: 'issued',
122
+ data: <Date fhirData={issued} isBlack />,
123
+ status: issued,
124
+ },
125
+ {
126
+ label: 'Category',
127
+ testId: 'categoryCoding',
128
+ data:
129
+ categoryCoding &&
130
+ categoryCoding.map((coding, i) => (
131
+ <Coding key={`item-${i}`} fhirData={coding} />
132
+ )),
133
+ status: hasCategoryCoding,
134
+ },
135
+ {
136
+ label: 'Performer',
137
+ testId: 'performer',
138
+ data: <Reference fhirData={performer} />,
139
+ status: hasPerformer,
140
+ },
141
+ {
142
+ label: 'Conclusion',
143
+ testId: 'conclusion',
144
+ data: conclusion,
145
+ status: conclusion,
146
+ },
147
+ ];
148
+
124
149
  return (
125
150
  <Root name="DiagnosticReport">
126
- <Header>
127
- <Title data-testid="title">{title}</Title>
128
- {status && <Badge data-testid="status">{status}</Badge>}
129
- {effectiveDateTime && (
130
- <BadgeSecondary data-testid="effectiveDateTime">
131
- <Date fhirData={effectiveDateTime} />
132
- </BadgeSecondary>
133
- )}
134
- </Header>
135
- <Body>
136
- {issued && (
137
- <Value label="Issued" data-testid="issued">
138
- <Date fhirData={issued} />
139
- </Value>
140
- )}
141
- {hasCategoryCoding && (
142
- <Value label="Category" data-testid="categoryCoding">
143
- {categoryCoding.map((coding, i) => (
144
- <Coding key={`item-${i}`} fhirData={coding} />
145
- ))}
146
- </Value>
147
- )}
148
- {hasPerformer && (
149
- <Value label="Performer" data-testid="performer">
150
- <Reference fhirData={performer} />
151
- </Value>
152
- )}
153
- {conclusion && (
154
- <Value label="Conclusion" data-testid="conclusion">
155
- {conclusion}
156
- </Value>
157
- )}
158
- </Body>
151
+ <Accordion
152
+ headerContent={
153
+ <Header
154
+ icon={fhirIcons}
155
+ resourceName="DiagnosticReport"
156
+ badges={status && <Badge data-testid="status">{status}</Badge>}
157
+ title={title}
158
+ additionalContent={
159
+ effectiveDateTime && (
160
+ <Value label="On" data-testid="effectiveDateTime">
161
+ <Date fhirData={effectiveDateTime} isBlack />
162
+ </Value>
163
+ )
164
+ }
165
+ />
166
+ }
167
+ bodyContent={<Body tableData={tableData} />}
168
+ />
159
169
  </Root>
160
170
  );
161
171
  };
@@ -9,6 +9,8 @@ import exampleDiagnosticReportSTU3 from '../../../fixtures/stu3/resources/diagno
9
9
  import exampleDiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example1.json';
10
10
  import example2DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example2.json';
11
11
  import example3DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example3.json';
12
+ import fhirIcons from '../../../fixtures/example-icons';
13
+ import DiagnosticReportIcon from '../../../assets/containers/DiagnosticReport/diagnostic-report.svg';
12
14
 
13
15
  export default { title: 'DiagnosticReport' };
14
16
 
@@ -18,6 +20,7 @@ export const DefaultVisualizationDSTU2 = () => {
18
20
  <DiagnosticReport
19
21
  fhirVersion={fhirVersions.DSTU2}
20
22
  fhirResource={fhirResource}
23
+ fhirIcons={require('../../../assets/containers/DiagnosticReport/diagnostic-report.svg')}
21
24
  />
22
25
  );
23
26
  };
@@ -28,6 +31,7 @@ export const ExampleDiagnosticReportSTU3 = () => {
28
31
  <DiagnosticReport
29
32
  fhirVersion={fhirVersions.STU3}
30
33
  fhirResource={fhirResource}
34
+ fhirIcons={DiagnosticReportIcon}
31
35
  />
32
36
  );
33
37
  };
@@ -38,6 +42,7 @@ export const ExampleDiagnosticReportR4 = () => {
38
42
  <DiagnosticReport
39
43
  fhirVersion={fhirVersions.R4}
40
44
  fhirResource={fhirResource}
45
+ fhirIcons={fhirIcons}
41
46
  />
42
47
  );
43
48
  };
@@ -48,6 +53,7 @@ export const Example2DiagnosticReportR4 = () => {
48
53
  <DiagnosticReport
49
54
  fhirVersion={fhirVersions.R4}
50
55
  fhirResource={fhirResource}
56
+ fhirIcons={false}
51
57
  />
52
58
  );
53
59
  };
@@ -58,11 +64,12 @@ export const Example3DiagnosticReportR4 = () => {
58
64
  <DiagnosticReport
59
65
  fhirVersion={fhirVersions.R4}
60
66
  fhirResource={fhirResource}
67
+ fhirIcons={'random text'}
61
68
  />
62
69
  );
63
70
  };
64
71
 
65
72
  export const ExampleWithoutFhirVersionProperty = () => {
66
73
  const fhirResource = object('Resource', exampleDiagnosticReportSTU3);
67
- return <DiagnosticReport fhirResource={fhirResource} />;
74
+ return <DiagnosticReport fhirResource={fhirResource} fhirIcons={fhirIcons} />;
68
75
  };
@@ -7,8 +7,79 @@ import exampleDiagnosticReportDSTU2 from '../../../fixtures/dstu2/resources/diag
7
7
  import exampleDiagnosticReportSTU3 from '../../../fixtures/stu3/resources/diagnosticReport/example1.json';
8
8
  import exampleDiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example1.json';
9
9
  import example2DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example2.json';
10
+ import fhirIcons from '../../../fixtures/example-icons';
10
11
 
11
12
  describe('should render component correctly', () => {
13
+ it('component without a fhirIcons props should render a default icon', () => {
14
+ const defaultProps = {
15
+ fhirResource: exampleDiagnosticReportDSTU2,
16
+ fhirVersion: fhirVersions.DSTU2,
17
+ };
18
+
19
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
20
+ const headerIcon = getByAltText('diagnostic report');
21
+
22
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
23
+ });
24
+
25
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
26
+ const defaultProps = {
27
+ fhirResource: exampleDiagnosticReportDSTU2,
28
+ fhirVersion: fhirVersions.DSTU2,
29
+ fhirIcons: false,
30
+ };
31
+
32
+ const { getByTestId } = render(<DiagnosticReport {...defaultProps} />);
33
+ const headerIcon = getByTestId('placeholder');
34
+
35
+ expect(headerIcon).toBeTruthy();
36
+ });
37
+
38
+ it('component with the img as a fhirIcons props should render an img', () => {
39
+ const defaultProps = {
40
+ fhirResource: exampleDiagnosticReportDSTU2,
41
+ fhirVersion: fhirVersions.DSTU2,
42
+ fhirIcons: (
43
+ <img
44
+ src={require('../assets/containers/DiagnosticReport/diagnostic-report.svg')}
45
+ alt="diagnostic report"
46
+ />
47
+ ),
48
+ };
49
+
50
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
51
+ const headerIcon = getByAltText('diagnostic report');
52
+
53
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
54
+ });
55
+
56
+ it('component with the resources object as a fhirIcons props should render an img', () => {
57
+ const defaultProps = {
58
+ fhirResource: exampleDiagnosticReportDSTU2,
59
+ fhirVersion: fhirVersions.DSTU2,
60
+ fhirIcons: fhirIcons,
61
+ };
62
+
63
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
64
+ const headerIcon = getByAltText('diagnostic report');
65
+
66
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
67
+ });
68
+
69
+ it('component with the url as a fhirIcons props should render an img', () => {
70
+ const avatarSrc =
71
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
72
+ const defaultProps = {
73
+ fhirResource: exampleDiagnosticReportDSTU2,
74
+ fhirVersion: fhirVersions.DSTU2,
75
+ fhirIcons: avatarSrc,
76
+ };
77
+
78
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
79
+ const headerIcon = getByAltText('header icon');
80
+
81
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
82
+ });
12
83
  it('should render with DSTU2 source data', () => {
13
84
  const defaultProps = {
14
85
  fhirResource: exampleDiagnosticReportDSTU2,