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
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import _get from 'lodash/get';
4
+ import Accordion from '../../containers/Accordion/Accordion';
4
5
  import Reference from '../../datatypes/Reference';
5
6
  import CodeableConcept from '../../datatypes/CodeableConcept';
6
7
  import Coding from '../../datatypes/Coding';
7
8
  import Date from '../../datatypes/Date';
8
9
 
9
- import { Root, Header, Title, Body, Value } from '../../ui';
10
+ import { Root, Header, Body } from '../../ui';
10
11
 
11
12
  const MedicationRequest = props => {
12
- const { fhirResource } = props;
13
+ const { fhirResource, fhirIcons } = props;
14
+ const headerIcon = fhirIcons && fhirIcons['Medication'];
13
15
  const medicationReference = _get(fhirResource, 'medicationReference');
14
16
  const medicationCodeableConcept = _get(
15
17
  fhirResource,
@@ -25,49 +27,69 @@ const MedicationRequest = props => {
25
27
  _get(fhirResource, 'requester.agent') || _get(fhirResource, 'requester');
26
28
  const created = _get(fhirResource, 'authoredOn');
27
29
  const intent = _get(fhirResource, 'intent');
30
+ const tableData = [
31
+ {
32
+ label: 'Medication',
33
+ testId: 'medication',
34
+ data: showMedicationCodeableConcept && (
35
+ <Coding fhirData={medicationCodeableConcept} />
36
+ ),
37
+ status: showMedicationCodeableConcept,
38
+ },
39
+ {
40
+ label: 'Requester',
41
+ testId: 'requester',
42
+ data: requester && <Reference fhirData={requester} />,
43
+ status: requester,
44
+ },
45
+ {
46
+ label: 'Created',
47
+ testId: 'created',
48
+ data: created && <Date fhirData={created} />,
49
+ status: created,
50
+ },
51
+ {
52
+ label: 'Type of request',
53
+ testId: 'intent',
54
+ data: intent,
55
+ status: intent,
56
+ },
57
+ {
58
+ label: 'Reason',
59
+ testId: 'reasonCode',
60
+ data: reasonCode && <CodeableConcept fhirData={reasonCode} />,
61
+ status: reasonCode,
62
+ },
63
+ {
64
+ label: 'Dosage',
65
+ testId: 'hasDosageInstruction',
66
+ data:
67
+ hasDosageInstruction &&
68
+ dosageInstruction.map((item, i) => (
69
+ <p key={`dosage-instruction-item-${i}`}>{item.text}</p>
70
+ )),
71
+ status: hasDosageInstruction,
72
+ },
73
+ ];
74
+
28
75
  return (
29
76
  <Root name="MedicationRequest">
30
- <Header>
31
- <Title>
32
- {medicationReference && <Reference fhirData={medicationReference} />}
33
- </Title>
34
- </Header>
35
- <Body>
36
- {showMedicationCodeableConcept && (
37
- <Value label="Medication" data-testid="medication">
38
- <Coding fhirData={medicationCodeableConcept} />
39
- </Value>
40
- )}
41
- {requester && (
42
- <Value label="Requester" data-testid="requester">
43
- <Reference fhirData={requester} />
44
- </Value>
45
- )}
46
- {created && (
47
- <Value label="Created" data-testid="created">
48
- <Date fhirData={created} />
49
- </Value>
50
- )}
51
- {intent && (
52
- <Value label="Type of request" data-testid="intent">
53
- {intent}
54
- </Value>
55
- )}
56
- {reasonCode && (
57
- <Value label="Reason" data-testid="reasonCode">
58
- <CodeableConcept fhirData={reasonCode} />
59
- </Value>
60
- )}
61
- {hasDosageInstruction && (
62
- <Value label="Dosage" data-testid="hasDosageInstruction">
63
- <ul>
64
- {dosageInstruction.map((item, i) => (
65
- <li key={`item-${i}`}>{item.text}</li>
66
- ))}
67
- </ul>
68
- </Value>
69
- )}
70
- </Body>
77
+ <Accordion
78
+ headerContent={
79
+ <Header
80
+ icon={headerIcon}
81
+ resourceName="MedicationRequest"
82
+ title={
83
+ medicationReference ? (
84
+ <Reference fhirData={medicationReference} />
85
+ ) : (
86
+ 'Medication request'
87
+ )
88
+ }
89
+ />
90
+ }
91
+ bodyContent={<Body tableData={tableData} />}
92
+ />
71
93
  </Root>
72
94
  );
73
95
  };
@@ -8,6 +8,7 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medicationRequest/exa
8
8
  import R4Example1 from '../../../fixtures/r4/resources/medicationRequest/example1.json';
9
9
  import R4Example2 from '../../../fixtures/r4/resources/medicationRequest/example2.json';
10
10
  import R4Example3 from '../../../fixtures/r4/resources/medicationRequest/example3.json';
11
+ import fhirIcons from '../../../fixtures/example-icons';
11
12
 
12
13
  export default {
13
14
  title: 'MedicationRequest',
@@ -15,25 +16,35 @@ export default {
15
16
 
16
17
  export const DefaultVisualizationSTU3 = () => {
17
18
  const fhirResource = object('Resource', stu3Example1);
18
- return <MedicationRequest fhirResource={fhirResource} />;
19
+ return (
20
+ <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
21
+ );
19
22
  };
20
23
 
21
24
  export const Example2OfSTU3 = () => {
22
25
  const fhirResource = object('Resource', stu3Example2);
23
- return <MedicationRequest fhirResource={fhirResource} />;
26
+ return (
27
+ <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
28
+ );
24
29
  };
25
30
 
26
31
  export const Example1OfR4 = () => {
27
32
  const fhirResource = object('Resource', R4Example1);
28
- return <MedicationRequest fhirResource={fhirResource} />;
33
+ return (
34
+ <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
35
+ );
29
36
  };
30
37
 
31
38
  export const Example2OfR4 = () => {
32
39
  const fhirResource = object('Resource', R4Example2);
33
- return <MedicationRequest fhirResource={fhirResource} />;
40
+ return (
41
+ <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
42
+ );
34
43
  };
35
44
 
36
45
  export const Example3OfR4 = () => {
37
46
  const fhirResource = object('Resource', R4Example3);
38
- return <MedicationRequest fhirResource={fhirResource} />;
47
+ return (
48
+ <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
49
+ );
39
50
  };
@@ -0,0 +1,52 @@
1
+ import { ValueSection, ValueSectionItem } from '../../ui';
2
+ import React from 'react';
3
+ import Reference from '../../datatypes/Reference';
4
+ import _get from 'lodash/get';
5
+
6
+ const MedicationDetails = props => {
7
+ const {
8
+ medication,
9
+ expiration,
10
+ ingredient,
11
+ medicationReference,
12
+ hasReasonCode,
13
+ reasonCode,
14
+ } = props;
15
+ return (
16
+ <ValueSection label={medication} marginBottom>
17
+ <ValueSectionItem label="Expiration date" data-testid="expirationDate">
18
+ {expiration}
19
+ </ValueSectionItem>
20
+ {ingredient && (
21
+ <ValueSectionItem label="Ingredient" data-testid="ingredient">
22
+ {ingredient.map((item, i) => (
23
+ <div key={`item-${i}`} data-testid="ingredient-item">
24
+ {_get(item, 'itemCodeableConcept.coding.0.display', '')}
25
+ </div>
26
+ ))}
27
+ </ValueSectionItem>
28
+ )}
29
+ {medicationReference && (
30
+ <ValueSectionItem
31
+ label="Medication reference"
32
+ data-testid="medicationReference"
33
+ >
34
+ {<Reference fhirData={medicationReference} />}
35
+ </ValueSectionItem>
36
+ )}
37
+ {hasReasonCode && (
38
+ <ValueSectionItem label="Reasons" data-testid="hasReasonCode">
39
+ {reasonCode.map((item, i) => {
40
+ const display = _get(item, 'coding.0.display');
41
+ if (display) {
42
+ return <div key={`item-${i}`}>{display}</div>;
43
+ }
44
+ return null;
45
+ })}
46
+ </ValueSectionItem>
47
+ )}
48
+ </ValueSection>
49
+ );
50
+ };
51
+
52
+ export default MedicationDetails;
@@ -0,0 +1,46 @@
1
+ import { ValueSection, ValueSectionItem } from '../../ui';
2
+ import React from 'react';
3
+ import _get from 'lodash/get';
4
+
5
+ const MedicationDosage = props => {
6
+ const { dosage, hasNote, note, key } = props;
7
+
8
+ const instructions = _get(dosage, 'text');
9
+ const additionalInstructionText = _get(
10
+ dosage,
11
+ 'additionalInstruction[0].text',
12
+ );
13
+ const route =
14
+ _get(dosage, 'route.coding[0].display') ||
15
+ `${_get(dosage, 'route.text', '')} ${_get(dosage, 'text', '')}`;
16
+ const hasRoute = route.trim() !== '';
17
+
18
+ return (
19
+ <ValueSection label="Dosage" key={key}>
20
+ <ValueSectionItem label="Instructions" data-testid="dosageInstruction">
21
+ {instructions}
22
+ </ValueSectionItem>
23
+ {additionalInstructionText && (
24
+ <ValueSectionItem
25
+ label="Additional instruction"
26
+ data-testid="additionalInstruction"
27
+ >
28
+ {additionalInstructionText}
29
+ </ValueSectionItem>
30
+ )}
31
+ {hasRoute && (
32
+ <ValueSectionItem label="Route" data-testid="route">
33
+ {route}
34
+ </ValueSectionItem>
35
+ )}
36
+ {hasNote && (
37
+ <ValueSectionItem label="Notes" data-testid="hasNote">
38
+ {note.map((item, i) => (
39
+ <div key={`note-${i}`}>{item.text}</div>
40
+ ))}
41
+ </ValueSectionItem>
42
+ )}
43
+ </ValueSection>
44
+ );
45
+ };
46
+ export default MedicationDosage;
@@ -3,42 +3,13 @@ import PropTypes from 'prop-types';
3
3
 
4
4
  import _get from 'lodash/get';
5
5
  import _has from 'lodash/has';
6
- import Date from '../../datatypes/Date';
7
6
  import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
8
7
  import fhirVersions from '../fhirResourceVersions';
9
- import Annotation from '../../datatypes/Annotation';
10
- import Reference from '../../datatypes/Reference';
11
- import {
12
- Root,
13
- Header,
14
- Title,
15
- Badge,
16
- BadgeSecondary,
17
- Body,
18
- Value,
19
- ValueSection,
20
- } from '../../ui';
21
-
22
- const MedicationDetails = props => {
23
- const { medication, expiration, ingredient } = props;
24
- return (
25
- <div>
26
- <h5>{medication} </h5>
27
- <Value label="Expiration date">{expiration}</Value>
28
- {ingredient && (
29
- <Value label="Ingredient">
30
- <ul>
31
- {ingredient.map((item, i) => (
32
- <li key={`item-${i}`}>
33
- {_get(item, 'itemCodeableConcept.coding.0.display', '')}
34
- </li>
35
- ))}
36
- </ul>
37
- </Value>
38
- )}
39
- </div>
40
- );
41
- };
8
+ import Accordion from '../../containers/Accordion';
9
+ import DatePeriod from '../../datatypes/DatePeriod/DatePeriod';
10
+ import MedicationDetails from './MedicationDetails';
11
+ import { Root, Header, Badge, Body } from '../../ui';
12
+ import MedicationDosage from './MedicationDosage';
42
13
 
43
14
  const DEFAULT_TITLE = 'Medication Statement';
44
15
 
@@ -137,7 +108,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
137
108
  };
138
109
 
139
110
  const MedicationStatement = props => {
140
- const { fhirResource, fhirVersion } = props;
111
+ const { fhirResource, fhirVersion, fhirIcons } = props;
141
112
  let fhirResourceData = {};
142
113
  try {
143
114
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -165,94 +136,70 @@ const MedicationStatement = props => {
165
136
 
166
137
  return (
167
138
  <Root name="MedicationStatement">
168
- <Header>
169
- <Title>{title}</Title>
170
- {status && <Badge data-testid="hasStatus">{status}</Badge>}
171
- {hasEffectivePeriod && (
172
- <BadgeSecondary data-testid="hasEffectivePeriod">
173
- from <Date fhirData={statusDesc.from} /> {'to '}
174
- <Date fhirData={statusDesc.to} />
175
- <span>{reported}</span>
176
- </BadgeSecondary>
177
- )}
178
- </Header>
179
- <Body>
180
- {hasMedications && (
181
- <Value label="Medications">
182
- {contained.map((medication, i) => {
183
- const hasMedicationDetails = _has(
184
- medication,
185
- 'code.coding[0].display',
186
- );
187
- if (hasMedicationDetails) {
188
- return (
189
- <MedicationDetails
190
- key={`item-${i}`}
191
- medication={_get(medication, 'code.coding[0].display')}
192
- expiration={_get(
193
- medication,
194
- 'package.batch[0].expirationDate',
195
- )}
196
- ingredient={_get(medication, 'ingredient', [])}
139
+ <Accordion
140
+ headerContent={
141
+ <Header
142
+ icon={fhirIcons}
143
+ resourceName="MedicationStatement"
144
+ badges={status && <Badge data-testid="hasStatus">{status}</Badge>}
145
+ title={title}
146
+ additionalContent={
147
+ hasEffectivePeriod && (
148
+ <>
149
+ <DatePeriod
150
+ periodBeginLabel="Start date"
151
+ periodBeginDate={statusDesc.from}
152
+ periodBeginTestId="startDate"
153
+ periodEndLabel="End date"
154
+ periodEndDate={statusDesc.to}
155
+ periodEndTestId="endDate"
197
156
  />
157
+ <span>{reported}</span>
158
+ </>
159
+ )
160
+ }
161
+ />
162
+ }
163
+ bodyContent={
164
+ <Body>
165
+ {hasMedications &&
166
+ contained.map((medication, i) => {
167
+ const hasMedicationDetails = _has(
168
+ medication,
169
+ 'code.coding[0].display',
198
170
  );
199
- }
200
- return null;
201
- })}
202
- </Value>
203
- )}
204
- {medicationReference && (
205
- <Value label="Medication Reference" data-testid="medicationReference">
206
- <Reference fhirData={medicationReference} />
207
- </Value>
208
- )}
209
- {hasReasonCode && (
210
- <Value label="Reason" data-testid="hasReasonCode">
211
- <ul>
212
- {reasonCode.map((item, i) => {
213
- const display = _get(item, 'coding.0.display');
214
- if (display) {
215
- return <li key={`item-${i}`}>{display}</li>;
171
+ if (hasMedicationDetails) {
172
+ return (
173
+ <MedicationDetails
174
+ key={`item-${i}`}
175
+ medication={_get(medication, 'code.coding[0].display')}
176
+ expiration={_get(
177
+ medication,
178
+ 'package.batch[0].expirationDate',
179
+ )}
180
+ ingredient={_get(medication, 'ingredient', [])}
181
+ medicationReference={medicationReference}
182
+ hasReasonCode={hasReasonCode}
183
+ reasonCode={reasonCode}
184
+ />
185
+ );
216
186
  }
217
187
  return null;
218
188
  })}
219
- </ul>
220
- </Value>
221
- )}
222
- {hasDosage && (
223
- <ValueSection label="Dosage" data-testid="dosage">
224
- {fhirResource.dosage.map((dosage, i) => {
225
- const text = _get(dosage, 'text');
226
- const additionalInstructionText = _get(
227
- dosage,
228
- 'additionalInstruction[0].text',
229
- );
230
- const route =
231
- _get(dosage, 'route.coding[0].display') ||
232
- `${_get(dosage, 'route.text', '')} ${_get(dosage, 'text', '')}`;
233
- const hasRoute = route.trim() !== '';
234
- return (
235
- <div key={`dosage-${i}`}>
236
- <Value label="Instructions" data-testid="dosageInstruction">
237
- {text}
238
- </Value>
239
- {additionalInstructionText && (
240
- <Value label="Additional Instruction">
241
- {additionalInstructionText}
242
- </Value>
243
- )}
244
- {hasRoute && <Value label="Route">{route}</Value>}
245
- </div>
246
- );
247
- })}
248
- </ValueSection>
249
- )}
250
- {hasNote && (
251
- <Value label="Notes" data-testid="hasNote">
252
- <Annotation fhirData={note} />
253
- </Value>
254
- )}
255
- </Body>
189
+ {hasDosage &&
190
+ fhirResource.dosage.map((dosage, i) => {
191
+ return (
192
+ <MedicationDosage
193
+ key={`dosage-${i}`}
194
+ dosage={dosage}
195
+ hasNote={hasNote}
196
+ note={note}
197
+ />
198
+ );
199
+ })}
200
+ </Body>
201
+ }
202
+ />
256
203
  </Root>
257
204
  );
258
205
  };
@@ -9,6 +9,7 @@ import stu3Example1 from '../../../fixtures/stu3/resources/medicationStatement/e
9
9
  import stu3Example2 from '../../../fixtures/stu3/resources/medicationStatement/example2.json';
10
10
  import r4Example1 from '../../../fixtures/r4/resources/medicationStatement/example1.json';
11
11
  import r4Example2 from '../../../fixtures/r4/resources/medicationStatement/example2.json';
12
+ import fhirIcons from '../../../fixtures/example-icons';
12
13
 
13
14
  export default {
14
15
  title: 'MedicationStatement',
@@ -20,6 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
20
21
  <MedicationStatement
21
22
  fhirVersion={fhirVersions.DSTU2}
22
23
  fhirResource={fhirResource}
24
+ fhirIcons={fhirIcons}
23
25
  />
24
26
  );
25
27
  };
@@ -30,6 +32,7 @@ export const ExampleOfSTU3 = () => {
30
32
  <MedicationStatement
31
33
  fhirVersion={fhirVersions.STU3}
32
34
  fhirResource={fhirResource}
35
+ fhirIcons={fhirIcons}
33
36
  />
34
37
  );
35
38
  };
@@ -40,6 +43,7 @@ export const Example2OfSTU3 = () => {
40
43
  <MedicationStatement
41
44
  fhirVersion={fhirVersions.STU3}
42
45
  fhirResource={fhirResource}
46
+ fhirIcons={fhirIcons}
43
47
  />
44
48
  );
45
49
  };
@@ -50,6 +54,7 @@ export const Example1OfR4 = () => {
50
54
  <MedicationStatement
51
55
  fhirVersion={fhirVersions.R4}
52
56
  fhirResource={fhirResource}
57
+ fhirIcons={fhirIcons}
53
58
  />
54
59
  );
55
60
  };
@@ -60,6 +65,7 @@ export const Example2OfR4 = () => {
60
65
  <MedicationStatement
61
66
  fhirVersion={fhirVersions.R4}
62
67
  fhirResource={fhirResource}
68
+ fhirIcons={fhirIcons}
63
69
  />
64
70
  );
65
71
  };
@@ -19,7 +19,7 @@ describe('should render MedicationStatement component correctly', () => {
19
19
  expect(getByTestId('title').textContent).toContain(
20
20
  'amphetamine-dextroamphetamine',
21
21
  );
22
- expect(getByTestId('hasEffectivePeriod').textContent).toContain('from');
22
+ expect(getByTestId('startDate').textContent).toContain('4/19/2016');
23
23
  expect(queryByTestId('medicationReference')).toBeNull();
24
24
 
25
25
  expect(getByTestId('dosageInstruction').textContent).toContain(
@@ -32,19 +32,35 @@ describe('should render MedicationStatement component correctly', () => {
32
32
  fhirResource: stu3Example,
33
33
  fhirVersion: fhirVersions.STU3,
34
34
  };
35
- const { getByTestId, queryAllByTestId } = render(
35
+ const { getByTestId, queryAllByTestId, queryByTestId } = render(
36
36
  <MedicationStatement {...defaultProps} />,
37
37
  );
38
38
 
39
39
  expect(getByTestId('title').textContent).toEqual('Medication Statement');
40
- expect(queryAllByTestId('hasEffectivePeriod')).toHaveLength(0);
40
+ expect(queryAllByTestId('startDate')).toHaveLength(0);
41
+ expect(queryAllByTestId('endDate')).toHaveLength(0);
41
42
 
42
43
  expect(getByTestId('dosageInstruction').textContent).toContain(
43
44
  '1-2 tablets once daily',
44
45
  );
45
46
 
46
- expect(getByTestId('hasNote').textContent).toContain('occasional');
47
+ const ingredients = queryAllByTestId('ingredient-item').map(
48
+ x => x.textContent,
49
+ );
50
+ expect(ingredients).toHaveLength(2);
51
+ expect(ingredients).toEqual([
52
+ 'Acetaminophen 500 MG',
53
+ 'Diphenhydramine Hydrochloride 25 mg',
54
+ ]);
55
+
56
+ expect(getByTestId('dosageInstruction').textContent).toContain(
57
+ '1-2 tablets once daily at bedtime as needed for restless legs',
58
+ );
47
59
 
60
+ expect(queryByTestId('medicationReference').textContent).toContain(
61
+ '#med0309',
62
+ );
63
+ expect(getByTestId('hasNote').textContent).toContain('occasional');
48
64
  expect(getByTestId('hasReasonCode').textContent).toContain('Legs');
49
65
  });
50
66
 
@@ -58,14 +74,23 @@ describe('should render MedicationStatement component correctly', () => {
58
74
  );
59
75
 
60
76
  expect(getByTestId('title').textContent).toEqual('Medication Statement');
61
- expect(queryAllByTestId('hasEffectivePeriod')).toHaveLength(0);
77
+ expect(queryAllByTestId('startDate')).toHaveLength(0);
78
+ expect(queryAllByTestId('endDate')).toHaveLength(0);
62
79
 
63
80
  expect(getByTestId('dosageInstruction').textContent).toContain(
64
81
  '1-2 tablets once daily',
65
82
  );
66
83
 
67
- expect(getByTestId('hasNote').textContent).toContain('occasional');
84
+ const ingredients = queryAllByTestId('ingredient-item').map(
85
+ x => x.textContent,
86
+ );
87
+ expect(ingredients).toHaveLength(2);
88
+ expect(ingredients).toEqual([
89
+ 'Acetaminophen 500 MG',
90
+ 'Diphenhydramine Hydrochloride 25 mg',
91
+ ]);
68
92
 
93
+ expect(getByTestId('hasNote').textContent).toContain('occasional');
69
94
  expect(getByTestId('hasReasonCode').textContent).toContain('Legs');
70
95
  expect(getByTestId('medicationReference').textContent).toContain(
71
96
  '#med0309',
@@ -18,8 +18,7 @@ import {
18
18
  } from '../../ui';
19
19
  import Reference from '../../datatypes/Reference';
20
20
 
21
- const Observation = props => {
22
- const { fhirResource } = props;
21
+ const Observation = ({ fhirResource, fhirIcons }) => {
23
22
  const effectiveDate = _get(fhirResource, 'effectiveDateTime');
24
23
  const codeCodingDisplay = _get(fhirResource, 'code.coding.0.display');
25
24
  const codeText = _get(fhirResource, 'code.text', '');
@@ -72,7 +71,7 @@ const Observation = props => {
72
71
  <Accordion
73
72
  headerContent={
74
73
  <Header
75
- resourceName={fhirResource.resourceType}
74
+ resourceName="Observation"
76
75
  additionalContent={
77
76
  issued && (
78
77
  <Value label="Start date" data-testid="headerStartDate">
@@ -104,6 +103,7 @@ const Observation = props => {
104
103
  small
105
104
  />
106
105
  }
106
+ icon={fhirIcons}
107
107
  />
108
108
  }
109
109
  bodyContent={