fhir-react 0.2.3 → 0.3.2

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 (140) 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 +48 -4
  6. package/build/bootstrap-reboot.min.css +2 -22
  7. package/build/index.js +38 -3
  8. package/build/style.css +31 -459
  9. package/package.json +15 -5
  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 +64 -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 +77 -87
  103. package/src/components/resources/Patient/Patient.test.js +1 -1
  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 +55 -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/supportedFhirResourceList.js +2 -0
  118. package/src/components/ui/_header.scss +3 -0
  119. package/src/components/ui/bootstrap-reboot.min.css +2 -22
  120. package/src/components/ui/index.js +191 -29
  121. package/src/constants/badge-status.jsx +98 -0
  122. package/src/fixtures/dstu2/resources/condition/condition.svg +35 -0
  123. package/src/fixtures/dstu2/resources/immunization/immunization.svg +10 -0
  124. package/src/fixtures/example-icons.jsx +169 -0
  125. package/src/fixtures/r4/resources/explanationOfBenefit/c4bbExtendedDiagnosis.json +446 -0
  126. package/src/index.js +7 -1
  127. package/src/style.scss +176 -0
  128. package/src/utils/formatDate.js +21 -0
  129. package/src/utils/formatDate.test.js +22 -0
  130. package/src/utils/getBadgeColor.js +6 -0
  131. package/src/utils/getBadgeColor.test.js +14 -0
  132. package/src/utils/isUrl.js +9 -0
  133. package/src/utils/isUrl.test.js +12 -0
  134. package/src/utils.js +7 -0
  135. package/webpack.config.js +10 -1
  136. package/src/components/datatypes/HumanName/HumanName.css +0 -15
  137. package/src/components/datatypes/Reference/Reference.css +0 -8
  138. package/src/components/resources/Observation/ObservationGraph.css +0 -51
  139. package/src/components/resources/Patient/Patient.css +0 -19
  140. package/src/components/ui/index.css +0 -123
@@ -0,0 +1,9 @@
1
+ export const isUrl = str => {
2
+ let url;
3
+ try {
4
+ url = new URL(str);
5
+ } catch (err) {
6
+ return false;
7
+ }
8
+ return url.protocol === 'http:' || url.protocol === 'https:';
9
+ };
@@ -0,0 +1,12 @@
1
+ import { isUrl } from './isUrl';
2
+
3
+ describe('isUrl function', () => {
4
+ it('should return true if passed a valid Url', () => {
5
+ const str = 'https://placekeanu.com/24/24';
6
+ expect(isUrl(str)).toBeTruthy();
7
+ });
8
+ it('should return false if passed an invalid Url', () => {
9
+ const str = '<div><img/><p>test</p><div>';
10
+ expect(isUrl(str)).toBeFalsy();
11
+ });
12
+ });
package/src/utils.js CHANGED
@@ -6,3 +6,10 @@ export function toTrimedFixedNumber(number, digits = 4) {
6
6
  }
7
7
 
8
8
  export const isNotEmptyArray = data => Array.isArray(data) && data.length > 0;
9
+
10
+ export const parseValueIntoMonetaryValueOfGivenCurrency = (value, currency) => {
11
+ return new Intl.NumberFormat('en-US', {
12
+ style: 'currency',
13
+ currency: currency,
14
+ }).format(Math.round(value * 100) / 100);
15
+ };
package/webpack.config.js CHANGED
@@ -25,7 +25,7 @@ module.exports = {
25
25
  },
26
26
  },
27
27
  {
28
- test: /\.css$/,
28
+ test: /\.(css|scss)$/,
29
29
  exclude: path.resolve(
30
30
  __dirname,
31
31
  'src/components/ui/bootstrap-reboot.min.css',
@@ -35,6 +35,15 @@ module.exports = {
35
35
  loader: MiniCssExtractPlugin.loader,
36
36
  },
37
37
  'css-loader',
38
+ 'sass-loader',
39
+ ],
40
+ },
41
+ {
42
+ test: /\.svg$/,
43
+ use: [
44
+ {
45
+ loader: 'svg-url-loader',
46
+ },
38
47
  ],
39
48
  },
40
49
  ],
@@ -1,15 +0,0 @@
1
- /* HumanName */
2
- .fhir-datatype__HumanName__not-primary-block {
3
- font-weight: 700;
4
- }
5
-
6
- .fhir-datatype__HumanName__Header--primary {
7
- margin-bottom: 0;
8
- font-weight: 500;
9
- line-height: 1.2;
10
- font-size: 1.5rem;
11
- }
12
-
13
- .fhir-datatype__HumanName__use-block {
14
- margin-left: 3px;
15
- }
@@ -1,8 +0,0 @@
1
- .fhir-datatype__Reference {
2
- display: inline-block;
3
- }
4
-
5
- .fhir-datatype__Reference__title {
6
- font-weight: 700;
7
- margin-right: 10px;
8
- }
@@ -1,51 +0,0 @@
1
- .fhir-resource__ObservationGraph {
2
- margin: 0.5rem 0;
3
- position: relative;
4
- }
5
-
6
- .fhir-resource__ObservationGraph__value-wrapper {
7
- position: relative;
8
- }
9
-
10
- .fhir-resource__ObservationGraph__value-actual {
11
- display: inline-block;
12
- font-size: 1.5rem;
13
- font-weight: bold;
14
- margin: 0;
15
- }
16
-
17
- .fhir-resource__ObservationGraph__value-unit {
18
- display: inline-block;
19
- }
20
-
21
- .fhir-resource__ObservationGraph__progress {
22
- display: flex;
23
- height: 1rem;
24
- overflow: hidden;
25
- font-size: 0.75rem;
26
- background-color: #e9ecef;
27
- border-radius: 0.25rem;
28
- }
29
-
30
- .fhir-resource__ObservationGraph__progress-value {
31
- opacity: 0.5;
32
- width: 12px;
33
- height: 12px;
34
- margin-top: 2px;
35
- position: absolute;
36
- background-color: #007bff;
37
- border-radius: 50%;
38
- }
39
-
40
- .fhir-resource__ObservationGraph__progress-bar--outside-range {
41
- color: #6c757d;
42
- background-color: transparent;
43
- display: flex;
44
- align-items: center;
45
- justify-content: center;
46
- white-space: nowrap;
47
- }
48
-
49
- .fhir-resource__ObservationGraph__progress-bar--inside-range {
50
- background-color: #0003;
51
- }
@@ -1,19 +0,0 @@
1
- .fhir-resource__Patient__patientContact-relationship {
2
- font-weight: 700;
3
- }
4
-
5
- .fhir-resource__Patient__patient-avatar {
6
- border: 4px solid #fff;
7
- border-radius: 50%;
8
- margin-right: 10px;
9
- }
10
-
11
- .fhir-resource__Patient__patient-block {
12
- display: flex;
13
- align-items: baseline;
14
- }
15
-
16
- .fhir-resource__Patient__BirthDate-block {
17
- font-weight: 700;
18
- color: #6c757d;
19
- }
@@ -1,123 +0,0 @@
1
- .fhir-ui__Header {
2
- width: 100%;
3
- margin-bottom: 10px;
4
- display: flex;
5
- flex-wrap: wrap;
6
- align-items: center;
7
- word-break: break-word;
8
- }
9
-
10
- .fhir-ui__Title {
11
- margin-right: 10px;
12
- margin-bottom: 0;
13
- }
14
-
15
- .fhir-ui__Badge {
16
- margin-right: 10px;
17
- display: inline-block;
18
- padding: 0.25em 0.4em;
19
- font-size: 75%;
20
- font-weight: 700;
21
- line-height: 1;
22
- color: #fff;
23
- text-align: center;
24
- white-space: nowrap;
25
- vertical-align: baseline;
26
- border-radius: 3px;
27
- background-color: #6c757d;
28
- }
29
-
30
- .fhir-ui__BadgeSecondary {
31
- margin-right: 10px;
32
- display: inline-block;
33
- padding: 0.25em 0.4em;
34
- font-size: 75%;
35
- font-weight: 700;
36
- line-height: 1;
37
- text-align: center;
38
- white-space: nowrap;
39
- vertical-align: baseline;
40
- border-radius: 3px;
41
- background-color: #f8f9fa;
42
- color: #000;
43
- overflow: auto;
44
- }
45
-
46
- .fhir-ui__Value {
47
- display: flex;
48
- margin-bottom: 5px;
49
- font-size: 90%;
50
- }
51
-
52
- .fhir-ui__Value :not(.fhir-ui__Value-label) {
53
- word-break: break-all;
54
- }
55
-
56
- .fhir-ui__Value-label {
57
- text-transform: uppercase;
58
- font-weight: bold;
59
- color: #6c757d;
60
- margin: 0 10px 0 0;
61
- }
62
-
63
- /* Based on bootstrap striped-table */
64
- .fhir-ui__Table {
65
- width: 100%;
66
- margin-bottom: 1rem;
67
- color: #212529;
68
- }
69
-
70
- .fhir-ui__TableHeader,
71
- .fhir-ui__TableCell {
72
- padding: 0.4rem 0.75rem;
73
- vertical-align: top;
74
- border-top: 1px solid #dee2e6;
75
- }
76
-
77
- .fhir-ui__TableHeader {
78
- vertical-align: bottom;
79
- border-bottom: 2px solid #dee2e6;
80
- }
81
-
82
- .fhir-ui__TableHeader--expand {
83
- width: 100%;
84
- }
85
-
86
- .fhir-ui__TableHeader--no-word-wrap {
87
- white-space: nowrap;
88
- }
89
-
90
- .fhir-ui__Table tbody + tbody {
91
- border-top: 2px solid #dee2e6;
92
- }
93
-
94
- .fhir-ui__Table tbody .fhir-ui__TableRow:nth-of-type(odd) {
95
- background-color: rgba(0, 0, 0, 0.05);
96
- }
97
-
98
- .fhir-ui__ValueSection {
99
- overflow: auto;
100
- }
101
-
102
- .fhir-ui__ValueSection-label {
103
- margin-top: 5px;
104
- font-size: 1.1em;
105
- color: #6c757d;
106
- text-transform: uppercase;
107
- font-weight: 700;
108
- }
109
-
110
- .fhir-ui__ValueSection-body {
111
- padding: 0 10px;
112
- }
113
-
114
- .fhir-ui__MissingValue {
115
- font-weight: 700;
116
- }
117
-
118
- .fhir-ui__NotEnoughData {
119
- background-color: rgba(0, 0, 0, 0.01);
120
- padding: 5px 15px;
121
- margin: 10px 0;
122
- border: 1px solid rgba(0, 0, 0, 0.03);
123
- }