fhir-react 0.3.6 → 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 (31) hide show
  1. package/README.md +1 -1
  2. package/build/index.js +7 -7
  3. package/build/style.css +2 -1
  4. package/package.json +1 -1
  5. package/src/assets/containers/Coverage/coverage.svg +4 -0
  6. package/src/assets/containers/Medication/medication.svg +5 -0
  7. package/src/assets/containers/Organization/organization.svg +5 -0
  8. package/src/components/datatypes/Attachment/Attachment.css +5 -0
  9. package/src/components/datatypes/Attachment/Attachment.js +7 -2
  10. package/src/components/datatypes/Identifier/Identifier.js +7 -3
  11. package/src/components/datatypes/Reference/Reference.js +5 -1
  12. package/src/components/resources/Claim/CareTeam.js +55 -0
  13. package/src/components/resources/Claim/Claim.css +2 -11
  14. package/src/components/resources/Claim/Claim.js +157 -309
  15. package/src/components/resources/Claim/Claim.stories.js +37 -5
  16. package/src/components/resources/Claim/Claim.test.js +72 -0
  17. package/src/components/resources/Claim/Diagnosis.js +61 -0
  18. package/src/components/resources/Claim/Insurance.js +58 -0
  19. package/src/components/resources/Claim/Item.js +79 -0
  20. package/src/components/resources/Claim/Items.js +29 -0
  21. package/src/components/resources/Coverage/Coverage.js +96 -69
  22. package/src/components/resources/Coverage/Coverage.stories.js +31 -5
  23. package/src/components/resources/Coverage/Coverage.test.js +75 -3
  24. package/src/components/resources/Medication/Medication.js +90 -51
  25. package/src/components/resources/Medication/Medication.stories.js +37 -7
  26. package/src/components/resources/Medication/Medication.test.js +78 -4
  27. package/src/components/resources/Organization/Organization.js +55 -37
  28. package/src/components/resources/Organization/Organization.stories.js +15 -2
  29. package/src/components/resources/Organization/Organization.test.js +73 -0
  30. package/src/components/ui/index.js +11 -4
  31. package/src/fixtures/example-icons.jsx +21 -0
@@ -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
  };
@@ -9,8 +9,80 @@ import stu3Example1 from '../../../fixtures/stu3/resources/medication/example1.j
9
9
  import stu3Example2 from '../../../fixtures/stu3/resources/medication/example2.json';
10
10
  import r4Example1 from '../../../fixtures/r4/resources/medication/example1.json';
11
11
  import r4Example2 from '../../../fixtures/r4/resources/medication/example2.json';
12
+ import fhirIcons from '../../../fixtures/example-icons';
13
+
14
+ describe('should render Medication component properly', () => {
15
+ it('component without a fhirIcons props should render a default icon', () => {
16
+ const defaultProps = {
17
+ fhirVersion: fhirVersions.DSTU2,
18
+ fhirResource: dstu2Example1,
19
+ };
20
+
21
+ const { getByAltText } = render(<Medication {...defaultProps} />);
22
+ const headerIcon = getByAltText('medication');
23
+
24
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
25
+ });
26
+
27
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
28
+ const defaultProps = {
29
+ fhirVersion: fhirVersions.DSTU2,
30
+ fhirResource: dstu2Example1,
31
+ fhirIcons: false,
32
+ };
33
+
34
+ const { getByTestId } = render(<Medication {...defaultProps} />);
35
+ const headerIcon = getByTestId('placeholder');
36
+
37
+ expect(headerIcon).toBeTruthy();
38
+ });
39
+
40
+ it('component with the img as a fhirIcons props should render an img', () => {
41
+ const defaultProps = {
42
+ fhirVersion: fhirVersions.DSTU2,
43
+ fhirResource: dstu2Example1,
44
+ fhirIcons: (
45
+ <img
46
+ src={require('../assets/containers/Medication/medication.svg')}
47
+ alt="medication"
48
+ />
49
+ ),
50
+ };
51
+
52
+ const { getByAltText } = render(<Medication {...defaultProps} />);
53
+ const headerIcon = getByAltText('medication');
54
+
55
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
56
+ });
57
+
58
+ it('component with the resources object as a fhirIcons props should render an img', () => {
59
+ const defaultProps = {
60
+ fhirVersion: fhirVersions.DSTU2,
61
+ fhirResource: dstu2Example1,
62
+ fhirIcons: fhirIcons,
63
+ };
64
+
65
+ const { getByAltText } = render(<Medication {...defaultProps} />);
66
+ const headerIcon = getByAltText('medication');
67
+
68
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
69
+ });
70
+
71
+ it('component with the url as a fhirIcons props should render an img', () => {
72
+ const avatarSrc =
73
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
74
+ const defaultProps = {
75
+ fhirVersion: fhirVersions.DSTU2,
76
+ fhirResource: dstu2Example1,
77
+ fhirIcons: avatarSrc,
78
+ };
79
+
80
+ const { getByAltText } = render(<Medication {...defaultProps} />);
81
+ const headerIcon = getByAltText('header icon');
82
+
83
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
84
+ });
12
85
 
13
- describe('should render MedicationOrder component properly', () => {
14
86
  it('should render with DSTU2 source data', () => {
15
87
  const defaultProps = {
16
88
  fhirResource: dstu2Example1,
@@ -41,7 +113,9 @@ describe('should render MedicationOrder component properly', () => {
41
113
  fhirVersion: fhirVersions.STU3,
42
114
  };
43
115
 
44
- const { container, getByTestId } = render(<Medication {...defaultProps} />);
116
+ const { container, getByTestId, getByAltText } = render(
117
+ <Medication {...defaultProps} />,
118
+ );
45
119
  expect(container).not.toBeNull();
46
120
 
47
121
  expect(getByTestId('title').textContent).toContain(
@@ -56,8 +130,8 @@ describe('should render MedicationOrder component properly', () => {
56
130
  );
57
131
  expect(getByTestId('package-container').textContent).toContain('Vial');
58
132
 
59
- expect(getByTestId('product-images').textContent).toContain(
60
- 'Vancomycin Image',
133
+ expect(getByAltText('Vancomycin Image').src).toContain(
134
+ 'https://www.drugs.com/images/pills/fio/AKN07410.JPG',
61
135
  );
62
136
  });
63
137
 
@@ -8,7 +8,8 @@ import Telecom from '../../datatypes/Telecom';
8
8
  import Identifier from '../../datatypes/Identifier';
9
9
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
10
10
  import fhirVersions from '../fhirResourceVersions';
11
- import { Root, Header, Title, Body, Value, NotEnoughData } from '../../ui';
11
+ import { Root, Header, Body, NotEnoughData } from '../../ui';
12
+ import Accordion from '../../containers/Accordion';
12
13
 
13
14
  const commonDTO = fhirResource => {
14
15
  const identifier = _get(fhirResource, 'identifier', '');
@@ -54,8 +55,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
54
55
  }
55
56
  };
56
57
 
57
- const Organization = props => {
58
- const { fhirResource, fhirVersion } = props;
58
+ const Organization = ({ fhirResource, fhirVersion, fhirIcons }) => {
59
59
  let fhirResourceData = {};
60
60
  try {
61
61
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -74,42 +74,60 @@ const Organization = props => {
74
74
  const hasTelecom = Array.isArray(telecom) && telecom.length > 0;
75
75
  const hasTypes = Array.isArray(typeCodings) && typeCodings.length > 0;
76
76
  const notEnoughData = !hasAddresses && !hasTelecom && !hasTypes;
77
+
78
+ const tableData = [
79
+ {
80
+ label: 'Identifiers',
81
+ testId: 'identifier',
82
+ data: identifier && <Identifier fhirData={identifier} noCursive />,
83
+ status: identifier,
84
+ },
85
+ {
86
+ label: 'Addresses',
87
+ testId: 'address',
88
+ data:
89
+ hasAddresses &&
90
+ addresses.map((item, i) => (
91
+ <Address key={`item-${i}`} fhirData={item} />
92
+ )),
93
+ status: hasAddresses,
94
+ },
95
+ {
96
+ label: 'Contacts',
97
+ testId: 'contact',
98
+ data:
99
+ hasTelecom &&
100
+ telecom.map((item, i) => <Telecom key={`item-${i}`} fhirData={item} />),
101
+ status: hasTelecom,
102
+ },
103
+ {
104
+ label: 'Type',
105
+ testId: 'type',
106
+ data:
107
+ hasTypes &&
108
+ typeCodings.map((typeCoding, idx) => (
109
+ <Coding key={idx} fhirData={typeCoding} />
110
+ )),
111
+ status: hasTypes,
112
+ },
113
+ {
114
+ label: '',
115
+ testId: '',
116
+ data: notEnoughData && <NotEnoughData data-testid="NotEnoughData" />,
117
+ status: notEnoughData,
118
+ },
119
+ ];
120
+
77
121
  return (
78
122
  <Root name="Organization">
79
- {name && (
80
- <Header>
81
- <Title>{name}</Title>
82
- </Header>
83
- )}
84
- <Body>
85
- {identifier && (
86
- <Value label="Identifiers" data-testid="identifier">
87
- <Identifier fhirData={identifier} />
88
- </Value>
89
- )}
90
- {hasAddresses && (
91
- <Value label="Addresses" data-testid="address">
92
- {addresses.map((item, i) => (
93
- <Address key={`item-${i}`} fhirData={item} />
94
- ))}
95
- </Value>
96
- )}
97
- {hasTelecom && (
98
- <Value label="Contacts" data-testid="contact">
99
- {telecom.map((item, i) => (
100
- <Telecom key={`item-${i}`} fhirData={item} />
101
- ))}
102
- </Value>
103
- )}
104
- {hasTypes && (
105
- <Value label="Type" data-testid="type">
106
- {typeCodings.map((typeCoding, idx) => (
107
- <Coding key={idx} fhirData={typeCoding} />
108
- ))}
109
- </Value>
110
- )}
111
- {notEnoughData && <NotEnoughData data-testid="NotEnoughData" />}
112
- </Body>
123
+ <Accordion
124
+ headerContent={
125
+ name && (
126
+ <Header resourceName="Organization" title={name} icon={fhirIcons} />
127
+ )
128
+ }
129
+ bodyContent={<Body tableData={tableData} />}
130
+ />
113
131
  </Root>
114
132
  );
115
133
  };
@@ -14,6 +14,9 @@ import r4Example1 from '../../../fixtures/r4/resources/organization/example1.jso
14
14
  import r4Example2 from '../../../fixtures/r4/resources/organization/example2.json';
15
15
  import r4Example3 from '../../../fixtures/r4/resources/organization/example3.json';
16
16
 
17
+ import fhirIcons from '../../../fixtures/example-icons';
18
+ import OrganizationIcon from '../../../assets/containers/Organization/organization.svg';
19
+
17
20
  export default {
18
21
  title: 'Organization',
19
22
  };
@@ -24,6 +27,7 @@ export const DefaultVisualizationDSTU2 = () => {
24
27
  <Organization
25
28
  fhirResource={fhirResource}
26
29
  fhirVersion={fhirVersions.DSTU2}
30
+ fhirIcons={OrganizationIcon}
27
31
  />
28
32
  );
29
33
  };
@@ -34,6 +38,7 @@ export const Example2OfDSTU2 = () => {
34
38
  <Organization
35
39
  fhirResource={fhirResource}
36
40
  fhirVersion={fhirVersions.DSTU2}
41
+ fhirIcons={fhirIcons}
37
42
  />
38
43
  );
39
44
  };
@@ -41,14 +46,22 @@ export const Example2OfDSTU2 = () => {
41
46
  export const Example1OfSTU3 = () => {
42
47
  const fhirResource = object('Resource', stu3Example1);
43
48
  return (
44
- <Organization fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />
49
+ <Organization
50
+ fhirResource={fhirResource}
51
+ fhirVersion={fhirVersions.STU3}
52
+ fhirIcons={false}
53
+ />
45
54
  );
46
55
  };
47
56
 
48
57
  export const Example2OfSTU3 = () => {
49
58
  const fhirResource = object('Resource', stu3Example2);
50
59
  return (
51
- <Organization fhirResource={fhirResource} fhirVersion={fhirVersions.STU3} />
60
+ <Organization
61
+ fhirResource={fhirResource}
62
+ fhirVersion={fhirVersions.STU3}
63
+ fhirIcons={'random text'}
64
+ />
52
65
  );
53
66
  };
54
67
 
@@ -14,7 +14,80 @@ import r4Example1 from '../../../fixtures/r4/resources/organization/example1.jso
14
14
  import r4Example2 from '../../../fixtures/r4/resources/organization/example2.json';
15
15
  import r4Example3 from '../../../fixtures/r4/resources/organization/example3.json';
16
16
 
17
+ import fhirIcons from '../../../fixtures/example-icons';
18
+
17
19
  describe('should render Organization component properly', () => {
20
+ it('component without a fhirIcons props should render a default icon', () => {
21
+ const defaultProps = {
22
+ fhirVersion: fhirVersions.DSTU2,
23
+ fhirResource: dstu2Example1,
24
+ };
25
+
26
+ const { getByAltText } = render(<Organization {...defaultProps} />);
27
+ const headerIcon = getByAltText('organization');
28
+
29
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
30
+ });
31
+
32
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
33
+ const defaultProps = {
34
+ fhirVersion: fhirVersions.DSTU2,
35
+ fhirResource: dstu2Example1,
36
+ fhirIcons: false,
37
+ };
38
+
39
+ const { getByTestId } = render(<Organization {...defaultProps} />);
40
+ const headerIcon = getByTestId('placeholder');
41
+
42
+ expect(headerIcon).toBeTruthy();
43
+ });
44
+
45
+ it('component with the img as a fhirIcons props should render an img', () => {
46
+ const defaultProps = {
47
+ fhirVersion: fhirVersions.DSTU2,
48
+ fhirResource: dstu2Example1,
49
+ fhirIcons: (
50
+ <img
51
+ src={require('../assets/containers/Organization/organization.svg')}
52
+ alt="organization"
53
+ />
54
+ ),
55
+ };
56
+
57
+ const { getByAltText } = render(<Organization {...defaultProps} />);
58
+ const headerIcon = getByAltText('organization');
59
+
60
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
61
+ });
62
+
63
+ it('component with the resources object as a fhirIcons props should render an img', () => {
64
+ const defaultProps = {
65
+ fhirVersion: fhirVersions.DSTU2,
66
+ fhirResource: dstu2Example1,
67
+ fhirIcons: fhirIcons,
68
+ };
69
+
70
+ const { getByAltText } = render(<Organization {...defaultProps} />);
71
+ const headerIcon = getByAltText('organization');
72
+
73
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
74
+ });
75
+
76
+ it('component with the url as a fhirIcons props should render an img', () => {
77
+ const avatarSrc =
78
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
79
+ const defaultProps = {
80
+ fhirVersion: fhirVersions.DSTU2,
81
+ fhirResource: dstu2Example1,
82
+ fhirIcons: avatarSrc,
83
+ };
84
+
85
+ const { getByAltText } = render(<Organization {...defaultProps} />);
86
+ const headerIcon = getByAltText('header icon');
87
+
88
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
89
+ });
90
+
18
91
  it('should render with DSTU2 source data', () => {
19
92
  const defaultProps = {
20
93
  fhirResource: dstu2Example1,
@@ -87,7 +87,7 @@ export const Title = props => (
87
87
  export const Badge = props => {
88
88
  return (
89
89
  <small
90
- className={`fhir-ui__Badge text-capitalize d-flex align-items-center px-2 py-1 rounded-1 fw-bold ${getBadgeColor(
90
+ className={`fhir-ui__Badge text-capitalize d-flex align-items-center mx-1 px-2 py-1 rounded-1 fw-bold ${getBadgeColor(
91
91
  props,
92
92
  )}`}
93
93
  data-testid={props['data-testid']}
@@ -128,7 +128,7 @@ export const ValueUnit = props => (
128
128
  export const Body = ({ tableData = [], reverseContent, children }) => (
129
129
  <div className="fhir-ui__Body">
130
130
  {reverseContent ? children : null}
131
- <div className="row">
131
+ <div className="row gap-3">
132
132
  {tableData.map(
133
133
  (value, index) =>
134
134
  value.status && (
@@ -199,10 +199,17 @@ export const TableHeader = props => {
199
199
  );
200
200
  };
201
201
 
202
- export const TableRow = props => <tr>{props.children}</tr>;
202
+ export const TableRow = props => {
203
+ const { children, ...rest } = props;
204
+ return <tr {...rest}>{props.children}</tr>;
205
+ };
203
206
 
204
207
  export const TableCell = props => (
205
- <td className="align-text-top border-0" data-testid={props['data-testid']}>
208
+ <td
209
+ className={`align-middle border-0 ${props.className || ''}`}
210
+ data-testid={props['data-testid']}
211
+ style={props.style}
212
+ >
206
213
  {props.children}
207
214
  </td>
208
215
  );