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
@@ -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 Claim from './Claim';
5
5
  import fhirVersions from '../fhirResourceVersions';
@@ -16,64 +16,51 @@ import fhirIcons from '../../../fixtures/example-icons';
16
16
 
17
17
  export default {
18
18
  title: 'Claim',
19
+ component: Claim,
20
+ argTypes: {
21
+ ...defaultArgTypes,
22
+ },
19
23
  };
20
24
 
21
- export const ExampleOfDSTU2 = () => {
22
- const fhirResource = object('Resource', dstu2Example1);
23
- return (
24
- <Claim
25
- fhirVersion={fhirVersions.DSTU2}
26
- fhirResource={fhirResource}
27
- fhirIcons={require('../../../assets/containers/Claim/claim.svg')}
28
- />
29
- );
25
+ const Template = args => <Claim {...args} />;
26
+
27
+ export const ExampleOfDSTU2 = Template.bind({});
28
+ ExampleOfDSTU2.args = {
29
+ fhirVersion: fhirVersions.DSTU2,
30
+ fhirResource: dstu2Example1,
31
+ fhirIcons: require('../../../assets/containers/Claim/claim.svg'),
30
32
  };
31
33
 
32
- export const ExampleOfSTU3 = () => {
33
- const fhirResource = object('Resource', stu3Example1);
34
- return (
35
- <Claim
36
- fhirVersion={fhirVersions.STU3}
37
- fhirResource={fhirResource}
38
- fhirIcons={ClaimIcon}
39
- />
40
- );
34
+ export const ExampleOfSTU3 = Template.bind({});
35
+ ExampleOfSTU3.args = {
36
+ fhirVersion: fhirVersions.STU3,
37
+ fhirResource: stu3Example1,
38
+ fhirIcons: ClaimIcon,
41
39
  };
42
40
 
43
- export const Example2OfSTU3 = () => {
44
- const fhirResource = object('Resource', stu3Example2);
45
- return (
46
- <Claim
47
- fhirVersion={fhirVersions.STU3}
48
- fhirResource={fhirResource}
49
- fhirIcons={fhirIcons}
50
- />
51
- );
41
+ export const Example2OfSTU3 = Template.bind({});
42
+ Example2OfSTU3.args = {
43
+ fhirVersion: fhirVersions.STU3,
44
+ fhirResource: stu3Example2,
45
+ fhirIcons: fhirIcons,
52
46
  };
53
47
 
54
- export const Example3OfSTU3 = () => {
55
- const fhirResource = object('Resource', stu3Example3);
56
- return (
57
- <Claim
58
- fhirVersion={fhirVersions.STU3}
59
- fhirResource={fhirResource}
60
- fhirIcons={false}
61
- />
62
- );
48
+ export const Example3OfSTU3 = Template.bind({});
49
+ Example3OfSTU3.args = {
50
+ fhirVersion: fhirVersions.STU3,
51
+ fhirResource: stu3Example3,
52
+ fhirIcons: false,
63
53
  };
64
54
 
65
- export const Example1OfR4 = () => {
66
- const fhirResource = object('Resource', r4Example1);
67
- return (
68
- <Claim
69
- fhirVersion={fhirVersions.R4}
70
- fhirResource={fhirResource}
71
- fhirIcons={'random text'}
72
- />
73
- );
55
+ export const Example1OfR4 = Template.bind({});
56
+ Example1OfR4.args = {
57
+ fhirVersion: fhirVersions.R4,
58
+ fhirResource: r4Example1,
59
+ fhirIcons: 'random text',
74
60
  };
75
61
 
76
- export const Example2OfR4 = () => {
77
- const fhirResource = object('Resource', r4Example2);
78
- return <Claim fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />;
62
+ export const Example2OfR4 = Template.bind({});
63
+ Example2OfR4.args = {
64
+ fhirVersion: fhirVersions.R4,
65
+ fhirResource: r4Example2,
79
66
  };
@@ -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 Claim from './Claim';
5
5
  import fhirVersions from '../fhirResourceVersions';
@@ -360,4 +360,35 @@ describe('should render the Claim component properly', () => {
360
360
  expect(quantities).toEqual(['-']);
361
361
  expect(netPrices).toEqual(['135.57 USD']);
362
362
  });
363
+
364
+ it('should fire custom onClick function', () => {
365
+ const defaultProps = {
366
+ fhirResource: r4Example1,
367
+ fhirVersion: fhirVersions.R4,
368
+ };
369
+
370
+ const onClick = jest.fn();
371
+ const { getByRole } = render(<Claim {...defaultProps} onClick={onClick} />);
372
+ const accordion = getByRole('button');
373
+ fireEvent.click(accordion);
374
+
375
+ const attribute = accordion.getAttribute('data-bs-toggle');
376
+ expect(attribute).not.toEqual('collapse');
377
+ expect(onClick).toHaveBeenCalled();
378
+ });
379
+
380
+ it('should not fire custom onClick function', () => {
381
+ const defaultProps = {
382
+ fhirResource: r4Example1,
383
+ fhirVersion: fhirVersions.R4,
384
+ };
385
+
386
+ const onClick = 'test';
387
+ const { getByRole } = render(<Claim {...defaultProps} onClick={onClick} />);
388
+ const accordion = getByRole('button');
389
+ fireEvent.click(accordion);
390
+
391
+ const attribute = accordion.getAttribute('data-bs-toggle');
392
+ expect(attribute).toEqual('collapse');
393
+ });
363
394
  });
@@ -1,27 +1,62 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
 
3
- import { TableCell, TableRow } from '../../ui';
3
+ import { Chevron, TableCell, TableRow } from '../../ui';
4
4
  import Coding from '../../datatypes/Coding';
5
5
  import Money from '../../datatypes/Money';
6
6
  import Item from './Item';
7
7
 
8
- const AddedItem = props => {
9
- const { addedItem, parentSequences, level } = props;
10
-
8
+ const AddedItem = ({
9
+ addedItem,
10
+ parentSequences,
11
+ parentId,
12
+ isCollapse = false,
13
+ }) => {
11
14
  const itemSequences = [...parentSequences, addedItem.sequenceLinkId];
12
15
  const id = itemSequences.join('.');
16
+ const collapseId = parentSequences.length
17
+ ? parentId
18
+ : addedItem.sequenceLinkId;
19
+
20
+ const [rotate, setRotate] = useState(false);
21
+ const handleTableExpand = () => setRotate(!rotate);
22
+
23
+ const isExpandable =
24
+ parentSequences.length === 0 && addedItem.subItems.length !== 0;
13
25
 
14
26
  return (
15
27
  <>
16
- <TableRow>
17
- <TableCell data-testid="addedItems.sequence">{id}</TableCell>
18
- <TableCell data-testid="addedItems.service">
28
+ <TableRow
29
+ className={`${isCollapse ? `collapse item-${parentId}` : ''} ${
30
+ isExpandable ? 'fw-bold table-expandable-row border-top' : ''
31
+ }`}
32
+ data-bs-target={`.item-${collapseId}`}
33
+ data-bs-toggle={'collapse'}
34
+ aria-controls={id}
35
+ aria-expanded="false"
36
+ onClick={handleTableExpand}
37
+ >
38
+ <TableCell
39
+ data-testid="addedItems.sequence"
40
+ className="col-md-2"
41
+ isAlignTop
42
+ >
43
+ {id}
44
+ </TableCell>
45
+ <TableCell
46
+ data-testid="addedItems.service"
47
+ className="col-md-2"
48
+ isAlignTop
49
+ >
19
50
  {addedItem.service && <Coding fhirData={addedItem.service} />}
20
51
  </TableCell>
21
- <TableCell data-testid="addedItems.fee">
52
+ <TableCell data-testid="addedItems.fee" className="col-md-2" isAlignTop>
22
53
  {addedItem.fee && <Money fhirData={addedItem.fee} />}
23
54
  </TableCell>
24
- <TableCell data-testid="addedItems.adjudication">
55
+ <TableCell
56
+ data-testid="addedItems.adjudication"
57
+ className="col-md-2"
58
+ isAlignTop
59
+ >
25
60
  {addedItem.adjudication.map((adjudication, idx) => (
26
61
  <div
27
62
  key={idx}
@@ -36,13 +71,28 @@ const AddedItem = props => {
36
71
  </div>
37
72
  ))}
38
73
  </TableCell>
74
+ {isExpandable ? (
75
+ <TableCell className="col-md-2" isAlignTop>
76
+ <button
77
+ className="fhir-container__Accordion__header-button w-100 p-0 border-0 rounded-1 collapsed text-dark bg-transparent shadow-none "
78
+ type="button"
79
+ >
80
+ <div className={` ${rotate ? ' header-rotate' : ''}`}>
81
+ <Chevron strokeColor={rotate ? '#2a6fd7' : '#6f83a9'} />
82
+ </div>
83
+ </button>
84
+ </TableCell>
85
+ ) : (
86
+ <TableCell style={{ width: '64px' }} className="col-md-2" />
87
+ )}
39
88
  </TableRow>
40
89
  {addedItem.subItems.map((subItem, idx) => (
41
90
  <Item
42
91
  key={idx}
43
92
  addedItem={subItem}
44
- level={level + 1}
45
93
  parentSequences={itemSequences}
94
+ parentId={collapseId}
95
+ isCollapse
46
96
  />
47
97
  ))}
48
98
  </>
@@ -7,24 +7,20 @@ const AddedItems = props => {
7
7
  const { addedItems } = props;
8
8
 
9
9
  return (
10
- <ValueSection label="Added Items" data-testid="addedItems">
10
+ <ValueSection label="Added Items" data-testid="addedItems" marginTop>
11
11
  <Table>
12
12
  <thead>
13
13
  <TableRow>
14
14
  <TableHeader>ID</TableHeader>
15
15
  <TableHeader>Service</TableHeader>
16
16
  <TableHeader>Fee</TableHeader>
17
- <TableHeader expand>Adjudication</TableHeader>
17
+ <TableHeader>Adjudication</TableHeader>
18
+ <TableHeader></TableHeader>
18
19
  </TableRow>
19
20
  </thead>
20
- <tbody>
21
+ <tbody className="border-top-0">
21
22
  {addedItems.map((item, idx) => (
22
- <AddedItem
23
- key={idx}
24
- addedItem={item}
25
- level={0}
26
- parentSequences={[]}
27
- />
23
+ <AddedItem key={idx} addedItem={item} parentSequences={[]} />
28
24
  ))}
29
25
  </tbody>
30
26
  </Table>
@@ -21,11 +21,11 @@ import {
21
21
  Header,
22
22
  MissingValue,
23
23
  Root,
24
- Title,
25
- Value,
26
24
  ValueSection,
27
25
  BadgeSecondary,
26
+ ValueSectionItem,
28
27
  } from '../../ui';
28
+ import Accordion from '../../containers/Accordion';
29
29
 
30
30
  const commonDTO = fhirResource => {
31
31
  const id = _get(fhirResource, 'id');
@@ -285,8 +285,13 @@ const hasPaymentInfo = payment => {
285
285
  return Object.values(payment).filter(item => item).length > 0;
286
286
  };
287
287
 
288
- const ClaimResponse = props => {
289
- const { fhirVersion, fhirResource } = props;
288
+ const ClaimResponse = ({
289
+ fhirVersion,
290
+ fhirResource,
291
+ fhirIcons,
292
+ onClick,
293
+ rawOnClick,
294
+ }) => {
290
295
  let fhirResourceData = {};
291
296
  try {
292
297
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -314,88 +319,144 @@ const ClaimResponse = props => {
314
319
  const hasAddedItems = addedItems.length > 0;
315
320
  const hasPayment = hasPaymentInfo(payment);
316
321
 
322
+ const tableData = [
323
+ {
324
+ label: 'Created At',
325
+ testId: 'created',
326
+ data: created && <DateType fhirData={created} isBlack />,
327
+ status: created,
328
+ },
329
+ {
330
+ label: 'Request claim',
331
+ testId: 'request',
332
+ data: requestReference && <Reference fhirData={requestReference} />,
333
+ status: requestReference,
334
+ },
335
+ {
336
+ label: 'Disposition',
337
+ testId: 'disposition',
338
+ data: disposition,
339
+ status: disposition,
340
+ },
341
+ {
342
+ label: 'Total cost',
343
+ testId: 'totalCost',
344
+ data: totalCost && <Money fhirData={totalCost} />,
345
+ status: totalCost,
346
+ },
347
+ {
348
+ label: 'Total benefit',
349
+ testId: 'totalBenefit',
350
+ data: totalBenefit && <Money fhirData={totalBenefit} />,
351
+ status: totalBenefit,
352
+ },
353
+ ];
354
+
355
+ const paymentData = [
356
+ {
357
+ label: 'Type',
358
+ testId: 'payment.type',
359
+ data: payment.typeCoding ? (
360
+ <Coding fhirData={payment.typeCoding} />
361
+ ) : (
362
+ <MissingValue />
363
+ ),
364
+ status: true,
365
+ },
366
+ {
367
+ label: 'Amount',
368
+ testId: 'payment.amount',
369
+ data: payment.amount ? (
370
+ <Money fhirData={payment.amount} />
371
+ ) : (
372
+ <MissingValue />
373
+ ),
374
+ status: payment.amount,
375
+ },
376
+ {
377
+ label: 'Date',
378
+ testId: 'payment.date',
379
+ data: payment.date ? (
380
+ <DateType fhirData={payment.date} isBlack />
381
+ ) : (
382
+ <MissingValue />
383
+ ),
384
+ status: payment.date,
385
+ },
386
+ {
387
+ label: 'Reference',
388
+ testId: 'payment.ref',
389
+ data: payment.ref ? (
390
+ <Identifier fhirData={payment.ref} />
391
+ ) : (
392
+ <MissingValue />
393
+ ),
394
+ status: payment.ref,
395
+ },
396
+ ];
397
+
317
398
  return (
318
399
  <Root name="ClaimResponse">
319
- <Header>
320
- <Title>Claim response #{id}</Title>
321
- {outcome && <Badge data-testid="outcome">{outcome}</Badge>}
322
- {status && (
323
- <BadgeSecondary data-testid="status">{status}</BadgeSecondary>
324
- )}
325
- </Header>
326
- <Body>
327
- {created && (
328
- <Value label="Created At" data-testid="created">
329
- <DateType fhirData={created} />
330
- </Value>
331
- )}
332
- {requestReference && (
333
- <Value label="Request claim" data-testid="request">
334
- <Reference fhirData={requestReference} />
335
- </Value>
336
- )}
337
- {disposition && (
338
- <Value label="Disposition" data-testid="disposition">
339
- {disposition}
340
- </Value>
341
- )}
342
- {totalCost && (
343
- <Value label="Total cost" data-testid="totalCost">
344
- <Money fhirData={totalCost} />
345
- </Value>
346
- )}
347
- {totalBenefit && (
348
- <Value label="Total benefit" data-testid="totalBenefit">
349
- <Money fhirData={totalBenefit} />
350
- </Value>
351
- )}
352
- {isNotEmptyArray(totalCostsArr) && (
353
- <ValueSection label="Total" data-testid="totalSection">
354
- {totalCostsArr.map(
355
- ({ category, amount }, i) =>
356
- category && (
357
- <Value label={category} key={`total-value-${i}`}>
358
- <Money fhirData={amount} />
359
- </Value>
360
- ),
400
+ <Accordion
401
+ headerContent={
402
+ <Header
403
+ resourceName="ClaimResponse"
404
+ title={`Claim response #${id}`}
405
+ badges={
406
+ <>
407
+ {outcome && <Badge data-testid="outcome">{outcome}</Badge>}
408
+ {status && (
409
+ <BadgeSecondary data-testid="status">{status}</BadgeSecondary>
410
+ )}
411
+ </>
412
+ }
413
+ icon={fhirIcons}
414
+ />
415
+ }
416
+ bodyContent={
417
+ <Body tableData={tableData}>
418
+ {isNotEmptyArray(totalCostsArr) && (
419
+ <ValueSection label="Total" data-testid="totalSection" marginTop>
420
+ {totalCostsArr.map(
421
+ ({ category, amount }, i) =>
422
+ category && (
423
+ <ValueSectionItem
424
+ label={category}
425
+ key={`total-value-${i}`}
426
+ >
427
+ <Money fhirData={amount} />
428
+ </ValueSectionItem>
429
+ ),
430
+ )}
431
+ </ValueSection>
432
+ )}
433
+ {hasPayment && (
434
+ <ValueSection
435
+ label="Payment"
436
+ data-testid="paymentSection"
437
+ marginTop
438
+ >
439
+ {paymentData.map(
440
+ (item, index) =>
441
+ item.status && (
442
+ <ValueSectionItem
443
+ key={`payment-item-${index}`}
444
+ label={item.label}
445
+ data-testid={item.testId}
446
+ >
447
+ {item.data}
448
+ </ValueSectionItem>
449
+ ),
450
+ )}
451
+ </ValueSection>
361
452
  )}
362
- </ValueSection>
363
- )}
364
- {hasPayment && (
365
- <ValueSection label="Payment" data-testid="paymentSection">
366
- <Value label="Type" data-testid="payment.type">
367
- {payment.typeCoding ? (
368
- <Coding fhirData={payment.typeCoding} />
369
- ) : (
370
- <MissingValue />
371
- )}
372
- </Value>
373
- <Value label="Amount" data-testid="payment.amount">
374
- {payment.amount ? (
375
- <Money fhirData={payment.amount} />
376
- ) : (
377
- <MissingValue />
378
- )}
379
- </Value>
380
- <Value label="Date" data-testid="payment.date">
381
- {payment.date ? (
382
- <DateType fhirData={payment.date} />
383
- ) : (
384
- <MissingValue />
385
- )}
386
- </Value>
387
- <Value label="Reference" data-testid="payment.ref">
388
- {payment.ref ? (
389
- <Identifier fhirData={payment.ref} />
390
- ) : (
391
- <MissingValue />
392
- )}
393
- </Value>
394
- </ValueSection>
395
- )}
396
- {hasAddedItems && <AddedItems addedItems={addedItems} />}
397
- {hasItems && <Items items={items} />}
398
- </Body>
453
+ {hasAddedItems && <AddedItems addedItems={addedItems} />}
454
+ {hasItems && <Items items={items} />}
455
+ </Body>
456
+ }
457
+ onClick={onClick}
458
+ rawOnClick={rawOnClick}
459
+ />
399
460
  </Root>
400
461
  );
401
462
  };
@@ -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 fhirVersions from '../fhirResourceVersions';
5
5
  import ClaimResponse from './ClaimResponse';
@@ -10,53 +10,56 @@ import example2ClaimResponseSTU3 from '../../../fixtures/stu3/resources/claimRes
10
10
  import example1ClaimResponseR4 from '../../../fixtures/r4/resources/claimResponse/example1.json';
11
11
  import example2ClaimResponseR4 from '../../../fixtures/r4/resources/claimResponse/example2.json';
12
12
  import example3ClaimResponseR4 from '../../../fixtures/r4/resources/claimResponse/example3.json';
13
+ import fhirIcons from '../../../fixtures/example-icons';
14
+ import ClaimResponseIcon from '../../../assets/containers/ClaimResponse/claim-response.svg';
13
15
 
14
- export default { title: 'Claim Response' };
16
+ export default {
17
+ title: 'ClaimResponse',
18
+ component: ClaimResponse,
19
+ argTypes: {
20
+ ...defaultArgTypes,
21
+ },
22
+ };
23
+
24
+ const Template = args => <ClaimResponse {...args} />;
15
25
 
16
- export const ExampleDSTU2 = () => {
17
- const fhirResource = object('Resource', exampleClaimResponseDSTU2);
18
- return (
19
- <ClaimResponse
20
- fhirResource={fhirResource}
21
- fhirVersion={fhirVersions.DSTU2}
22
- />
23
- );
26
+ export const ExampleDSTU2 = Template.bind({});
27
+ ExampleDSTU2.args = {
28
+ fhirVersion: fhirVersions.DSTU2,
29
+ fhirResource: exampleClaimResponseDSTU2,
30
+ fhirIcons: require('../../../assets/containers/ClaimResponse/claim-response.svg'),
24
31
  };
25
32
 
26
- export const Example1OfSTU3 = () => {
27
- const fhirResource = object('Resource', exampleClaimResponseSTU3);
28
- return (
29
- <ClaimResponse
30
- fhirResource={fhirResource}
31
- fhirVersion={fhirVersions.STU3}
32
- />
33
- );
33
+ export const Example1OfSTU3 = Template.bind({});
34
+ Example1OfSTU3.args = {
35
+ fhirVersion: fhirVersions.STU3,
36
+ fhirResource: exampleClaimResponseSTU3,
37
+ fhirIcons: ClaimResponseIcon,
34
38
  };
35
- export const Example2OfSTU3 = () => {
36
- const fhirResource = object('Resource', example2ClaimResponseSTU3);
37
- return (
38
- <ClaimResponse
39
- fhirResource={fhirResource}
40
- fhirVersion={fhirVersions.STU3}
41
- />
42
- );
39
+
40
+ export const Example2OfSTU3 = Template.bind({});
41
+ Example2OfSTU3.args = {
42
+ fhirVersion: fhirVersions.STU3,
43
+ fhirResource: example2ClaimResponseSTU3,
44
+ fhirIcons: fhirIcons,
43
45
  };
44
46
 
45
- export const Example1OfR4 = () => {
46
- const fhirResource = object('Resource', example1ClaimResponseR4);
47
- return (
48
- <ClaimResponse fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
49
- );
47
+ export const Example1OfR4 = Template.bind({});
48
+ Example1OfR4.args = {
49
+ fhirVersion: fhirVersions.R4,
50
+ fhirResource: example1ClaimResponseR4,
51
+ fhirIcons: false,
50
52
  };
51
- export const Example2OfR4 = () => {
52
- const fhirResource = object('Resource', example2ClaimResponseR4);
53
- return (
54
- <ClaimResponse fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
55
- );
53
+
54
+ export const Example2OfR4 = Template.bind({});
55
+ Example2OfR4.args = {
56
+ fhirVersion: fhirVersions.R4,
57
+ fhirResource: example2ClaimResponseR4,
58
+ fhirIcons: 'random text',
56
59
  };
57
- export const Example3OfR4 = () => {
58
- const fhirResource = object('Resource', example3ClaimResponseR4);
59
- return (
60
- <ClaimResponse fhirResource={fhirResource} fhirVersion={fhirVersions.R4} />
61
- );
60
+
61
+ export const Example3OfR4 = Template.bind({});
62
+ Example3OfR4.args = {
63
+ fhirVersion: fhirVersions.R4,
64
+ fhirResource: example3ClaimResponseR4,
62
65
  };