fhir-react 0.2.2 → 0.3.1

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 (138) hide show
  1. package/.github/workflows/publish_npmjs.yml +20 -0
  2. package/.storybook/config.js +9 -3
  3. package/.storybook/presets.js +1 -0
  4. package/.storybook/preview-head.html +4 -0
  5. package/README.md +41 -13
  6. package/build/bootstrap-reboot.min.css +2 -22
  7. package/build/index.js +38 -3
  8. package/build/style.css +11 -227
  9. package/package.json +13 -4
  10. package/src/assets/common/chevron-right.svg +3 -0
  11. package/src/assets/containers/AllergyIntolerance/allergy-intolerance.svg +9 -0
  12. package/src/assets/containers/Appointment/appointment.svg +14 -0
  13. package/src/assets/containers/CarePlan/care-plan.svg +10 -0
  14. package/src/assets/containers/CareTeam/care-team.svg +10 -0
  15. package/src/assets/containers/Claim/claim.svg +6 -0
  16. package/src/assets/containers/ClaimResponse/claim-response.svg +7 -0
  17. package/src/assets/containers/Condition/condition.svg +11 -0
  18. package/src/assets/containers/Device/device.svg +8 -0
  19. package/src/assets/containers/DiagnosticReport/diagnostic-report.svg +14 -0
  20. package/src/assets/containers/DocumentReference/document-reference.svg +10 -0
  21. package/src/assets/containers/Encounter/encounter.svg +10 -0
  22. package/src/assets/containers/ExplanationOfBenefit/explanation-of-benefit.svg +3 -0
  23. package/src/assets/containers/FamilyMemberHistory/family-member-history.svg +7 -0
  24. package/src/assets/containers/Goal/goal.svg +11 -0
  25. package/src/assets/containers/Immunization/immunization.svg +7 -0
  26. package/src/assets/containers/List/list.svg +3 -0
  27. package/src/assets/containers/Location/location.svg +4 -0
  28. package/src/assets/containers/Medication/medication.svg +5 -0
  29. package/src/assets/containers/MedicationAdministration/medication-administration.svg +6 -0
  30. package/src/assets/containers/MedicationKnowledge/medication-knowledge.svg +11 -0
  31. package/src/assets/containers/MedicationStatement/medication-statement.svg +5 -0
  32. package/src/assets/containers/Observation/observation.svg +12 -0
  33. package/src/assets/containers/Practitioner/practitioner.svg +5 -0
  34. package/src/assets/containers/Procedure/procedure.svg +9 -0
  35. package/src/assets/containers/Questionnaire/questionnaire.svg +6 -0
  36. package/src/assets/containers/QuestionnaireResponse/questionnaire-response.svg +6 -0
  37. package/src/assets/containers/QustionnaireResponse/questionnaire-response.svg +6 -0
  38. package/src/assets/containers/ResearchStudy/research-study.svg +9 -0
  39. package/src/assets/containers/ResourceCategory/resource-placeholder.svg +3 -0
  40. package/src/components/containers/Accordion/Accordion.js +80 -0
  41. package/src/components/containers/Accordion/Accordion.stories.js +76 -0
  42. package/src/components/containers/Accordion/index.js +3 -0
  43. package/src/components/containers/ResourceContainer/ResourceContainer.css +0 -1
  44. package/src/components/containers/ResourceContainer/ResourceContainer.js +1 -1
  45. package/src/components/datatypes/AccountBalance/AccountBalance.js +33 -0
  46. package/src/components/datatypes/AccountBalance/index.js +3 -0
  47. package/src/components/datatypes/Annotation/Annotation.js +1 -1
  48. package/src/components/datatypes/Coding/Coding.js +1 -1
  49. package/src/components/datatypes/Date/Date.js +14 -4
  50. package/src/components/datatypes/DatePeriod/DatePeriod.js +38 -0
  51. package/src/components/datatypes/DatePeriod/index.js +3 -0
  52. package/src/components/datatypes/HeaderIcon/HeaderIcon.js +31 -0
  53. package/src/components/datatypes/HeaderIcon/index.js +3 -0
  54. package/src/components/datatypes/HumanName/HumanName.js +6 -21
  55. package/src/components/datatypes/Reference/Reference.js +3 -6
  56. package/src/components/resources/AdverseEvent/AdverseEvent.test.js +2 -2
  57. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +4 -4
  58. package/src/components/resources/Appointment/Appointment.js +91 -65
  59. package/src/components/resources/Appointment/Appointment.test.js +3 -3
  60. package/src/components/resources/Bundle/Bundle.js +2 -2
  61. package/src/components/resources/Bundle/Bundle.stories.js +78 -12
  62. package/src/components/resources/Bundle/Bundle.test.js +3 -0
  63. package/src/components/resources/CarePlan/CarePlan.test.js +4 -4
  64. package/src/components/resources/CareTeam/CareTeam.js +13 -14
  65. package/src/components/resources/CareTeam/CareTeam.test.js +4 -4
  66. package/src/components/resources/Claim/Claim.test.js +6 -6
  67. package/src/components/resources/ClaimResponse/ClaimResponse.test.js +6 -6
  68. package/src/components/resources/Condition/Condition.js +63 -47
  69. package/src/components/resources/Condition/Condition.stories.js +41 -8
  70. package/src/components/resources/Condition/Condition.test.js +20 -14
  71. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +5 -7
  72. package/src/components/resources/DocumentReference/DocumentReference.js +1 -1
  73. package/src/components/resources/DocumentReference/DocumentReference.test.js +3 -3
  74. package/src/components/resources/Encounter/Encounter.js +66 -36
  75. package/src/components/resources/Encounter/EncounterParticipants.js +2 -2
  76. package/src/components/resources/ExplanationOfBenefit/CareTeam.js +2 -2
  77. package/src/components/resources/ExplanationOfBenefit/Diagnosis.js +31 -5
  78. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +272 -201
  79. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.stories.js +12 -0
  80. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +96 -62
  81. package/src/components/resources/ExplanationOfBenefit/Items.js +2 -2
  82. package/src/components/resources/ExplanationOfBenefit/PriceLabel.js +20 -0
  83. package/src/components/resources/ExplanationOfBenefit/Related.js +3 -3
  84. package/src/components/resources/ExplanationOfBenefit/SupportingInfo.js +14 -3
  85. package/src/components/resources/ExplanationOfBenefit/TotalGraph.js +68 -0
  86. package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.js +89 -0
  87. package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.stories.js +78 -0
  88. package/src/components/resources/ExplanationOfBenefitGraph/ExplanationOfBenefitGraph.test.js +51 -0
  89. package/src/components/resources/ExplanationOfBenefitGraph/index.js +3 -0
  90. package/src/components/resources/Goal/Goal.test.js +1 -1
  91. package/src/components/resources/Immunization/Immunization.js +125 -94
  92. package/src/components/resources/Immunization/Immunization.stories.js +23 -4
  93. package/src/components/resources/Immunization/Immunization.test.js +17 -12
  94. package/src/components/resources/List/List.test.js +3 -3
  95. package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +7 -7
  96. package/src/components/resources/MedicationDispense/MedicationDispense.test.js +2 -2
  97. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +4 -4
  98. package/src/components/resources/Observation/Observation.js +72 -54
  99. package/src/components/resources/Observation/Observation.test.js +6 -18
  100. package/src/components/resources/Observation/ObservationGraph.js +159 -55
  101. package/src/components/resources/Observation/ObservationGraph.test.js +47 -26
  102. package/src/components/resources/Patient/Patient.js +79 -97
  103. package/src/components/resources/Patient/Patient.test.js +10 -10
  104. package/src/components/resources/Practitioner/Practitioner.js +80 -60
  105. package/src/components/resources/Practitioner/Practitioner.test.js +4 -4
  106. package/src/components/resources/Procedure/Procedure.js +99 -87
  107. package/src/components/resources/Procedure/Procedure.stories.js +8 -6
  108. package/src/components/resources/Procedure/Procedure.test.js +11 -8
  109. package/src/components/resources/Questionnaire/Questionnaire.test.js +3 -3
  110. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +5 -5
  111. package/src/components/resources/ReferralRequest/ReferralRequest.test.js +2 -2
  112. package/src/components/resources/ResearchStudy/ResearchStudy.test.js +1 -1
  113. package/src/components/resources/ResourceCategory/ResourceCategory.js +56 -0
  114. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +29 -0
  115. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +101 -0
  116. package/src/components/resources/ResourceCategory/index.js +3 -0
  117. package/src/components/ui/_header.scss +3 -0
  118. package/src/components/ui/bootstrap-reboot.min.css +2 -22
  119. package/src/components/ui/index.js +191 -29
  120. package/src/constants/badge-status.jsx +98 -0
  121. package/src/fixtures/dstu2/resources/condition/condition.svg +35 -0
  122. package/src/fixtures/dstu2/resources/immunization/immunization.svg +10 -0
  123. package/src/fixtures/example-icons.jsx +169 -0
  124. package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json +446 -0
  125. package/src/index.js +6 -1
  126. package/src/style.scss +176 -0
  127. package/src/utils/formatDate.js +21 -0
  128. package/src/utils/formatDate.test.js +22 -0
  129. package/src/utils/getBadgeColor.js +6 -0
  130. package/src/utils/getBadgeColor.test.js +14 -0
  131. package/src/utils/isUrl.js +9 -0
  132. package/src/utils/isUrl.test.js +12 -0
  133. package/src/utils.js +7 -0
  134. package/src/components/datatypes/HumanName/HumanName.css +0 -15
  135. package/src/components/datatypes/Reference/Reference.css +0 -8
  136. package/src/components/resources/Observation/ObservationGraph.css +0 -51
  137. package/src/components/resources/Patient/Patient.css +0 -19
  138. package/src/components/ui/index.css +0 -123
@@ -0,0 +1,76 @@
1
+ import { BadgeSecondary, Body, MissingValue, Title, Value } from '../../ui';
2
+
3
+ import Accordion from './Accordion';
4
+ import Annotation from '../../datatypes/Annotation';
5
+ import Date from '../../datatypes/Date';
6
+ import Procedure from '../../resources/Procedure/Procedure';
7
+ import React from 'react';
8
+ import Reference from '../../datatypes/Reference';
9
+ import _get from 'lodash/get';
10
+ import example1 from '../../../fixtures/dstu2/resources/procedure/example1.json';
11
+ import fhirIcons from '../../../fixtures/example-icons';
12
+ import { object } from '@storybook/addon-knobs';
13
+ import stu3Example1 from '../../../fixtures/stu3/resources/procedure/example1.json';
14
+
15
+ export default {
16
+ title: 'Accordion',
17
+ };
18
+
19
+ export const DefaultVisualization = () => {
20
+ const fhirResource = object('Resource', stu3Example1);
21
+ const title =
22
+ _get(fhirResource, 'code.coding[0].display') ||
23
+ _get(fhirResource, 'code.text');
24
+ const performedDateTime = _get(fhirResource, 'performedDateTime');
25
+ const performer = _get(fhirResource, 'performer', []);
26
+ const locationReference = _get(fhirResource, 'location[0]');
27
+ const reasonCode = _get(fhirResource, 'reasonCode', []);
28
+ const note = _get(fhirResource, 'note', []);
29
+
30
+ return (
31
+ <Accordion
32
+ headerContent={
33
+ <div className="">
34
+ <Title>{title}</Title>
35
+ <div className="pb-3" />
36
+ <BadgeSecondary data-testid="performedDateTime">
37
+ <Date fhirData={performedDateTime} />
38
+ </BadgeSecondary>
39
+ </div>
40
+ }
41
+ bodyContent={
42
+ <Body>
43
+ <Value label="Performed by">
44
+ {performer.map((item, i) => (
45
+ <div key={`item-${i}`}>
46
+ {_get(item, 'actor.display', <MissingValue />)}
47
+ </div>
48
+ ))}
49
+ </Value>
50
+ <Value label="Location" data-testid="location">
51
+ <Reference fhirData={locationReference} />
52
+ </Value>
53
+ <Value label="Reason" data-testid="hasReasonCode">
54
+ <Annotation fhirData={reasonCode} />
55
+ </Value>
56
+ <Value label="Notes" data-testid="hasNote">
57
+ <Annotation fhirData={note} />
58
+ </Value>
59
+ </Body>
60
+ }
61
+ />
62
+ );
63
+ };
64
+
65
+ export const ProcedureVisualization = () => {
66
+ const fhirResource = object('Resource', example1);
67
+
68
+ return (
69
+ <Accordion
70
+ headerContent={<div className=""></div>}
71
+ bodyContent={
72
+ <Procedure fhirResource={fhirResource} fhirIcons={fhirIcons} />
73
+ }
74
+ />
75
+ );
76
+ };
@@ -0,0 +1,3 @@
1
+ import Accordion from './Accordion';
2
+
3
+ export default Accordion;
@@ -1,5 +1,4 @@
1
1
  .fhir-container__ResourceContainer__card {
2
- background-color: #f8f9fa;
3
2
  border: 0;
4
3
  position: relative;
5
4
  display: flex;
@@ -23,7 +23,7 @@ class ResourceContainer extends React.Component {
23
23
  className="fhir-container__ResourceContainer__json-button"
24
24
  onClick={() => this.setState({ jsonOpen: !this.state.jsonOpen })}
25
25
  >
26
- JSON
26
+ RAW
27
27
  </button>
28
28
  </div>
29
29
  {this.props.children}
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Value } from '../../ui';
3
+ import { parseValueIntoMonetaryValueOfGivenCurrency } from '../../../utils';
4
+
5
+ const AccountBalance = props => {
6
+ const { totalBenefit, totalCost } = props;
7
+
8
+ return (
9
+ <div className="fhir-datatype__AccountBalance container-fluid p-0 m-0 ">
10
+ <Value label="Total cost" data-testid="totalCost" secondary>
11
+ {parseValueIntoMonetaryValueOfGivenCurrency(
12
+ totalCost.value,
13
+ totalCost.code,
14
+ )}
15
+ </Value>
16
+ <Value label="Coverd by benefit" data-testid="totalBenefit" secondary>
17
+ {parseValueIntoMonetaryValueOfGivenCurrency(
18
+ totalBenefit.value * -1,
19
+ totalBenefit.code,
20
+ )}
21
+ </Value>
22
+ <div className="border-top my-1 row border-secondary" />
23
+ <Value label="Patient Owed" secondary>
24
+ {parseValueIntoMonetaryValueOfGivenCurrency(
25
+ totalCost.value - totalBenefit.value,
26
+ totalBenefit.code,
27
+ )}
28
+ </Value>
29
+ </div>
30
+ );
31
+ };
32
+
33
+ export default AccountBalance;
@@ -0,0 +1,3 @@
1
+ import MoneyCalculator from './MoneyCalculator';
2
+
3
+ export default MoneyCalculator;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
2
+ import React from 'react';
3
3
 
4
4
  const Annotation = props => {
5
5
  const { fhirData } = props;
@@ -15,7 +15,7 @@ const Coding = props => {
15
15
  <span className="fhir-datatype__Coding__title">{display}</span>&nbsp;
16
16
  {hasAdditionalInfo && (
17
17
  <span className="fhir-datatype__Coding__code" title={system}>
18
- ({code})
18
+ ({code || '?'})
19
19
  </span>
20
20
  )}
21
21
  </div>
@@ -1,12 +1,22 @@
1
1
  import React from 'react';
2
+ import { formatDate } from '../../../utils/formatDate';
2
3
 
3
- const Date = props => {
4
- const { fhirData } = props;
4
+ const Date = ({ fhirData, isBlack, testId, className = '' }) => {
5
5
  if (!fhirData) {
6
6
  return null;
7
7
  }
8
- const dateValue = String(fhirData).slice(0, 10);
9
- return <span className="fhir-datatype__Date">{dateValue}</span>;
8
+ const locale = 'en-US';
9
+ const dateValue = formatDate(String(fhirData).slice(0, 10), locale);
10
+ return (
11
+ <span
12
+ data-testid={testId || 'providedDate'}
13
+ className={`${[className, 'fhir-datatype__Date', 'font-source'].join(
14
+ ' ',
15
+ )}${isBlack ? '' : ' text-secondary'}`}
16
+ >
17
+ {dateValue}
18
+ </span>
19
+ );
10
20
  };
11
21
 
12
22
  export default Date;
@@ -0,0 +1,38 @@
1
+ import Date from '../Date';
2
+ import React from 'react';
3
+
4
+ const DatePeriod = props => {
5
+ const {
6
+ periodBeginLabel,
7
+ periodBeginDate,
8
+ periodBeginTestId,
9
+ periodEndLabel,
10
+ periodEndDate,
11
+ periodEndTestId,
12
+ } = props;
13
+
14
+ const SingleDateSpan = props => (
15
+ <span className="fhir-datetype__DatePeriod__begin-date text-black-50 me-2 font-source fw-normal lh-lg">
16
+ {props.label}
17
+ </span>
18
+ );
19
+
20
+ return (
21
+ <div className="d-flex flex-column flex-sm-row align-items-start align-items-sm-start">
22
+ {periodBeginDate && (
23
+ <div className="d-flex flex-wrap">
24
+ <SingleDateSpan label={periodBeginLabel} />
25
+ <Date testId={periodBeginTestId} isBlack fhirData={periodBeginDate} />
26
+ </div>
27
+ )}
28
+ {periodEndDate && (
29
+ <div className="ms-sm-4 d-flex flex-wrap">
30
+ <SingleDateSpan label={periodEndLabel} />
31
+ <Date testId={periodEndTestId} isBlack fhirData={periodEndDate} />
32
+ </div>
33
+ )}
34
+ </div>
35
+ );
36
+ };
37
+
38
+ export default DatePeriod;
@@ -0,0 +1,3 @@
1
+ import DatePeriod from './DatePeriod';
2
+
3
+ export default DatePeriod;
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { isUrl } from '../../../utils/isUrl';
3
+
4
+ const HeaderIcon = ({ headerIcon }) => {
5
+ const PlaceholderImage = () => {
6
+ return <div className="header-icon__placeholder rounded-1" />;
7
+ };
8
+
9
+ const Image = () => {
10
+ if (
11
+ React.isValidElement(headerIcon) &&
12
+ typeof headerIcon.type === 'string'
13
+ ) {
14
+ return headerIcon;
15
+ }
16
+ if (isUrl(headerIcon)) {
17
+ return (
18
+ <img
19
+ className="header-icon__image"
20
+ src={headerIcon}
21
+ alt="header icon"
22
+ />
23
+ );
24
+ }
25
+ return <PlaceholderImage />;
26
+ };
27
+
28
+ return <Image />;
29
+ };
30
+
31
+ export default HeaderIcon;
@@ -0,0 +1,3 @@
1
+ import HeaderIcon from './HeaderIcon';
2
+
3
+ export default HeaderIcon;
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
- import _get from 'lodash/get';
3
2
  import _flatten from 'lodash/flatten';
4
-
5
- import './HumanName.css';
3
+ import _get from 'lodash/get';
6
4
 
7
5
  function HumanName(props) {
8
- const { fhirData, primary } = props;
6
+ const { fhirData, isTitle } = props;
9
7
  const givenName = _get(fhirData, 'given', []).join(', ');
10
8
  const familyName = _flatten(Array(_get(fhirData, 'family', ''))).join(', ');
11
9
  const suffix = _get(fhirData, 'suffix', []).join(' ');
@@ -15,24 +13,11 @@ function HumanName(props) {
15
13
  ? textName
16
14
  : `${givenName} ${familyName} ${suffix}`.trim();
17
15
 
18
- const headerElement = primary ? (
19
- <span className="fhir-datatype__HumanName__Header--primary">{header}</span>
20
- ) : (
21
- <span className="fhir-datatype__HumanName__Header--default">{header}</span>
22
- );
23
- const rootClassName = primary
24
- ? ''
25
- : 'fhir-datatype__HumanName__not-primary-block';
26
-
27
16
  return (
28
- <div className={`fhir-datatype__HumanName ${rootClassName}`}>
29
- {headerElement}
30
- {use && (
31
- <small className="fhir-datatype__HumanName__use-block">
32
- {` (${use})`}
33
- </small>
34
- )}
35
- </div>
17
+ <>
18
+ {header}
19
+ {!isTitle && use && <span>{` (${use})`}</span>}
20
+ </>
36
21
  );
37
22
  }
38
23
 
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import _get from 'lodash/get';
3
- import './Reference.css';
4
3
 
5
4
  const Reference = props => {
6
5
  const { fhirData } = props;
@@ -8,13 +7,11 @@ const Reference = props => {
8
7
  const reference = _get(fhirData, 'reference', '');
9
8
  return (
10
9
  <div
11
- className="fhir-datatype__Reference"
10
+ className="fhir-datatype__Reference d-inline-block"
12
11
  data-testid={props['data-testid']}
13
12
  >
14
- {display && (
15
- <span className="fhir-datatype__Reference__title">{display}</span>
16
- )}
17
- <span className="fhir-datatype__Reference__details">{reference}</span>
13
+ {display && <span className="mr-2 pe-1">{display}</span>}
14
+ <span>{reference}</span>
18
15
  </div>
19
16
  );
20
17
  };
@@ -16,7 +16,7 @@ describe('should render component correctly', () => {
16
16
 
17
17
  expect(getByTestId('title').textContent).toContain('Patient');
18
18
 
19
- expect(getByTestId('date').textContent).toEqual('2017-01-29');
19
+ expect(getByTestId('date').textContent).toEqual('1/29/2017');
20
20
 
21
21
  expect(getByTestId('type').textContent).toContain('304386008');
22
22
 
@@ -36,7 +36,7 @@ describe('should render component correctly', () => {
36
36
 
37
37
  expect(getByTestId('title').textContent).toContain('Patient');
38
38
 
39
- expect(getByTestId('date').textContent).toEqual('2017-01-29');
39
+ expect(getByTestId('date').textContent).toEqual('1/29/2017');
40
40
 
41
41
  expect(getByTestId('hasSeriousness').textContent).toContain('Non-serious');
42
42
 
@@ -22,7 +22,7 @@ describe('should render component correctly', () => {
22
22
 
23
23
  expect(getByTestId('status').textContent).toContain('unconfirmed');
24
24
 
25
- expect(getByTestId('recordedDate').textContent).toContain('2010-03-01');
25
+ expect(getByTestId('recordedDate').textContent).toContain('3/1/2010');
26
26
 
27
27
  expect(getByTestId('substance').textContent).toContain('PENICILLIN');
28
28
 
@@ -46,7 +46,7 @@ describe('should render component correctly', () => {
46
46
 
47
47
  expect(getByTestId('status').textContent).toContain('confirmed');
48
48
 
49
- expect(getByTestId('recordedDate').textContent).toContain('2014-10-09');
49
+ expect(getByTestId('recordedDate').textContent).toContain('10/9/2014');
50
50
 
51
51
  expect(getByTestId('substance').textContent).toContain(
52
52
  'allergenic extract',
@@ -78,7 +78,7 @@ describe('should render component correctly', () => {
78
78
 
79
79
  expect(getByTestId('status').textContent).toContain('Confirmed');
80
80
 
81
- expect(getByTestId('recordedDate').textContent).toContain('2014-10-09');
81
+ expect(getByTestId('recordedDate').textContent).toContain('10/9/2014');
82
82
 
83
83
  expect(getByTestId('substance').textContent).toContain(
84
84
  'allergenic extract',
@@ -114,7 +114,7 @@ describe('should render component correctly', () => {
114
114
 
115
115
  expect(getByTestId('status').textContent).toContain('Confirmed');
116
116
 
117
- expect(getByTestId('recordedDate').textContent).toContain('2015-08-06');
117
+ expect(getByTestId('recordedDate').textContent).toContain('8/6/2015');
118
118
 
119
119
  expect(getByTestId('patient').textContent).toEqual('Patient/mom');
120
120
 
@@ -6,9 +6,7 @@ import fhirVersions from '../fhirResourceVersions';
6
6
  import {
7
7
  Root,
8
8
  Header,
9
- Title,
10
9
  Badge,
11
- BadgeSecondary,
12
10
  Body,
13
11
  Value,
14
12
  ValueSection,
@@ -23,6 +21,7 @@ import Coding from '../../datatypes/Coding';
23
21
  import Reference from '../../datatypes/Reference';
24
22
  import CodeableConcept from '../../datatypes/CodeableConcept';
25
23
  import { isNotEmptyArray } from '../../../utils';
24
+ import Accordion from '../../containers/Accordion';
26
25
 
27
26
  const prepareParticipantData = data => {
28
27
  let participantPatient = [];
@@ -163,71 +162,98 @@ const Appointment = props => {
163
162
  serviceCategory,
164
163
  } = resourceDTO(fhirVersion, fhirResource);
165
164
 
165
+ const tableData = [
166
+ {
167
+ label: 'Type',
168
+ testId: 'type',
169
+ data:
170
+ isNotEmptyArray(typeCoding) &&
171
+ typeCoding.map((item, i) => (
172
+ <Coding key={`item-${i}`} fhirData={item} />
173
+ )),
174
+ status: isNotEmptyArray(typeCoding),
175
+ },
176
+ {
177
+ label: 'Duration [min]',
178
+ testId: 'minutesDuration',
179
+ data: minutesDuration,
180
+ status: minutesDuration,
181
+ },
182
+ {
183
+ label: 'Reason',
184
+ testId: 'reason',
185
+ data: isNotEmptyArray(reason) && <CodeableConcept fhirData={reason} />,
186
+ status: isNotEmptyArray(reason),
187
+ },
188
+ {
189
+ label: 'Cancelation Reason',
190
+ testId: 'cancelationReason',
191
+ data: isNotEmptyArray(cancelationReason) && (
192
+ <CodeableConcept fhirData={cancelationReason} />
193
+ ),
194
+ status: isNotEmptyArray(cancelationReason),
195
+ },
196
+ {
197
+ label: 'Service Category',
198
+ testId: 'serviceCategory',
199
+ data: isNotEmptyArray(serviceCategory) && (
200
+ <CodeableConcept fhirData={serviceCategory} />
201
+ ),
202
+ status: isNotEmptyArray(serviceCategory),
203
+ },
204
+ ];
205
+
166
206
  return (
167
207
  <Root name="Appointment">
168
- <Header>
169
- {description && <Title>{description}</Title>}
170
- {status && <Badge data-testid="status">{status}</Badge>}
171
- {start && (
172
- <BadgeSecondary data-testid="startDate">
173
- on <Date fhirData={start} />
174
- </BadgeSecondary>
175
- )}
176
- </Header>
177
- <Body>
178
- {isNotEmptyArray(typeCoding) && (
179
- <Value label="Type" data-testid="type">
180
- {typeCoding.map((item, i) => (
181
- <Coding key={`item-${i}`} fhirData={item} />
182
- ))}
183
- </Value>
184
- )}
185
- {minutesDuration && (
186
- <Value label="Duration [min]" data-testid="minutesDuration">
187
- {minutesDuration}
188
- </Value>
189
- )}
190
- {isNotEmptyArray(reason) && (
191
- <Value label="Reason" data-testid="reason">
192
- <CodeableConcept fhirData={reason} />
193
- </Value>
194
- )}
195
- {isNotEmptyArray(cancelationReason) && (
196
- <Value label="Cancelation Reason" data-testid="cancelationReason">
197
- <CodeableConcept fhirData={cancelationReason} />
198
- </Value>
199
- )}
200
- {isNotEmptyArray(serviceCategory) && (
201
- <Value label="Service Category" data-testid="serviceCategory">
202
- <CodeableConcept fhirData={serviceCategory} />
203
- </Value>
204
- )}
205
- {isNotEmptyArray(participant) && (
206
- <ValueSection label="Participant" data-testid="participant">
207
- <Table>
208
- <thead>
209
- <TableRow>
210
- <TableHeader>Patient</TableHeader>
211
- <TableHeader>Practitioner</TableHeader>
212
- <TableHeader>Other</TableHeader>
213
- </TableRow>
214
- </thead>
215
- <tbody>
216
- <TableRow>
217
- <TableCell>{participantPatient}</TableCell>
218
- <TableCell>{participantPractitioner}</TableCell>
219
- <TableCell>{participantLocation}</TableCell>
220
- </TableRow>
221
- </tbody>
222
- </Table>
223
- </ValueSection>
224
- )}
225
- {comment && (
226
- <Value label="Comment" data-testid="comment">
227
- {comment}
228
- </Value>
229
- )}
230
- </Body>
208
+ <Accordion
209
+ headerContent={
210
+ <Header
211
+ resourceName={fhirResource.resourceName}
212
+ additionalContent={
213
+ start && (
214
+ <Value label="Start date" data-testid="headerStartDate">
215
+ <Date fhirData={start} isBlack />
216
+ </Value>
217
+ )
218
+ }
219
+ badges={status && <Badge data-testid="status">{status}</Badge>}
220
+ title={description}
221
+ />
222
+ }
223
+ bodyContent={
224
+ <Body tableData={tableData}>
225
+ {isNotEmptyArray(participant) && (
226
+ <ValueSection
227
+ label="Participant"
228
+ data-testid="participant"
229
+ marginTop
230
+ >
231
+ <Table>
232
+ <thead>
233
+ <TableRow>
234
+ <TableHeader>Patient</TableHeader>
235
+ <TableHeader>Practitioner</TableHeader>
236
+ <TableHeader>Other</TableHeader>
237
+ </TableRow>
238
+ </thead>
239
+ <tbody className="border-top-0">
240
+ <TableRow>
241
+ <TableCell>{participantPatient}</TableCell>
242
+ <TableCell>{participantPractitioner}</TableCell>
243
+ <TableCell>{participantLocation}</TableCell>
244
+ </TableRow>
245
+ </tbody>
246
+ </Table>
247
+ </ValueSection>
248
+ )}
249
+ {comment && (
250
+ <ValueSection label="Comment" data-testid="comment" marginTop>
251
+ <span className="text-secondary">{comment}</span>
252
+ </ValueSection>
253
+ )}
254
+ </Body>
255
+ }
256
+ />
231
257
  </Root>
232
258
  );
233
259
  };
@@ -24,7 +24,7 @@ describe('should render component correctly', () => {
24
24
  'Discussion on the results',
25
25
  );
26
26
  expect(getByTestId('status').textContent).toEqual('booked');
27
- expect(getByTestId('startDate').textContent).toContain('2013-12-10');
27
+ expect(getByTestId('headerStartDate').textContent).toContain('12/10/2013');
28
28
  expect(getByTestId('type').textContent).toContain('General Discussion');
29
29
  expect(getByTestId('participant').textContent).toContain(
30
30
  'Peter James Chalmers',
@@ -71,7 +71,7 @@ describe('should render component correctly', () => {
71
71
  'Discussion on the results',
72
72
  );
73
73
  expect(getByTestId('status').textContent).toEqual('booked');
74
- expect(getByTestId('startDate').textContent).toContain('2013-12-10');
74
+ expect(getByTestId('headerStartDate').textContent).toContain('12/10/2013');
75
75
 
76
76
  expect(getByTestId('participant').textContent).toContain(
77
77
  'Peter James Chalmers',
@@ -108,7 +108,7 @@ describe('should render component correctly', () => {
108
108
  'Discussion on the results',
109
109
  );
110
110
  expect(getByTestId('status').textContent).toEqual('booked');
111
- expect(getByTestId('startDate').textContent).toContain('2013-12-10');
111
+ expect(getByTestId('headerStartDate').textContent).toContain('12/10/2013');
112
112
 
113
113
  expect(getByTestId('participant').textContent).toContain(
114
114
  'Peter James Chalmers',
@@ -9,7 +9,7 @@ import * as FhirResourceTypes from '../../supportedFhirResourceList';
9
9
 
10
10
  import './Bundle.css';
11
11
 
12
- export default function Bundle(props) {
12
+ export default function Bundle({ fhirResource, fhirVersion, fhirIcons }) {
13
13
  const commonDTO = fhirResource => {
14
14
  const type = _get(fhirResource, 'type', null);
15
15
  const total = _get(fhirResource, 'total');
@@ -36,7 +36,6 @@ export default function Bundle(props) {
36
36
  }
37
37
  };
38
38
 
39
- const { fhirResource, fhirVersion } = props;
40
39
  let fhirResourceData = {};
41
40
  try {
42
41
  fhirResourceData = resourceDTO(fhirVersion, fhirResource);
@@ -79,6 +78,7 @@ export default function Bundle(props) {
79
78
  <FhirComponent
80
79
  fhirResource={resource}
81
80
  fhirVersion={fhirVersion}
81
+ fhirIcons={fhirIcons}
82
82
  />
83
83
  </div>
84
84
  );