fhir-react 0.3.1 → 0.3.5

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 (83) hide show
  1. package/README.md +85 -2
  2. package/build/bootstrap-reboot.min.css +8 -2
  3. package/build/index.js +7 -14
  4. package/build/style.css +26 -239
  5. package/package.json +3 -2
  6. package/src/assets/containers/Binary/binary.svg +9 -0
  7. package/src/assets/containers/Patient/patient.svg +6 -0
  8. package/src/components/containers/Accordion/Accordion.js +17 -12
  9. package/src/components/datatypes/Annotation/Annotation.js +4 -4
  10. package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
  11. package/src/components/datatypes/Coding/Coding.css +0 -1
  12. package/src/components/datatypes/HeaderIcon/HeaderIcon.js +67 -22
  13. package/src/components/datatypes/Reference/Reference.css +3 -0
  14. package/src/components/datatypes/Reference/Reference.js +2 -0
  15. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +87 -76
  16. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +11 -1
  17. package/src/components/resources/Appointment/Appointment.js +3 -3
  18. package/src/components/resources/Appointment/Appointment.stories.js +28 -5
  19. package/src/components/resources/Appointment/Appointment.test.js +72 -0
  20. package/src/components/resources/Binary/Binary.js +31 -20
  21. package/src/components/resources/Binary/Binary.stories.js +6 -5
  22. package/src/components/resources/CarePlan/CarePlan.js +111 -96
  23. package/src/components/resources/CarePlan/CarePlan.test.js +2 -2
  24. package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
  25. package/src/components/resources/Condition/Condition.js +1 -2
  26. package/src/components/resources/Condition/Condition.stories.js +9 -19
  27. package/src/components/resources/Condition/Condition.test.js +71 -1
  28. package/src/components/resources/Device/Device.js +54 -34
  29. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +53 -43
  30. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +7 -1
  31. package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
  32. package/src/components/resources/DocumentReference/DocumentReference.stories.js +4 -0
  33. package/src/components/resources/Encounter/Encounter.js +3 -4
  34. package/src/components/resources/Encounter/Encounter.stories.js +27 -5
  35. package/src/components/resources/Encounter/Encounter.test.js +72 -0
  36. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +26 -10
  37. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +8 -0
  38. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +80 -3
  39. package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +21 -6
  40. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
  41. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +4 -0
  42. package/src/components/resources/Goal/Goal.js +104 -85
  43. package/src/components/resources/Goal/Goal.stories.js +37 -7
  44. package/src/components/resources/Goal/Goal.test.js +1 -3
  45. package/src/components/resources/Immunization/Immunization.js +1 -2
  46. package/src/components/resources/Immunization/Immunization.stories.js +6 -9
  47. package/src/components/resources/Immunization/Immunization.test.js +71 -1
  48. package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
  49. package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +2 -1
  50. package/src/components/resources/MedicationRequest/MedicationRequest.js +65 -43
  51. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +16 -5
  52. package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
  53. package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
  54. package/src/components/resources/MedicationStatement/MedicationStatement.js +65 -118
  55. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +6 -0
  56. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +31 -6
  57. package/src/components/resources/Observation/Observation.js +3 -3
  58. package/src/components/resources/Observation/Observation.stories.js +14 -5
  59. package/src/components/resources/Observation/Observation.test.js +67 -0
  60. package/src/components/resources/Patient/Patient.js +9 -6
  61. package/src/components/resources/Patient/Patient.stories.js +12 -5
  62. package/src/components/resources/Patient/Patient.test.js +67 -0
  63. package/src/components/resources/Practitioner/Practitioner.js +3 -13
  64. package/src/components/resources/Practitioner/Practitioner.stories.js +19 -3
  65. package/src/components/resources/Practitioner/Practitioner.test.js +72 -0
  66. package/src/components/resources/Procedure/Procedure.js +1 -2
  67. package/src/components/resources/Procedure/Procedure.stories.js +11 -5
  68. package/src/components/resources/Procedure/Procedure.test.js +71 -1
  69. package/src/components/resources/ResourceCategory/ResourceCategory.js +6 -3
  70. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +1 -1
  71. package/src/components/supportedFhirResourceList.js +2 -0
  72. package/src/components/ui/bootstrap-reboot.min.css +8 -2
  73. package/src/components/ui/index.js +44 -25
  74. package/src/fixtures/example-icons.jsx +55 -10
  75. package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExample.json +18 -2
  76. package/src/index.js +1 -0
  77. package/src/style.scss +1 -0
  78. package/src/utils/convertCamelCaseToSentence.js +9 -0
  79. package/src/utils/convertCamelCaseToSentence.test.js +9 -0
  80. package/src/utils/formatDate.js +6 -4
  81. package/webpack.config.js +10 -1
  82. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
  83. package/src/components/resources/CarePlan/CarePlan.css +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fhir-react",
3
- "version": "0.3.1",
3
+ "version": "0.3.5",
4
4
  "description": "React component library for displaying FHIR Resources ",
5
5
  "main": "build/index.js",
6
6
  "peerDependencies": {
@@ -17,7 +17,8 @@
17
17
  "md5": "^2.2.1",
18
18
  "pretty-bytes": "^5.3.0",
19
19
  "prop-types": "^15.7.2",
20
- "react": "^17.0.1"
20
+ "react": "^17.0.1",
21
+ "svg-url-loader": "^7.1.1"
21
22
  },
22
23
  "scripts": {
23
24
  "test": "NODE_ENV=test jest",
@@ -0,0 +1,9 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M5 20H15C15.5523 20 16 19.5523 16 19V8.72076C16 8.29033 15.7246 7.90819 15.3162 7.77208L13.5208 7.17359C13.1964 7.06547 12.9498 6.79914 12.8669 6.46744L12.4394 4.75746C12.3281 4.3123 11.9281 4 11.4692 4H5C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20Z" fill="#0D6EFD" stroke="#0D6EFD"/>
3
+ <mask id="path-2-outside-1_2206_5395" maskUnits="userSpaceOnUse" x="11" y="3" width="6" height="6" fill="black">
4
+ <rect fill="white" x="11" y="3" width="6" height="6"/>
5
+ <path d="M12 4V7.18534C12 7.4014 12.0858 7.60861 12.2386 7.76139C12.3914 7.91417 12.5986 8 12.8147 8H16"/>
6
+ </mask>
7
+ <path d="M12 4V7.18534C12 7.4014 12.0858 7.60861 12.2386 7.76139C12.3914 7.91417 12.5986 8 12.8147 8H16" fill="#6EA8FE"/>
8
+ <path d="M12 4V7.18534C12 7.4014 12.0858 7.60861 12.2386 7.76139C12.3914 7.91417 12.5986 8 12.8147 8H16" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" mask="url(#path-2-outside-1_2206_5395)"/>
9
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0 12C0 8.27247 0 6.4087 0.608964 4.93853C1.42092 2.97831 2.97831 1.42092 4.93853 0.608964C6.4087 0 8.27247 0 12 0C15.7275 0 17.5913 0 19.0615 0.608964C21.0217 1.42092 22.5791 2.97831 23.391 4.93853C24 6.4087 24 8.27247 24 12C24 15.7275 24 17.5913 23.391 19.0615C22.5791 21.0217 21.0217 22.5791 19.0615 23.391C17.5913 24 15.7275 24 12 24C8.27247 24 6.4087 24 4.93853 23.391C2.97831 22.5791 1.42092 21.0217 0.608964 19.0615C0 17.5913 0 15.7275 0 12Z" fill="#F8F9FA"/>
3
+ <path d="M12 11C13.933 11 15.5 9.433 15.5 7.5C15.5 5.567 13.933 4 12 4C10.067 4 8.5 5.567 8.5 7.5C8.5 9.433 10.067 11 12 11Z" stroke="#3D8BFD" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M9.5 5C10.0015 5.63268 10.6029 6.13588 11.268 6.47953C11.9332 6.82317 12.6485 7.00019 13.3712 7C14.1033 7.00035 14.8277 6.81885 15.5 6.46662" stroke="#3D8BFD" stroke-linejoin="round"/>
5
+ <path d="M4 20C4 18.1435 4.84285 16.363 6.34315 15.0503C7.84344 13.7375 9.87827 13 12 13C14.1217 13 16.1566 13.7375 17.6569 15.0503C19.1571 16.363 20 18.1435 20 20" stroke="#3D8BFD" stroke-linecap="round" stroke-linejoin="round"/>
6
+ </svg>
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Chevron } from '../../ui';
3
+ import uniqueId from 'lodash/uniqueId';
3
4
 
4
5
  const CHEVRON_DOWN_COLOR = '#6f83a9';
5
6
  const CHEVRON_UP_COLOR = '#2a6fd7';
@@ -8,18 +9,22 @@ const Accordion = props => {
8
9
  const { headerContent, bodyContent } = props;
9
10
  const [rotate, setRotate] = useState(false);
10
11
  const handleAccordionClick = () => setRotate(!rotate);
12
+ const accordionId = uniqueId(
13
+ `accordion-type-${headerContent.props.resourceName || 'default'}-`,
14
+ );
11
15
 
12
16
  const isAccordionOpenable = () => {
13
- let childrenCondition = false;
14
- let tableDataCondition = false;
15
- if (bodyContent.props.children)
16
- childrenCondition = bodyContent.props.children.length > 0;
17
- if (bodyContent.props.tableData)
18
- tableDataCondition =
19
- bodyContent.props.tableData.filter(x => 'data' in x && x.data).length >
20
- 0;
17
+ const tableDataCondition =
18
+ bodyContent.props.tableData &&
19
+ bodyContent.props.tableData.filter(x => 'data' in x && x.data).length > 0;
20
+ const childrenCondition =
21
+ bodyContent.props.children &&
22
+ (bodyContent.props.children.length > 0 || bodyContent.props.children);
23
+ if (tableDataCondition || childrenCondition) {
24
+ return true;
25
+ }
21
26
 
22
- return childrenCondition || tableDataCondition;
27
+ return false;
23
28
  };
24
29
 
25
30
  const getChevron = () =>
@@ -49,9 +54,9 @@ const Accordion = props => {
49
54
  isAccordionOpenable() ? '' : 'pe-none'
50
55
  }`}
51
56
  type="button"
52
- data-bs-target="#collapseTarget"
57
+ data-bs-target={`#${accordionId}`}
53
58
  data-bs-toggle={isAccordionOpenable() ? 'collapse' : null}
54
- aria-controls="collapseTarget"
59
+ aria-controls={accordionId}
55
60
  aria-expanded="false"
56
61
  onClick={handleAccordionClick}
57
62
  >
@@ -65,7 +70,7 @@ const Accordion = props => {
65
70
  </div>
66
71
  <div
67
72
  className="fhir-container__Accordion__data accordion-collapse collapse"
68
- id="collapseTarget"
73
+ id={accordionId}
69
74
  >
70
75
  <div className="fhir-container__Accordion__data-text accordion-body ps-4 pt-3 pe-4 border-top">
71
76
  {bodyContent}
@@ -7,13 +7,13 @@ const Annotation = props => {
7
7
  return null;
8
8
  }
9
9
  return (
10
- <ul className="fhir-datatype__Annotation">
10
+ <div className="fhir-datatype__Annotation">
11
11
  {fhirData.map((item, i) => (
12
- <li className="fhir-datatype__Annotation__item" key={`item-${i}`}>
12
+ <p className="fhir-datatype__Annotation__item" key={`item-${i}`}>
13
13
  {item.text}
14
- </li>
14
+ </p>
15
15
  ))}
16
- </ul>
16
+ </div>
17
17
  );
18
18
  };
19
19
 
@@ -1,4 +1,7 @@
1
+ .fhir-datatype__CodeableConcept {
2
+ flex: 1;
3
+ }
4
+
1
5
  .fhir-datatype__CodeableConcept-item-label {
2
- font-size: 80%;
3
6
  font-weight: 400;
4
7
  }
@@ -1,4 +1,3 @@
1
1
  .fhir-datatype__Coding__code {
2
- font-style: italic;
3
2
  cursor: help;
4
3
  }
@@ -1,31 +1,76 @@
1
1
  import React from 'react';
2
- import { isUrl } from '../../../utils/isUrl';
2
+ import { useState, useEffect, useRef } from 'react';
3
+ import { convertCamelCaseToSentence } from '../../../utils/convertCamelCaseToSentence';
3
4
 
4
- const HeaderIcon = ({ headerIcon }) => {
5
- const PlaceholderImage = () => {
6
- return <div className="header-icon__placeholder rounded-1" />;
5
+ const PlaceholderImage = () => {
6
+ return (
7
+ <div
8
+ className="header-icon__placeholder rounded-1"
9
+ data-testid="placeholder"
10
+ />
11
+ );
12
+ };
13
+
14
+ const defaultIconOrPlaceholder = (headerIcon, resourceName) => {
15
+ let imageSrc;
16
+ const svgFileName =
17
+ resourceName && convertCamelCaseToSentence(resourceName).replace(/ /g, '-');
18
+ try {
19
+ imageSrc = require(`../../../assets/containers/${resourceName}/${svgFileName}.svg`);
20
+ } catch (err) {
21
+ imageSrc = null;
22
+ }
23
+ return imageSrc && headerIcon !== false ? (
24
+ <img
25
+ className="header-icon__image"
26
+ src={imageSrc}
27
+ alt={convertCamelCaseToSentence(resourceName)}
28
+ />
29
+ ) : (
30
+ <PlaceholderImage />
31
+ );
32
+ };
33
+
34
+ const useImageError = () => {
35
+ const [error, setError] = useState(false);
36
+ const ref = useRef();
37
+
38
+ const onError = () => {
39
+ setError(true);
7
40
  };
8
41
 
9
- const Image = () => {
10
- if (
11
- React.isValidElement(headerIcon) &&
12
- typeof headerIcon.type === 'string'
13
- ) {
14
- return headerIcon;
42
+ useEffect(() => {
43
+ if (ref.current && ref.current.error) {
44
+ onError();
15
45
  }
16
- if (isUrl(headerIcon)) {
17
- return (
18
- <img
19
- className="header-icon__image"
20
- src={headerIcon}
21
- alt="header icon"
22
- />
23
- );
24
- }
25
- return <PlaceholderImage />;
26
- };
46
+ });
47
+
48
+ return [ref, error, onError];
49
+ };
50
+
51
+ const HeaderIcon = ({ headerIcon, resourceName }) => {
52
+ const [ref, error, onError] = useImageError();
53
+ if (!headerIcon) {
54
+ return defaultIconOrPlaceholder(headerIcon, resourceName);
55
+ }
56
+ if (headerIcon[resourceName]) {
57
+ return headerIcon[resourceName];
58
+ }
59
+ if (React.isValidElement(headerIcon) && typeof headerIcon.type === 'string') {
60
+ return headerIcon;
61
+ }
27
62
 
28
- return <Image />;
63
+ return !error ? (
64
+ <img
65
+ ref={ref}
66
+ onError={onError}
67
+ className="header-icon__image"
68
+ src={headerIcon}
69
+ alt="header icon"
70
+ />
71
+ ) : (
72
+ defaultIconOrPlaceholder(headerIcon, resourceName)
73
+ );
29
74
  };
30
75
 
31
76
  export default HeaderIcon;
@@ -0,0 +1,3 @@
1
+ .fhir-datatype__Reference {
2
+ word-break: break-all;
3
+ }
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import _get from 'lodash/get';
3
3
 
4
+ import './Reference.css';
5
+
4
6
  const Reference = props => {
5
7
  const { fhirData } = props;
6
8
  const display = _get(fhirData, 'display');
@@ -3,23 +3,15 @@ import PropTypes from 'prop-types';
3
3
 
4
4
  import _get from 'lodash/get';
5
5
 
6
+ import Accordion from '../../containers/Accordion';
6
7
  import Reference from '../../datatypes/Reference';
7
8
  import Coding from '../../datatypes/Coding';
8
9
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
9
10
  import fhirVersions from '../fhirResourceVersions';
10
11
  import Date from '../../datatypes/Date';
11
12
  import Annotation from '../../datatypes/Annotation';
12
- import './AllergyIntolerance.css';
13
-
14
- import {
15
- Root,
16
- Header,
17
- Title,
18
- Badge,
19
- BadgeSecondary,
20
- Body,
21
- Value,
22
- } from '../../ui';
13
+
14
+ import { Root, Header, Badge, BadgeSecondary, Body } from '../../ui';
23
15
  import CodeableConcept from '../../datatypes/CodeableConcept';
24
16
 
25
17
  const commonDTO = fhirResource => {
@@ -132,7 +124,8 @@ const resourceDTO = (fhirVersion, fhirResource) => {
132
124
  };
133
125
 
134
126
  const AllergyIntolerance = props => {
135
- const { fhirResource, fhirVersion } = props;
127
+ const { fhirResource, fhirVersion, fhirIcons } = props;
128
+ const headerIcon = fhirIcons && fhirIcons['AllergyIntolerance'];
136
129
  let fhirResourceData = {};
137
130
  try {
138
131
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -157,72 +150,90 @@ const AllergyIntolerance = props => {
157
150
  patient,
158
151
  } = fhirResourceData;
159
152
 
153
+ const tableData = [
154
+ {
155
+ label: 'Substance',
156
+ testId: 'substance',
157
+ data:
158
+ hasSubstanceCoding &&
159
+ substanceCoding.map((item, i) => (
160
+ <Coding key={`item-${i}`} fhirData={item} />
161
+ )),
162
+ status: hasSubstanceCoding,
163
+ },
164
+ {
165
+ label: 'Type',
166
+ testId: 'type',
167
+ data: type,
168
+ status: type,
169
+ },
170
+ {
171
+ label: 'Category',
172
+ testId: 'category',
173
+ data: category,
174
+ status: category,
175
+ },
176
+ {
177
+ label: 'Patient',
178
+ testId: 'patient',
179
+ data: <Reference fhirData={patient} />,
180
+ status: patient,
181
+ },
182
+ {
183
+ label: 'Asserted by',
184
+ testId: 'asserter',
185
+ data: asserter && <Reference fhirData={asserter} />,
186
+ status: asserter,
187
+ },
188
+ {
189
+ label: 'Manifestation',
190
+ testId: 'manifestation',
191
+ data: reaction.map((reaction, i) => {
192
+ const manifestations = _get(reaction, 'manifestation', []);
193
+ const severity = _get(reaction, 'severity');
194
+ return manifestations.map((manifestation, j) => {
195
+ return (
196
+ <div key={`item-${i}${j}`} className="d-flex">
197
+ <CodeableConcept fhirData={manifestation} />
198
+ {severity && (
199
+ <span className="ms-4">
200
+ <BadgeSecondary>{severity}</BadgeSecondary>
201
+ </span>
202
+ )}
203
+ </div>
204
+ );
205
+ });
206
+ }),
207
+ status: hasReaction,
208
+ },
209
+ {
210
+ label: 'Notes',
211
+ testId: 'hasNote',
212
+ data: hasNote && <Annotation fhirData={note} />,
213
+ status: hasNote,
214
+ },
215
+ ];
216
+
160
217
  return (
161
218
  <Root name="AllergyIntolerance">
162
- <Header>
163
- <Title>{title}</Title>
164
- {status && <Badge data-testid="status">{status}</Badge>}
165
- {recordedDate && (
166
- <BadgeSecondary data-testid="recordedDate">
167
- recorded on <Date fhirData={recordedDate} />
168
- </BadgeSecondary>
169
- )}
170
- </Header>
171
- <Body>
172
- {hasSubstanceCoding && (
173
- <Value label="Substance" data-testid="substance">
174
- {substanceCoding.map((item, i) => (
175
- <div key={`item-${i}`}>
176
- <Coding fhirData={item} />
177
- </div>
178
- ))}
179
- </Value>
180
- )}
181
- {type && (
182
- <Value label="Type" data-testid="type">
183
- {type}
184
- </Value>
185
- )}
186
- {category && (
187
- <Value label="Category" data-testid="category">
188
- {category}
189
- </Value>
190
- )}
191
- {patient && (
192
- <Value label="Patient" data-testid="patient">
193
- <Reference fhirData={patient} />
194
- </Value>
195
- )}
196
- {asserter && (
197
- <Value label="Asserted by" data-testid="asserter">
198
- <Reference fhirData={asserter} />
199
- </Value>
200
- )}
201
- {hasReaction && (
202
- <Value label="Manifestation" data-testid="manifestation">
203
- {reaction.map((reaction, i) => {
204
- const manifestations = _get(reaction, 'manifestation', []);
205
- const severity = _get(reaction, 'severity');
206
- return manifestations.map((manifestation, j) => {
207
- return (
208
- <div
209
- key={`item-${i}${j}`}
210
- className="fhir-resource__AllergyIntolerance__grouping"
211
- >
212
- <CodeableConcept fhirData={manifestation} />
213
- {severity && <BadgeSecondary>{severity}</BadgeSecondary>}
214
- </div>
215
- );
216
- });
217
- })}
218
- </Value>
219
- )}
220
- {hasNote && (
221
- <Value label="Notes" data-testid="hasNote">
222
- <Annotation fhirData={note} />
223
- </Value>
224
- )}
225
- </Body>
219
+ <Accordion
220
+ headerContent={
221
+ <Header
222
+ resourceName="AllergyIntollerance"
223
+ badges={status && <Badge data-testid="status">{status}</Badge>}
224
+ title={title}
225
+ icon={headerIcon}
226
+ rightAdditionalContent={
227
+ recordedDate && (
228
+ <BadgeSecondary data-testid="recordedDate">
229
+ recorded on <Date fhirData={recordedDate} />
230
+ </BadgeSecondary>
231
+ )
232
+ }
233
+ />
234
+ }
235
+ bodyContent={<Body tableData={tableData} />}
236
+ />
226
237
  </Root>
227
238
  );
228
239
  };
@@ -10,6 +10,7 @@ import example2AllergyIntoleranceSTU3 from '../../../fixtures/stu3/resources/all
10
10
  import example1AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example1.json';
11
11
  import example2AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example2.json';
12
12
  import example3AllergyIntoleranceR4 from '../../../fixtures/r4/resources/allergyIntolerance/example3.json';
13
+ import fhirIcons from '../../../fixtures/example-icons';
13
14
  import fhirVersions from '../fhirResourceVersions';
14
15
 
15
16
  export default { title: 'AllergyIntolerance' };
@@ -20,6 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
20
21
  <AllergyIntolerance
21
22
  fhirVersion={fhirVersions.DSTU2}
22
23
  fhirResource={fhirResource}
24
+ fhirIcons={fhirIcons}
23
25
  />
24
26
  );
25
27
  };
@@ -30,6 +32,7 @@ export const Example2ofDSTU2 = () => {
30
32
  <AllergyIntolerance
31
33
  fhirVersion={fhirVersions.DSTU2}
32
34
  fhirResource={fhirResource}
35
+ fhirIcons={fhirIcons}
33
36
  />
34
37
  );
35
38
  };
@@ -40,6 +43,7 @@ export const ExampleDiagnosticReportSTU3 = () => {
40
43
  <AllergyIntolerance
41
44
  fhirVersion={fhirVersions.STU3}
42
45
  fhirResource={fhirResource}
46
+ fhirIcons={fhirIcons}
43
47
  />
44
48
  );
45
49
  };
@@ -50,6 +54,7 @@ export const Example2DiagnosticReportSTU3 = () => {
50
54
  <AllergyIntolerance
51
55
  fhirVersion={fhirVersions.STU3}
52
56
  fhirResource={fhirResource}
57
+ fhirIcons={fhirIcons}
53
58
  />
54
59
  );
55
60
  };
@@ -60,6 +65,7 @@ export const Example1R4 = () => {
60
65
  <AllergyIntolerance
61
66
  fhirVersion={fhirVersions.R4}
62
67
  fhirResource={fhirResource}
68
+ fhirIcons={fhirIcons}
63
69
  />
64
70
  );
65
71
  };
@@ -70,6 +76,7 @@ export const Example2R4 = () => {
70
76
  <AllergyIntolerance
71
77
  fhirVersion={fhirVersions.R4}
72
78
  fhirResource={fhirResource}
79
+ fhirIcons={fhirIcons}
73
80
  />
74
81
  );
75
82
  };
@@ -80,11 +87,14 @@ export const Example3R4 = () => {
80
87
  <AllergyIntolerance
81
88
  fhirVersion={fhirVersions.R4}
82
89
  fhirResource={fhirResource}
90
+ fhirIcons={fhirIcons}
83
91
  />
84
92
  );
85
93
  };
86
94
 
87
95
  export const ExampleWithoutFhirVersionProperty = () => {
88
96
  const fhirResource = object('Resource', example2AllergyIntoleranceSTU3);
89
- return <AllergyIntolerance fhirResource={fhirResource} />;
97
+ return (
98
+ <AllergyIntolerance fhirResource={fhirResource} fhirIcons={fhirIcons} />
99
+ );
90
100
  };
@@ -144,8 +144,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
144
144
  }
145
145
  };
146
146
 
147
- const Appointment = props => {
148
- const { fhirResource, fhirVersion } = props;
147
+ const Appointment = ({ fhirResource, fhirVersion, fhirIcons }) => {
149
148
  const {
150
149
  description,
151
150
  status,
@@ -208,7 +207,7 @@ const Appointment = props => {
208
207
  <Accordion
209
208
  headerContent={
210
209
  <Header
211
- resourceName={fhirResource.resourceName}
210
+ resourceName="Appointment"
212
211
  additionalContent={
213
212
  start && (
214
213
  <Value label="Start date" data-testid="headerStartDate">
@@ -218,6 +217,7 @@ const Appointment = props => {
218
217
  }
219
218
  badges={status && <Badge data-testid="status">{status}</Badge>}
220
219
  title={description}
220
+ icon={fhirIcons}
221
221
  />
222
222
  }
223
223
  bodyContent={
@@ -13,38 +13,61 @@ import example1AppointmentR4 from '../../../fixtures/r4/resources/appointment/ex
13
13
  import example2AppointmentR4 from '../../../fixtures/r4/resources/appointment/example2.json';
14
14
  import example3AppointmentR4 from '../../../fixtures/r4/resources/appointment/example3.json';
15
15
 
16
+ import fhirIcons from '../../../fixtures/example-icons';
17
+ import AppointmentIcon from '../../../assets/containers/Appointment/appointment.svg';
18
+
16
19
  export default { title: 'Appointment' };
17
20
 
18
21
  export const DefaultVisualizationDSTU2 = () => {
19
22
  const fhirResource = object('Resource', exampleAppointmentDSTU2);
20
23
  return (
21
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
24
+ <Appointment
25
+ fhirResource={fhirResource}
26
+ fhirVersion={fhirVersions.DSTU2}
27
+ fhirIcons={require('../../../assets/containers/Appointment/appointment.svg')}
28
+ />
22
29
  );
23
30
  };
24
31
 
25
32
  export const Example2OfDSTU2 = () => {
26
33
  const fhirResource = object('Resource', example2AppointmentDSTU2);
27
34
  return (
28
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.DSTU2} />
35
+ <Appointment
36
+ fhirResource={fhirResource}
37
+ fhirVersion={fhirVersions.DSTU2}
38
+ fhirIcons={AppointmentIcon}
39
+ />
29
40
  );
30
41
  };
31
42
 
32
43
  export const Example1OfSTU3 = () => {
33
44
  const fhirResource = object('Resource', example1AppointmentSTU3);
34
45
  return (
35
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />
46
+ <Appointment
47
+ fhirResource={fhirResource}
48
+ fhirVersion={fhirVersions.STU3}
49
+ fhirIcons={fhirIcons}
50
+ />
36
51
  );
37
52
  };
38
53
  export const Example2OfSTU3 = () => {
39
54
  const fhirResource = object('Resource', example2AppointmentSTU3);
40
55
  return (
41
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />
56
+ <Appointment
57
+ fhirResource={fhirResource}
58
+ fhirVersion={fhirVersions.STU3}
59
+ fhirIcons={false}
60
+ />
42
61
  );
43
62
  };
44
63
  export const Example3OfSTU3 = () => {
45
64
  const fhirResource = object('Resource', example3AppointmentSTU3);
46
65
  return (
47
- <Appointment fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />
66
+ <Appointment
67
+ fhirResource={fhirResource}
68
+ fhirVersion={fhirVersions.STU3}
69
+ fhirIcons={'random text'}
70
+ />
48
71
  );
49
72
  };
50
73