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 stu3Example1 from '../../../fixtures/stu3/resources/medicationStatement/e
9
9
  import stu3Example2 from '../../../fixtures/stu3/resources/medicationStatement/example2.json';
10
10
  import r4Example1 from '../../../fixtures/r4/resources/medicationStatement/example1.json';
11
11
  import r4Example2 from '../../../fixtures/r4/resources/medicationStatement/example2.json';
12
+ import fhirIcons from '../../../fixtures/example-icons';
13
+ import MedicationStatementIcon from '../../../assets/containers/MedicationStatement/medication-statement.svg';
12
14
 
13
15
  export default {
14
16
  title: 'MedicationStatement',
@@ -20,6 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
20
22
  <MedicationStatement
21
23
  fhirVersion={fhirVersions.DSTU2}
22
24
  fhirResource={fhirResource}
25
+ fhirIcons={require('../../../assets/containers/MedicationStatement/medication-statement.svg')}
23
26
  />
24
27
  );
25
28
  };
@@ -30,6 +33,7 @@ export const ExampleOfSTU3 = () => {
30
33
  <MedicationStatement
31
34
  fhirVersion={fhirVersions.STU3}
32
35
  fhirResource={fhirResource}
36
+ fhirIcons={MedicationStatementIcon}
33
37
  />
34
38
  );
35
39
  };
@@ -40,6 +44,7 @@ export const Example2OfSTU3 = () => {
40
44
  <MedicationStatement
41
45
  fhirVersion={fhirVersions.STU3}
42
46
  fhirResource={fhirResource}
47
+ fhirIcons={fhirIcons}
43
48
  />
44
49
  );
45
50
  };
@@ -50,6 +55,7 @@ export const Example1OfR4 = () => {
50
55
  <MedicationStatement
51
56
  fhirVersion={fhirVersions.R4}
52
57
  fhirResource={fhirResource}
58
+ fhirIcons={false}
53
59
  />
54
60
  );
55
61
  };
@@ -60,6 +66,7 @@ export const Example2OfR4 = () => {
60
66
  <MedicationStatement
61
67
  fhirVersion={fhirVersions.R4}
62
68
  fhirResource={fhirResource}
69
+ fhirIcons={'random text'}
63
70
  />
64
71
  );
65
72
  };
@@ -5,8 +5,80 @@ import fhirVersions from '../fhirResourceVersions';
5
5
  import example1MedicationStatement from '../../../fixtures/dstu2/resources/medicationStatement/example1.json';
6
6
  import stu3Example from '../../../fixtures/stu3/resources/medicationStatement/example1.json';
7
7
  import r4Example1 from '../../../fixtures/r4/resources/medicationStatement/example1.json';
8
+ import fhirIcons from '../../../fixtures/example-icons';
8
9
 
9
10
  describe('should render MedicationStatement component correctly', () => {
11
+ it('component without a fhirIcons props should render a default icon', () => {
12
+ const defaultProps = {
13
+ fhirResource: example1MedicationStatement,
14
+ fhirVersion: fhirVersions.DSTU2,
15
+ };
16
+
17
+ const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
18
+ const headerIcon = getByAltText('medication statement');
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: example1MedicationStatement,
26
+ fhirVersion: fhirVersions.DSTU2,
27
+ fhirIcons: false,
28
+ };
29
+
30
+ const { getByTestId } = render(<MedicationStatement {...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: example1MedicationStatement,
39
+ fhirVersion: fhirVersions.DSTU2,
40
+ fhirIcons: (
41
+ <img
42
+ src={require('../assets/containers/MedicationStatement/medication-statement.svg')}
43
+ alt="medication statement"
44
+ />
45
+ ),
46
+ };
47
+
48
+ const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
49
+ const headerIcon = getByAltText('medication statement');
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: example1MedicationStatement,
57
+ fhirVersion: fhirVersions.DSTU2,
58
+ fhirIcons: fhirIcons,
59
+ };
60
+
61
+ const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
62
+ const headerIcon = getByAltText('medication statement');
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: example1MedicationStatement,
72
+ fhirVersion: fhirVersions.DSTU2,
73
+ fhirIcons: avatarSrc,
74
+ };
75
+
76
+ const { getByAltText } = render(<MedicationStatement {...defaultProps} />);
77
+ const headerIcon = getByAltText('header icon');
78
+
79
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
80
+ });
81
+
10
82
  it('with DSTU2 source data', () => {
11
83
  const defaultProps = {
12
84
  fhirResource: example1MedicationStatement,
@@ -19,7 +91,7 @@ describe('should render MedicationStatement component correctly', () => {
19
91
  expect(getByTestId('title').textContent).toContain(
20
92
  'amphetamine-dextroamphetamine',
21
93
  );
22
- expect(getByTestId('hasEffectivePeriod').textContent).toContain('from');
94
+ expect(getByTestId('startDate').textContent).toContain('4/19/2016');
23
95
  expect(queryByTestId('medicationReference')).toBeNull();
24
96
 
25
97
  expect(getByTestId('dosageInstruction').textContent).toContain(
@@ -32,19 +104,35 @@ describe('should render MedicationStatement component correctly', () => {
32
104
  fhirResource: stu3Example,
33
105
  fhirVersion: fhirVersions.STU3,
34
106
  };
35
- const { getByTestId, queryAllByTestId } = render(
107
+ const { getByTestId, queryAllByTestId, queryByTestId } = render(
36
108
  <MedicationStatement {...defaultProps} />,
37
109
  );
38
110
 
39
111
  expect(getByTestId('title').textContent).toEqual('Medication Statement');
40
- expect(queryAllByTestId('hasEffectivePeriod')).toHaveLength(0);
112
+ expect(queryAllByTestId('startDate')).toHaveLength(0);
113
+ expect(queryAllByTestId('endDate')).toHaveLength(0);
41
114
 
42
115
  expect(getByTestId('dosageInstruction').textContent).toContain(
43
116
  '1-2 tablets once daily',
44
117
  );
45
118
 
46
- expect(getByTestId('hasNote').textContent).toContain('occasional');
119
+ const ingredients = queryAllByTestId('ingredient-item').map(
120
+ x => x.textContent,
121
+ );
122
+ expect(ingredients).toHaveLength(2);
123
+ expect(ingredients).toEqual([
124
+ 'Acetaminophen 500 MG',
125
+ 'Diphenhydramine Hydrochloride 25 mg',
126
+ ]);
127
+
128
+ expect(getByTestId('dosageInstruction').textContent).toContain(
129
+ '1-2 tablets once daily at bedtime as needed for restless legs',
130
+ );
47
131
 
132
+ expect(queryByTestId('medicationReference').textContent).toContain(
133
+ '#med0309',
134
+ );
135
+ expect(getByTestId('hasNote').textContent).toContain('occasional');
48
136
  expect(getByTestId('hasReasonCode').textContent).toContain('Legs');
49
137
  });
50
138
 
@@ -58,14 +146,23 @@ describe('should render MedicationStatement component correctly', () => {
58
146
  );
59
147
 
60
148
  expect(getByTestId('title').textContent).toEqual('Medication Statement');
61
- expect(queryAllByTestId('hasEffectivePeriod')).toHaveLength(0);
149
+ expect(queryAllByTestId('startDate')).toHaveLength(0);
150
+ expect(queryAllByTestId('endDate')).toHaveLength(0);
62
151
 
63
152
  expect(getByTestId('dosageInstruction').textContent).toContain(
64
153
  '1-2 tablets once daily',
65
154
  );
66
155
 
67
- expect(getByTestId('hasNote').textContent).toContain('occasional');
156
+ const ingredients = queryAllByTestId('ingredient-item').map(
157
+ x => x.textContent,
158
+ );
159
+ expect(ingredients).toHaveLength(2);
160
+ expect(ingredients).toEqual([
161
+ 'Acetaminophen 500 MG',
162
+ 'Diphenhydramine Hydrochloride 25 mg',
163
+ ]);
68
164
 
165
+ expect(getByTestId('hasNote').textContent).toContain('occasional');
69
166
  expect(getByTestId('hasReasonCode').textContent).toContain('Legs');
70
167
  expect(getByTestId('medicationReference').textContent).toContain(
71
168
  '#med0309',
@@ -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 = () => {
@@ -7,8 +7,75 @@ import examplePatientSTU3 from '../../../fixtures/stu3/resources/patient/example
7
7
  import example2PatientSTU3 from '../../../fixtures/stu3/resources/patient/example2.json';
8
8
  import example1PatientR4 from '../../../fixtures/r4/resources/patient/example1.json';
9
9
  import example3PatientR4 from '../../../fixtures/r4/resources/patient/example3.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: examplePatient,
16
+ };
17
+
18
+ const { getByAltText } = render(<Patient {...defaultProps} />);
19
+ const headerIcon = getByAltText('patient');
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: examplePatient,
27
+ fhirIcons: false,
28
+ };
29
+
30
+ const { getByTestId } = render(<Patient {...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: examplePatient,
39
+ fhirIcons: (
40
+ <img
41
+ src={require('../assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg.svg')}
42
+ alt="patient"
43
+ />
44
+ ),
45
+ };
46
+
47
+ const { getByAltText } = render(<Patient {...defaultProps} />);
48
+ const headerIcon = getByAltText('patient');
49
+
50
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
51
+ });
52
+
53
+ it('component with the resources object as a fhirIcons props should render an img', () => {
54
+ const defaultProps = {
55
+ fhirResource: examplePatient,
56
+ fhirIcons: fhirIcons,
57
+ };
58
+
59
+ const { getByAltText } = render(<Patient {...defaultProps} />);
60
+ const headerIcon = getByAltText('patient');
61
+
62
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
63
+ });
64
+
65
+ it('component with the url as a fhirIcons props should render an img', () => {
66
+ const avatarSrc =
67
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
68
+ const defaultProps = {
69
+ fhirResource: examplePatient,
70
+ fhirIcons: avatarSrc,
71
+ };
72
+
73
+ const { getByAltText } = render(<Patient {...defaultProps} />);
74
+ const headerIcon = getByAltText('header icon');
75
+
76
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
77
+ });
78
+
12
79
  it('DSTU2', () => {
13
80
  const defaultProps = {
14
81
  fhirResource: examplePatient,
@@ -15,7 +15,6 @@ import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
15
15
  import _get from 'lodash/get';
16
16
  import _has from 'lodash/has';
17
17
  import fhirVersions from '../fhirResourceVersions';
18
- import md5 from 'md5';
19
18
 
20
19
  const commonDTO = fhirResource => {
21
20
  const id = _get(fhirResource, 'id', '');
@@ -83,8 +82,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
83
82
  }
84
83
  };
85
84
 
86
- const Practitioner = props => {
87
- const { fhirResource, fhirVersion } = props;
85
+ const Practitioner = ({ fhirResource, fhirVersion, fhirIcons }) => {
88
86
  let fhirResourceData = {};
89
87
  try {
90
88
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -93,7 +91,6 @@ const Practitioner = props => {
93
91
  return <UnhandledResourceDataStructure resourceName="Practitioner" />;
94
92
  }
95
93
  const {
96
- id,
97
94
  identifier,
98
95
  name,
99
96
  gender,
@@ -155,17 +152,10 @@ const Practitioner = props => {
155
152
  <Accordion
156
153
  headerContent={
157
154
  <Header
155
+ resourceName="Practitioner"
158
156
  additionalContent={<p className="mb-0">{`(${use})`}</p>}
159
157
  badges={status && <Badge data-testid="status">{status}</Badge>}
160
- icon={
161
- <img
162
- className="header-icon__practitioner-avatar rounded-1"
163
- src={`http://www.gravatar.com/avatar/${md5(
164
- id,
165
- )}?s=30&r=any&default=identicon&forcedefault=1`}
166
- alt=""
167
- />
168
- }
158
+ icon={fhirIcons}
169
159
  title={<HumanName fhirData={name} isTitle />}
170
160
  />
171
161
  }
@@ -11,6 +11,8 @@ import stu3Example1 from '../../../fixtures/stu3/resources/practitioner/example-
11
11
  import r4Example1 from '../../../fixtures/r4/resources/practitioner/example1.json';
12
12
  import r4Example2 from '../../../fixtures/r4/resources/practitioner/example2.json';
13
13
  import r4Example3 from '../../../fixtures/r4/resources/practitioner/example3.json';
14
+ import PractitionerIcon from '../../../assets/containers/Practitioner/practitioner.svg';
15
+ import fhirIcons from '../../../fixtures/example-icons';
14
16
 
15
17
  export default { title: 'Practitioner' };
16
18
 
@@ -20,6 +22,7 @@ export const DefaultVisualizationDSTU2 = () => {
20
22
  <Practitioner
21
23
  fhirVersion={fhirVersions.DSTU2}
22
24
  fhirResource={fhirResource}
25
+ fhirIcons={require('../../../assets/containers/Practitioner/practitioner.svg')}
23
26
  />
24
27
  );
25
28
  };
@@ -30,6 +33,7 @@ export const Example2OfDSTU2 = () => {
30
33
  <Practitioner
31
34
  fhirVersion={fhirVersions.DSTU2}
32
35
  fhirResource={fhirResource}
36
+ fhirIcons={PractitionerIcon}
33
37
  />
34
38
  );
35
39
  };
@@ -37,21 +41,33 @@ export const Example2OfDSTU2 = () => {
37
41
  export const ExampleOfSTU3 = () => {
38
42
  const fhirResource = object('Resource', stu3Example1);
39
43
  return (
40
- <Practitioner fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />
44
+ <Practitioner
45
+ fhirVersion={fhirVersions.STU3}
46
+ fhirResource={fhirResource}
47
+ fhirIcons={fhirIcons}
48
+ />
41
49
  );
42
50
  };
43
51
 
44
52
  export const Example1OfR4 = () => {
45
53
  const fhirResource = object('Resource', r4Example1);
46
54
  return (
47
- <Practitioner fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />
55
+ <Practitioner
56
+ fhirVersion={fhirVersions.R4}
57
+ fhirResource={fhirResource}
58
+ fhirIcons={false}
59
+ />
48
60
  );
49
61
  };
50
62
 
51
63
  export const Example2OfR4 = () => {
52
64
  const fhirResource = object('Resource', r4Example2);
53
65
  return (
54
- <Practitioner fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />
66
+ <Practitioner
67
+ fhirVersion={fhirVersions.R4}
68
+ fhirResource={fhirResource}
69
+ fhirIcons={'random text'}
70
+ />
55
71
  );
56
72
  };
57
73