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
@@ -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 { object } from '@storybook/addon-knobs';
2
+ import { defaultArgTypes } from '../../defaultArgTypes';
3
3
  import fhirVersions from '../fhirResourceVersions';
4
4
 
5
5
  import Appointment from './Appointment';
@@ -16,76 +16,65 @@ import example3AppointmentR4 from '../../../fixtures/r4/resources/appointment/ex
16
16
  import fhirIcons from '../../../fixtures/example-icons';
17
17
  import AppointmentIcon from '../../../assets/containers/Appointment/appointment.svg';
18
18
 
19
- export default { title: 'Appointment' };
19
+ export default {
20
+ title: 'Appointment',
21
+ component: Appointment,
22
+ argTypes: {
23
+ ...defaultArgTypes,
24
+ },
25
+ };
26
+
27
+ const Template = args => <Appointment {...args} />;
20
28
 
21
- export const DefaultVisualizationDSTU2 = () => {
22
- const fhirResource = object('Resource', exampleAppointmentDSTU2);
23
- return (
24
- <Appointment
25
- fhirResource={fhirResource}
26
- fhirVersion={fhirVersions.DSTU2}
27
- fhirIcons={require('../../../assets/containers/Appointment/appointment.svg')}
28
- />
29
- );
29
+ export const DefaultVisualizationDSTU2 = Template.bind({});
30
+ DefaultVisualizationDSTU2.args = {
31
+ fhirResource: exampleAppointmentDSTU2,
32
+ fhirVersion: fhirVersions.DSTU2,
33
+ fhirIcons: require('../../../assets/containers/Appointment/appointment.svg'),
30
34
  };
31
35
 
32
- export const Example2OfDSTU2 = () => {
33
- const fhirResource = object('Resource', example2AppointmentDSTU2);
34
- return (
35
- <Appointment
36
- fhirResource={fhirResource}
37
- fhirVersion={fhirVersions.DSTU2}
38
- fhirIcons={AppointmentIcon}
39
- />
40
- );
36
+ export const Example2OfDSTU2 = Template.bind({});
37
+ Example2OfDSTU2.args = {
38
+ fhirResource: example2AppointmentDSTU2,
39
+ fhirVersion: fhirVersions.DSTU2,
40
+ fhirIcons: AppointmentIcon,
41
41
  };
42
42
 
43
- export const Example1OfSTU3 = () => {
44
- const fhirResource = object('Resource', example1AppointmentSTU3);
45
- return (
46
- <Appointment
47
- fhirResource={fhirResource}
48
- fhirVersion={fhirVersions.STU3}
49
- fhirIcons={fhirIcons}
50
- />
51
- );
43
+ export const Example1OfSTU3 = Template.bind({});
44
+ Example1OfSTU3.args = {
45
+ fhirResource: example1AppointmentSTU3,
46
+ fhirVersion: fhirVersions.STU3,
47
+ fhirIcons: fhirIcons,
52
48
  };
53
- export const Example2OfSTU3 = () => {
54
- const fhirResource = object('Resource', example2AppointmentSTU3);
55
- return (
56
- <Appointment
57
- fhirResource={fhirResource}
58
- fhirVersion={fhirVersions.STU3}
59
- fhirIcons={false}
60
- />
61
- );
49
+
50
+ export const Example2OfSTU3 = Template.bind({});
51
+ Example2OfSTU3.args = {
52
+ fhirResource: example2AppointmentSTU3,
53
+ fhirVersion: fhirVersions.STU3,
54
+ fhirIcons: false,
62
55
  };
63
- export const Example3OfSTU3 = () => {
64
- const fhirResource = object('Resource', example3AppointmentSTU3);
65
- return (
66
- <Appointment
67
- fhirResource={fhirResource}
68
- fhirVersion={fhirVersions.STU3}
69
- fhirIcons={'random text'}
70
- />
71
- );
56
+
57
+ export const Example3OfSTU3 = Template.bind({});
58
+ Example3OfSTU3.args = {
59
+ fhirResource: example3AppointmentSTU3,
60
+ fhirVersion: fhirVersions.STU3,
61
+ fhirIcons: 'random text',
72
62
  };
73
63
 
74
- export const Example1OfR4 = () => {
75
- const fhirResource = object('Resource', example1AppointmentR4);
76
- return (
77
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
78
- );
64
+ export const Example1OfR4 = Template.bind({});
65
+ Example1OfR4.args = {
66
+ fhirResource: example1AppointmentR4,
67
+ fhirVersion: fhirVersions.R4,
79
68
  };
80
- export const Example2OfR4 = () => {
81
- const fhirResource = object('Resource', example2AppointmentR4);
82
- return (
83
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
84
- );
69
+
70
+ export const Example2OfR4 = Template.bind({});
71
+ Example2OfR4.args = {
72
+ fhirResource: example2AppointmentR4,
73
+ fhirVersion: fhirVersions.R4,
85
74
  };
86
- export const Example3OfR4 = () => {
87
- const fhirResource = object('Resource', example3AppointmentR4);
88
- return (
89
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
90
- );
75
+
76
+ export const Example3OfR4 = Template.bind({});
77
+ Example3OfR4.args = {
78
+ fhirResource: example3AppointmentR4,
79
+ fhirVersion: fhirVersions.R4,
91
80
  };
@@ -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,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 Binary from './Binary';
5
5
 
@@ -13,34 +13,40 @@ import BinaryIcon from '../../../assets/containers/Binary/binary.svg';
13
13
 
14
14
  export default {
15
15
  title: 'Binary',
16
+ component: Binary,
17
+ argTypes: {
18
+ ...defaultArgTypes,
19
+ },
16
20
  };
17
21
 
18
- export const PdfDSTU2 = () => {
19
- const fhirResource = object('Resource', dstu2ExamplePdf);
20
- return (
21
- <Binary
22
- fhirResource={fhirResource}
23
- fhirIcons={require('../../../assets/containers/Binary/binary.svg')}
24
- />
25
- );
22
+ const Template = args => <Binary {...args} />;
23
+
24
+ export const PdfDSTU2 = Template.bind({});
25
+ PdfDSTU2.args = {
26
+ fhirResource: dstu2ExamplePdf,
27
+ fhirIcons: require('../../../assets/containers/Binary/binary.svg'),
26
28
  };
27
29
 
28
- export const JpegDSTU2 = () => {
29
- const fhirResource = object('Resource', dstu2ExampleJpeg);
30
- return <Binary fhirResource={fhirResource} fhirIcons={BinaryIcon} />;
30
+ export const JpegDSTU2 = Template.bind({});
31
+ JpegDSTU2.args = {
32
+ fhirResource: dstu2ExampleJpeg,
33
+ fhirIcons: BinaryIcon,
31
34
  };
32
35
 
33
- export const PdfSTU3 = () => {
34
- const fhirResource = object('Resource', stu3ExamplePdf);
35
- return <Binary fhirResource={fhirResource} fhirIcons={false} />;
36
+ export const PdfSTU3 = Template.bind({});
37
+ PdfSTU3.args = {
38
+ fhirResource: stu3ExamplePdf,
39
+ fhirIcons: false,
36
40
  };
37
41
 
38
- export const JpegSTU3 = () => {
39
- const fhirResource = object('Resource', stu3ExampleJpeg);
40
- return <Binary fhirResource={fhirResource} fhirIcons={'random text'} />;
42
+ export const JpegSTU3 = Template.bind({});
43
+ JpegSTU3.args = {
44
+ fhirResource: stu3ExampleJpeg,
45
+ fhirIcons: 'random text',
41
46
  };
42
47
 
43
- export const JsonSTU3 = () => {
44
- const fhirResource = object('Resource', stu3ExampleJson);
45
- return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
48
+ export const JsonSTU3 = Template.bind({});
49
+ JsonSTU3.args = {
50
+ fhirResource: stu3ExampleJson,
51
+ fhirIcons: fhirIcons,
46
52
  };
@@ -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
  );
@@ -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 Bundle from './Bundle';
5
5
 
@@ -17,145 +17,89 @@ import r4Example3 from '../../../fixtures/r4/resources/bundle/example3.json';
17
17
  import r4Example4 from '../../../fixtures/r4/resources/bundle/example4.json';
18
18
  import fhirVersions from '../fhirResourceVersions';
19
19
 
20
- import fhirIcons from '../../../fixtures/example-icons';
21
-
22
20
  export default {
23
21
  title: 'Bundle',
22
+ component: Bundle,
23
+ argTypes: {
24
+ ...defaultArgTypes,
25
+ },
24
26
  };
25
27
 
26
- export const Example1OfDSTU2 = () => {
27
- const fhirResource = object('Resource', dstu2Example1);
28
- return (
29
- <Bundle
30
- fhirResource={fhirResource}
31
- fhirVersion={fhirVersions.DSTU2}
32
- fhirIcons={fhirIcons}
33
- />
34
- );
28
+ const Template = args => <Bundle {...args} />;
29
+
30
+ export const Example1OfDSTU2 = Template.bind({});
31
+ Example1OfDSTU2.args = {
32
+ fhirVersion: fhirVersions.DSTU2,
33
+ fhirResource: dstu2Example1,
35
34
  };
36
35
 
37
- export const Example2OfDSTU2 = () => {
38
- const fhirResource = object('Resource', dstu2Example2);
39
- return (
40
- <Bundle
41
- fhirResource={fhirResource}
42
- fhirVersion={fhirVersions.DSTU2}
43
- fhirIcons={fhirIcons}
44
- />
45
- );
36
+ export const Example2OfDSTU2 = Template.bind({});
37
+ Example2OfDSTU2.args = {
38
+ fhirVersion: fhirVersions.DSTU2,
39
+ fhirResource: dstu2Example2,
46
40
  };
47
41
 
48
- export const Example3OfDSTU2 = () => {
49
- const fhirResource = object('Resource', dstu2Example3);
50
- return (
51
- <Bundle
52
- fhirResource={fhirResource}
53
- fhirVersion={fhirVersions.DSTU2}
54
- fhirIcons={fhirIcons}
55
- />
56
- );
42
+ export const Example3OfDSTU2 = Template.bind({});
43
+ Example3OfDSTU2.args = {
44
+ fhirVersion: fhirVersions.DSTU2,
45
+ fhirResource: dstu2Example3,
57
46
  };
58
47
 
59
- export const Example4OfDSTU2 = () => {
60
- const fhirResource = object('Resource', dstu2Example4);
61
- return (
62
- <Bundle
63
- fhirResource={fhirResource}
64
- fhirVersion={fhirVersions.DSTU2}
65
- fhirIcons={fhirIcons}
66
- />
67
- );
48
+ export const Example4OfDSTU2 = Template.bind({});
49
+ Example4OfDSTU2.args = {
50
+ fhirVersion: fhirVersions.DSTU2,
51
+ fhirResource: dstu2Example4,
68
52
  };
69
53
 
70
- export const Example1OfSTU3 = () => {
71
- const fhirResource = object('Resource', stu3Example1);
72
- return (
73
- <Bundle
74
- fhirResource={fhirResource}
75
- fhirVersion={fhirVersions.STU3}
76
- fhirIcons={fhirIcons}
77
- />
78
- );
54
+ export const Example1OfSTU3 = Template.bind({});
55
+ Example1OfSTU3.args = {
56
+ fhirVersion: fhirVersions.STU3,
57
+ fhirResource: stu3Example1,
79
58
  };
80
59
 
81
- export const Example2OfSTU3 = () => {
82
- const fhirResource = object('Resource', stu3Example2);
83
- return (
84
- <Bundle
85
- fhirResource={fhirResource}
86
- fhirVersion={fhirVersions.STU3}
87
- fhirIcons={fhirIcons}
88
- />
89
- );
60
+ export const Example2OfSTU3 = Template.bind({});
61
+ Example2OfSTU3.args = {
62
+ fhirVersion: fhirVersions.STU3,
63
+ fhirResource: stu3Example2,
90
64
  };
91
65
 
92
- export const Example3OfSTU3 = () => {
93
- const fhirResource = object('Resource', stu3Example3);
94
- return (
95
- <Bundle
96
- fhirResource={fhirResource}
97
- fhirVersion={fhirVersions.STU3}
98
- fhirIcons={fhirIcons}
99
- />
100
- );
66
+ export const Example3OfSTU3 = Template.bind({});
67
+ Example3OfSTU3.args = {
68
+ fhirVersion: fhirVersions.STU3,
69
+ fhirResource: stu3Example3,
101
70
  };
102
71
 
103
- export const Example4OfSTU3 = () => {
104
- const fhirResource = object('Resource', stu3Example4);
105
- return (
106
- <Bundle
107
- fhirResource={fhirResource}
108
- fhirVersion={fhirVersions.STU3}
109
- fhirIcons={fhirIcons}
110
- />
111
- );
72
+ export const Example4OfSTU3 = Template.bind({});
73
+ Example4OfSTU3.args = {
74
+ fhirVersion: fhirVersions.STU3,
75
+ fhirResource: stu3Example4,
112
76
  };
113
77
 
114
- export const Example1OfR4 = () => {
115
- const fhirResource = object('Resource', r4Example1);
116
- return (
117
- <Bundle
118
- fhirResource={fhirResource}
119
- fhirVersion={fhirVersions.R4}
120
- fhirIcons={fhirIcons}
121
- />
122
- );
78
+ export const Example1OfR4 = Template.bind({});
79
+ Example1OfR4.args = {
80
+ fhirVersion: fhirVersions.R4,
81
+ fhirResource: r4Example1,
123
82
  };
124
83
 
125
- export const Example2OfR4 = () => {
126
- const fhirResource = object('Resource', r4Example2);
127
- return (
128
- <Bundle
129
- fhirResource={fhirResource}
130
- fhirVersion={fhirVersions.R4}
131
- fhirIcons={fhirIcons}
132
- />
133
- );
84
+ export const Example2OfR4 = Template.bind({});
85
+ Example2OfR4.args = {
86
+ fhirVersion: fhirVersions.R4,
87
+ fhirResource: r4Example2,
134
88
  };
135
89
 
136
- export const Example3OfR4 = () => {
137
- const fhirResource = object('Resource', r4Example3);
138
- return (
139
- <Bundle
140
- fhirResource={fhirResource}
141
- fhirVersion={fhirVersions.R4}
142
- fhirIcons={fhirIcons}
143
- />
144
- );
90
+ export const Example3OfR4 = Template.bind({});
91
+ Example3OfR4.args = {
92
+ fhirVersion: fhirVersions.R4,
93
+ fhirResource: r4Example3,
145
94
  };
146
95
 
147
- export const Example4OfR4 = () => {
148
- const fhirResource = object('Resource', r4Example4);
149
- return (
150
- <Bundle
151
- fhirResource={fhirResource}
152
- fhirVersion={fhirVersions.R4}
153
- fhirIcons={fhirIcons}
154
- />
155
- );
96
+ export const Example4OfR4 = Template.bind({});
97
+ Example4OfR4.args = {
98
+ fhirVersion: fhirVersions.R4,
99
+ fhirResource: r4Example4,
156
100
  };
157
101
 
158
- // export const ExampleWithoutFHIRVersionProperty = () => {
159
- // const fhirResource = object('Resource', stu3Example2);
160
- // return <Bundle fhirResource={fhirResource} />;
161
- // };
102
+ export const ExampleWithoutFHIRVersionProperty = Template.bind({});
103
+ ExampleWithoutFHIRVersionProperty.args = {
104
+ fhirResource: stu3Example2,
105
+ };
@@ -8,8 +8,6 @@ import dstu2Example2 from '../../../fixtures/dstu2/resources/bundle/example3.jso
8
8
  import stu3Example1 from '../../../fixtures/stu3/resources/bundle/example1.json';
9
9
  import r4Example1 from '../../../fixtures/r4/resources/bundle/example1.json';
10
10
 
11
- import fhirIcons from '../../../fixtures/example-icons';
12
-
13
11
  describe('Bundle should render component correctly', () => {
14
12
  it('should render component correctly with DSTU2 source data', () => {
15
13
  const defaultProps = {
@@ -31,7 +29,6 @@ describe('Bundle should render component correctly', () => {
31
29
  const defaultProps = {
32
30
  fhirVersion: fhirVersions.DSTU2,
33
31
  fhirResource: dstu2Example2,
34
- fhirIcons: fhirIcons,
35
32
  };
36
33
  const { getByText, getAllByTestId } = render(<Bundle {...defaultProps} />);
37
34
  expect(getAllByTestId('title').map(title => title.textContent)).toEqual([
@@ -162,7 +162,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
162
162
  }
163
163
  };
164
164
 
165
- const CarePlan = ({ fhirResource, fhirVersion, fhirIcons }) => {
165
+ const CarePlan = ({
166
+ fhirResource,
167
+ fhirVersion,
168
+ fhirIcons,
169
+ onClick,
170
+ rawOnClick,
171
+ }) => {
166
172
  let fhirResourceData = {};
167
173
  try {
168
174
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -304,6 +310,8 @@ const CarePlan = ({ fhirResource, fhirVersion, fhirIcons }) => {
304
310
  )}
305
311
  </Body>
306
312
  }
313
+ onClick={onClick}
314
+ rawOnClick={rawOnClick}
307
315
  />
308
316
  </Root>
309
317
  );