fhir-react 0.3.7 → 0.3.8

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/.circleci/config.yml +1 -1
  2. package/.eslintrc +10 -1
  3. package/.stylelintrc +6 -2
  4. package/README.md +19 -1
  5. package/build/index.js +15 -11
  6. package/build/style.css +7 -7
  7. package/package.json +55 -54
  8. package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
  9. package/src/assets/containers/Generic/generic.svg +3 -0
  10. package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
  11. package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
  12. package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
  13. package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
  14. package/src/components/containers/Accordion/Accordion.js +21 -13
  15. package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
  16. package/src/components/datatypes/Coding/Coding.js +7 -3
  17. package/src/components/datatypes/Reference/Reference.js +7 -5
  18. package/src/components/datatypes/Telecom/Telecom.js +2 -3
  19. package/src/components/resources/AdverseEvent/AdverseEvent.js +81 -42
  20. package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
  21. package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
  22. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +7 -1
  23. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
  24. package/src/components/resources/Appointment/Appointment.js +2 -1
  25. package/src/components/resources/Appointment/Appointment.test.js +36 -1
  26. package/src/components/resources/Bundle/Bundle.css +7 -0
  27. package/src/components/resources/Bundle/Bundle.js +15 -11
  28. package/src/components/resources/Bundle/Bundle.stories.js +12 -78
  29. package/src/components/resources/Bundle/Bundle.test.js +0 -3
  30. package/src/components/resources/CarePlan/CarePlan.js +2 -1
  31. package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
  32. package/src/components/resources/CareTeam/CareTeam.js +72 -50
  33. package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
  34. package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
  35. package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
  36. package/src/components/resources/Claim/Claim.js +2 -1
  37. package/src/components/resources/Claim/Claim.test.js +32 -1
  38. package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
  39. package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
  40. package/src/components/resources/ClaimResponse/ClaimResponse.js +137 -83
  41. package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
  42. package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
  43. package/src/components/resources/ClaimResponse/Item.js +44 -9
  44. package/src/components/resources/ClaimResponse/Items.js +5 -4
  45. package/src/components/resources/Condition/Condition.js +3 -3
  46. package/src/components/resources/Condition/Condition.test.js +37 -4
  47. package/src/components/resources/Coverage/Coverage.js +2 -1
  48. package/src/components/resources/Coverage/Coverage.test.js +36 -1
  49. package/src/components/resources/Device/Device.js +2 -1
  50. package/src/components/resources/Device/Device.test.js +36 -1
  51. package/src/components/resources/DiagnosticReport/DiagnosticReport.js +7 -2
  52. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
  53. package/src/components/resources/DocumentReference/DocumentReference.js +7 -2
  54. package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
  55. package/src/components/resources/Encounter/Encounter.js +2 -1
  56. package/src/components/resources/Encounter/Encounter.test.js +36 -1
  57. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +2 -0
  58. package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
  59. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +7 -2
  60. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
  61. package/src/components/resources/Generic/Generic.js +20 -7
  62. package/src/components/resources/Generic/Generic.stories.js +2 -1
  63. package/src/components/resources/Generic/Generic.test.js +26 -7
  64. package/src/components/resources/Goal/Goal.js +2 -3
  65. package/src/components/resources/Goal/Goal.test.js +32 -1
  66. package/src/components/resources/Immunization/Immunization.js +2 -2
  67. package/src/components/resources/Immunization/Immunization.test.js +36 -1
  68. package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
  69. package/src/components/resources/List/Entries.js +3 -3
  70. package/src/components/resources/List/List.js +135 -88
  71. package/src/components/resources/List/List.stories.js +38 -5
  72. package/src/components/resources/List/List.test.js +105 -1
  73. package/src/components/resources/Location/Location.js +65 -47
  74. package/src/components/resources/Location/Location.stories.js +11 -4
  75. package/src/components/resources/Location/Location.test.js +106 -4
  76. package/src/components/resources/Medication/Medication.js +2 -1
  77. package/src/components/resources/Medication/Medication.test.js +36 -1
  78. package/src/components/resources/MedicationAdministration/MedicationAdministration.js +86 -62
  79. package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
  80. package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
  81. package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
  82. package/src/components/resources/MedicationDispense/MedicationDispense.js +68 -68
  83. package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
  84. package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
  85. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +115 -66
  86. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
  87. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
  88. package/src/components/resources/MedicationOrder/MedicationOrder.js +2 -3
  89. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
  90. package/src/components/resources/MedicationRequest/MedicationRequest.js +2 -1
  91. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
  92. package/src/components/resources/MedicationStatement/MedicationStatement.js +7 -2
  93. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
  94. package/src/components/resources/Observation/Observation.js +2 -1
  95. package/src/components/resources/Observation/Observation.test.js +30 -1
  96. package/src/components/resources/Organization/Organization.js +3 -2
  97. package/src/components/resources/Organization/Organization.test.js +36 -1
  98. package/src/components/resources/Patient/Patient.js +2 -0
  99. package/src/components/resources/Patient/Patient.test.js +31 -2
  100. package/src/components/resources/Practitioner/Practitioner.js +2 -1
  101. package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
  102. package/src/components/resources/PractitionerRole/PractitionerRole.js +50 -29
  103. package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
  104. package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
  105. package/src/components/resources/Procedure/Procedure.js +2 -2
  106. package/src/components/resources/Procedure/Procedure.test.js +30 -1
  107. package/src/components/resources/Questionnaire/Group.js +53 -0
  108. package/src/components/resources/Questionnaire/Items.js +45 -0
  109. package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
  110. package/src/components/resources/Questionnaire/Questionnaire.js +31 -170
  111. package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
  112. package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
  113. package/src/components/resources/Questionnaire/Questions.js +40 -0
  114. package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
  115. package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
  116. package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
  117. package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
  118. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
  119. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +52 -236
  120. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
  121. package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
  122. package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
  123. package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
  124. package/src/components/resources/ReferralRequest/ReferralRequest.js +65 -40
  125. package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
  126. package/src/components/resources/RelatedPerson/RelatedPerson.js +151 -0
  127. package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -0
  128. package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
  129. package/src/components/resources/RelatedPerson/index.js +3 -0
  130. package/src/components/resources/ResearchStudy/ResearchStudy.js +160 -130
  131. package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
  132. package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
  133. package/src/components/ui/index.js +22 -9
  134. package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
  135. package/src/fixtures/example-icons.jsx +42 -0
  136. package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
  137. package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
  138. package/src/style.scss +3 -1
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import _get from 'lodash/get';
4
4
  import { getExtension } from './utils';
5
- import { ValueSection, Value } from '../../ui';
5
+ import { ValueSection, ValueSectionItem } from '../../ui';
6
6
  import CodeableConcept from '../../datatypes/CodeableConcept';
7
7
  import Money from '../../datatypes/Money';
8
8
 
@@ -82,48 +82,92 @@ const DrugTierDefinitionExtension = props => {
82
82
  coinsuranceOption,
83
83
  } = dto(drugTierDefinitionExtension);
84
84
 
85
+ const drugData = [
86
+ {
87
+ label: 'Drug Tier ID',
88
+ testId: 'drugTierID',
89
+ data: drugTierID && <CodeableConcept fhirData={drugTierID} />,
90
+ status: drugTierID,
91
+ },
92
+ {
93
+ label: 'Mail order',
94
+ testId: 'mailOrder',
95
+ data: mailOrder ? 'yes' : 'no',
96
+ status: mailOrder,
97
+ },
98
+ ];
99
+
100
+ const costData = [
101
+ {
102
+ label: 'Pharmacy Type',
103
+ testId: 'pharmacyType',
104
+ data: pharmacyType && <CodeableConcept fhirData={pharmacyType} />,
105
+ status: pharmacyType,
106
+ },
107
+ {
108
+ label: 'Copay Amount',
109
+ testId: 'copayAmount',
110
+ data: copayAmount && <Money fhirData={copayAmount} />,
111
+ status: copayAmount,
112
+ },
113
+ {
114
+ label: 'Copay Option',
115
+ testId: 'copayOption',
116
+ data: copayOption && <CodeableConcept fhirData={copayOption} />,
117
+ status: copayOption,
118
+ },
119
+ {
120
+ label: 'Coinsurance Rate',
121
+ testId: 'coinsuranceRate',
122
+ data: coinsuranceRate,
123
+ status: coinsuranceRate === 0 || coinsuranceRate,
124
+ },
125
+ {
126
+ label: 'Coinsurance Option',
127
+ testId: 'coinsuranceOption',
128
+ data: coinsuranceOption && (
129
+ <CodeableConcept fhirData={coinsuranceOption} />
130
+ ),
131
+ status: coinsuranceOption,
132
+ },
133
+ ];
134
+
85
135
  return (
86
136
  hasExtensions && (
87
137
  <ValueSection
88
138
  label="Drug Tier Definition"
89
139
  data-testid="drugTierDefinition"
140
+ marginTop
90
141
  >
91
- {drugTierID && (
92
- <Value label="Drug Tier ID" data-testid="drugTierID">
93
- <CodeableConcept fhirData={drugTierID} />
94
- </Value>
95
- )}
96
- {mailOrder && (
97
- <Value label="Mail order" data-testid="mailOrder">
98
- {mailOrder ? 'yes' : 'no'}
99
- </Value>
142
+ {drugData.map(
143
+ (item, index) =>
144
+ item.status && (
145
+ <ValueSectionItem
146
+ key={`drug-item-${index}`}
147
+ label={item.label}
148
+ data-testid={item.testId}
149
+ >
150
+ {item.data}
151
+ </ValueSectionItem>
152
+ ),
100
153
  )}
101
154
  {hasConstSharing && (
102
- <ValueSection label="Cost sharing" data-testid="costSharing">
103
- {pharmacyType && (
104
- <Value label="Pharmacy Type" data-testid="pharmacyType">
105
- <CodeableConcept fhirData={pharmacyType} />
106
- </Value>
107
- )}
108
- {copayAmount && (
109
- <Value label="Copay Amount" data-testid="copayAmount">
110
- <Money fhirData={copayAmount} />
111
- </Value>
112
- )}
113
- {copayOption && (
114
- <Value label="Copay Option" data-testid="copayOption">
115
- <CodeableConcept fhirData={copayOption} />
116
- </Value>
117
- )}
118
- {(coinsuranceRate === 0 || coinsuranceRate) && (
119
- <Value label="Coinsurance Rate" data-testid="coinsuranceRate">
120
- {coinsuranceRate}
121
- </Value>
122
- )}
123
- {coinsuranceOption && (
124
- <Value label="Coinsurance Option" data-testid="coinsuranceOption">
125
- <CodeableConcept fhirData={coinsuranceOption} />
126
- </Value>
155
+ <ValueSection
156
+ label="Cost sharing"
157
+ data-testid="costSharing"
158
+ marginTop
159
+ >
160
+ {costData.map(
161
+ (item, index) =>
162
+ item.status && (
163
+ <ValueSectionItem
164
+ key={`cost-item-${index}`}
165
+ label={item.label}
166
+ data-testid={item.testId}
167
+ >
168
+ {item.data}
169
+ </ValueSectionItem>
170
+ ),
127
171
  )}
128
172
  </ValueSection>
129
173
  )}
@@ -16,7 +16,7 @@ import Reference from '../../datatypes/Reference';
16
16
  const Entries = ({ fhirData: items = [] }) => {
17
17
  if (items.length === 0) return null;
18
18
  return (
19
- <ValueSection label="Entries" data-testid="entries">
19
+ <ValueSection label="Entries" data-testid="entries" marginTop>
20
20
  <Table>
21
21
  <thead>
22
22
  <TableRow>
@@ -26,7 +26,7 @@ const Entries = ({ fhirData: items = [] }) => {
26
26
  <TableHeader>Status</TableHeader>
27
27
  </TableRow>
28
28
  </thead>
29
- <tbody>
29
+ <tbody className="border-top-0">
30
30
  {items.map((item, idx) => (
31
31
  <Entry key={idx} item={item} />
32
32
  ))}
@@ -50,7 +50,7 @@ const Entry = props => {
50
50
  <Reference fhirData={entry} />
51
51
  </TableCell>
52
52
  <TableCell data-testid="items.date">
53
- {date ? <Date fhirData={date} /> : <MissingValue />}
53
+ {date ? <Date fhirData={date} isBlack /> : <MissingValue />}
54
54
  </TableCell>
55
55
  <TableCell data-testid="items.isDeleted">
56
56
  {deleted === true ? 'yes' : 'no'}
@@ -8,11 +8,10 @@ import { getExtension } from './utils';
8
8
  import {
9
9
  Root,
10
10
  Header,
11
- Title,
12
- Value,
13
11
  Body,
14
12
  ValueSection,
15
13
  Badge,
14
+ ValueSectionItem,
16
15
  } from '../../ui';
17
16
  import Date from '../../datatypes/Date';
18
17
  import Reference from '../../datatypes/Reference';
@@ -20,6 +19,7 @@ import Entries from './Entries';
20
19
  import Identifier from '../../datatypes/Identifier/Identifier';
21
20
  import CodeableConcept from '../../datatypes/CodeableConcept';
22
21
  import DrugTierDefinitionExtension from './DrugTierDefinitionExtension';
22
+ import Accordion from '../../containers/Accordion';
23
23
 
24
24
  const commonDTO = fhirResource => {
25
25
  const id = _get(fhirResource, 'id');
@@ -125,8 +125,13 @@ const resourceDTO = (fhirVersion, fhirResource, withDaVinciPDex) => {
125
125
  }
126
126
  };
127
127
 
128
- const List = props => {
129
- const { fhirResource, fhirVersion, withDaVinciPDex = false } = props;
128
+ const List = ({
129
+ fhirResource,
130
+ fhirVersion,
131
+ withDaVinciPDex = false,
132
+ fhirIcons,
133
+ onClick,
134
+ }) => {
130
135
  let fhirResourceData = {};
131
136
  try {
132
137
  fhirResourceData = resourceDTO(fhirVersion, fhirResource, withDaVinciPDex);
@@ -156,95 +161,137 @@ const List = props => {
156
161
  usdfPlanIDType,
157
162
  } = fhirResourceData;
158
163
 
164
+ const tableData = [
165
+ {
166
+ label: 'Identifier',
167
+ testId: 'identifier',
168
+ data:
169
+ identifier &&
170
+ identifier.map((id, index) => (
171
+ <div key={`identifier-${index}`}>
172
+ <Identifier fhirData={id} />
173
+ </div>
174
+ )),
175
+ status: identifier,
176
+ },
177
+ {
178
+ label: 'Mode',
179
+ testId: 'mode',
180
+ data: mode,
181
+ status: mode,
182
+ },
183
+ {
184
+ label: 'code',
185
+ testId: 'code',
186
+ data: code && <CodeableConcept fhirData={code} />,
187
+ status: code,
188
+ },
189
+ {
190
+ label: 'Subject',
191
+ testId: 'subject',
192
+ data: subject && <Reference fhirData={subject} />,
193
+ status: subject,
194
+ },
195
+ {
196
+ label: 'Date',
197
+ testId: 'date',
198
+ data: date && <Date fhirData={date} isBlack />,
199
+ status: date,
200
+ },
201
+ {
202
+ label: 'Source',
203
+ testId: 'source',
204
+ data: source && <Reference fhirData={source} />,
205
+ status: source,
206
+ },
207
+ ];
208
+
209
+ const extensionData = [
210
+ {
211
+ label: 'Network',
212
+ testId: 'usdfNetwork',
213
+ data: usdfNetwork,
214
+ status: usdfNetwork,
215
+ },
216
+ {
217
+ label: 'Summary URL',
218
+ testId: 'usdfSummaryURL',
219
+ data: usdfSummaryURL,
220
+ status: usdfSummaryURL,
221
+ },
222
+ {
223
+ label: 'Formulary URL',
224
+ testId: 'usdfFormularyURL',
225
+ data: usdfFormularyURL,
226
+ status: usdfFormularyURL,
227
+ },
228
+ {
229
+ label: 'Email Plan Contact',
230
+ testId: 'usdfEmailPlanContact',
231
+ data: usdfEmailPlanContact,
232
+ status: usdfEmailPlanContact,
233
+ },
234
+ {
235
+ label: 'Marketing URL',
236
+ testId: 'usdfMarketingURL',
237
+ data: usdfMarketingURL,
238
+ status: usdfMarketingURL,
239
+ },
240
+ {
241
+ label: 'Plan ID Type',
242
+ testId: 'usdfPlanIDType',
243
+ data: usdfPlanIDType,
244
+ status: usdfPlanIDType,
245
+ },
246
+ ];
247
+
159
248
  return (
160
249
  <Root name="List">
161
- <Header>
162
- <Title>
163
- {title || 'List'} {id && id}{' '}
164
- {status && <Badge data-testid="status">{status}</Badge>}
165
- </Title>
166
- </Header>
167
- <Body>
168
- {identifier && (
169
- <Value label="Identifier" data-testid="identifier">
170
- {identifier.map((id, index) => (
171
- <div key={`identifier-${index}`}>
172
- <Identifier fhirData={id} />
173
- </div>
174
- ))}
175
- </Value>
176
- )}
177
- {mode && (
178
- <Value label="Mode" data-testid="mode">
179
- {mode}
180
- </Value>
181
- )}
182
- {code && (
183
- <Value label="code" data-testid="code">
184
- <CodeableConcept fhirData={code} />
185
- </Value>
186
- )}
187
- {subject && (
188
- <Value label="Subject" data-testid="subject">
189
- <Reference fhirData={subject} />
190
- </Value>
191
- )}
192
- {date && (
193
- <Value label="Date" data-testid="date">
194
- <Date fhirData={date} />
195
- </Value>
196
- )}
197
- {source && (
198
- <Value label="Source" data-testid="source">
199
- <Reference fhirData={source} />
200
- </Value>
201
- )}
202
- {entry && <Entries fhirData={entry} />}
250
+ <Accordion
251
+ headerContent={
252
+ <Header
253
+ resourceName="List"
254
+ title={`${title || 'List'} ${id && id} `}
255
+ badges={status && <Badge data-testid="status">{status}</Badge>}
256
+ icon={fhirIcons}
257
+ />
258
+ }
259
+ bodyContent={
260
+ <Body tableData={tableData}>
261
+ {entry && <Entries fhirData={entry} />}
203
262
 
204
- {hasExtensions && (
205
- <ValueSection label="USDF extensions" data-testid="usdfExtensions">
206
- {usdfDrugTierDefinition && (
207
- <DrugTierDefinitionExtension
208
- drugTierDefinitionExtension={usdfDrugTierDefinition}
209
- data-testid="usdfDrugTierDefinition"
210
- />
211
- )}
212
- {usdfNetwork && (
213
- <Value label="Network" data-testid="usdfNetwork">
214
- {usdfNetwork}
215
- </Value>
216
- )}
217
- {usdfSummaryURL && (
218
- <Value label="Summary URL" data-testid="usdfSummaryURL">
219
- {usdfSummaryURL}
220
- </Value>
221
- )}
222
- {usdfFormularyURL && (
223
- <Value label="Formulary URL" data-testid="usdfFormularyURL">
224
- {usdfFormularyURL}
225
- </Value>
226
- )}
227
- {usdfEmailPlanContact && (
228
- <Value
229
- label="Email Plan Contact"
230
- data-testid="usdfEmailPlanContact"
263
+ {hasExtensions && (
264
+ <ValueSection
265
+ label="USDF extensions"
266
+ data-testid="usdfExtensions"
267
+ marginTop
231
268
  >
232
- {usdfEmailPlanContact}
233
- </Value>
234
- )}
235
- {usdfMarketingURL && (
236
- <Value label="Marketing URL" data-testid="usdfMarketingURL">
237
- {usdfMarketingURL}
238
- </Value>
239
- )}
240
- {usdfPlanIDType && (
241
- <Value label="Plan ID Type" data-testid="usdfPlanIDType">
242
- {usdfPlanIDType}
243
- </Value>
269
+ {usdfDrugTierDefinition && (
270
+ <DrugTierDefinitionExtension
271
+ drugTierDefinitionExtension={usdfDrugTierDefinition}
272
+ data-testid="usdfDrugTierDefinition"
273
+ />
274
+ )}
275
+ <ValueSection marginTop>
276
+ {extensionData.map(
277
+ (item, index) =>
278
+ item.status && (
279
+ <ValueSectionItem
280
+ key={`extension-item-${index}`}
281
+ label={item.label}
282
+ data-testid={item.testId}
283
+ >
284
+ {item.data}
285
+ </ValueSectionItem>
286
+ ),
287
+ )}
288
+ </ValueSection>
289
+ </ValueSection>
244
290
  )}
245
- </ValueSection>
246
- )}
247
- </Body>
291
+ </Body>
292
+ }
293
+ onClick={onClick}
294
+ />
248
295
  </Root>
249
296
  );
250
297
  };
@@ -14,32 +14,65 @@ import example1R4 from '../../../fixtures/r4/resources/list/example1.json';
14
14
  import example2R4 from '../../../fixtures/r4/resources/list/example2.json';
15
15
  import example3R4 from '../../../fixtures/r4/resources/list/example3.json';
16
16
 
17
+ import fhirIcons from '../../../fixtures/example-icons';
18
+ import ListIcon from '../../../assets/containers/List/list.svg';
19
+
17
20
  export default {
18
21
  title: 'List',
19
22
  };
20
23
 
21
24
  export const DefaultVisualizationDSTU2 = () => {
22
25
  const fhirResource = object('Resource', example1Dstu2);
23
- return <List fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
26
+ return (
27
+ <List
28
+ fhirVersion={fhirVersions.DSTU2}
29
+ fhirResource={fhirResource}
30
+ fhirIcons={require('../../../assets/containers/List/list.svg')}
31
+ />
32
+ );
24
33
  };
25
34
 
26
35
  export const Example2DSTU2 = () => {
27
36
  const fhirResource = object('Resource', example2Dstu2);
28
- return <List fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
37
+ return (
38
+ <List
39
+ fhirVersion={fhirVersions.DSTU2}
40
+ fhirResource={fhirResource}
41
+ fhirIcons={ListIcon}
42
+ />
43
+ );
29
44
  };
30
45
  export const Example3DSTU2 = () => {
31
46
  const fhirResource = object('Resource', example3Dstu2);
32
- return <List fhirVersion={fhirVersions.DSTU2} fhirResource={fhirResource} />;
47
+ return (
48
+ <List
49
+ fhirVersion={fhirVersions.DSTU2}
50
+ fhirResource={fhirResource}
51
+ fhirIcons={fhirIcons}
52
+ />
53
+ );
33
54
  };
34
55
 
35
56
  export const DefaultVisualizationSTU3 = () => {
36
57
  const fhirResource = object('Resource', example1Stu3);
37
- return <List fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />;
58
+ return (
59
+ <List
60
+ fhirVersion={fhirVersions.STU3}
61
+ fhirResource={fhirResource}
62
+ fhirIcons={false}
63
+ />
64
+ );
38
65
  };
39
66
 
40
67
  export const Example2STU3 = () => {
41
68
  const fhirResource = object('Resource', example2Stu3);
42
- return <List fhirVersion={fhirVersions.STU3} fhirResource={fhirResource} />;
69
+ return (
70
+ <List
71
+ fhirVersion={fhirVersions.STU3}
72
+ fhirResource={fhirResource}
73
+ fhirIcons={'random text'}
74
+ />
75
+ );
43
76
  };
44
77
  export const Example3STU3 = () => {
45
78
  const fhirResource = object('Resource', example3Stu3);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { fireEvent, render } from '@testing-library/react';
3
3
 
4
4
  import { fhirVersions } from '../../../index';
5
5
 
@@ -7,8 +7,79 @@ import List from './List';
7
7
 
8
8
  import example1Dstu2 from '../../../fixtures/dstu2/resources/list/example1.json';
9
9
  import example2R4 from '../../../fixtures/r4/resources/list/example2.json';
10
+ import fhirIcons from '../../../fixtures/example-icons';
10
11
 
11
12
  describe('should render List component properly', () => {
13
+ it('component without a fhirIcons props should render a default icon', () => {
14
+ const defaultProps = {
15
+ fhirVersion: fhirVersions.DSTU2,
16
+ fhirResource: example1Dstu2,
17
+ };
18
+
19
+ const { getByAltText } = render(<List {...defaultProps} />);
20
+ const headerIcon = getByAltText('list');
21
+
22
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
23
+ });
24
+
25
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
26
+ const defaultProps = {
27
+ fhirVersion: fhirVersions.DSTU2,
28
+ fhirResource: example1Dstu2,
29
+ fhirIcons: false,
30
+ };
31
+
32
+ const { getByTestId } = render(<List {...defaultProps} />);
33
+ const headerIcon = getByTestId('placeholder');
34
+
35
+ expect(headerIcon).toBeTruthy();
36
+ });
37
+
38
+ it('component with the img as a fhirIcons props should render an img', () => {
39
+ const defaultProps = {
40
+ fhirVersion: fhirVersions.DSTU2,
41
+ fhirResource: example1Dstu2,
42
+ fhirIcons: (
43
+ <img
44
+ src={require('../assets/containers/List/list.svg')}
45
+ alt="checklist"
46
+ />
47
+ ),
48
+ };
49
+
50
+ const { getByAltText } = render(<List {...defaultProps} />);
51
+ const headerIcon = getByAltText('checklist');
52
+
53
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
54
+ });
55
+
56
+ it('component with the resources object as a fhirIcons props should render an img', () => {
57
+ const defaultProps = {
58
+ fhirVersion: fhirVersions.DSTU2,
59
+ fhirResource: example1Dstu2,
60
+ fhirIcons: fhirIcons,
61
+ };
62
+
63
+ const { getByAltText } = render(<List {...defaultProps} />);
64
+ const headerIcon = getByAltText('checklist');
65
+
66
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
67
+ });
68
+
69
+ it('component with the url as a fhirIcons props should render an img', () => {
70
+ const avatarSrc =
71
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
72
+ const defaultProps = {
73
+ fhirVersion: fhirVersions.DSTU2,
74
+ fhirResource: example1Dstu2,
75
+ fhirIcons: avatarSrc,
76
+ };
77
+
78
+ const { getByAltText } = render(<List {...defaultProps} />);
79
+ const headerIcon = getByAltText('header icon');
80
+
81
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
82
+ });
12
83
  it('should render with DSTU2 source data', () => {
13
84
  const defaultProps = {
14
85
  fhirResource: example1Dstu2,
@@ -92,4 +163,37 @@ describe('should render List component properly', () => {
92
163
  );
93
164
  expect(getByTestId('usdfPlanIDType').textContent).toContain('HIOS-PLAN-ID');
94
165
  });
166
+
167
+ it('should fire custom onClick function', () => {
168
+ const defaultProps = {
169
+ fhirResource: example2R4,
170
+ fhirVersion: fhirVersions.R4,
171
+ withDaVinciPDex: true,
172
+ };
173
+
174
+ const onClick = jest.fn();
175
+ const { getByRole } = render(<List {...defaultProps} onClick={onClick} />);
176
+ const accordion = getByRole('button');
177
+ fireEvent.click(accordion);
178
+
179
+ const attribute = accordion.getAttribute('data-bs-toggle');
180
+ expect(attribute).not.toEqual('collapse');
181
+ expect(onClick).toHaveBeenCalled();
182
+ });
183
+
184
+ it('should not fire custom onClick function', () => {
185
+ const defaultProps = {
186
+ fhirResource: example2R4,
187
+ fhirVersion: fhirVersions.R4,
188
+ withDaVinciPDex: true,
189
+ };
190
+
191
+ const onClick = 'test';
192
+ const { getByRole } = render(<List {...defaultProps} onClick={onClick} />);
193
+ const accordion = getByRole('button');
194
+ fireEvent.click(accordion);
195
+
196
+ const attribute = accordion.getAttribute('data-bs-toggle');
197
+ expect(attribute).toEqual('collapse');
198
+ });
95
199
  });