fhir-react 0.3.4 → 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 (44) hide show
  1. package/build/bootstrap-reboot.min.css +8 -2
  2. package/build/index.js +7 -7
  3. package/build/style.css +4 -5
  4. package/package.json +1 -1
  5. package/src/assets/containers/Binary/binary.svg +9 -0
  6. package/src/components/containers/Accordion/Accordion.js +10 -9
  7. package/src/components/datatypes/Annotation/Annotation.js +4 -4
  8. package/src/components/datatypes/CodeableConcept/CodeableConcept.css +4 -1
  9. package/src/components/datatypes/Coding/Coding.css +0 -1
  10. package/src/components/datatypes/Reference/Reference.css +3 -0
  11. package/src/components/datatypes/Reference/Reference.js +2 -0
  12. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +87 -76
  13. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +11 -1
  14. package/src/components/resources/Binary/Binary.js +31 -20
  15. package/src/components/resources/Binary/Binary.stories.js +6 -5
  16. package/src/components/resources/CarePlan/CarePlan.js +111 -96
  17. package/src/components/resources/CarePlan/CarePlan.test.js +2 -2
  18. package/src/components/resources/CarePlan/CarePlanActivity.js +6 -2
  19. package/src/components/resources/Device/Device.js +54 -34
  20. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +53 -43
  21. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +7 -1
  22. package/src/components/resources/DocumentReference/DocumentReference.js +101 -65
  23. package/src/components/resources/DocumentReference/DocumentReference.stories.js +4 -0
  24. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +47 -38
  25. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +4 -0
  26. package/src/components/resources/Goal/Goal.js +104 -85
  27. package/src/components/resources/Goal/Goal.stories.js +37 -7
  28. package/src/components/resources/Goal/Goal.test.js +1 -3
  29. package/src/components/resources/MedicationOrder/MedicationOrder.js +45 -28
  30. package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +2 -1
  31. package/src/components/resources/MedicationRequest/MedicationRequest.js +65 -43
  32. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +16 -5
  33. package/src/components/resources/MedicationStatement/MedicationDetails.js +52 -0
  34. package/src/components/resources/MedicationStatement/MedicationDosage.js +46 -0
  35. package/src/components/resources/MedicationStatement/MedicationStatement.js +65 -118
  36. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +6 -0
  37. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +31 -6
  38. package/src/components/ui/bootstrap-reboot.min.css +8 -2
  39. package/src/components/ui/index.js +11 -0
  40. package/src/fixtures/example-icons.jsx +7 -0
  41. package/src/style.scss +1 -0
  42. package/src/utils/formatDate.js +6 -4
  43. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.css +0 -4
  44. 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.4",
3
+ "version": "0.3.5",
4
4
  "description": "React component library for displaying FHIR Resources ",
5
5
  "main": "build/index.js",
6
6
  "peerDependencies": {
@@ -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>
@@ -14,16 +14,17 @@ const Accordion = props => {
14
14
  );
15
15
 
16
16
  const isAccordionOpenable = () => {
17
- let childrenCondition = false;
18
- let tableDataCondition = false;
19
- if (bodyContent.props.children)
20
- childrenCondition = bodyContent.props.children.length > 0;
21
- if (bodyContent.props.tableData)
22
- tableDataCondition =
23
- bodyContent.props.tableData.filter(x => 'data' in x && x.data).length >
24
- 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
+ }
25
26
 
26
- return childrenCondition || tableDataCondition;
27
+ return false;
27
28
  };
28
29
 
29
30
  const getChevron = () =>
@@ -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
  }
@@ -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
  };
@@ -2,32 +2,43 @@ import React from 'react';
2
2
  import Img from '../../datatypes/Img';
3
3
  import Pdf from '../../datatypes/Pdf';
4
4
  import BinaryText from '../../datatypes/BinaryText';
5
+ import Accordion from '../../containers/Accordion/Accordion';
6
+ import { Body, Header } from '../../ui';
5
7
 
6
8
  const Binary = props => {
7
- const { fhirResource } = props;
9
+ const { fhirResource, fhirIcons } = props;
10
+ const headerIcon = fhirIcons && fhirIcons['Binary'];
11
+
12
+ const loadBinaryFile = () => {
13
+ switch (fhirResource.contentType) {
14
+ case 'application/pdf':
15
+ if (props.children && typeof props.children === 'function') {
16
+ return props.children(fhirResource.content, fhirResource.contentType);
17
+ }
18
+ return <Pdf fhirResource={fhirResource} />;
19
+ case 'image/jpeg':
20
+ return <Img fhirResource={fhirResource} />;
21
+ case 'application/xml':
22
+ return <BinaryText fhirResource={fhirResource} />;
23
+ case 'application/json':
24
+ return <BinaryText fhirResource={fhirResource} />;
25
+ default:
26
+ return null;
27
+ }
28
+ };
8
29
 
9
30
  return (
10
31
  <div>
11
- {(() => {
12
- switch (fhirResource.contentType) {
13
- case 'application/pdf':
14
- if (props.children && typeof props.children === 'function') {
15
- return props.children(
16
- fhirResource.content,
17
- fhirResource.contentType,
18
- );
19
- }
20
- return <Pdf fhirResource={fhirResource} />;
21
- case 'image/jpeg':
22
- return <Img fhirResource={fhirResource} />;
23
- case 'application/xml':
24
- return <BinaryText fhirResource={fhirResource} />;
25
- case 'application/json':
26
- return <BinaryText fhirResource={fhirResource} />;
27
- default:
28
- return null;
32
+ <Accordion
33
+ headerContent={
34
+ <Header
35
+ resourceName="Binary"
36
+ title={`Binary file: ${fhirResource.contentType}`}
37
+ icon={headerIcon}
38
+ />
29
39
  }
30
- })()}
40
+ bodyContent={<Body>{loadBinaryFile()}</Body>}
41
+ />
31
42
  </div>
32
43
  );
33
44
  };
@@ -8,6 +8,7 @@ import dstu2ExampleJpeg from '../../../fixtures/dstu2/resources/binary/example-j
8
8
  import stu3ExamplePdf from '../../../fixtures/stu3/resources/binary/example-pdf.json';
9
9
  import stu3ExampleJpeg from '../../../fixtures/stu3/resources/binary/example-jpeg.json';
10
10
  import stu3ExampleJson from '../../../fixtures/stu3/resources/binary/example-json.json';
11
+ import fhirIcons from '../../../fixtures/example-icons';
11
12
 
12
13
  export default {
13
14
  title: 'Binary',
@@ -15,25 +16,25 @@ export default {
15
16
 
16
17
  export const PdfDSTU2 = () => {
17
18
  const fhirResource = object('Resource', dstu2ExamplePdf);
18
- return <Binary fhirResource={fhirResource} />;
19
+ return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
19
20
  };
20
21
 
21
22
  export const JpegDSTU2 = () => {
22
23
  const fhirResource = object('Resource', dstu2ExampleJpeg);
23
- return <Binary fhirResource={fhirResource} />;
24
+ return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
24
25
  };
25
26
 
26
27
  export const PdfSTU3 = () => {
27
28
  const fhirResource = object('Resource', stu3ExamplePdf);
28
- return <Binary fhirResource={fhirResource} />;
29
+ return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
29
30
  };
30
31
 
31
32
  export const JpegSTU3 = () => {
32
33
  const fhirResource = object('Resource', stu3ExampleJpeg);
33
- return <Binary fhirResource={fhirResource} />;
34
+ return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
34
35
  };
35
36
 
36
37
  export const JsonSTU3 = () => {
37
38
  const fhirResource = object('Resource', stu3ExampleJson);
38
- return <Binary fhirResource={fhirResource} />;
39
+ return <Binary fhirResource={fhirResource} fhirIcons={fhirIcons} />;
39
40
  };