fhir-react 0.3.3 → 0.3.4

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 (38) hide show
  1. package/README.md +85 -2
  2. package/build/index.js +7 -14
  3. package/package.json +1 -1
  4. package/src/assets/containers/Patient/patient.svg +6 -0
  5. package/src/components/containers/Accordion/Accordion.js +7 -3
  6. package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
  7. package/src/components/resources/Appointment/Appointment.js +3 -3
  8. package/src/components/resources/Appointment/Appointment.stories.js +28 -5
  9. package/src/components/resources/Appointment/Appointment.test.js +72 -0
  10. package/src/components/resources/Condition/Condition.js +1 -3
  11. package/src/components/resources/Condition/Condition.stories.js +9 -19
  12. package/src/components/resources/Condition/Condition.test.js +71 -1
  13. package/src/components/resources/Encounter/Encounter.js +3 -4
  14. package/src/components/resources/Encounter/Encounter.stories.js +27 -5
  15. package/src/components/resources/Encounter/Encounter.test.js +72 -0
  16. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +7 -2
  17. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
  18. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +72 -0
  19. package/src/components/resources/Immunization/Immunization.js +1 -2
  20. package/src/components/resources/Immunization/Immunization.stories.js +6 -9
  21. package/src/components/resources/Immunization/Immunization.test.js +71 -1
  22. package/src/components/resources/Observation/Observation.js +3 -3
  23. package/src/components/resources/Observation/Observation.stories.js +14 -5
  24. package/src/components/resources/Observation/Observation.test.js +67 -0
  25. package/src/components/resources/Patient/Patient.js +9 -6
  26. package/src/components/resources/Patient/Patient.stories.js +12 -5
  27. package/src/components/resources/Patient/Patient.test.js +67 -0
  28. package/src/components/resources/Practitioner/Practitioner.js +3 -13
  29. package/src/components/resources/Practitioner/Practitioner.stories.js +19 -3
  30. package/src/components/resources/Practitioner/Practitioner.test.js +72 -0
  31. package/src/components/resources/Procedure/Procedure.js +1 -2
  32. package/src/components/resources/Procedure/Procedure.stories.js +11 -5
  33. package/src/components/resources/Procedure/Procedure.test.js +71 -1
  34. package/src/components/resources/ResourceCategory/ResourceCategory.js +5 -1
  35. package/src/components/ui/index.js +33 -25
  36. package/src/fixtures/example-icons.jsx +47 -9
  37. package/src/utils/convertCamelCaseToSentence.js +9 -0
  38. package/src/utils/convertCamelCaseToSentence.test.js +9 -0
@@ -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,
@@ -228,8 +228,12 @@ const resourceDTO = (fhirVersion, fhirResource, withCarinBBProfile) => {
228
228
  }
229
229
  };
230
230
 
231
- const ExplanationOfBenefit = props => {
232
- const { fhirResource, fhirVersion, withCarinBBProfile = false } = props;
231
+ const ExplanationOfBenefit = ({
232
+ fhirResource,
233
+ fhirVersion,
234
+ withCarinBBProfile = false,
235
+ fhirIcons,
236
+ }) => {
233
237
  let fhirResourceData = {};
234
238
  try {
235
239
  fhirResourceData = resourceDTO(
@@ -414,6 +418,7 @@ const ExplanationOfBenefit = props => {
414
418
  </Value>
415
419
  )
416
420
  }
421
+ icon={fhirIcons}
417
422
  />
418
423
  }
419
424
  bodyContent={
@@ -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,
@@ -125,7 +125,6 @@ const Immunization = props => {
125
125
  note,
126
126
  } = resourceDTO(fhirVersion, fhirResource);
127
127
 
128
- const headerIcon = fhirIcons && fhirIcons[_get(fhirResource, 'resourceType')];
129
128
  const tableData = [
130
129
  {
131
130
  label: 'Manufacturer Text',
@@ -237,7 +236,7 @@ const Immunization = props => {
237
236
  )
238
237
  }
239
238
  badges={status && <Badge data-testid="status">{status}</Badge>}
240
- icon={headerIcon}
239
+ icon={fhirIcons}
241
240
  title={title}
242
241
  />
243
242
  }
@@ -11,6 +11,7 @@ import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.jso
11
11
  import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
12
12
  import r4Example3 from '../../../fixtures/r4/resources/immunization/example3.json';
13
13
  import fhirIcons from '../../../fixtures/example-icons';
14
+ import ImmunizationIcon from '../../../assets/containers/Immunization/immunization.svg';
14
15
 
15
16
  export default {
16
17
  title: 'Immunization',
@@ -22,7 +23,7 @@ export const DefaultVisualizationDSTU2 = () => {
22
23
  <Immunization
23
24
  fhirResource={fhirResource}
24
25
  fhirVersion={fhirVersions.DSTU2}
25
- fhirIcons={fhirIcons}
26
+ fhirIcons={require('../../../assets/containers/Immunization/immunization.svg')}
26
27
  />
27
28
  );
28
29
  };
@@ -33,7 +34,7 @@ export const Example2OfDSTU2 = () => {
33
34
  <Immunization
34
35
  fhirResource={fhirResource}
35
36
  fhirVersion={fhirVersions.DSTU2}
36
- fhirIcons={fhirIcons}
37
+ fhirIcons={ImmunizationIcon}
37
38
  />
38
39
  );
39
40
  };
@@ -55,7 +56,7 @@ export const Example1R4 = () => {
55
56
  <Immunization
56
57
  fhirResource={fhirResource}
57
58
  fhirVersion={fhirVersions.R4}
58
- fhirIcons={fhirIcons}
59
+ fhirIcons={false}
59
60
  />
60
61
  );
61
62
  };
@@ -65,17 +66,13 @@ export const Example2R4 = () => {
65
66
  <Immunization
66
67
  fhirResource={fhirResource}
67
68
  fhirVersion={fhirVersions.R4}
68
- fhirIcons={fhirIcons}
69
+ fhirIcons={'random text'}
69
70
  />
70
71
  );
71
72
  };
72
73
  export const Example3R4 = () => {
73
74
  const fhirResource = object('Resource', r4Example3);
74
75
  return (
75
- <Immunization
76
- fhirResource={fhirResource}
77
- fhirVersion={fhirVersions.R4}
78
- fhirIcons={fhirIcons}
79
- />
76
+ <Immunization fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
80
77
  );
81
78
  };
@@ -6,10 +6,80 @@ import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.jso
6
6
  import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
7
7
  import { render } from '@testing-library/react';
8
8
  import stu3Example from '../../../fixtures/stu3/resources/immunization/example1.json';
9
-
10
9
  import fhirIcons from '../../../fixtures/example-icons';
11
10
 
12
11
  describe('should render Immunization component properly', () => {
12
+ it('component without a fhirIcons props should render a default icon', () => {
13
+ const defaultProps = {
14
+ fhirVersion: fhirVersions.DSTU2,
15
+ fhirResource: dstu2Example,
16
+ };
17
+
18
+ const { getByAltText } = render(<Immunization {...defaultProps} />);
19
+ const headerIcon = getByAltText('immunization');
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
+ fhirVersion: fhirVersions.DSTU2,
27
+ fhirResource: dstu2Example,
28
+ fhirIcons: false,
29
+ };
30
+
31
+ const { getByTestId } = render(<Immunization {...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
+ fhirVersion: fhirVersions.DSTU2,
40
+ fhirResource: dstu2Example,
41
+ fhirIcons: (
42
+ <img
43
+ src={require('../assets/containers/Immunization/immunization.svg')}
44
+ alt="immunization"
45
+ />
46
+ ),
47
+ };
48
+
49
+ const { getByAltText } = render(<Immunization {...defaultProps} />);
50
+ const headerIcon = getByAltText('immunization');
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
+ fhirVersion: fhirVersions.DSTU2,
58
+ fhirResource: dstu2Example,
59
+ fhirIcons: fhirIcons,
60
+ };
61
+
62
+ const { getByAltText } = render(<Immunization {...defaultProps} />);
63
+ const headerIcon = getByAltText('immunization');
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
+ fhirVersion: fhirVersions.DSTU2,
73
+ fhirResource: dstu2Example,
74
+ fhirIcons: avatarSrc,
75
+ };
76
+
77
+ const { getByAltText } = render(<Immunization {...defaultProps} />);
78
+ const headerIcon = getByAltText('header icon');
79
+
80
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
81
+ });
82
+
13
83
  it('should render with DSTU2 source data', () => {
14
84
  const defaultProps = {
15
85
  fhirResource: dstu2Example,
@@ -18,8 +18,7 @@ import {
18
18
  } from '../../ui';
19
19
  import Reference from '../../datatypes/Reference';
20
20
 
21
- const Observation = props => {
22
- const { fhirResource } = props;
21
+ const Observation = ({ fhirResource, fhirIcons }) => {
23
22
  const effectiveDate = _get(fhirResource, 'effectiveDateTime');
24
23
  const codeCodingDisplay = _get(fhirResource, 'code.coding.0.display');
25
24
  const codeText = _get(fhirResource, 'code.text', '');
@@ -72,7 +71,7 @@ const Observation = props => {
72
71
  <Accordion
73
72
  headerContent={
74
73
  <Header
75
- resourceName={fhirResource.resourceType}
74
+ resourceName="Observation"
76
75
  additionalContent={
77
76
  issued && (
78
77
  <Value label="Start date" data-testid="headerStartDate">
@@ -104,6 +103,7 @@ const Observation = props => {
104
103
  small
105
104
  />
106
105
  }
106
+ icon={fhirIcons}
107
107
  />
108
108
  }
109
109
  bodyContent={
@@ -12,32 +12,41 @@ import example3ObservationExcessSTU3 from '../../../fixtures/stu3/resources/obse
12
12
  import example1ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example1.json';
13
13
  import example2ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example2.json';
14
14
  import example3ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example3.json';
15
+ import ObservationIcon from '../../../assets/containers/Observation/observation.svg';
16
+ import fhirIcons from '../../../fixtures/example-icons';
15
17
 
16
18
  export default { title: 'Observation' };
17
19
 
18
20
  export const DefaultVisualizationDSTU2 = () => {
19
21
  const fhirResource = object('Resource', exampleObservationIssued);
20
- return <Observation fhirResource={fhirResource} />;
22
+ return (
23
+ <Observation
24
+ fhirResource={fhirResource}
25
+ fhirIcons={require('../../../assets/containers/Observation/observation.svg')}
26
+ />
27
+ );
21
28
  };
22
29
 
23
30
  export const ExampleWithoutIssuedDSTU2 = () => {
24
31
  const fhirResource = object('Resource', exampleObservation);
25
- return <Observation fhirResource={fhirResource} />;
32
+ return (
33
+ <Observation fhirResource={fhirResource} fhirIcons={ObservationIcon} />
34
+ );
26
35
  };
27
36
 
28
37
  export const ExampleWithIssuedSTU3 = () => {
29
38
  const fhirResource = object('Resource', exampleObservationExcessSTU3);
30
- return <Observation fhirResource={fhirResource} />;
39
+ return <Observation fhirResource={fhirResource} fhirIcons={fhirIcons} />;
31
40
  };
32
41
 
33
42
  export const ExampleWithoutIssuedSTU3 = () => {
34
43
  const fhirResource = object('Resource', exampleObservationSTU3);
35
- return <Observation fhirResource={fhirResource} />;
44
+ return <Observation fhirResource={fhirResource} fhirIcons={false} />;
36
45
  };
37
46
 
38
47
  export const Example3OfSTU3 = () => {
39
48
  const fhirResource = object('Resource', example3ObservationExcessSTU3);
40
- return <Observation fhirResource={fhirResource} />;
49
+ return <Observation fhirResource={fhirResource} fhirIcons={'random text'} />;
41
50
  };
42
51
 
43
52
  export const Example1OfR4 = () => {
@@ -11,8 +11,75 @@ import exampleObservationExcessSTU3 from '../../../fixtures/stu3/resources/obser
11
11
 
12
12
  import example1ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example2.json';
13
13
  import example2ObservationExcessR4 from '../../../fixtures/r4/resources/observation/example3.json';
14
+ import fhirIcons from '../../../fixtures/example-icons';
14
15
 
15
16
  describe('should render component correctly', () => {
17
+ it('component without a fhirIcons props should render a default icon', () => {
18
+ const defaultProps = {
19
+ fhirResource: exampleObservationIssued,
20
+ };
21
+
22
+ const { getByAltText } = render(<Observation {...defaultProps} />);
23
+ const headerIcon = getByAltText('observation');
24
+
25
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
26
+ });
27
+
28
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
29
+ const defaultProps = {
30
+ fhirResource: exampleObservationIssued,
31
+ fhirIcons: false,
32
+ };
33
+
34
+ const { getByTestId } = render(<Observation {...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
+ fhirResource: exampleObservationIssued,
43
+ fhirIcons: (
44
+ <img
45
+ src={require('../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg')}
46
+ alt="observation"
47
+ />
48
+ ),
49
+ };
50
+
51
+ const { getByAltText } = render(<Observation {...defaultProps} />);
52
+ const headerIcon = getByAltText('observation');
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: exampleObservationIssued,
60
+ fhirIcons: fhirIcons,
61
+ };
62
+
63
+ const { getByAltText } = render(<Observation {...defaultProps} />);
64
+ const headerIcon = getByAltText('observation');
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: exampleObservationIssued,
74
+ fhirIcons: avatarSrc,
75
+ };
76
+
77
+ const { getByAltText } = render(<Observation {...defaultProps} />);
78
+ const headerIcon = getByAltText('header icon');
79
+
80
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
81
+ });
82
+
16
83
  test('DSTU2 renders properly', () => {
17
84
  const defaultProps = {
18
85
  fhirResource: exampleObservationIssued,
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import _get from 'lodash/get';
4
4
  import _isEmpty from 'lodash/isEmpty';
5
- import md5 from 'md5';
6
5
 
7
6
  import HumanName from '../../datatypes/HumanName';
8
7
  import Telecom from '../../datatypes/Telecom';
@@ -41,11 +40,15 @@ export function getGender(fhirResource) {
41
40
  }
42
41
 
43
42
  function Patient(props) {
44
- const { fhirResource, fhirVersion, renderName, patientSimple } = props;
43
+ const {
44
+ fhirResource,
45
+ fhirVersion,
46
+ renderName,
47
+ patientSimple,
48
+ fhirIcons,
49
+ } = props;
45
50
 
46
51
  const id = getId(fhirResource);
47
- const idHash = md5(id || '');
48
- const avatarSrc = `http://www.gravatar.com/avatar/${idHash}?s=50&r=any&default=identicon&forcedefault=1`;
49
52
  const patientName = getNames(fhirResource);
50
53
  const patientBirthDate = getBirthDate(fhirResource);
51
54
  const patientGender = getGender(fhirResource);
@@ -118,7 +121,7 @@ function Patient(props) {
118
121
  <Accordion
119
122
  headerContent={
120
123
  <Header
121
- resourceName={fhirResource.resourceType}
124
+ resourceName="Patient"
122
125
  additionalContent={
123
126
  patientBirthDate && (
124
127
  <span className="text-gray-600">
@@ -130,7 +133,7 @@ function Patient(props) {
130
133
  </span>
131
134
  )
132
135
  }
133
- icon={avatarSrc}
136
+ icon={fhirIcons}
134
137
  badges={
135
138
  active && <Badge data-testid="activeStatus">{activeStatus}</Badge>
136
139
  }
@@ -12,32 +12,39 @@ import example2PatientSTU3 from '../../../fixtures/stu3/resources/patient/exampl
12
12
  import example1PatientR4 from '../../../fixtures/r4/resources/patient/example1.json';
13
13
  import example2PatientR4 from '../../../fixtures/r4/resources/patient/example2.json';
14
14
  import example3PatientR4 from '../../../fixtures/r4/resources/patient/example3.json';
15
+ import PatientIcon from '../../../assets/containers/Patient/patient.svg';
16
+ import fhirIcons from '../../../fixtures/example-icons';
15
17
 
16
18
  export default { title: 'Patient' };
17
19
 
18
20
  export const DefaultVisualizationDSTU2 = () => {
19
21
  const fhirResource = object('Resource', examplePatient);
20
- return <Patient fhirResource={fhirResource} />;
22
+ return (
23
+ <Patient
24
+ fhirResource={fhirResource}
25
+ fhirIcons={require('../../../assets/containers/Patient/patient.svg')}
26
+ />
27
+ );
21
28
  };
22
29
 
23
30
  export const Example2OfDSTU2 = () => {
24
31
  const fhirResource = object('Resource', example2PatientDSTU2);
25
- return <Patient fhirResource={fhirResource} />;
32
+ return <Patient fhirResource={fhirResource} fhirIcons={PatientIcon} />;
26
33
  };
27
34
 
28
35
  export const ExampleSTU3 = () => {
29
36
  const fhirResource = object('Resource', examplePatientSTU3);
30
- return <Patient fhirResource={fhirResource} />;
37
+ return <Patient fhirResource={fhirResource} fhirIcons={fhirIcons} />;
31
38
  };
32
39
 
33
40
  export const Example2STU3 = () => {
34
41
  const fhirResource = object('Resource', example2PatientSTU3);
35
- return <Patient fhirResource={fhirResource} />;
42
+ return <Patient fhirResource={fhirResource} fhirIcons={false} />;
36
43
  };
37
44
 
38
45
  export const Example1R4 = () => {
39
46
  const fhirResource = object('Resource', example1PatientR4);
40
- return <Patient fhirResource={fhirResource} />;
47
+ return <Patient fhirResource={fhirResource} fhirIcons={'random text'} />;
41
48
  };
42
49
 
43
50
  export const Example2R4 = () => {