fhir-react 0.3.5 → 0.3.8

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 (173) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.eslintrc +10 -1
  3. package/.stylelintrc +6 -2
  4. package/README.md +19 -1
  5. package/build/index.js +15 -11
  6. package/build/style.css +9 -8
  7. package/package.json +55 -54
  8. package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
  9. package/src/assets/containers/Coverage/coverage.svg +4 -0
  10. package/src/assets/containers/{ResourceCategory/resource-placeholder.svg → Generic/generic.svg} +0 -0
  11. package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
  12. package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
  13. package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
  14. package/src/assets/containers/Organization/organization.svg +5 -0
  15. package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
  16. package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
  17. package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
  18. package/src/assets/containers/ResourceCategory/resource-category.svg +3 -0
  19. package/src/components/containers/Accordion/Accordion.js +21 -13
  20. package/src/components/datatypes/Attachment/Attachment.css +5 -0
  21. package/src/components/datatypes/Attachment/Attachment.js +7 -2
  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/Identifier/Identifier.js +7 -3
  25. package/src/components/datatypes/Reference/Reference.js +7 -1
  26. package/src/components/datatypes/Telecom/Telecom.js +2 -3
  27. package/src/components/resources/AdverseEvent/AdverseEvent.js +81 -42
  28. package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
  29. package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
  30. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -5
  31. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +5 -4
  32. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +107 -1
  33. package/src/components/resources/Appointment/Appointment.js +2 -1
  34. package/src/components/resources/Appointment/Appointment.test.js +36 -1
  35. package/src/components/resources/Binary/Binary.js +1 -2
  36. package/src/components/resources/Binary/Binary.stories.js +10 -4
  37. package/src/components/resources/Binary/Binary.test.js +67 -0
  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 +12 -78
  41. package/src/components/resources/Bundle/Bundle.test.js +0 -3
  42. package/src/components/resources/CarePlan/CarePlan.js +2 -1
  43. package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
  44. package/src/components/resources/CarePlan/CarePlan.test.js +114 -6
  45. package/src/components/resources/CareTeam/CareTeam.js +72 -50
  46. package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
  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/CareTeam.js +55 -0
  50. package/src/components/resources/Claim/Claim.css +2 -11
  51. package/src/components/resources/Claim/Claim.js +158 -309
  52. package/src/components/resources/Claim/Claim.stories.js +37 -5
  53. package/src/components/resources/Claim/Claim.test.js +104 -1
  54. package/src/components/resources/Claim/Diagnosis.js +61 -0
  55. package/src/components/resources/Claim/Insurance.js +58 -0
  56. package/src/components/resources/Claim/Item.js +79 -0
  57. package/src/components/resources/Claim/Items.js +29 -0
  58. package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
  59. package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
  60. package/src/components/resources/ClaimResponse/ClaimResponse.js +137 -83
  61. package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
  62. package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
  63. package/src/components/resources/ClaimResponse/Item.js +44 -9
  64. package/src/components/resources/ClaimResponse/Items.js +5 -4
  65. package/src/components/resources/Condition/Condition.js +3 -3
  66. package/src/components/resources/Condition/Condition.test.js +37 -4
  67. package/src/components/resources/Coverage/Coverage.js +97 -69
  68. package/src/components/resources/Coverage/Coverage.stories.js +31 -5
  69. package/src/components/resources/Coverage/Coverage.test.js +111 -4
  70. package/src/components/resources/Device/Device.js +2 -1
  71. package/src/components/resources/Device/Device.stories.js +33 -5
  72. package/src/components/resources/Device/Device.test.js +108 -1
  73. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
  74. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +5 -4
  75. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +107 -1
  76. package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
  77. package/src/components/resources/DocumentReference/DocumentReference.stories.js +3 -2
  78. package/src/components/resources/DocumentReference/DocumentReference.test.js +113 -1
  79. package/src/components/resources/Encounter/Encounter.js +2 -1
  80. package/src/components/resources/Encounter/Encounter.test.js +36 -1
  81. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +2 -0
  82. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
  83. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +7 -2
  84. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +3 -2
  85. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +108 -1
  86. package/src/components/resources/Generic/Generic.js +20 -7
  87. package/src/components/resources/Generic/Generic.stories.js +2 -1
  88. package/src/components/resources/Generic/Generic.test.js +26 -7
  89. package/src/components/resources/Goal/Goal.js +3 -5
  90. package/src/components/resources/Goal/Goal.stories.js +5 -4
  91. package/src/components/resources/Goal/Goal.test.js +101 -1
  92. package/src/components/resources/Immunization/Immunization.js +2 -2
  93. package/src/components/resources/Immunization/Immunization.test.js +36 -1
  94. package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
  95. package/src/components/resources/List/Entries.js +3 -3
  96. package/src/components/resources/List/List.js +135 -88
  97. package/src/components/resources/List/List.stories.js +38 -5
  98. package/src/components/resources/List/List.test.js +105 -1
  99. package/src/components/resources/Location/Location.js +65 -47
  100. package/src/components/resources/Location/Location.stories.js +11 -4
  101. package/src/components/resources/Location/Location.test.js +106 -4
  102. package/src/components/resources/Medication/Medication.js +91 -51
  103. package/src/components/resources/Medication/Medication.stories.js +37 -7
  104. package/src/components/resources/Medication/Medication.test.js +113 -4
  105. package/src/components/resources/MedicationAdministration/MedicationAdministration.js +86 -62
  106. package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
  107. package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
  108. package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
  109. package/src/components/resources/MedicationDispense/MedicationDispense.js +68 -68
  110. package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
  111. package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
  112. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +115 -66
  113. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
  114. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
  115. package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -4
  116. package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +1 -2
  117. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +102 -4
  118. package/src/components/resources/MedicationRequest/MedicationRequest.js +3 -4
  119. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +11 -6
  120. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +100 -4
  121. package/src/components/resources/MedicationStatement/MedicationDosage.js +2 -2
  122. package/src/components/resources/MedicationStatement/MedicationStatement.js +8 -2
  123. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +5 -4
  124. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +108 -1
  125. package/src/components/resources/Observation/Observation.js +2 -1
  126. package/src/components/resources/Observation/Observation.test.js +30 -1
  127. package/src/components/resources/Organization/Organization.js +56 -37
  128. package/src/components/resources/Organization/Organization.stories.js +15 -2
  129. package/src/components/resources/Organization/Organization.test.js +109 -1
  130. package/src/components/resources/Patient/Patient.js +2 -0
  131. package/src/components/resources/Patient/Patient.test.js +31 -2
  132. package/src/components/resources/Practitioner/Practitioner.js +2 -1
  133. package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
  134. package/src/components/resources/PractitionerRole/PractitionerRole.js +50 -29
  135. package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
  136. package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
  137. package/src/components/resources/Procedure/Procedure.js +2 -2
  138. package/src/components/resources/Procedure/Procedure.test.js +30 -1
  139. package/src/components/resources/Questionnaire/Group.js +53 -0
  140. package/src/components/resources/Questionnaire/Items.js +45 -0
  141. package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
  142. package/src/components/resources/Questionnaire/Questionnaire.js +31 -170
  143. package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
  144. package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
  145. package/src/components/resources/Questionnaire/Questions.js +40 -0
  146. package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
  147. package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
  148. package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
  149. package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
  150. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
  151. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +52 -236
  152. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
  153. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
  154. package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
  155. package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
  156. package/src/components/resources/ReferralRequest/ReferralRequest.js +65 -40
  157. package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
  158. package/src/components/resources/RelatedPerson/RelatedPerson.js +151 -0
  159. package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -0
  160. package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
  161. package/src/components/resources/RelatedPerson/index.js +3 -0
  162. package/src/components/resources/ResearchStudy/ResearchStudy.js +160 -130
  163. package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
  164. package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
  165. package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
  166. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
  167. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
  168. package/src/components/ui/index.js +32 -12
  169. package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
  170. package/src/fixtures/example-icons.jsx +81 -11
  171. package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
  172. package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
  173. package/src/style.scss +3 -1
@@ -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 CareTeam from './CareTeam';
5
5
  import fhirVersions from '../fhirResourceVersions';
@@ -8,7 +8,80 @@ import stu3Example1 from '../../../fixtures/stu3/resources/careTeam/example1.jso
8
8
  import stu3Example2 from '../../../fixtures/stu3/resources/careTeam/example2.json';
9
9
  import r4Example1 from '../../../fixtures/r4/resources/careTeam/example1.json';
10
10
 
11
+ import fhirIcons from '../../../fixtures/example-icons';
12
+
11
13
  describe('should render the CareTeam component properly', () => {
14
+ it('component without a fhirIcons props should render a default icon', () => {
15
+ const defaultProps = {
16
+ fhirVersion: fhirVersions.STU3,
17
+ fhirResource: stu3Example1,
18
+ };
19
+
20
+ const { getByAltText } = render(<CareTeam {...defaultProps} />);
21
+ const headerIcon = getByAltText('care team');
22
+
23
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
24
+ });
25
+
26
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
27
+ const defaultProps = {
28
+ fhirVersion: fhirVersions.STU3,
29
+ fhirResource: stu3Example1,
30
+ fhirIcons: false,
31
+ };
32
+
33
+ const { getByTestId } = render(<CareTeam {...defaultProps} />);
34
+ const headerIcon = getByTestId('placeholder');
35
+
36
+ expect(headerIcon).toBeTruthy();
37
+ });
38
+
39
+ it('component with the img as a fhirIcons props should render an img', () => {
40
+ const defaultProps = {
41
+ fhirVersion: fhirVersions.STU3,
42
+ fhirResource: stu3Example1,
43
+ fhirIcons: (
44
+ <img
45
+ src={require('../assets/containers/CareTeam/care-team.svg')}
46
+ alt="group of people"
47
+ />
48
+ ),
49
+ };
50
+
51
+ const { getByAltText } = render(<CareTeam {...defaultProps} />);
52
+ const headerIcon = getByAltText('group of people');
53
+
54
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
55
+ });
56
+
57
+ it('component with the resources object as a fhirIcons props should render an img', () => {
58
+ const defaultProps = {
59
+ fhirVersion: fhirVersions.STU3,
60
+ fhirResource: stu3Example1,
61
+ fhirIcons: fhirIcons,
62
+ };
63
+
64
+ const { getByAltText } = render(<CareTeam {...defaultProps} />);
65
+ const headerIcon = getByAltText('group of people');
66
+
67
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
68
+ });
69
+
70
+ it('component with the url as a fhirIcons props should render an img', () => {
71
+ const avatarSrc =
72
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
73
+ const defaultProps = {
74
+ fhirVersion: fhirVersions.STU3,
75
+ fhirResource: stu3Example1,
76
+ fhirIcons: avatarSrc,
77
+ };
78
+
79
+ const { getByAltText } = render(<CareTeam {...defaultProps} />);
80
+ const headerIcon = getByAltText('header icon');
81
+
82
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
83
+ });
84
+
12
85
  it('should render with STU3 source data', () => {
13
86
  const defaultProps = {
14
87
  fhirResource: stu3Example1,
@@ -117,4 +190,39 @@ describe('should render the CareTeam component properly', () => {
117
190
  );
118
191
  expect(periodEnds).toEqual(['-', '1/1/2013']);
119
192
  });
193
+
194
+ it('should fire custom onClick function', () => {
195
+ const defaultProps = {
196
+ fhirResource: r4Example1,
197
+ fhirVersion: fhirVersions.R4,
198
+ };
199
+
200
+ const onClick = jest.fn();
201
+ const { getByRole } = render(
202
+ <CareTeam {...defaultProps} onClick={onClick} />,
203
+ );
204
+ const accordion = getByRole('button');
205
+ fireEvent.click(accordion);
206
+
207
+ const attribute = accordion.getAttribute('data-bs-toggle');
208
+ expect(attribute).not.toEqual('collapse');
209
+ expect(onClick).toHaveBeenCalled();
210
+ });
211
+
212
+ it('should not fire custom onClick function', () => {
213
+ const defaultProps = {
214
+ fhirResource: r4Example1,
215
+ fhirVersion: fhirVersions.R4,
216
+ };
217
+
218
+ const onClick = 'test';
219
+ const { getByRole } = render(
220
+ <CareTeam {...defaultProps} onClick={onClick} />,
221
+ );
222
+ const accordion = getByRole('button');
223
+ fireEvent.click(accordion);
224
+
225
+ const attribute = accordion.getAttribute('data-bs-toggle');
226
+ expect(attribute).toEqual('collapse');
227
+ });
120
228
  });
@@ -20,7 +20,7 @@ const CareTeamParticipants = props => {
20
20
  <TableHeader>End</TableHeader>
21
21
  </TableRow>
22
22
  </thead>
23
- <tbody>{allParticipants}</tbody>
23
+ <tbody className="border-top-0">{allParticipants}</tbody>
24
24
  </Table>
25
25
  </ValueSection>
26
26
  );
@@ -0,0 +1,55 @@
1
+ import {
2
+ MissingValue,
3
+ Table,
4
+ TableCell,
5
+ TableHeader,
6
+ TableRow,
7
+ ValueSection,
8
+ } from '../../ui';
9
+ import Reference from '../../datatypes/Reference';
10
+ import Coding from '../../datatypes/Coding';
11
+ import React from 'react';
12
+
13
+ const CareTeam = ({ careTeam }) => {
14
+ return (
15
+ <ValueSection label="Care Team" data-testid="careTeam" marginTop>
16
+ <Table>
17
+ <thead>
18
+ <TableRow>
19
+ <TableHeader>Provider</TableHeader>
20
+ <TableHeader>Role</TableHeader>
21
+ <TableHeader>Qualification</TableHeader>
22
+ </TableRow>
23
+ </thead>
24
+ <tbody className="border-top-0">
25
+ {careTeam.map((member, idx) => (
26
+ <TableRow key={idx}>
27
+ <TableCell data-testid="careTeam.provider" className="col-md-4">
28
+ <Reference fhirData={member.provider} />
29
+ </TableCell>
30
+ <TableCell data-testid="careTeam.role" className="col-md-4">
31
+ {member.role ? (
32
+ <Coding fhirData={member.role} />
33
+ ) : (
34
+ <MissingValue />
35
+ )}
36
+ </TableCell>
37
+ <TableCell
38
+ data-testid="careTeam.qualification"
39
+ className="col-md-4"
40
+ >
41
+ {careTeam.qualification ? (
42
+ <Coding fhirData={member.qualification} />
43
+ ) : (
44
+ <MissingValue />
45
+ )}
46
+ </TableCell>
47
+ </TableRow>
48
+ ))}
49
+ </tbody>
50
+ </Table>
51
+ </ValueSection>
52
+ );
53
+ };
54
+
55
+ export default CareTeam;
@@ -1,12 +1,3 @@
1
- .fhir-resource__Claim__item-level {
2
- height: 100%;
3
- height: 50px;
4
- margin: -12px;
5
- display: flex;
6
- }
7
-
8
- .fhir-resource__Claim__item-level-fill {
9
- width: 10px;
10
- height: 100%;
11
- background: #dee2e6;
1
+ .table-expandable-row {
2
+ --bs-table-striped-bg: #eef1f3;
12
3
  }