fhir-react 0.3.4 → 0.3.7

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 (84) hide show
  1. package/README.md +1 -1
  2. package/build/bootstrap-reboot.min.css +8 -2
  3. package/build/index.js +7 -7
  4. package/build/style.css +6 -6
  5. package/package.json +1 -1
  6. package/src/assets/containers/Binary/binary.svg +9 -0
  7. package/src/assets/containers/Coverage/coverage.svg +4 -0
  8. package/src/assets/containers/MedicationOrder/medication-order.svg +5 -0
  9. package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
  10. package/src/assets/containers/Organization/organization.svg +5 -0
  11. package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
  12. package/src/components/containers/Accordion/Accordion.js +10 -9
  13. package/src/components/datatypes/Annotation/Annotation.js +4 -4
  14. package/src/components/datatypes/Attachment/Attachment.css +5 -0
  15. package/src/components/datatypes/Attachment/Attachment.js +7 -2
  16. package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
  17. package/src/components/datatypes/Coding/Coding.css +0 -1
  18. package/src/components/datatypes/Identifier/Identifier.js +7 -3
  19. package/src/components/datatypes/Reference/Reference.css +3 -0
  20. package/src/components/datatypes/Reference/Reference.js +7 -1
  21. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +86 -77
  22. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +12 -1
  23. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +71 -0
  24. package/src/components/resources/Binary/Binary.js +30 -20
  25. package/src/components/resources/Binary/Binary.stories.js +12 -5
  26. package/src/components/resources/Binary/Binary.test.js +67 -0
  27. package/src/components/resources/CarePlan/CarePlan.js +111 -96
  28. package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
  29. package/src/components/resources/CarePlan/CarePlan.test.js +74 -2
  30. package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
  31. package/src/components/resources/Claim/CareTeam.js +55 -0
  32. package/src/components/resources/Claim/Claim.css +2 -11
  33. package/src/components/resources/Claim/Claim.js +157 -309
  34. package/src/components/resources/Claim/Claim.stories.js +37 -5
  35. package/src/components/resources/Claim/Claim.test.js +72 -0
  36. package/src/components/resources/Claim/Diagnosis.js +61 -0
  37. package/src/components/resources/Claim/Insurance.js +58 -0
  38. package/src/components/resources/Claim/Item.js +79 -0
  39. package/src/components/resources/Claim/Items.js +29 -0
  40. package/src/components/resources/Coverage/Coverage.js +96 -69
  41. package/src/components/resources/Coverage/Coverage.stories.js +31 -5
  42. package/src/components/resources/Coverage/Coverage.test.js +75 -3
  43. package/src/components/resources/Device/Device.js +54 -34
  44. package/src/components/resources/Device/Device.stories.js +33 -5
  45. package/src/components/resources/Device/Device.test.js +72 -0
  46. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +53 -43
  47. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +8 -1
  48. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +71 -0
  49. package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
  50. package/src/components/resources/DocumentReference/DocumentReference.stories.js +5 -0
  51. package/src/components/resources/DocumentReference/DocumentReference.test.js +71 -0
  52. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
  53. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +5 -0
  54. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +72 -0
  55. package/src/components/resources/Goal/Goal.js +103 -85
  56. package/src/components/resources/Goal/Goal.stories.js +38 -7
  57. package/src/components/resources/Goal/Goal.test.js +70 -3
  58. package/src/components/resources/Medication/Medication.js +90 -51
  59. package/src/components/resources/Medication/Medication.stories.js +37 -7
  60. package/src/components/resources/Medication/Medication.test.js +77 -3
  61. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +1 -1
  62. package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
  63. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +67 -0
  64. package/src/components/resources/MedicationRequest/MedicationRequest.js +64 -44
  65. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +21 -5
  66. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +67 -0
  67. package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
  68. package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
  69. package/src/components/resources/MedicationStatement/MedicationStatement.js +66 -118
  70. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +7 -0
  71. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +103 -6
  72. package/src/components/resources/Organization/Organization.js +55 -37
  73. package/src/components/resources/Organization/Organization.stories.js +15 -2
  74. package/src/components/resources/Organization/Organization.test.js +73 -0
  75. package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
  76. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
  77. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
  78. package/src/components/ui/bootstrap-reboot.min.css +8 -2
  79. package/src/components/ui/index.js +22 -4
  80. package/src/fixtures/example-icons.jsx +46 -11
  81. package/src/style.scss +1 -0
  82. package/src/utils/formatDate.js +6 -4
  83. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
  84. package/src/components/resources/CarePlan/CarePlan.css +0 -7
@@ -3,20 +3,13 @@ import PropTypes from 'prop-types';
3
3
  import Reference from '../../datatypes/Reference';
4
4
  import Coding from '../../datatypes/Coding';
5
5
  import Date from '../../datatypes/Date';
6
+ import Accordion from '../../containers/Accordion/Accordion';
6
7
  import _get from 'lodash/get';
7
8
  import _has from 'lodash/has';
8
9
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
9
10
  import fhirVersions from '../fhirResourceVersions';
10
11
 
11
- import {
12
- Root,
13
- Header,
14
- Title,
15
- Badge,
16
- BadgeSecondary,
17
- Body,
18
- Value,
19
- } from '../../ui';
12
+ import { Root, Header, Badge, Body, Value } from '../../ui';
20
13
 
21
14
  const commonDTO = fhirResource => {
22
15
  const title = _get(fhirResource, 'note[0].text', 'Goal');
@@ -107,7 +100,8 @@ const resourceDTO = (fhirVersion, fhirResource) => {
107
100
  };
108
101
 
109
102
  const Goal = props => {
110
- const { fhirResource, fhirVersion } = props;
103
+ const { fhirResource, fhirVersion, fhirIcons } = props;
104
+
111
105
  let fhirResourceData = {};
112
106
  try {
113
107
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -135,83 +129,107 @@ const Goal = props => {
135
129
  statusDate,
136
130
  } = fhirResourceData;
137
131
 
132
+ const tableData = [
133
+ {
134
+ label: 'Subject',
135
+ testId: 'subject',
136
+ data: subject && <Reference fhirData={subject} />,
137
+ status: subject,
138
+ },
139
+ {
140
+ label: 'Subject',
141
+ testId: 'statusDate',
142
+ data: statusDate && <Date fhirData={statusDate} />,
143
+ status: statusDate,
144
+ },
145
+ {
146
+ label: 'Description',
147
+ testId: 'description',
148
+ data: description,
149
+ status: description,
150
+ },
151
+ {
152
+ label: 'Category',
153
+ testId: 'category',
154
+ data:
155
+ hasCategory &&
156
+ category.map((item, i) => {
157
+ const coding = _get(item, 'coding', []);
158
+ if (!Array.isArray(coding)) {
159
+ return null;
160
+ }
161
+ return coding.map((codingItem, j) => (
162
+ <Coding key={`coding-item-${j}`} fhirData={codingItem} />
163
+ ));
164
+ }),
165
+ status: hasCategory,
166
+ },
167
+ {
168
+ label: 'Universal Device Identifier',
169
+ testId: 'udi',
170
+ data: udi,
171
+ status: hasUdi,
172
+ },
173
+ {
174
+ label: 'Addresses',
175
+ testId: 'addresses',
176
+ data:
177
+ hasAddresses &&
178
+ addresses.map((address, i) => (
179
+ <Reference key={`address-item-${i}`} fhirData={address} />
180
+ )),
181
+ status: hasAddresses,
182
+ },
183
+ {
184
+ label: 'Priority',
185
+ testId: 'priority',
186
+ data: priority && <Coding fhirData={priority} />,
187
+ status: priority,
188
+ },
189
+ {
190
+ label: 'Author',
191
+ testId: 'author',
192
+ data: author && <Reference fhirData={author} />,
193
+ status: author,
194
+ },
195
+ {
196
+ label: 'Outcome',
197
+ testId: 'outcomeReference',
198
+ data:
199
+ outcomeReference &&
200
+ outcomeReference.map((item, i) => (
201
+ <Reference key={`outcome-reference-item-${i}`} fhirData={item} />
202
+ )),
203
+ status: outcomeReference,
204
+ },
205
+ {
206
+ label: 'Achievement Status',
207
+ testId: 'achievementStatus',
208
+ data: achievementStatus && <Coding fhirData={achievementStatus} />,
209
+ status: achievementStatus,
210
+ },
211
+ ];
212
+
138
213
  return (
139
214
  <Root name="Goal">
140
- <Header>
141
- <Title data-testid="title">{title}</Title>
142
- {hasStatus && <Badge data-testid="status">{status}</Badge>}
143
- {startDate && (
144
- <BadgeSecondary data-testid="statusSecondary">
145
- starting on {startDate}
146
- </BadgeSecondary>
147
- )}
148
- </Header>
149
- <Body>
150
- {subject && (
151
- <Value label="Subject" data-testid="subject">
152
- <Reference fhirData={subject} />
153
- </Value>
154
- )}
155
- {statusDate && (
156
- <Value label="Status Date" data-testid="statusDate">
157
- <Date fhirData={statusDate} />
158
- </Value>
159
- )}
160
- {description && (
161
- <Value label="Description" data-testid="description">
162
- {description}
163
- </Value>
164
- )}
165
- {hasCategory && (
166
- <Value label="Category" data-testid="category">
167
- {category.map((item, i) => {
168
- const coding = _get(item, 'coding', []);
169
- if (!Array.isArray(coding)) {
170
- return null;
171
- }
172
- return coding.map((codingItem, j) => (
173
- <div key={`item-${j}`}>
174
- <Coding fhirData={codingItem} />
175
- </div>
176
- ));
177
- })}
178
- </Value>
179
- )}
180
- {hasUdi && <Value label="Universal Device Identifier"> {udi}</Value>}
181
- {hasAddresses && (
182
- <Value label="Addresses" data-testid="addresses">
183
- {addresses.map((address, i) => {
184
- return (
185
- <div key={`item-${i}`}>
186
- <Reference fhirData={address} />
187
- </div>
188
- );
189
- })}
190
- </Value>
191
- )}
192
- {priority && (
193
- <Value label="Priority" data-testid="priority">
194
- <Coding fhirData={priority} />
195
- </Value>
196
- )}
197
- {author && (
198
- <Value label="Author" data-testid="author">
199
- <Reference fhirData={author} />
200
- </Value>
201
- )}
202
- {outcomeReference && (
203
- <Value label="Outcome" data-testid="outcomeReference">
204
- {outcomeReference.map((item, i) => (
205
- <Reference key={`item-${i}`} fhirData={item} />
206
- ))}
207
- </Value>
208
- )}
209
- {achievementStatus && (
210
- <Value label="Achievement Status" data-testid="achievementStatus">
211
- <Coding fhirData={achievementStatus} />
212
- </Value>
213
- )}
214
- </Body>
215
+ <Accordion
216
+ headerContent={
217
+ <Header
218
+ resourceName="Goal"
219
+ additionalContent={
220
+ startDate && (
221
+ <Value label="Started" data-testid="headerStartDate">
222
+ <Date fhirData={startDate} isBlack />
223
+ </Value>
224
+ )
225
+ }
226
+ badges={hasStatus && <Badge data-testid="status">{status}</Badge>}
227
+ icon={fhirIcons}
228
+ title={title}
229
+ />
230
+ }
231
+ bodyContent={<Body tableData={tableData} />}
232
+ />
215
233
  </Root>
216
234
  );
217
235
  };
@@ -2,13 +2,14 @@ import React from 'react';
2
2
  import { object } from '@storybook/addon-knobs';
3
3
 
4
4
  import Goal from './Goal';
5
-
5
+ import fhirIcons from '../../../fixtures/example-icons';
6
6
  import dstu2Example1 from '../../../fixtures/dstu2/resources/goal/example1.json';
7
7
  import dstu2Example2 from '../../../fixtures/dstu2/resources/goal/example2.json';
8
8
  import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
9
9
  import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
10
10
  import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
11
11
  import fhirVersions from '../fhirResourceVersions';
12
+ import GoalIcon from '../../../assets/containers/Goal/goal.svg';
12
13
 
13
14
  export default {
14
15
  title: 'Goal',
@@ -16,30 +17,60 @@ export default {
16
17
 
17
18
  export const DefaultVisualizationDSTU2 = () => {
18
19
  const fhirResource = object('Resource', dstu2Example1);
19
- return <Goal fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
20
+ return (
21
+ <Goal
22
+ fhirVersion={fhirVersions.DSTU2}
23
+ fhirResource={fhirResource}
24
+ fhirIcons={require('../../../assets/containers/Goal/goal.svg')}
25
+ />
26
+ );
20
27
  };
21
28
 
22
29
  export const Example2OfDSTU2 = () => {
23
30
  const fhirResource = object('Resource', dstu2Example2);
24
- return <Goal fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
31
+ return (
32
+ <Goal
33
+ fhirVersion={fhirVersions.DSTU2}
34
+ fhirResource={fhirResource}
35
+ fhirIcons={GoalIcon}
36
+ />
37
+ );
25
38
  };
26
39
 
27
40
  export const ExampleOfSTU3 = () => {
28
41
  const fhirResource = object('Resource', stu3Example1);
29
- return <Goal fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />;
42
+ return (
43
+ <Goal
44
+ fhirVersion={fhirVersions.STU3}
45
+ fhirResource={fhirResource}
46
+ fhirIcons={fhirIcons}
47
+ />
48
+ );
30
49
  };
31
50
 
32
51
  export const Example1OfR4 = () => {
33
52
  const fhirResource = object('Resource', r4Example1);
34
- return <Goal fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />;
53
+ return (
54
+ <Goal
55
+ fhirVersion={fhirVersions.R4}
56
+ fhirResource={fhirResource}
57
+ fhirIcons={false}
58
+ />
59
+ );
35
60
  };
36
61
 
37
62
  export const Example2OfR4 = () => {
38
63
  const fhirResource = object('Resource', r4Example2);
39
- return <Goal fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />;
64
+ return (
65
+ <Goal
66
+ fhirVersion={fhirVersions.R4}
67
+ fhirResource={fhirResource}
68
+ fhirIcons={'random text'}
69
+ />
70
+ );
40
71
  };
41
72
 
42
73
  export const ExampleWithoutFhirVersionProperty = () => {
43
74
  const fhirResource = object('Resource', stu3Example1);
44
- return <Goal fhirResource={fhirResource} />;
75
+ return <Goal fhirResource={fhirResource} fhirIcons={fhirIcons} />;
45
76
  };
@@ -7,8 +7,77 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/goal/example1.json'
7
7
  import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
8
8
  import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
9
9
  import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
10
+ import fhirIcons from '../../../fixtures/example-icons';
10
11
 
11
12
  describe('should render Goal component properly', () => {
13
+ it('component without a fhirIcons props should render a default icon', () => {
14
+ const defaultProps = {
15
+ fhirResource: dstu2Example1,
16
+ fhirVersion: fhirVersions.DSTU2,
17
+ };
18
+
19
+ const { getByAltText } = render(<Goal {...defaultProps} />);
20
+ const headerIcon = getByAltText('goal');
21
+
22
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
23
+ });
24
+
25
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
26
+ const defaultProps = {
27
+ fhirResource: dstu2Example1,
28
+ fhirVersion: fhirVersions.DSTU2,
29
+ fhirIcons: false,
30
+ };
31
+
32
+ const { getByTestId } = render(<Goal {...defaultProps} />);
33
+ const headerIcon = getByTestId('placeholder');
34
+
35
+ expect(headerIcon).toBeTruthy();
36
+ });
37
+
38
+ it('component with the img as a fhirIcons props should render an img', () => {
39
+ const defaultProps = {
40
+ fhirResource: dstu2Example1,
41
+ fhirVersion: fhirVersions.DSTU2,
42
+ fhirIcons: (
43
+ <img src={require('../assets/containers/Goal/goal.svg')} alt="goal" />
44
+ ),
45
+ };
46
+
47
+ const { getByAltText } = render(<Goal {...defaultProps} />);
48
+ const headerIcon = getByAltText('goal');
49
+
50
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
51
+ });
52
+
53
+ it('component with the resources object as a fhirIcons props should render an img', () => {
54
+ const defaultProps = {
55
+ fhirResource: dstu2Example1,
56
+ fhirVersion: fhirVersions.DSTU2,
57
+ fhirIcons: fhirIcons,
58
+ };
59
+
60
+ const { getByAltText } = render(<Goal {...defaultProps} />);
61
+ const headerIcon = getByAltText('goal');
62
+
63
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
64
+ });
65
+
66
+ it('component with the url as a fhirIcons props should render an img', () => {
67
+ const avatarSrc =
68
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
69
+ const defaultProps = {
70
+ fhirResource: dstu2Example1,
71
+ fhirVersion: fhirVersions.DSTU2,
72
+ fhirIcons: avatarSrc,
73
+ };
74
+
75
+ const { getByAltText } = render(<Goal {...defaultProps} />);
76
+ const headerIcon = getByAltText('header icon');
77
+
78
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
79
+ });
80
+
12
81
  it('should render with DSTU2 source data', () => {
13
82
  const defaultProps = {
14
83
  fhirResource: dstu2Example1,
@@ -100,9 +169,7 @@ describe('should render Goal component properly', () => {
100
169
 
101
170
  expect(getByTestId('status').textContent).toEqual('completed');
102
171
 
103
- expect(getByTestId('statusSecondary').textContent).toEqual(
104
- 'starting on 2015-04-05',
105
- );
172
+ expect(getByTestId('headerStartDate').textContent).toEqual('4/5/2015');
106
173
 
107
174
  expect(getByTestId('subject').textContent).toContain(
108
175
  'Peter James Chalmers',
@@ -5,18 +5,17 @@ import _get from 'lodash/get';
5
5
  import {
6
6
  Root,
7
7
  Header,
8
- Title,
9
8
  Badge,
10
9
  Body,
11
10
  ValueSection,
12
- Value,
13
- BadgeSecondary,
11
+ ValueSectionItem,
14
12
  } from '../../ui';
15
13
  import Coding from '../../datatypes/Coding';
16
14
  import Reference from '../../datatypes/Reference';
17
15
  import fhirVersions from '../fhirResourceVersions';
18
16
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
19
17
  import Attachment from '../../datatypes/Attachment';
18
+ import Accordion from '../../containers/Accordion';
20
19
 
21
20
  const commonDTO = fhirResource => {
22
21
  let title = _get(fhirResource, 'code.coding.0');
@@ -158,13 +157,12 @@ const Ingredient = props => {
158
157
  <Coding fhirData={itemDisplay} />
159
158
  </label>
160
159
  <Reference fhirData={reference} />
161
- {hasAmount && <BadgeSecondary>{amount}</BadgeSecondary>}
160
+ {hasAmount && <span>, {amount}</span>}
162
161
  </div>
163
162
  );
164
163
  };
165
164
 
166
- const Medication = props => {
167
- const { fhirResource, fhirVersion } = props;
165
+ const Medication = ({ fhirResource, fhirVersion, fhirIcons }) => {
168
166
  let fhirResourceData = {};
169
167
  try {
170
168
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -187,54 +185,95 @@ const Medication = props => {
187
185
  status,
188
186
  } = fhirResourceData;
189
187
 
188
+ const tableData = [
189
+ {
190
+ label: 'Manufacturer',
191
+ testId: 'manufacturer',
192
+ data: manufacturer && <Reference fhirData={manufacturer} />,
193
+ status: manufacturer,
194
+ },
195
+ ];
196
+
197
+ const productData = [
198
+ {
199
+ label: 'Form',
200
+ testId: 'product-form',
201
+ data:
202
+ productForm &&
203
+ productForm.map((item, i) => (
204
+ <Coding key={`item-${i}`} fhirData={item} />
205
+ )),
206
+ status: productForm,
207
+ },
208
+ {
209
+ label: 'Ingredient',
210
+ testId: 'product-ingredient',
211
+ data:
212
+ hasProductIngredient &&
213
+ productIngredient.map((item, i) => (
214
+ <Ingredient key={`item-${i}`} {...item} />
215
+ )),
216
+ status: hasProductIngredient,
217
+ },
218
+ {
219
+ label: 'Package container',
220
+ testId: 'package-container',
221
+ data:
222
+ hasPackageCoding &&
223
+ packageCoding.map((item, i) => (
224
+ <Coding key={`item-${i}`} fhirData={item} />
225
+ )),
226
+ status: hasPackageCoding,
227
+ },
228
+ {
229
+ label: 'Images',
230
+ testId: 'product-images',
231
+ data:
232
+ hasImages &&
233
+ images.map((item, i) => (
234
+ <Attachment key={`item-${i}`} fhirData={item} isImage />
235
+ )),
236
+ status: hasImages,
237
+ },
238
+ ];
239
+
190
240
  return (
191
241
  <Root name="Medication">
192
- <Header>
193
- <Title>
194
- <Coding fhirData={title} />
195
- </Title>
196
- {isBrand && <Badge>Brand</Badge>}
197
- {status && <Badge>{status}</Badge>}
198
- </Header>
199
- <Body>
200
- {manufacturer && (
201
- <Value label="Manufacturer" data-testid="manufacturer">
202
- <Reference fhirData={manufacturer} />
203
- </Value>
204
- )}
205
- {hasProduct && (
206
- <ValueSection label="Product">
207
- {productForm && (
208
- <Value label="Form" data-testid="product-form">
209
- {productForm.map((item, i) => (
210
- <Coding key={`item-${i}`} fhirData={item} />
211
- ))}
212
- </Value>
213
- )}
214
- {hasProductIngredient && (
215
- <Value label="Ingredient" data-testid="product-ingredient">
216
- {productIngredient.map((item, i) => (
217
- <Ingredient key={`item-${i}`} {...item} />
218
- ))}
219
- </Value>
220
- )}
221
- {hasPackageCoding && (
222
- <Value label="Package container" data-testid="package-container">
223
- {packageCoding.map((item, i) => (
224
- <Coding key={`item-${i}`} fhirData={item} />
225
- ))}
226
- </Value>
227
- )}
228
- {hasImages && (
229
- <Value label="Images" data-testid="product-images">
230
- {images.map((item, i) => (
231
- <Attachment key={`item-${i}`} fhirData={item} />
232
- ))}
233
- </Value>
242
+ <Accordion
243
+ headerContent={
244
+ <Header
245
+ resourceName="Medication"
246
+ badges={
247
+ <>
248
+ {isBrand && <Badge data-testid="brand-badge">Brand</Badge>}
249
+ {status && <Badge data-testid="status">{status}</Badge>}
250
+ </>
251
+ }
252
+ title={<Coding fhirData={title} />}
253
+ icon={fhirIcons}
254
+ />
255
+ }
256
+ bodyContent={
257
+ <Body tableData={tableData}>
258
+ {hasProduct && (
259
+ <ValueSection label="Product" marginTop={manufacturer}>
260
+ {productData.map(
261
+ (item, index) =>
262
+ item.status && (
263
+ <ValueSectionItem
264
+ key={`product-item-${index}`}
265
+ label={item.label}
266
+ data-testid={item.testId}
267
+ >
268
+ {item.data}
269
+ </ValueSectionItem>
270
+ ),
271
+ )}
272
+ </ValueSection>
234
273
  )}
235
- </ValueSection>
236
- )}
237
- </Body>
274
+ </Body>
275
+ }
276
+ />
238
277
  </Root>
239
278
  );
240
279
  };
@@ -11,6 +11,8 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medication/example2.j
11
11
  import r4Example1 from '../../../fixtures/r4/resources/medication/example1.json';
12
12
  import r4Example2 from '../../../fixtures/r4/resources/medication/example2.json';
13
13
  import r4Example3 from '../../../fixtures/r4/resources/medication/example3.json';
14
+ import fhirIcons from '../../../fixtures/example-icons';
15
+ import MedicationIcon from '../../../assets/containers/Medication/medication.svg';
14
16
 
15
17
  export default {
16
18
  title: 'Medication',
@@ -19,46 +21,74 @@ export default {
19
21
  export const DefaultVisualizationDSTU2 = () => {
20
22
  const fhirResource = object('Resource', dstu2Example1);
21
23
  return (
22
- <Medication fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />
24
+ <Medication
25
+ fhirVersion={fhirVersions.DSTU2}
26
+ fhirResource={fhirResource}
27
+ fhirIcons={require('../../../assets/containers/Medication/medication.svg')}
28
+ />
23
29
  );
24
30
  };
25
31
 
26
32
  export const Example2OfDSTU2 = () => {
27
33
  const fhirResource = object('Resource', dstu2Example2);
28
34
  return (
29
- <Medication fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />
35
+ <Medication
36
+ fhirVersion={fhirVersions.DSTU2}
37
+ fhirResource={fhirResource}
38
+ fhirIcons={MedicationIcon}
39
+ />
30
40
  );
31
41
  };
32
42
 
33
43
  export const Example1OfSTU3 = () => {
34
44
  const fhirResource = object('Resource', stu3Example1);
35
45
  return (
36
- <Medication fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />
46
+ <Medication
47
+ fhirVersion={fhirVersions.STU3}
48
+ fhirResource={fhirResource}
49
+ fhirIcons={fhirIcons}
50
+ />
37
51
  );
38
52
  };
39
53
 
40
54
  export const Example2OfSTU3 = () => {
41
55
  const fhirResource = object('Resource', stu3Example2);
42
56
  return (
43
- <Medication fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />
57
+ <Medication
58
+ fhirVersion={fhirVersions.STU3}
59
+ fhirResource={fhirResource}
60
+ fhirIcons={false}
61
+ />
44
62
  );
45
63
  };
46
64
 
47
65
  export const Example1OfR4 = () => {
48
66
  const fhirResource = object('Resource', r4Example1);
49
67
  return (
50
- <Medication fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />
68
+ <Medication
69
+ fhirVersion={fhirVersions.R4}
70
+ fhirResource={fhirResource}
71
+ fhirIcons={'random text'}
72
+ />
51
73
  );
52
74
  };
53
75
  export const Example2OfR4 = () => {
54
76
  const fhirResource = object('Resource', r4Example2);
55
77
  return (
56
- <Medication fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />
78
+ <Medication
79
+ fhirVersion={fhirVersions.R4}
80
+ fhirResource={fhirResource}
81
+ fhirIcons={fhirIcons}
82
+ />
57
83
  );
58
84
  };
59
85
  export const Example3OfR4 = () => {
60
86
  const fhirResource = object('Resource', r4Example3);
61
87
  return (
62
- <Medication fhirVersion={fhirVersions.R4} fhirResource={fhirResource} />
88
+ <Medication
89
+ fhirVersion={fhirVersions.R4}
90
+ fhirResource={fhirResource}
91
+ fhirIcons={fhirIcons}
92
+ />
63
93
  );
64
94
  };