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
@@ -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,
@@ -5,17 +5,16 @@ import prettyBytes from 'pretty-bytes';
5
5
 
6
6
  import fhirVersions from '../fhirResourceVersions';
7
7
  import Coding from '../../datatypes/Coding';
8
- import DateType from '../../datatypes/Date';
9
8
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
9
+ import Accordion from '../../containers/Accordion';
10
+ import Date from '../../datatypes/Date';
10
11
 
11
12
  import {
12
13
  Root,
13
14
  Body,
14
15
  Header,
15
- Title,
16
16
  Badge,
17
- BadgeSecondary,
18
- Value,
17
+ ValueSectionItem,
19
18
  ValueSection,
20
19
  Table,
21
20
  TableRow,
@@ -202,7 +201,7 @@ const Content = props => {
202
201
  <ContentItem key={i} item={item} />
203
202
  ));
204
203
  return (
205
- <ValueSection label="Content">
204
+ <ValueSection label="Content" marginTop>
206
205
  <Table>
207
206
  <thead>
208
207
  <TableRow>
@@ -211,14 +210,14 @@ const Content = props => {
211
210
  <TableHeader>Resource</TableHeader>
212
211
  </TableRow>
213
212
  </thead>
214
- <tbody>{allContent}</tbody>
213
+ <tbody className="border-top-0">{allContent}</tbody>
215
214
  </Table>
216
215
  </ValueSection>
217
216
  );
218
217
  };
219
218
 
220
219
  const DocumentReference = props => {
221
- const { fhirVersion, fhirResource } = props;
220
+ const { fhirVersion, fhirResource, fhirIcons } = props;
222
221
  let fhirResourceData = {};
223
222
  try {
224
223
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -241,67 +240,104 @@ const DocumentReference = props => {
241
240
  const hasContent = content.length > 0;
242
241
  const hasPeriod = context.periodStart || context.periodEnd;
243
242
 
243
+ const tableData = [
244
+ {
245
+ label: 'Document type',
246
+ testId: 'type',
247
+ data: <Coding fhirData={typeCoding} />,
248
+ status: typeCoding,
249
+ },
250
+ {
251
+ label: 'Document categorization',
252
+ testId: 'class',
253
+ data: <Coding fhirData={classCoding} />,
254
+ status: classCoding,
255
+ },
256
+ {
257
+ label: 'Security Label',
258
+ testId: 'securityLabel',
259
+ data: <Coding fhirData={securityLabelCoding} />,
260
+ status: securityLabelCoding,
261
+ },
262
+ {
263
+ label: 'Created At',
264
+ testId: 'createdAt',
265
+ data: <Date fhirData={createdAt} isBlack />,
266
+ status: createdAt,
267
+ },
268
+ ];
269
+
270
+ const contextTable = [
271
+ {
272
+ label: 'Event',
273
+ testId: 'context.event',
274
+ data: <Coding fhirData={context.eventCoding} />,
275
+ status: context.eventCoding,
276
+ },
277
+ {
278
+ label: 'Facility',
279
+ testId: 'context.facilityType',
280
+ data: <Coding fhirData={context.facilityTypeCoding} />,
281
+ status: context.facilityTypeCoding,
282
+ },
283
+ {
284
+ label: 'Practice Setting',
285
+ testId: 'context.practiceSetting',
286
+ data: <Coding fhirData={context.practiceSettingCoding} />,
287
+ status: context.practiceSettingCoding,
288
+ },
289
+ {
290
+ label: 'Period',
291
+ testId: 'context.period',
292
+ data: (
293
+ <>
294
+ {context.periodStart && (
295
+ <Date fhirData={context.periodStart} isBlack />
296
+ )}
297
+ {' - '}
298
+ {context.periodEnd && <Date fhirData={context.periodEnd} isBlack />}
299
+ </>
300
+ ),
301
+ status: hasPeriod,
302
+ },
303
+ ];
304
+
305
+ const getValueSectionItem = (item, index) =>
306
+ item.status && (
307
+ <ValueSectionItem
308
+ key={`context-item-${index}`}
309
+ label={item.label}
310
+ data-testid={item.testId}
311
+ >
312
+ {item.data}
313
+ </ValueSectionItem>
314
+ );
315
+
244
316
  return (
245
317
  <Root name="DocumentReference">
246
- <Header>
247
- <Title data-testid="title">{description}</Title>
248
- {status && <Badge data-testid="status">{status}</Badge>}
249
- {docStatus && (
250
- <BadgeSecondary data-testid="docStatus">{docStatus}</BadgeSecondary>
251
- )}
252
- </Header>
253
- <Body>
254
- {typeCoding && (
255
- <Value label="Document type" data-testid="type">
256
- <Coding fhirData={typeCoding} />
257
- </Value>
258
- )}
259
- {classCoding && (
260
- <Value label="Document categorization" data-testid="class">
261
- <Coding fhirData={classCoding} />
262
- </Value>
263
- )}
264
- {securityLabelCoding && (
265
- <Value label="Security Label" data-testid="securityLabel">
266
- <Coding fhirData={securityLabelCoding} />
267
- </Value>
268
- )}
269
- {createdAt && (
270
- <Value label="Created At" data-testid="createdAt">
271
- <DateType fhirData={createdAt} />
272
- </Value>
273
- )}
274
- <ValueSection label="Context">
275
- {context.eventCoding && (
276
- <Value label="Event" data-testid="context.event">
277
- <Coding fhirData={context.eventCoding} />
278
- </Value>
279
- )}
280
- {context.facilityTypeCoding && (
281
- <Value label="Facility" data-testid="context.facilityType">
282
- <Coding fhirData={context.facilityTypeCoding} />
283
- </Value>
284
- )}
285
- {context.practiceSettingCoding && (
286
- <Value
287
- label="Practice Setting"
288
- data-testid="context.practiceSetting"
289
- >
290
- <Coding fhirData={context.practiceSettingCoding} />
291
- </Value>
292
- )}
293
- {hasPeriod && (
294
- <Value label="Period" data-testid="context.period">
295
- {context.periodStart && (
296
- <DateType fhirData={context.periodStart} />
318
+ <Accordion
319
+ headerContent={
320
+ <Header
321
+ icon={fhirIcons}
322
+ resourceName="DocumentReference"
323
+ title={description}
324
+ badges={status && <Badge data-testid="status">{status}</Badge>}
325
+ additionalBadge={
326
+ docStatus && <Badge data-testid="docStatus">{docStatus}</Badge>
327
+ }
328
+ />
329
+ }
330
+ bodyContent={
331
+ <Body tableData={tableData}>
332
+ <ValueSection label="Context" marginTop>
333
+ {contextTable.map((item, index) =>
334
+ getValueSectionItem(item, index),
297
335
  )}
298
- {' - '}
299
- {context.periodEnd && <DateType fhirData={context.periodEnd} />}
300
- </Value>
301
- )}
302
- </ValueSection>
303
- {hasContent && <Content content={content} />}
304
- </Body>
336
+ </ValueSection>
337
+ {hasContent && <Content content={content} />}
338
+ </Body>
339
+ }
340
+ />
305
341
  </Root>
306
342
  );
307
343
  };
@@ -7,6 +7,8 @@ import DocumentReference from './DocumentReference';
7
7
  import exampleDocumentReference from '../../../fixtures/dstu2/resources/documentReference/example1.json';
8
8
  import exampleDocumentReferenceSTU3 from '../../../fixtures/stu3/resources/documentReference/example1.json';
9
9
  import example1DocumentReferenceR4 from '../../../fixtures/r4/resources/documentReference/example1.json';
10
+ import fhirIcons from '../../../fixtures/example-icons';
11
+ import DocumentReferenceIcon from '../../../assets/containers/DocumentReference/document-reference.svg';
10
12
 
11
13
  export default { title: 'Document Reference' };
12
14
 
@@ -16,6 +18,7 @@ export const DefaultVisualizationDSTU2 = () => {
16
18
  <DocumentReference
17
19
  fhirResource={fhirResource}
18
20
  fhirVersion={fhirVersions.DSTU2}
21
+ fhirIcons={require('../../../assets/containers/DocumentReference/document-reference.svg')}
19
22
  />
20
23
  );
21
24
  };
@@ -26,6 +29,7 @@ export const ExampleSTU3 = () => {
26
29
  <DocumentReference
27
30
  fhirResource={fhirResource}
28
31
  fhirVersion={fhirVersions.STU3}
32
+ fhirIcons={DocumentReferenceIcon}
29
33
  />
30
34
  );
31
35
  };
@@ -36,6 +40,7 @@ export const ExampleR4 = () => {
36
40
  <DocumentReference
37
41
  fhirResource={fhirResource}
38
42
  fhirVersion={fhirVersions.R4}
43
+ fhirIcons={fhirIcons}
39
44
  />
40
45
  );
41
46
  };
@@ -8,8 +8,79 @@ import DocumentReference from './DocumentReference';
8
8
  import dstu2Example1 from '../../../fixtures/dstu2/resources/documentReference/example1.json';
9
9
  import stu3Example1 from '../../../fixtures/stu3/resources/documentReference/example1.json';
10
10
  import r4Example1 from '../../../fixtures/r4/resources/documentReference/example1.json';
11
+ import fhirIcons from '../../../fixtures/example-icons';
11
12
 
12
13
  describe('should render the DocumentReference component properly', () => {
14
+ it('component without a fhirIcons props should render a default icon', () => {
15
+ const defaultProps = {
16
+ fhirResource: dstu2Example1,
17
+ fhirVersion: fhirVersions.DSTU2,
18
+ };
19
+
20
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
21
+ const headerIcon = getByAltText('document reference');
22
+
23
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
24
+ });
25
+
26
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
27
+ const defaultProps = {
28
+ fhirResource: dstu2Example1,
29
+ fhirVersion: fhirVersions.DSTU2,
30
+ fhirIcons: false,
31
+ };
32
+
33
+ const { getByTestId } = render(<DocumentReference {...defaultProps} />);
34
+ const headerIcon = getByTestId('placeholder');
35
+
36
+ expect(headerIcon).toBeTruthy();
37
+ });
38
+
39
+ it('component with the img as a fhirIcons props should render an img', () => {
40
+ const defaultProps = {
41
+ fhirResource: dstu2Example1,
42
+ fhirVersion: fhirVersions.DSTU2,
43
+ fhirIcons: (
44
+ <img
45
+ src={require('../assets/containers/DocumentReference/document-reference.svg')}
46
+ alt="document reference"
47
+ />
48
+ ),
49
+ };
50
+
51
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
52
+ const headerIcon = getByAltText('document reference');
53
+
54
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
55
+ });
56
+
57
+ it('component with the resources object as a fhirIcons props should render an img', () => {
58
+ const defaultProps = {
59
+ fhirResource: dstu2Example1,
60
+ fhirVersion: fhirVersions.DSTU2,
61
+ fhirIcons: fhirIcons,
62
+ };
63
+
64
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
65
+ const headerIcon = getByAltText('document reference');
66
+
67
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
68
+ });
69
+
70
+ it('component with the url as a fhirIcons props should render an img', () => {
71
+ const avatarSrc =
72
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
73
+ const defaultProps = {
74
+ fhirResource: dstu2Example1,
75
+ fhirVersion: fhirVersions.DSTU2,
76
+ fhirIcons: avatarSrc,
77
+ };
78
+
79
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
80
+ const headerIcon = getByAltText('header icon');
81
+
82
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
83
+ });
13
84
  it('should render with DSTU2 source data', () => {
14
85
  const { getByTestId } = render(
15
86
  <DocumentReference
@@ -160,8 +160,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
160
160
  }
161
161
  };
162
162
 
163
- const Encounter = props => {
164
- const { fhirResource, fhirVersion } = props;
163
+ const Encounter = ({ fhirResource, fhirVersion, fhirIcons }) => {
165
164
  let fhirResourceData = {};
166
165
  try {
167
166
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -177,7 +176,6 @@ const Encounter = props => {
177
176
  encounterType,
178
177
  resourceClass,
179
178
  resourceStatus,
180
- resourceName,
181
179
  participant,
182
180
  } = fhirResourceData;
183
181
 
@@ -207,7 +205,7 @@ const Encounter = props => {
207
205
  <Accordion
208
206
  headerContent={
209
207
  <Header
210
- resourceName={resourceName}
208
+ resourceName={'Encounter'}
211
209
  additionalContent={
212
210
  periodStart && (
213
211
  <Value label="Start date" data-testid="headerStartDate">
@@ -221,6 +219,7 @@ const Encounter = props => {
221
219
  )
222
220
  }
223
221
  title={locationDisplay}
222
+ icon={fhirIcons}
224
223
  />
225
224
  }
226
225
  bodyContent={
@@ -11,6 +11,8 @@ import example1_R4 from '../../../fixtures/r4/resources/encounter/example1.json'
11
11
  import example2_R4 from '../../../fixtures/r4/resources/encounter/example2.json';
12
12
  import example3_R4 from '../../../fixtures/r4/resources/encounter/example3.json';
13
13
  import fhirVersions from '../fhirResourceVersions';
14
+ import fhirIcons from '../../../fixtures/example-icons';
15
+ import EncounterIcon from '../../../assets/containers/Encounter/encounter.svg';
14
16
 
15
17
  export default {
16
18
  title: 'Encounter',
@@ -19,35 +21,55 @@ export default {
19
21
  export const DefaultVisualizationDSTU2 = () => {
20
22
  const fhirResource = object('Resource', example1);
21
23
  return (
22
- <Encounter fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />
24
+ <Encounter
25
+ fhirVersion={fhirVersions.DSTU2}
26
+ fhirResource={fhirResource}
27
+ fhirIcons={require('../../../assets/containers/Encounter/encounter.svg')}
28
+ />
23
29
  );
24
30
  };
25
31
 
26
32
  export const ExampleWithoutParticipantsDSTU2 = () => {
27
33
  const fhirResource = object('Resource', example2);
28
34
  return (
29
- <Encounter fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />
35
+ <Encounter
36
+ fhirVersion={fhirVersions.DSTU2}
37
+ fhirResource={fhirResource}
38
+ fhirIcons={EncounterIcon}
39
+ />
30
40
  );
31
41
  };
32
42
 
33
43
  export const ExampleSTU3 = () => {
34
44
  const fhirResource = object('Resource', example_STU3);
35
45
  return (
36
- <Encounter fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />
46
+ <Encounter
47
+ fhirVersion={fhirVersions.STU3}
48
+ fhirResource={fhirResource}
49
+ fhirIcons={fhirIcons}
50
+ />
37
51
  );
38
52
  };
39
53
 
40
54
  export const ExampleWithoutParticipantSTU3 = () => {
41
55
  const fhirResource = object('Resource', example2_STU3);
42
56
  return (
43
- <Encounter fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />
57
+ <Encounter
58
+ fhirVersion={fhirVersions.STU3}
59
+ fhirResource={fhirResource}
60
+ fhirIcons={false}
61
+ />
44
62
  );
45
63
  };
46
64
 
47
65
  export const ExampleWithoutParticipantR4 = () => {
48
66
  const fhirResource = object('Resource', example1_R4);
49
67
  return (
50
- <Encounter fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />
68
+ <Encounter
69
+ fhirVersion={fhirVersions.R4}
70
+ fhirResource={fhirResource}
71
+ fhirIcons={'random text'}
72
+ />
51
73
  );
52
74
  };
53
75
 
@@ -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,