fhir-react 0.3.7 → 0.3.10

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 (179) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.eslintrc +10 -1
  3. package/.storybook/main.js +5 -0
  4. package/.storybook/manager.js +6 -0
  5. package/.storybook/preview.js +7 -0
  6. package/.stylelintrc +6 -2
  7. package/README.md +19 -1
  8. package/build/index.js +15 -11
  9. package/build/style.css +9 -9
  10. package/package.json +59 -57
  11. package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
  12. package/src/assets/containers/Generic/generic.svg +3 -0
  13. package/src/assets/containers/MedicationDispense/medication-dispense.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/Accordion/Accordion.stories.js +74 -58
  19. package/src/components/containers/ResourceContainer/ResourceContainer.css +4 -0
  20. package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
  21. package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +46 -22
  22. package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
  23. package/src/components/datatypes/Coding/Coding.js +7 -3
  24. package/src/components/datatypes/Reference/Reference.js +7 -5
  25. package/src/components/datatypes/Telecom/Telecom.js +2 -3
  26. package/src/components/defaultArgTypes.js +12 -0
  27. package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
  28. package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +19 -11
  29. package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
  30. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -1
  31. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +46 -70
  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.stories.js +51 -62
  35. package/src/components/resources/Appointment/Appointment.test.js +36 -1
  36. package/src/components/resources/Binary/Binary.js +2 -1
  37. package/src/components/resources/Binary/Binary.stories.js +27 -21
  38. package/src/components/resources/Bundle/Bundle.css +7 -0
  39. package/src/components/resources/Bundle/Bundle.js +15 -11
  40. package/src/components/resources/Bundle/Bundle.stories.js +59 -115
  41. package/src/components/resources/Bundle/Bundle.test.js +0 -3
  42. package/src/components/resources/CarePlan/CarePlan.js +9 -1
  43. package/src/components/resources/CarePlan/CarePlan.stories.js +44 -54
  44. package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
  45. package/src/components/resources/CareTeam/CareTeam.js +79 -50
  46. package/src/components/resources/CareTeam/CareTeam.stories.js +25 -14
  47. package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
  48. package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
  49. package/src/components/resources/Claim/Claim.js +9 -1
  50. package/src/components/resources/Claim/Claim.stories.js +36 -49
  51. package/src/components/resources/Claim/Claim.test.js +32 -1
  52. package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
  53. package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
  54. package/src/components/resources/ClaimResponse/ClaimResponse.js +144 -83
  55. package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +44 -41
  56. package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
  57. package/src/components/resources/ClaimResponse/Item.js +44 -9
  58. package/src/components/resources/ClaimResponse/Items.js +5 -4
  59. package/src/components/resources/Condition/Condition.js +10 -3
  60. package/src/components/resources/Condition/Condition.stories.js +47 -62
  61. package/src/components/resources/Condition/Condition.test.js +37 -4
  62. package/src/components/resources/Coverage/Coverage.js +9 -1
  63. package/src/components/resources/Coverage/Coverage.stories.js +38 -50
  64. package/src/components/resources/Coverage/Coverage.test.js +36 -1
  65. package/src/components/resources/Device/Device.js +9 -1
  66. package/src/components/resources/Device/Device.stories.js +40 -52
  67. package/src/components/resources/Device/Device.test.js +36 -1
  68. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +9 -2
  69. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +38 -50
  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.stories.js +25 -29
  73. package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
  74. package/src/components/resources/Encounter/Encounter.js +9 -1
  75. package/src/components/resources/Encounter/Encounter.stories.js +43 -59
  76. package/src/components/resources/Encounter/Encounter.test.js +36 -1
  77. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
  78. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +53 -67
  79. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
  80. package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js +74 -38
  81. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
  82. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +22 -28
  83. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
  84. package/src/components/resources/Generic/Generic.js +21 -7
  85. package/src/components/resources/Generic/Generic.stories.js +22 -12
  86. package/src/components/resources/Generic/Generic.test.js +26 -7
  87. package/src/components/resources/Goal/Goal.js +9 -3
  88. package/src/components/resources/Goal/Goal.stories.js +35 -49
  89. package/src/components/resources/Goal/Goal.test.js +32 -1
  90. package/src/components/resources/Immunization/Immunization.js +9 -2
  91. package/src/components/resources/Immunization/Immunization.stories.js +38 -51
  92. package/src/components/resources/Immunization/Immunization.test.js +36 -1
  93. package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
  94. package/src/components/resources/List/Entries.js +3 -3
  95. package/src/components/resources/List/List.js +137 -88
  96. package/src/components/resources/List/List.stories.js +69 -40
  97. package/src/components/resources/List/List.test.js +105 -1
  98. package/src/components/resources/Location/Location.js +66 -47
  99. package/src/components/resources/Location/Location.stories.js +25 -13
  100. package/src/components/resources/Location/Location.test.js +106 -4
  101. package/src/components/resources/Medication/Medication.js +9 -1
  102. package/src/components/resources/Medication/Medication.stories.js +42 -64
  103. package/src/components/resources/Medication/Medication.test.js +36 -1
  104. package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
  105. package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +34 -41
  106. package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
  107. package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
  108. package/src/components/resources/MedicationDispense/MedicationDispense.js +70 -68
  109. package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +41 -52
  110. package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
  111. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +117 -66
  112. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +51 -54
  113. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
  114. package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -3
  115. package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +11 -4
  116. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
  117. package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
  118. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +27 -30
  119. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
  120. package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
  121. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +32 -46
  122. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
  123. package/src/components/resources/Observation/Observation.js +3 -1
  124. package/src/components/resources/Observation/Observation.stories.js +39 -33
  125. package/src/components/resources/Observation/Observation.test.js +30 -1
  126. package/src/components/resources/Observation/ObservationGraph.js +1 -1
  127. package/src/components/resources/Organization/Organization.js +10 -2
  128. package/src/components/resources/Organization/Organization.stories.js +40 -52
  129. package/src/components/resources/Organization/Organization.test.js +36 -1
  130. package/src/components/resources/Patient/Patient.js +4 -0
  131. package/src/components/resources/Patient/Patient.stories.js +36 -28
  132. package/src/components/resources/Patient/Patient.test.js +31 -2
  133. package/src/components/resources/Practitioner/Practitioner.js +9 -1
  134. package/src/components/resources/Practitioner/Practitioner.stories.js +39 -52
  135. package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
  136. package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
  137. package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +45 -58
  138. package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
  139. package/src/components/resources/Procedure/Procedure.js +3 -2
  140. package/src/components/resources/Procedure/Procedure.stories.js +33 -25
  141. package/src/components/resources/Procedure/Procedure.test.js +30 -1
  142. package/src/components/resources/Questionnaire/Group.js +53 -0
  143. package/src/components/resources/Questionnaire/Items.js +45 -0
  144. package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
  145. package/src/components/resources/Questionnaire/Questionnaire.js +38 -170
  146. package/src/components/resources/Questionnaire/Questionnaire.stories.js +50 -57
  147. package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
  148. package/src/components/resources/Questionnaire/Questions.js +40 -0
  149. package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
  150. package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
  151. package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
  152. package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
  153. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
  154. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +54 -236
  155. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +46 -58
  156. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
  157. package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
  158. package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
  159. package/src/components/resources/ReferralRequest/ReferralRequest.js +72 -40
  160. package/src/components/resources/ReferralRequest/ReferralRequest.stories.js +20 -20
  161. package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
  162. package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
  163. package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +42 -0
  164. package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
  165. package/src/components/resources/RelatedPerson/index.js +3 -0
  166. package/src/components/resources/ResearchStudy/ResearchStudy.js +167 -130
  167. package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +18 -14
  168. package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
  169. package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
  170. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +40 -27
  171. package/src/components/ui/index.js +48 -31
  172. package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
  173. package/src/fixtures/example-icons.jsx +42 -0
  174. package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
  175. package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
  176. package/src/style.scss +14 -1
  177. package/.storybook/addons.js +0 -1
  178. package/.storybook/config.js +0 -26
  179. package/.storybook/presets.js +0 -1
@@ -99,9 +99,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
99
99
  }
100
100
  };
101
101
 
102
- const Goal = props => {
103
- const { fhirResource, fhirVersion, fhirIcons } = props;
104
-
102
+ const Goal = ({
103
+ fhirResource,
104
+ fhirVersion,
105
+ fhirIcons,
106
+ onClick,
107
+ rawOnClick,
108
+ }) => {
105
109
  let fhirResourceData = {};
106
110
  try {
107
111
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -229,6 +233,8 @@ const Goal = props => {
229
233
  />
230
234
  }
231
235
  bodyContent={<Body tableData={tableData} />}
236
+ onClick={onClick}
237
+ rawOnClick={rawOnClick}
232
238
  />
233
239
  </Root>
234
240
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { object } from '@storybook/addon-knobs';
2
+ import { defaultArgTypes } from '../../defaultArgTypes';
3
3
 
4
4
  import Goal from './Goal';
5
5
  import fhirIcons from '../../../fixtures/example-icons';
@@ -13,64 +13,50 @@ import GoalIcon from '../../../assets/containers/Goal/goal.svg';
13
13
 
14
14
  export default {
15
15
  title: 'Goal',
16
+ component: Goal,
17
+ argTypes: {
18
+ ...defaultArgTypes,
19
+ },
16
20
  };
17
21
 
18
- export const DefaultVisualizationDSTU2 = () => {
19
- const fhirResource = object('Resource', dstu2Example1);
20
- return (
21
- <Goal
22
- fhirVersion={fhirVersions.DSTU2}
23
- fhirResource={fhirResource}
24
- fhirIcons={require('../../../assets/containers/Goal/goal.svg')}
25
- />
26
- );
22
+ const Template = args => <Goal {...args} />;
23
+
24
+ export const DefaultVisualizationDSTU2 = Template.bind({});
25
+ DefaultVisualizationDSTU2.args = {
26
+ fhirVersion: fhirVersions.DSTU2,
27
+ fhirResource: dstu2Example1,
28
+ fhirIcons: require('../../../assets/containers/Goal/goal.svg'),
27
29
  };
28
30
 
29
- export const Example2OfDSTU2 = () => {
30
- const fhirResource = object('Resource', dstu2Example2);
31
- return (
32
- <Goal
33
- fhirVersion={fhirVersions.DSTU2}
34
- fhirResource={fhirResource}
35
- fhirIcons={GoalIcon}
36
- />
37
- );
31
+ export const Example2OfDSTU2 = Template.bind({});
32
+ Example2OfDSTU2.args = {
33
+ fhirVersion: fhirVersions.DSTU2,
34
+ fhirResource: dstu2Example2,
35
+ fhirIcons: GoalIcon,
38
36
  };
39
37
 
40
- export const ExampleOfSTU3 = () => {
41
- const fhirResource = object('Resource', stu3Example1);
42
- return (
43
- <Goal
44
- fhirVersion={fhirVersions.STU3}
45
- fhirResource={fhirResource}
46
- fhirIcons={fhirIcons}
47
- />
48
- );
38
+ export const ExampleOfSTU3 = Template.bind({});
39
+ ExampleOfSTU3.args = {
40
+ fhirVersion: fhirVersions.STU3,
41
+ fhirResource: stu3Example1,
42
+ fhirIcons: fhirIcons,
49
43
  };
50
44
 
51
- export const Example1OfR4 = () => {
52
- const fhirResource = object('Resource', r4Example1);
53
- return (
54
- <Goal
55
- fhirVersion={fhirVersions.R4}
56
- fhirResource={fhirResource}
57
- fhirIcons={false}
58
- />
59
- );
45
+ export const Example1OfR4 = Template.bind({});
46
+ Example1OfR4.args = {
47
+ fhirVersion: fhirVersions.R4,
48
+ fhirResource: r4Example1,
49
+ fhirIcons: false,
60
50
  };
61
51
 
62
- export const Example2OfR4 = () => {
63
- const fhirResource = object('Resource', r4Example2);
64
- return (
65
- <Goal
66
- fhirVersion={fhirVersions.R4}
67
- fhirResource={fhirResource}
68
- fhirIcons={'random text'}
69
- />
70
- );
52
+ export const Example2OfR4 = Template.bind({});
53
+ Example2OfR4.args = {
54
+ fhirVersion: fhirVersions.R4,
55
+ fhirResource: r4Example2,
56
+ fhirIcons: 'random text',
71
57
  };
72
58
 
73
- export const ExampleWithoutFhirVersionProperty = () => {
74
- const fhirResource = object('Resource', stu3Example1);
75
- return <Goal fhirResource={fhirResource} fhirIcons={fhirIcons} />;
59
+ export const ExampleWithoutFhirVersionProperty = Template.bind({});
60
+ ExampleWithoutFhirVersionProperty.args = {
61
+ fhirResource: stu3Example1,
76
62
  };
@@ -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
 
4
4
  import Goal from './Goal';
5
5
  import fhirVersions from '../fhirResourceVersions';
@@ -187,4 +187,35 @@ describe('should render Goal component properly', () => {
187
187
 
188
188
  expect(queryByTestId('priority')).toBeNull();
189
189
  });
190
+
191
+ it('should fire custom onClick function', () => {
192
+ const defaultProps = {
193
+ fhirResource: r4Example2,
194
+ fhirVersion: fhirVersions.R4,
195
+ };
196
+
197
+ const onClick = jest.fn();
198
+ const { getByRole } = render(<Goal {...defaultProps} onClick={onClick} />);
199
+ const accordion = getByRole('button');
200
+ fireEvent.click(accordion);
201
+
202
+ const attribute = accordion.getAttribute('data-bs-toggle');
203
+ expect(attribute).not.toEqual('collapse');
204
+ expect(onClick).toHaveBeenCalled();
205
+ });
206
+
207
+ it('should not fire custom onClick function', () => {
208
+ const defaultProps = {
209
+ fhirResource: r4Example2,
210
+ fhirVersion: fhirVersions.R4,
211
+ };
212
+
213
+ const onClick = 'test';
214
+ const { getByRole } = render(<Goal {...defaultProps} onClick={onClick} />);
215
+ const accordion = getByRole('button');
216
+ fireEvent.click(accordion);
217
+
218
+ const attribute = accordion.getAttribute('data-bs-toggle');
219
+ expect(attribute).toEqual('collapse');
220
+ });
190
221
  });
@@ -103,8 +103,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
103
103
  }
104
104
  };
105
105
 
106
- const Immunization = props => {
107
- const { fhirVersion, fhirResource, fhirIcons } = props;
106
+ const Immunization = ({
107
+ fhirVersion,
108
+ fhirResource,
109
+ fhirIcons,
110
+ onClick,
111
+ rawOnClick,
112
+ }) => {
108
113
  const {
109
114
  title,
110
115
  status,
@@ -241,6 +246,8 @@ const Immunization = props => {
241
246
  />
242
247
  }
243
248
  bodyContent={<Body tableData={tableData} />}
249
+ onClick={onClick}
250
+ rawOnClick={rawOnClick}
244
251
  />
245
252
  </Root>
246
253
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { object } from '@storybook/addon-knobs';
2
+ import { defaultArgTypes } from '../../defaultArgTypes';
3
3
 
4
4
  import Immunization from './Immunization';
5
5
 
@@ -15,64 +15,51 @@ import ImmunizationIcon from '../../../assets/containers/Immunization/immunizati
15
15
 
16
16
  export default {
17
17
  title: 'Immunization',
18
+ component: Immunization,
19
+ argTypes: {
20
+ ...defaultArgTypes,
21
+ },
18
22
  };
19
23
 
20
- export const DefaultVisualizationDSTU2 = () => {
21
- const fhirResource = object('Resource', example1);
22
- return (
23
- <Immunization
24
- fhirResource={fhirResource}
25
- fhirVersion={fhirVersions.DSTU2}
26
- fhirIcons={require('../../../assets/containers/Immunization/immunization.svg')}
27
- />
28
- );
24
+ const Template = args => <Immunization {...args} />;
25
+
26
+ export const DefaultVisualizationDSTU2 = Template.bind({});
27
+ DefaultVisualizationDSTU2.args = {
28
+ fhirVersion: fhirVersions.DSTU2,
29
+ fhirResource: example1,
30
+ fhirIcons: require('../../../assets/containers/Immunization/immunization.svg'),
29
31
  };
30
32
 
31
- export const Example2OfDSTU2 = () => {
32
- const fhirResource = object('Resource', example2);
33
- return (
34
- <Immunization
35
- fhirResource={fhirResource}
36
- fhirVersion={fhirVersions.DSTU2}
37
- fhirIcons={ImmunizationIcon}
38
- />
39
- );
33
+ export const Example2OfDSTU2 = Template.bind({});
34
+ Example2OfDSTU2.args = {
35
+ fhirVersion: fhirVersions.DSTU2,
36
+ fhirResource: example2,
37
+ fhirIcons: ImmunizationIcon,
40
38
  };
41
39
 
42
- export const ExampleSTU3 = () => {
43
- const fhirResource = object('Resource', stu3Example);
44
- return (
45
- <Immunization
46
- fhirResource={fhirResource}
47
- fhirVersion={fhirVersions.STU3}
48
- fhirIcons={fhirIcons}
49
- />
50
- );
40
+ export const ExampleSTU3 = Template.bind({});
41
+ ExampleSTU3.args = {
42
+ fhirVersion: fhirVersions.STU3,
43
+ fhirResource: stu3Example,
44
+ fhirIcons: fhirIcons,
51
45
  };
52
46
 
53
- export const Example1R4 = () => {
54
- const fhirResource = object('Resource', r4Example1);
55
- return (
56
- <Immunization
57
- fhirResource={fhirResource}
58
- fhirVersion={fhirVersions.R4}
59
- fhirIcons={false}
60
- />
61
- );
47
+ export const Example1R4 = Template.bind({});
48
+ Example1R4.args = {
49
+ fhirVersion: fhirVersions.R4,
50
+ fhirResource: r4Example1,
51
+ fhirIcons: false,
62
52
  };
63
- export const Example2R4 = () => {
64
- const fhirResource = object('Resource', r4Example2);
65
- return (
66
- <Immunization
67
- fhirResource={fhirResource}
68
- fhirVersion={fhirVersions.R4}
69
- fhirIcons={'random text'}
70
- />
71
- );
53
+
54
+ export const Example2R4 = Template.bind({});
55
+ Example2R4.args = {
56
+ fhirVersion: fhirVersions.R4,
57
+ fhirResource: r4Example2,
58
+ fhirIcons: 'random text',
72
59
  };
73
- export const Example3R4 = () => {
74
- const fhirResource = object('Resource', r4Example3);
75
- return (
76
- <Immunization fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
77
- );
60
+
61
+ export const Example3R4 = Template.bind({});
62
+ Example3R4.args = {
63
+ fhirVersion: fhirVersions.R4,
64
+ fhirResource: r4Example3,
78
65
  };
@@ -4,7 +4,7 @@ import dstu2Example from '../../../fixtures/dstu2/resources/immunization/example
4
4
  import fhirVersions from '../fhirResourceVersions';
5
5
  import r4Example1 from '../../../fixtures/r4/resources/immunization/example1.json';
6
6
  import r4Example2 from '../../../fixtures/r4/resources/immunization/example2.json';
7
- import { render } from '@testing-library/react';
7
+ import { fireEvent, render } from '@testing-library/react';
8
8
  import stu3Example from '../../../fixtures/stu3/resources/immunization/example1.json';
9
9
  import fhirIcons from '../../../fixtures/example-icons';
10
10
 
@@ -222,4 +222,39 @@ describe('should render Immunization component properly', () => {
222
222
 
223
223
  expect(queryByTestId('site')).toBeNull();
224
224
  });
225
+
226
+ it('should fire custom onClick function', () => {
227
+ const defaultProps = {
228
+ fhirResource: r4Example1,
229
+ fhirVersion: fhirVersions.R4,
230
+ };
231
+
232
+ const onClick = jest.fn();
233
+ const { getByRole } = render(
234
+ <Immunization {...defaultProps} onClick={onClick} />,
235
+ );
236
+ const accordion = getByRole('button');
237
+ fireEvent.click(accordion);
238
+
239
+ const attribute = accordion.getAttribute('data-bs-toggle');
240
+ expect(attribute).not.toEqual('collapse');
241
+ expect(onClick).toHaveBeenCalled();
242
+ });
243
+
244
+ it('should not fire custom onClick function', () => {
245
+ const defaultProps = {
246
+ fhirResource: r4Example1,
247
+ fhirVersion: fhirVersions.R4,
248
+ };
249
+
250
+ const onClick = 'test';
251
+ const { getByRole } = render(
252
+ <Immunization {...defaultProps} onClick={onClick} />,
253
+ );
254
+ const accordion = getByRole('button');
255
+ fireEvent.click(accordion);
256
+
257
+ const attribute = accordion.getAttribute('data-bs-toggle');
258
+ expect(attribute).toEqual('collapse');
259
+ });
225
260
  });
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import _get from 'lodash/get';
4
4
  import { getExtension } from './utils';
5
- import { ValueSection, Value } from '../../ui';
5
+ import { ValueSection, ValueSectionItem } from '../../ui';
6
6
  import CodeableConcept from '../../datatypes/CodeableConcept';
7
7
  import Money from '../../datatypes/Money';
8
8
 
@@ -82,48 +82,92 @@ const DrugTierDefinitionExtension = props => {
82
82
  coinsuranceOption,
83
83
  } = dto(drugTierDefinitionExtension);
84
84
 
85
+ const drugData = [
86
+ {
87
+ label: 'Drug Tier ID',
88
+ testId: 'drugTierID',
89
+ data: drugTierID && <CodeableConcept fhirData={drugTierID} />,
90
+ status: drugTierID,
91
+ },
92
+ {
93
+ label: 'Mail order',
94
+ testId: 'mailOrder',
95
+ data: mailOrder ? 'yes' : 'no',
96
+ status: mailOrder,
97
+ },
98
+ ];
99
+
100
+ const costData = [
101
+ {
102
+ label: 'Pharmacy Type',
103
+ testId: 'pharmacyType',
104
+ data: pharmacyType && <CodeableConcept fhirData={pharmacyType} />,
105
+ status: pharmacyType,
106
+ },
107
+ {
108
+ label: 'Copay Amount',
109
+ testId: 'copayAmount',
110
+ data: copayAmount && <Money fhirData={copayAmount} />,
111
+ status: copayAmount,
112
+ },
113
+ {
114
+ label: 'Copay Option',
115
+ testId: 'copayOption',
116
+ data: copayOption && <CodeableConcept fhirData={copayOption} />,
117
+ status: copayOption,
118
+ },
119
+ {
120
+ label: 'Coinsurance Rate',
121
+ testId: 'coinsuranceRate',
122
+ data: coinsuranceRate,
123
+ status: coinsuranceRate === 0 || coinsuranceRate,
124
+ },
125
+ {
126
+ label: 'Coinsurance Option',
127
+ testId: 'coinsuranceOption',
128
+ data: coinsuranceOption && (
129
+ <CodeableConcept fhirData={coinsuranceOption} />
130
+ ),
131
+ status: coinsuranceOption,
132
+ },
133
+ ];
134
+
85
135
  return (
86
136
  hasExtensions && (
87
137
  <ValueSection
88
138
  label="Drug Tier Definition"
89
139
  data-testid="drugTierDefinition"
140
+ marginTop
90
141
  >
91
- {drugTierID && (
92
- <Value label="Drug Tier ID" data-testid="drugTierID">
93
- <CodeableConcept fhirData={drugTierID} />
94
- </Value>
95
- )}
96
- {mailOrder && (
97
- <Value label="Mail order" data-testid="mailOrder">
98
- {mailOrder ? 'yes' : 'no'}
99
- </Value>
142
+ {drugData.map(
143
+ (item, index) =>
144
+ item.status && (
145
+ <ValueSectionItem
146
+ key={`drug-item-${index}`}
147
+ label={item.label}
148
+ data-testid={item.testId}
149
+ >
150
+ {item.data}
151
+ </ValueSectionItem>
152
+ ),
100
153
  )}
101
154
  {hasConstSharing && (
102
- <ValueSection label="Cost sharing" data-testid="costSharing">
103
- {pharmacyType && (
104
- <Value label="Pharmacy Type" data-testid="pharmacyType">
105
- <CodeableConcept fhirData={pharmacyType} />
106
- </Value>
107
- )}
108
- {copayAmount && (
109
- <Value label="Copay Amount" data-testid="copayAmount">
110
- <Money fhirData={copayAmount} />
111
- </Value>
112
- )}
113
- {copayOption && (
114
- <Value label="Copay Option" data-testid="copayOption">
115
- <CodeableConcept fhirData={copayOption} />
116
- </Value>
117
- )}
118
- {(coinsuranceRate === 0 || coinsuranceRate) && (
119
- <Value label="Coinsurance Rate" data-testid="coinsuranceRate">
120
- {coinsuranceRate}
121
- </Value>
122
- )}
123
- {coinsuranceOption && (
124
- <Value label="Coinsurance Option" data-testid="coinsuranceOption">
125
- <CodeableConcept fhirData={coinsuranceOption} />
126
- </Value>
155
+ <ValueSection
156
+ label="Cost sharing"
157
+ data-testid="costSharing"
158
+ marginTop
159
+ >
160
+ {costData.map(
161
+ (item, index) =>
162
+ item.status && (
163
+ <ValueSectionItem
164
+ key={`cost-item-${index}`}
165
+ label={item.label}
166
+ data-testid={item.testId}
167
+ >
168
+ {item.data}
169
+ </ValueSectionItem>
170
+ ),
127
171
  )}
128
172
  </ValueSection>
129
173
  )}
@@ -16,7 +16,7 @@ import Reference from '../../datatypes/Reference';
16
16
  const Entries = ({ fhirData: items = [] }) => {
17
17
  if (items.length === 0) return null;
18
18
  return (
19
- <ValueSection label="Entries" data-testid="entries">
19
+ <ValueSection label="Entries" data-testid="entries" marginTop>
20
20
  <Table>
21
21
  <thead>
22
22
  <TableRow>
@@ -26,7 +26,7 @@ const Entries = ({ fhirData: items = [] }) => {
26
26
  <TableHeader>Status</TableHeader>
27
27
  </TableRow>
28
28
  </thead>
29
- <tbody>
29
+ <tbody className="border-top-0">
30
30
  {items.map((item, idx) => (
31
31
  <Entry key={idx} item={item} />
32
32
  ))}
@@ -50,7 +50,7 @@ const Entry = props => {
50
50
  <Reference fhirData={entry} />
51
51
  </TableCell>
52
52
  <TableCell data-testid="items.date">
53
- {date ? <Date fhirData={date} /> : <MissingValue />}
53
+ {date ? <Date fhirData={date} isBlack /> : <MissingValue />}
54
54
  </TableCell>
55
55
  <TableCell data-testid="items.isDeleted">
56
56
  {deleted === true ? 'yes' : 'no'}