fhir-react 0.3.6 → 0.3.9

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 (160) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.eslintrc +10 -1
  3. package/.stylelintrc +6 -2
  4. package/README.md +19 -1
  5. package/build/index.js +15 -11
  6. package/build/style.css +11 -10
  7. package/package.json +55 -54
  8. package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
  9. package/src/assets/containers/Coverage/coverage.svg +4 -0
  10. package/src/assets/containers/Generic/generic.svg +3 -0
  11. package/src/assets/containers/Medication/medication.svg +5 -0
  12. package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
  13. package/src/assets/containers/Organization/organization.svg +5 -0
  14. package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
  15. package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
  16. package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
  17. package/src/components/containers/Accordion/Accordion.js +44 -13
  18. package/src/components/containers/ResourceContainer/ResourceContainer.css +4 -0
  19. package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
  20. package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +23 -1
  21. package/src/components/datatypes/Attachment/Attachment.css +5 -0
  22. package/src/components/datatypes/Attachment/Attachment.js +7 -2
  23. package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
  24. package/src/components/datatypes/Coding/Coding.js +7 -3
  25. package/src/components/datatypes/Identifier/Identifier.js +7 -3
  26. package/src/components/datatypes/Reference/Reference.js +7 -1
  27. package/src/components/datatypes/Telecom/Telecom.js +2 -3
  28. package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
  29. package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
  30. package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
  31. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -1
  32. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
  33. package/src/components/resources/Appointment/Appointment.js +9 -1
  34. package/src/components/resources/Appointment/Appointment.test.js +36 -1
  35. package/src/components/resources/Binary/Binary.js +2 -1
  36. package/src/components/resources/Bundle/Bundle.css +7 -0
  37. package/src/components/resources/Bundle/Bundle.js +15 -11
  38. package/src/components/resources/Bundle/Bundle.stories.js +12 -78
  39. package/src/components/resources/Bundle/Bundle.test.js +0 -3
  40. package/src/components/resources/CarePlan/CarePlan.js +9 -1
  41. package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
  42. package/src/components/resources/CareTeam/CareTeam.js +79 -50
  43. package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
  44. package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
  45. package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
  46. package/src/components/resources/Claim/CareTeam.js +55 -0
  47. package/src/components/resources/Claim/Claim.css +2 -11
  48. package/src/components/resources/Claim/Claim.js +165 -309
  49. package/src/components/resources/Claim/Claim.stories.js +37 -5
  50. package/src/components/resources/Claim/Claim.test.js +104 -1
  51. package/src/components/resources/Claim/Diagnosis.js +61 -0
  52. package/src/components/resources/Claim/Insurance.js +58 -0
  53. package/src/components/resources/Claim/Item.js +79 -0
  54. package/src/components/resources/Claim/Items.js +29 -0
  55. package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
  56. package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
  57. package/src/components/resources/ClaimResponse/ClaimResponse.js +144 -83
  58. package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
  59. package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
  60. package/src/components/resources/ClaimResponse/Item.js +44 -9
  61. package/src/components/resources/ClaimResponse/Items.js +5 -4
  62. package/src/components/resources/Condition/Condition.js +10 -3
  63. package/src/components/resources/Condition/Condition.test.js +37 -4
  64. package/src/components/resources/Coverage/Coverage.js +104 -69
  65. package/src/components/resources/Coverage/Coverage.stories.js +31 -5
  66. package/src/components/resources/Coverage/Coverage.test.js +111 -4
  67. package/src/components/resources/Device/Device.js +9 -1
  68. package/src/components/resources/Device/Device.test.js +36 -1
  69. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +9 -2
  70. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
  71. package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
  72. package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
  73. package/src/components/resources/Encounter/Encounter.js +9 -1
  74. package/src/components/resources/Encounter/Encounter.test.js +36 -1
  75. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
  76. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
  77. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
  78. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
  79. package/src/components/resources/Generic/Generic.js +21 -7
  80. package/src/components/resources/Generic/Generic.stories.js +2 -1
  81. package/src/components/resources/Generic/Generic.test.js +26 -7
  82. package/src/components/resources/Goal/Goal.js +9 -3
  83. package/src/components/resources/Goal/Goal.test.js +32 -1
  84. package/src/components/resources/Immunization/Immunization.js +9 -2
  85. package/src/components/resources/Immunization/Immunization.test.js +36 -1
  86. package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
  87. package/src/components/resources/List/Entries.js +3 -3
  88. package/src/components/resources/List/List.js +137 -88
  89. package/src/components/resources/List/List.stories.js +38 -5
  90. package/src/components/resources/List/List.test.js +105 -1
  91. package/src/components/resources/Location/Location.js +66 -47
  92. package/src/components/resources/Location/Location.stories.js +11 -4
  93. package/src/components/resources/Location/Location.test.js +106 -4
  94. package/src/components/resources/Medication/Medication.js +98 -51
  95. package/src/components/resources/Medication/Medication.stories.js +37 -7
  96. package/src/components/resources/Medication/Medication.test.js +114 -5
  97. package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
  98. package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
  99. package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
  100. package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
  101. package/src/components/resources/MedicationDispense/MedicationDispense.js +70 -68
  102. package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
  103. package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
  104. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +117 -66
  105. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
  106. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
  107. package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -3
  108. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
  109. package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
  110. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
  111. package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
  112. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
  113. package/src/components/resources/Observation/Observation.js +3 -1
  114. package/src/components/resources/Observation/Observation.test.js +30 -1
  115. package/src/components/resources/Observation/ObservationGraph.js +1 -1
  116. package/src/components/resources/Organization/Organization.js +63 -37
  117. package/src/components/resources/Organization/Organization.stories.js +15 -2
  118. package/src/components/resources/Organization/Organization.test.js +109 -1
  119. package/src/components/resources/Patient/Patient.js +4 -0
  120. package/src/components/resources/Patient/Patient.test.js +31 -2
  121. package/src/components/resources/Practitioner/Practitioner.js +9 -1
  122. package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
  123. package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
  124. package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
  125. package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
  126. package/src/components/resources/Procedure/Procedure.js +3 -2
  127. package/src/components/resources/Procedure/Procedure.test.js +30 -1
  128. package/src/components/resources/Questionnaire/Group.js +53 -0
  129. package/src/components/resources/Questionnaire/Items.js +45 -0
  130. package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
  131. package/src/components/resources/Questionnaire/Questionnaire.js +38 -170
  132. package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
  133. package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
  134. package/src/components/resources/Questionnaire/Questions.js +40 -0
  135. package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
  136. package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
  137. package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
  138. package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
  139. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
  140. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +54 -236
  141. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
  142. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
  143. package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
  144. package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
  145. package/src/components/resources/ReferralRequest/ReferralRequest.js +72 -40
  146. package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
  147. package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
  148. package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -0
  149. package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
  150. package/src/components/resources/RelatedPerson/index.js +3 -0
  151. package/src/components/resources/ResearchStudy/ResearchStudy.js +167 -130
  152. package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
  153. package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
  154. package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
  155. package/src/components/ui/index.js +56 -32
  156. package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
  157. package/src/fixtures/example-icons.jsx +63 -0
  158. package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
  159. package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
  160. package/src/style.scss +14 -1
@@ -2,11 +2,19 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import _get from 'lodash/get';
4
4
  import fhirVersions from '../fhirResourceVersions';
5
- import { Root, Header, Title, Body, Value } from '../../ui';
5
+ import {
6
+ Root,
7
+ Header,
8
+ Body,
9
+ ValueSection,
10
+ ValueSectionItem,
11
+ Value,
12
+ } from '../../ui';
6
13
  import Reference from '../../datatypes/Reference';
7
14
  import Date from '../../datatypes/Date';
8
15
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
9
16
  import CodeableConcept, { hasValue } from '../../datatypes/CodeableConcept';
17
+ import Accordion from '../../containers/Accordion';
10
18
 
11
19
  const commonDTO = fhirResource => {
12
20
  const subject = _get(fhirResource, 'subject');
@@ -63,8 +71,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
63
71
  }
64
72
  };
65
73
 
66
- const AdverseEvent = props => {
67
- const { fhirResource, fhirVersion } = props;
74
+ const AdverseEvent = ({
75
+ fhirResource,
76
+ fhirVersion,
77
+ fhirIcons,
78
+ onClick,
79
+ rawOnClick,
80
+ }) => {
68
81
  let fhirResourceData = {};
69
82
  try {
70
83
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -86,47 +99,80 @@ const AdverseEvent = props => {
86
99
  hasEvent,
87
100
  } = fhirResourceData;
88
101
 
102
+ const tableData = [
103
+ {
104
+ label: 'Event',
105
+ testId: 'event',
106
+ data: hasEventType && <CodeableConcept fhirData={eventType} />,
107
+ status: hasEventType,
108
+ },
109
+ {
110
+ label: 'Event',
111
+ testId: 'event',
112
+ data: hasEvent && <CodeableConcept fhirData={event} />,
113
+ status: hasEvent,
114
+ },
115
+ {
116
+ label: 'Seriousness',
117
+ testId: 'hasSeriousness',
118
+ data: hasSeriousness && (
119
+ <CodeableConcept fhirData={seriousness} isCursive />
120
+ ),
121
+ status: hasSeriousness,
122
+ },
123
+ {
124
+ label: 'Actuality',
125
+ testId: 'actuality',
126
+ data: actuality,
127
+ status: actuality,
128
+ },
129
+ ];
130
+
89
131
  return (
90
132
  <Root name="AdverseEvent">
91
- <Header>
92
- {subject && (
93
- <Title>
94
- <Reference fhirData={subject} />
95
- </Title>
96
- )}
97
- </Header>
98
- <Body>
99
- {date && (
100
- <Value label="Date" data-testid="date">
101
- <Date fhirData={date} />
102
- </Value>
103
- )}
104
- {hasEventType && (
105
- <Value label="Type" data-testid="type">
106
- <CodeableConcept fhirData={eventType} />
107
- </Value>
108
- )}
109
- {hasEvent && (
110
- <Value label="Event" data-testid="event">
111
- <CodeableConcept fhirData={event} />
112
- </Value>
113
- )}
114
- {description && (
115
- <Value label="Description" data-testid="description">
116
- {description}
117
- </Value>
118
- )}
119
- {hasSeriousness && (
120
- <Value label="Seriousness" data-testid="hasSeriousness">
121
- <CodeableConcept fhirData={seriousness} />
122
- </Value>
123
- )}
124
- {actuality && (
125
- <Value label="Actuality" data-testid="actuality">
126
- {actuality}
127
- </Value>
128
- )}
129
- </Body>
133
+ <Accordion
134
+ headerContent={
135
+ <Header
136
+ resourceName={'AdverseEvent'}
137
+ title={subject && <Reference fhirData={subject} />}
138
+ icon={fhirIcons}
139
+ additionalContent={
140
+ date && (
141
+ <Value label="Date" data-testid="date">
142
+ <Date fhirData={date} isBlack />
143
+ </Value>
144
+ )
145
+ }
146
+ />
147
+ }
148
+ bodyContent={
149
+ <Body>
150
+ {description && (
151
+ <ValueSection
152
+ label="Comment"
153
+ data-testid="description"
154
+ marginBottom
155
+ >
156
+ <span className="text-secondary">{description}</span>
157
+ </ValueSection>
158
+ )}
159
+ {tableData.map(
160
+ (item, index) =>
161
+ item.status && (
162
+ <ValueSectionItem
163
+ key={`adverse-event-item-${index}`}
164
+ label={item.label}
165
+ data-testid={item.testId}
166
+ >
167
+ {item.data}
168
+ </ValueSectionItem>
169
+ ),
170
+ )}
171
+ </Body>
172
+ }
173
+ onClick={onClick}
174
+ rawOnClick={rawOnClick}
175
+ />
130
176
  </Root>
131
177
  );
132
178
  };
@@ -7,6 +7,8 @@ import fhirVersions from '../fhirResourceVersions';
7
7
  import stu3Example1 from '../../../fixtures/stu3/resources/adverseEvent/example1.json';
8
8
  import r4Example1 from '../../../fixtures/r4/resources/adverseEvent/example1.json';
9
9
 
10
+ import fhirIcons from '../../../fixtures/example-icons';
11
+
10
12
  export default {
11
13
  title: 'AdverseEvent',
12
14
  };
@@ -14,13 +16,21 @@ export default {
14
16
  export const DefaultVisualizationSTU3 = () => {
15
17
  const fhirResource = object('Resource', stu3Example1);
16
18
  return (
17
- <AdverseEvent fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />
19
+ <AdverseEvent
20
+ fhirResource={fhirResource}
21
+ fhirVersion={fhirVersions.STU3}
22
+ fhirIcons={fhirIcons}
23
+ />
18
24
  );
19
25
  };
20
26
 
21
27
  export const Example1ofR4 = () => {
22
28
  const fhirResource = object('Resource', r4Example1);
23
29
  return (
24
- <AdverseEvent fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
30
+ <AdverseEvent
31
+ fhirResource={fhirResource}
32
+ fhirVersion={fhirVersions.R4}
33
+ fhirIcons={false}
34
+ />
25
35
  );
26
36
  };
@@ -1,12 +1,84 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { fireEvent, render } from '@testing-library/react';
3
3
  import AdverseEvent from './AdverseEvent';
4
4
  import fhirVersions from '../fhirResourceVersions';
5
5
 
6
6
  import stu3Example1 from '../../../fixtures/stu3/resources/adverseEvent/example1.json';
7
7
  import r4Example1 from '../../../fixtures/r4/resources/adverseEvent/example1.json';
8
+ import fhirIcons from '../../../fixtures/example-icons';
8
9
 
9
10
  describe('should render component correctly', () => {
11
+ it('component without a fhirIcons props should render a default icon', () => {
12
+ const defaultProps = {
13
+ fhirVersion: fhirVersions.STU3,
14
+ fhirResource: stu3Example1,
15
+ };
16
+
17
+ const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
18
+ const headerIcon = getByAltText('adverse event');
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
+ fhirVersion: fhirVersions.STU3,
26
+ fhirResource: stu3Example1,
27
+ fhirIcons: false,
28
+ };
29
+
30
+ const { getByTestId } = render(<AdverseEvent {...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
+ fhirVersion: fhirVersions.STU3,
39
+ fhirResource: stu3Example1,
40
+ fhirIcons: (
41
+ <img
42
+ src={require('../assets/containers/AdverseEvent/adverse-event.svg')}
43
+ alt="adverse event"
44
+ />
45
+ ),
46
+ };
47
+
48
+ const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
49
+ const headerIcon = getByAltText('adverse event');
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
+ fhirVersion: fhirVersions.STU3,
57
+ fhirResource: stu3Example1,
58
+ fhirIcons: fhirIcons,
59
+ };
60
+
61
+ const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
62
+ const headerIcon = getByAltText('adverse event');
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
+ fhirVersion: fhirVersions.STU3,
72
+ fhirResource: stu3Example1,
73
+ fhirIcons: avatarSrc,
74
+ };
75
+
76
+ const { getByAltText } = render(<AdverseEvent {...defaultProps} />);
77
+ const headerIcon = getByAltText('header icon');
78
+
79
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
80
+ });
81
+
10
82
  it('should render with STU3 source data', () => {
11
83
  const defaultProps = {
12
84
  fhirResource: stu3Example1,
@@ -18,7 +90,7 @@ describe('should render component correctly', () => {
18
90
 
19
91
  expect(getByTestId('date').textContent).toEqual('1/29/2017');
20
92
 
21
- expect(getByTestId('type').textContent).toContain('304386008');
93
+ expect(getByTestId('event').textContent).toContain('304386008');
22
94
 
23
95
  expect(getByTestId('description').textContent).toContain(
24
96
  'This was a mild rash',
@@ -44,4 +116,39 @@ describe('should render component correctly', () => {
44
116
 
45
117
  expect(getByTestId('actuality').textContent).toEqual('actual');
46
118
  });
119
+
120
+ it('should fire custom onClick function', () => {
121
+ const defaultProps = {
122
+ fhirResource: r4Example1,
123
+ fhirVersion: fhirVersions.R4,
124
+ };
125
+
126
+ const onClick = jest.fn();
127
+ const { getByRole } = render(
128
+ <AdverseEvent {...defaultProps} onClick={onClick} />,
129
+ );
130
+ const accordion = getByRole('button');
131
+ fireEvent.click(accordion);
132
+
133
+ const attribute = accordion.getAttribute('data-bs-toggle');
134
+ expect(attribute).not.toEqual('collapse');
135
+ expect(onClick).toHaveBeenCalled();
136
+ });
137
+
138
+ it('should not fire custom onClick function', () => {
139
+ const defaultProps = {
140
+ fhirResource: r4Example1,
141
+ fhirVersion: fhirVersions.R4,
142
+ };
143
+
144
+ const onClick = 'test';
145
+ const { getByRole } = render(
146
+ <AdverseEvent {...defaultProps} onClick={onClick} />,
147
+ );
148
+ const accordion = getByRole('button');
149
+ fireEvent.click(accordion);
150
+
151
+ const attribute = accordion.getAttribute('data-bs-toggle');
152
+ expect(attribute).toEqual('collapse');
153
+ });
47
154
  });
@@ -123,7 +123,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
123
123
  }
124
124
  };
125
125
 
126
- const AllergyIntolerance = ({ fhirResource, fhirVersion, fhirIcons }) => {
126
+ const AllergyIntolerance = ({
127
+ fhirResource,
128
+ fhirVersion,
129
+ fhirIcons,
130
+ onClick,
131
+ rawOnClick,
132
+ }) => {
127
133
  let fhirResourceData = {};
128
134
  try {
129
135
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -231,6 +237,8 @@ const AllergyIntolerance = ({ fhirResource, fhirVersion, fhirIcons }) => {
231
237
  />
232
238
  }
233
239
  bodyContent={<Body tableData={tableData} />}
240
+ onClick={onClick}
241
+ rawOnClick={rawOnClick}
234
242
  />
235
243
  </Root>
236
244
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { fireEvent, render } from '@testing-library/react';
3
3
  import AllergyIntolerance from './AllergyIntolerance';
4
4
 
5
5
  import exampleAllergyIntoleranceDSTU2 from '../../../fixtures/dstu2/resources/allergyIntolerance/example1.json';
@@ -201,4 +201,39 @@ describe('should render component correctly', () => {
201
201
 
202
202
  expect(queryByTestId('asserter')).toBeNull();
203
203
  });
204
+
205
+ it('should fire custom onClick function', () => {
206
+ const defaultProps = {
207
+ fhirResource: example2AllergyIntoleranceR4,
208
+ fhirVersion: fhirVersions.R4,
209
+ };
210
+
211
+ const onClick = jest.fn();
212
+ const { getByRole } = render(
213
+ <AllergyIntolerance {...defaultProps} onClick={onClick} />,
214
+ );
215
+ const accordion = getByRole('button');
216
+ fireEvent.click(accordion);
217
+
218
+ const attribute = accordion.getAttribute('data-bs-toggle');
219
+ expect(attribute).not.toEqual('collapse');
220
+ expect(onClick).toHaveBeenCalled();
221
+ });
222
+
223
+ it('should not fire custom onClick function', () => {
224
+ const defaultProps = {
225
+ fhirResource: example2AllergyIntoleranceR4,
226
+ fhirVersion: fhirVersions.R4,
227
+ };
228
+
229
+ const onClick = 'test';
230
+ const { getByRole } = render(
231
+ <AllergyIntolerance {...defaultProps} onClick={onClick} />,
232
+ );
233
+ const accordion = getByRole('button');
234
+ fireEvent.click(accordion);
235
+
236
+ const attribute = accordion.getAttribute('data-bs-toggle');
237
+ expect(attribute).toEqual('collapse');
238
+ });
204
239
  });
@@ -144,7 +144,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
144
144
  }
145
145
  };
146
146
 
147
- const Appointment = ({ fhirResource, fhirVersion, fhirIcons }) => {
147
+ const Appointment = ({
148
+ fhirResource,
149
+ fhirVersion,
150
+ fhirIcons,
151
+ onClick,
152
+ rawOnClick,
153
+ }) => {
148
154
  const {
149
155
  description,
150
156
  status,
@@ -253,6 +259,8 @@ const Appointment = ({ fhirResource, fhirVersion, fhirIcons }) => {
253
259
  )}
254
260
  </Body>
255
261
  }
262
+ onClick={onClick}
263
+ rawOnClick={rawOnClick}
256
264
  />
257
265
  </Root>
258
266
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { fireEvent, render } from '@testing-library/react';
3
3
  import Appointment from './Appointment';
4
4
  import fhirVersions from '../fhirResourceVersions';
5
5
 
@@ -231,4 +231,39 @@ describe('should render component correctly', () => {
231
231
 
232
232
  expect(getByTestId('reason').textContent).toContain('Clinical Review');
233
233
  });
234
+
235
+ it('should fire custom onClick function', () => {
236
+ const defaultProps = {
237
+ fhirResource: example3AppointmentR4,
238
+ fhirVersion: fhirVersions.R4,
239
+ };
240
+
241
+ const onClick = jest.fn();
242
+ const { getByRole } = render(
243
+ <Appointment {...defaultProps} onClick={onClick} />,
244
+ );
245
+ const accordion = getByRole('button');
246
+ fireEvent.click(accordion);
247
+
248
+ const attribute = accordion.getAttribute('data-bs-toggle');
249
+ expect(attribute).not.toEqual('collapse');
250
+ expect(onClick).toHaveBeenCalled();
251
+ });
252
+
253
+ it('should not fire custom onClick function', () => {
254
+ const defaultProps = {
255
+ fhirResource: example3AppointmentR4,
256
+ fhirVersion: fhirVersions.R4,
257
+ };
258
+
259
+ const onClick = 'test';
260
+ const { getByRole } = render(
261
+ <Appointment {...defaultProps} onClick={onClick} />,
262
+ );
263
+ const accordion = getByRole('button');
264
+ fireEvent.click(accordion);
265
+
266
+ const attribute = accordion.getAttribute('data-bs-toggle');
267
+ expect(attribute).toEqual('collapse');
268
+ });
234
269
  });
@@ -6,7 +6,7 @@ import Accordion from '../../containers/Accordion/Accordion';
6
6
  import { Body, Header } from '../../ui';
7
7
 
8
8
  const Binary = props => {
9
- const { fhirResource, fhirIcons } = props;
9
+ const { fhirResource, fhirIcons, rawOnClick } = props;
10
10
 
11
11
  const loadBinaryFile = () => {
12
12
  switch (fhirResource.contentType) {
@@ -37,6 +37,7 @@ const Binary = props => {
37
37
  />
38
38
  }
39
39
  bodyContent={<Body>{loadBinaryFile()}</Body>}
40
+ rawOnClick={rawOnClick}
40
41
  />
41
42
  </div>
42
43
  );
@@ -1,3 +1,10 @@
1
1
  .fhir-resource__Bundle__item {
2
2
  margin-top: 10px;
3
3
  }
4
+
5
+ .fhir-resource__Bundle__rootPadding:first-of-type {
6
+ padding: 8px;
7
+ background: white;
8
+ border-radius: 0.2rem;
9
+ border: 1px solid #dee2e6;
10
+ }
@@ -4,12 +4,12 @@ import _get from 'lodash/get';
4
4
 
5
5
  import fhirVersions from '../fhirResourceVersions';
6
6
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
7
- import { Root, Header, Title, Badge, Body, BadgeSecondary } from '../../ui';
7
+ import { Root, Header, Badge, Body, BadgeSecondary } from '../../ui';
8
8
  import * as FhirResourceTypes from '../../supportedFhirResourceList';
9
9
 
10
10
  import './Bundle.css';
11
11
 
12
- export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
12
+ export default function Bundle({ fhirResource, fhirVersion }) {
13
13
  const commonDTO = fhirResource => {
14
14
  const type = _get(fhirResource, 'type', null);
15
15
  const total = _get(fhirResource, 'total');
@@ -51,11 +51,14 @@ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
51
51
  .filter(Boolean);
52
52
 
53
53
  return (
54
- <Root name="Bundle">
55
- <Header>
56
- {type && <Title data-testid="title">{type}</Title>}
57
- {total && <Badge data-testid="total">{total}</Badge>}
58
- </Header>
54
+ <Root name="Bundle" className="fhir-resource__Bundle__rootPadding">
55
+ <Header
56
+ resourceName="Bundle"
57
+ title={type}
58
+ badges={!isNaN(total) && <Badge data-testid="total">{total}</Badge>}
59
+ capitalize
60
+ isNoIcon
61
+ />
59
62
  <Body>
60
63
  {resources.length > 0 &&
61
64
  resources.map((resource, index) => {
@@ -71,14 +74,15 @@ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
71
74
  key={`${resource.id}-${index}`}
72
75
  >
73
76
  {resourceType && (
74
- <BadgeSecondary data-testid="resourceType">
75
- {resourceType}
76
- </BadgeSecondary>
77
+ <div className="mx-20">
78
+ <BadgeSecondary data-testid="resourceType">
79
+ {resourceType}
80
+ </BadgeSecondary>
81
+ </div>
77
82
  )}
78
83
  <FhirComponent
79
84
  fhirResource={resource}
80
85
  fhirVersion={fhirVersion}
81
- fhirIcons={fhirIcons}
82
86
  />
83
87
  </div>
84
88
  );