fhir-react 0.3.6 → 0.3.9
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.
- package/.circleci/config.yml +1 -1
- package/.eslintrc +10 -1
- package/.stylelintrc +6 -2
- package/README.md +19 -1
- package/build/index.js +15 -11
- package/build/style.css +11 -10
- package/package.json +55 -54
- package/src/assets/containers/AdverseEvent/adverse-event.svg +6 -0
- package/src/assets/containers/Coverage/coverage.svg +4 -0
- package/src/assets/containers/Generic/generic.svg +3 -0
- package/src/assets/containers/Medication/medication.svg +5 -0
- package/src/assets/containers/MedicationDispense/medication-dispense.svg +5 -0
- package/src/assets/containers/Organization/organization.svg +5 -0
- package/src/assets/containers/PractitionerRole/practitioner-role.svg +5 -0
- package/src/assets/containers/ReferralRequest/referral-request.svg +8 -0
- package/src/assets/containers/RelatedPerson/related-person.svg +6 -0
- package/src/components/containers/Accordion/Accordion.js +44 -13
- package/src/components/containers/ResourceContainer/ResourceContainer.css +4 -0
- package/src/components/containers/ResourceContainer/ResourceContainer.js +28 -37
- package/src/components/containers/ResourceContainer/ResourceContainer.stories.js +23 -1
- package/src/components/datatypes/Attachment/Attachment.css +5 -0
- package/src/components/datatypes/Attachment/Attachment.js +7 -2
- package/src/components/datatypes/CodeableConcept/CodeableConcept.js +6 -3
- package/src/components/datatypes/Coding/Coding.js +7 -3
- package/src/components/datatypes/Identifier/Identifier.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +7 -1
- package/src/components/datatypes/Telecom/Telecom.js +2 -3
- package/src/components/resources/AdverseEvent/AdverseEvent.js +88 -42
- package/src/components/resources/AdverseEvent/AdverseEvent.stories.js +12 -2
- package/src/components/resources/AdverseEvent/AdverseEvent.test.js +109 -2
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +9 -1
- package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +36 -1
- package/src/components/resources/Appointment/Appointment.js +9 -1
- package/src/components/resources/Appointment/Appointment.test.js +36 -1
- package/src/components/resources/Binary/Binary.js +2 -1
- package/src/components/resources/Bundle/Bundle.css +7 -0
- package/src/components/resources/Bundle/Bundle.js +15 -11
- package/src/components/resources/Bundle/Bundle.stories.js +12 -78
- package/src/components/resources/Bundle/Bundle.test.js +0 -3
- package/src/components/resources/CarePlan/CarePlan.js +9 -1
- package/src/components/resources/CarePlan/CarePlan.test.js +42 -6
- package/src/components/resources/CareTeam/CareTeam.js +79 -50
- package/src/components/resources/CareTeam/CareTeam.stories.js +20 -3
- package/src/components/resources/CareTeam/CareTeam.test.js +109 -1
- package/src/components/resources/CareTeam/CareTeamParticipants.js +1 -1
- package/src/components/resources/Claim/CareTeam.js +55 -0
- package/src/components/resources/Claim/Claim.css +2 -11
- package/src/components/resources/Claim/Claim.js +165 -309
- package/src/components/resources/Claim/Claim.stories.js +37 -5
- package/src/components/resources/Claim/Claim.test.js +104 -1
- package/src/components/resources/Claim/Diagnosis.js +61 -0
- package/src/components/resources/Claim/Insurance.js +58 -0
- package/src/components/resources/Claim/Item.js +79 -0
- package/src/components/resources/Claim/Items.js +29 -0
- package/src/components/resources/ClaimResponse/AddedItem.js +61 -11
- package/src/components/resources/ClaimResponse/AddedItems.js +5 -9
- package/src/components/resources/ClaimResponse/ClaimResponse.js +144 -83
- package/src/components/resources/ClaimResponse/ClaimResponse.stories.js +15 -2
- package/src/components/resources/ClaimResponse/ClaimResponse.test.js +112 -1
- package/src/components/resources/ClaimResponse/Item.js +44 -9
- package/src/components/resources/ClaimResponse/Items.js +5 -4
- package/src/components/resources/Condition/Condition.js +10 -3
- package/src/components/resources/Condition/Condition.test.js +37 -4
- package/src/components/resources/Coverage/Coverage.js +104 -69
- package/src/components/resources/Coverage/Coverage.stories.js +31 -5
- package/src/components/resources/Coverage/Coverage.test.js +111 -4
- package/src/components/resources/Device/Device.js +9 -1
- package/src/components/resources/Device/Device.test.js +36 -1
- package/src/components/resources/DiagnosticReport/DiagnosticReport.js +9 -2
- package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +36 -1
- package/src/components/resources/DocumentReference/DocumentReference.js +9 -2
- package/src/components/resources/DocumentReference/DocumentReference.test.js +42 -1
- package/src/components/resources/Encounter/Encounter.js +9 -1
- package/src/components/resources/Encounter/Encounter.test.js +36 -1
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.js +4 -0
- package/src/components/resources/ExplanationOfBenefit/ExplanationOfBenefit.test.js +38 -1
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.js +9 -2
- package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +36 -1
- package/src/components/resources/Generic/Generic.js +21 -7
- package/src/components/resources/Generic/Generic.stories.js +2 -1
- package/src/components/resources/Generic/Generic.test.js +26 -7
- package/src/components/resources/Goal/Goal.js +9 -3
- package/src/components/resources/Goal/Goal.test.js +32 -1
- package/src/components/resources/Immunization/Immunization.js +9 -2
- package/src/components/resources/Immunization/Immunization.test.js +36 -1
- package/src/components/resources/List/DrugTierDefinitionExtension.js +79 -35
- package/src/components/resources/List/Entries.js +3 -3
- package/src/components/resources/List/List.js +137 -88
- package/src/components/resources/List/List.stories.js +38 -5
- package/src/components/resources/List/List.test.js +105 -1
- package/src/components/resources/Location/Location.js +66 -47
- package/src/components/resources/Location/Location.stories.js +11 -4
- package/src/components/resources/Location/Location.test.js +106 -4
- package/src/components/resources/Medication/Medication.js +98 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +114 -5
- package/src/components/resources/MedicationAdministration/MedicationAdministration.js +88 -62
- package/src/components/resources/MedicationAdministration/MedicationAdministration.stories.js +7 -0
- package/src/components/resources/MedicationAdministration/MedicationAdministration.test.js +117 -1
- package/src/components/resources/MedicationDispense/DosageInstruction.js +25 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.js +70 -68
- package/src/components/resources/MedicationDispense/MedicationDispense.stories.js +7 -0
- package/src/components/resources/MedicationDispense/MedicationDispense.test.js +108 -1
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +117 -66
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.stories.js +6 -0
- package/src/components/resources/MedicationKnowledge/MedicationKnowledge.test.js +110 -1
- package/src/components/resources/MedicationOrder/MedicationOrder.js +3 -3
- package/src/components/resources/MedicationOrder/MedicationOrder.test.js +35 -4
- package/src/components/resources/MedicationRequest/MedicationRequest.js +8 -1
- package/src/components/resources/MedicationRequest/MedicationRequest.test.js +33 -4
- package/src/components/resources/MedicationStatement/MedicationStatement.js +9 -2
- package/src/components/resources/MedicationStatement/MedicationStatement.test.js +36 -1
- package/src/components/resources/Observation/Observation.js +3 -1
- package/src/components/resources/Observation/Observation.test.js +30 -1
- package/src/components/resources/Observation/ObservationGraph.js +1 -1
- package/src/components/resources/Organization/Organization.js +63 -37
- package/src/components/resources/Organization/Organization.stories.js +15 -2
- package/src/components/resources/Organization/Organization.test.js +109 -1
- package/src/components/resources/Patient/Patient.js +4 -0
- package/src/components/resources/Patient/Patient.test.js +31 -2
- package/src/components/resources/Practitioner/Practitioner.js +9 -1
- package/src/components/resources/Practitioner/Practitioner.test.js +36 -1
- package/src/components/resources/PractitionerRole/PractitionerRole.js +52 -29
- package/src/components/resources/PractitionerRole/PractitionerRole.stories.js +7 -0
- package/src/components/resources/PractitionerRole/PractitionerRole.test.js +108 -1
- package/src/components/resources/Procedure/Procedure.js +3 -2
- package/src/components/resources/Procedure/Procedure.test.js +30 -1
- package/src/components/resources/Questionnaire/Group.js +53 -0
- package/src/components/resources/Questionnaire/Items.js +45 -0
- package/src/components/resources/Questionnaire/Questionnaire.css +24 -5
- package/src/components/resources/Questionnaire/Questionnaire.js +38 -170
- package/src/components/resources/Questionnaire/Questionnaire.stories.js +8 -0
- package/src/components/resources/Questionnaire/Questionnaire.test.js +194 -15
- package/src/components/resources/Questionnaire/Questions.js +40 -0
- package/src/components/resources/Questionnaire/getQuestionText.js +20 -0
- package/src/components/resources/QuestionnaireResponse/Answers.js +59 -0
- package/src/components/resources/QuestionnaireResponse/Group.js +70 -0
- package/src/components/resources/QuestionnaireResponse/Items.js +45 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.css +33 -8
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.js +54 -236
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.stories.js +8 -0
- package/src/components/resources/QuestionnaireResponse/QuestionnaireResponse.test.js +38 -3
- package/src/components/resources/QuestionnaireResponse/Questions.js +43 -0
- package/src/components/resources/QuestionnaireResponse/getQuestionText.js +22 -0
- package/src/components/resources/ReferralRequest/ReferralRequest.js +72 -40
- package/src/components/resources/ReferralRequest/ReferralRequest.test.js +111 -11
- package/src/components/resources/RelatedPerson/RelatedPerson.js +158 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.stories.js +46 -0
- package/src/components/resources/RelatedPerson/RelatedPerson.test.js +156 -0
- package/src/components/resources/RelatedPerson/index.js +3 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.js +167 -130
- package/src/components/resources/ResearchStudy/ResearchStudy.stories.js +2 -0
- package/src/components/resources/ResearchStudy/ResearchStudy.test.js +108 -1
- package/src/components/resources/ResourceCategory/ResourceCategory.js +1 -1
- package/src/components/ui/index.js +56 -32
- package/src/fixtures/dstu2/resources/relatedPerson/example1.json +79 -0
- package/src/fixtures/example-icons.jsx +63 -0
- package/src/fixtures/r4/resources/relatedPerson/example1.json +64 -0
- package/src/fixtures/stu3/resources/relatedPerson/example1.json +43 -0
- package/src/style.scss +14 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fhirVersions from '../fhirResourceVersions';
|
|
2
|
+
import _get from 'lodash/get';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import Group from './Group';
|
|
6
|
+
|
|
7
|
+
const Items = ({ fhirVersion, data }) => {
|
|
8
|
+
if (fhirVersion === fhirVersions.DSTU2) {
|
|
9
|
+
const prepareItems = item => ({
|
|
10
|
+
...item,
|
|
11
|
+
item: _get(item, 'question') || _get(item, 'group') || [],
|
|
12
|
+
isGroup: !!_get(item, 'group'),
|
|
13
|
+
});
|
|
14
|
+
return <Group data={data} prepareItems={prepareItems} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (fhirVersion === fhirVersions.STU3) {
|
|
18
|
+
const prepareItems = item => ({
|
|
19
|
+
...item,
|
|
20
|
+
isGroup: _get(item, 'type') === 'group',
|
|
21
|
+
});
|
|
22
|
+
return <Group data={data} prepareItems={prepareItems} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (fhirVersion === fhirVersions.R4) {
|
|
26
|
+
const prepareItems = item => ({
|
|
27
|
+
...item,
|
|
28
|
+
isGroup: _get(item, 'type') === 'group',
|
|
29
|
+
});
|
|
30
|
+
return <Group data={data} prepareItems={prepareItems} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Items.propTypes = {
|
|
37
|
+
data: PropTypes.array,
|
|
38
|
+
fhirVersion: PropTypes.oneOf([
|
|
39
|
+
fhirVersions.DSTU2,
|
|
40
|
+
fhirVersions.STU3,
|
|
41
|
+
fhirVersions.R4,
|
|
42
|
+
]).isRequired,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default Items;
|
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
.fhir-resource__Questionnaire-list {
|
|
2
2
|
list-style: none;
|
|
3
|
-
border: 1px solid #f0f0f0;
|
|
4
3
|
padding: 2px;
|
|
5
4
|
margin: 2px;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
.fhir-resource__Questionnaire-list-title {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
padding: 2px 2px 8px 2px;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.fhir-resource__Questionnaire-list-title-question {
|
|
13
|
+
background: #f8f9fa;
|
|
14
|
+
align-items: center;
|
|
15
|
+
margin-bottom: 56px;
|
|
16
|
+
padding-left: 16px;
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
color: #adb5bd;
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
.fhir-resource__Questionnaire-questions-list {
|
|
14
22
|
list-style: none;
|
|
23
|
+
padding-left: 0;
|
|
24
|
+
display: block;
|
|
25
|
+
color: #adb5bd;
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
.fhir-resource__Questionnaire-questions-list li {
|
|
18
|
-
|
|
29
|
+
display: block;
|
|
30
|
+
margin-bottom: 56px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.fhir-resource__Questionnaire-questions-list-element {
|
|
34
|
+
background: #f8f9fa;
|
|
35
|
+
border-radius: 4px;
|
|
36
|
+
width: 100%;
|
|
37
|
+
padding-left: 16px;
|
|
38
|
+
margin-bottom: 56px;
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
.fhir-resource__Questionnaire-questions-list li:last-child {
|
|
@@ -24,7 +44,6 @@
|
|
|
24
44
|
|
|
25
45
|
.fhir-resource__Questionnaire-questions-list-item-details {
|
|
26
46
|
font-size: 80%;
|
|
27
|
-
color: #606060;
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
.fhir-resource__Questionnaire-questions-list-item-details-el {
|
|
@@ -2,164 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import _get from 'lodash/get';
|
|
4
4
|
|
|
5
|
-
import { Root, Header,
|
|
5
|
+
import { Root, Header, Badge, Body, Value } from '../../ui';
|
|
6
6
|
import Date from '../../datatypes/Date';
|
|
7
7
|
import Coding from '../../datatypes/Coding';
|
|
8
8
|
|
|
9
9
|
import './Questionnaire.css';
|
|
10
|
-
import Reference from '../../datatypes/Reference/Reference';
|
|
11
10
|
import fhirVersions from '../fhirResourceVersions';
|
|
12
11
|
import UnhandledResourceDataStructure from '../UnhandledResourceDataStructure';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let text = _get(item, 'text');
|
|
16
|
-
if (!text) {
|
|
17
|
-
// DSTU2
|
|
18
|
-
const groupConcept = _get(item, 'concept.0');
|
|
19
|
-
if (groupConcept) {
|
|
20
|
-
text = <Coding fhirData={groupConcept} />;
|
|
21
|
-
}
|
|
22
|
-
// STU3 & R4
|
|
23
|
-
const groupCode = _get(item, 'code.0');
|
|
24
|
-
if (!text && groupCode) {
|
|
25
|
-
text = <Coding fhirData={groupCode} />;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return text;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const Questions = props => {
|
|
32
|
-
const { questions, prepareItems } = props;
|
|
33
|
-
if (!Array.isArray(questions) || questions.length === 0) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<ul className="fhir-resource__Questionnaire-questions-list">
|
|
39
|
-
{questions.map((item, i) => {
|
|
40
|
-
const hasLinkId = item.linkId;
|
|
41
|
-
let type = _get(item, 'type');
|
|
42
|
-
if (type === 'group') {
|
|
43
|
-
type = '';
|
|
44
|
-
}
|
|
45
|
-
const options = _get(item, 'options');
|
|
46
|
-
|
|
47
|
-
const text = getQuestionText(item);
|
|
48
|
-
const hasDetails = type || options;
|
|
49
|
-
return (
|
|
50
|
-
<li key={`item-${i}`} data-testid={`linkId-${item.linkId}`}>
|
|
51
|
-
{hasLinkId && <Badge>{item.linkId}</Badge>}
|
|
52
|
-
{text}
|
|
53
|
-
{hasDetails && (
|
|
54
|
-
<div className="fhir-resource__Questionnaire-questions-list-item-details">
|
|
55
|
-
{type && (
|
|
56
|
-
<div className="fhir-resource__Questionnaire-questions-list-item-details-el">
|
|
57
|
-
Type: {type}
|
|
58
|
-
</div>
|
|
59
|
-
)}
|
|
60
|
-
{options && (
|
|
61
|
-
<div className="fhir-resource__Questionnaire-questions-list-item-details-el">
|
|
62
|
-
Options: <Reference fhirData={options} />
|
|
63
|
-
</div>
|
|
64
|
-
)}
|
|
65
|
-
</div>
|
|
66
|
-
)}
|
|
67
|
-
{item.item && (
|
|
68
|
-
<Group data={item.item} prepareItems={prepareItems} />
|
|
69
|
-
)}
|
|
70
|
-
</li>
|
|
71
|
-
);
|
|
72
|
-
})}
|
|
73
|
-
</ul>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
Questions.propTypes = {
|
|
78
|
-
questions: PropTypes.array,
|
|
79
|
-
prepareItems: PropTypes.func.isRequired,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const Group = props => {
|
|
83
|
-
const { data, prepareItems } = props;
|
|
84
|
-
if (!Array.isArray(data) || data.length === 0) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return data.map(prepareItems).map((item, i) => {
|
|
89
|
-
const linkId = _get(item, 'linkId', '');
|
|
90
|
-
|
|
91
|
-
const text = getQuestionText(item);
|
|
92
|
-
let nestedItems = _get(item, 'item', []);
|
|
93
|
-
nestedItems = nestedItems.map(prepareItems);
|
|
94
|
-
const isGroup = _get(item, 'isGroup');
|
|
95
|
-
return (
|
|
96
|
-
<ul key={`item-${i}`} className="fhir-resource__Questionnaire-list">
|
|
97
|
-
<li
|
|
98
|
-
className="fhir-resource__Questionnaire-list-title"
|
|
99
|
-
data-testid={`linkId-${item.linkId}`}
|
|
100
|
-
>
|
|
101
|
-
<Badge>{linkId}</Badge>
|
|
102
|
-
<span>{text}</span>
|
|
103
|
-
</li>
|
|
104
|
-
{!isGroup && (
|
|
105
|
-
<li>
|
|
106
|
-
{<Questions questions={nestedItems} prepareItems={prepareItems} />}
|
|
107
|
-
</li>
|
|
108
|
-
)}
|
|
109
|
-
{isGroup && (
|
|
110
|
-
<li>
|
|
111
|
-
<Group data={nestedItems} prepareItems={prepareItems} />
|
|
112
|
-
</li>
|
|
113
|
-
)}
|
|
114
|
-
</ul>
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
Group.propTypes = {
|
|
120
|
-
data: PropTypes.array,
|
|
121
|
-
prepareItems: PropTypes.func.isRequired,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const Items = props => {
|
|
125
|
-
const { fhirVersion, data } = props;
|
|
126
|
-
|
|
127
|
-
if (fhirVersion === fhirVersions.DSTU2) {
|
|
128
|
-
const prepareItems = item => ({
|
|
129
|
-
...item,
|
|
130
|
-
item: _get(item, 'question') || _get(item, 'group') || [],
|
|
131
|
-
isGroup: !!_get(item, 'group'),
|
|
132
|
-
});
|
|
133
|
-
return <Group data={data} prepareItems={prepareItems} />;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (fhirVersion === fhirVersions.STU3) {
|
|
137
|
-
const prepareItems = item => ({
|
|
138
|
-
...item,
|
|
139
|
-
isGroup: _get(item, 'type') === 'group',
|
|
140
|
-
});
|
|
141
|
-
return <Group data={data} prepareItems={prepareItems} />;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (fhirVersion === fhirVersions.R4) {
|
|
145
|
-
const prepareItems = item => ({
|
|
146
|
-
...item,
|
|
147
|
-
isGroup: _get(item, 'type') === 'group',
|
|
148
|
-
});
|
|
149
|
-
return <Group data={data} prepareItems={prepareItems} />;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return null;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
Items.propTypes = {
|
|
156
|
-
data: PropTypes.array,
|
|
157
|
-
fhirVersion: PropTypes.oneOf([
|
|
158
|
-
fhirVersions.DSTU2,
|
|
159
|
-
fhirVersions.STU3,
|
|
160
|
-
fhirVersions.R4,
|
|
161
|
-
]).isRequired,
|
|
162
|
-
};
|
|
12
|
+
import Items from './Items';
|
|
13
|
+
import Accordion from '../../containers/Accordion';
|
|
163
14
|
|
|
164
15
|
const commonDTO = fhirResource => {
|
|
165
16
|
const status = _get(fhirResource, 'status');
|
|
@@ -224,8 +75,13 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
224
75
|
}
|
|
225
76
|
};
|
|
226
77
|
|
|
227
|
-
const Questionnaire =
|
|
228
|
-
|
|
78
|
+
const Questionnaire = ({
|
|
79
|
+
fhirResource,
|
|
80
|
+
fhirVersion,
|
|
81
|
+
fhirIcons,
|
|
82
|
+
onClick,
|
|
83
|
+
rawOnClick,
|
|
84
|
+
}) => {
|
|
229
85
|
let fhirResourceData = {};
|
|
230
86
|
|
|
231
87
|
try {
|
|
@@ -238,22 +94,34 @@ const Questionnaire = props => {
|
|
|
238
94
|
|
|
239
95
|
return (
|
|
240
96
|
<Root name="Questionnaire">
|
|
241
|
-
<
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
<
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
97
|
+
<Accordion
|
|
98
|
+
headerContent={
|
|
99
|
+
<Header
|
|
100
|
+
resourceName="Questionnaire"
|
|
101
|
+
title={title}
|
|
102
|
+
badges={status && <Badge data-testid="status">{status}</Badge>}
|
|
103
|
+
additionalContent={
|
|
104
|
+
dateTime && (
|
|
105
|
+
<Value label="On" data-testid="dateTime">
|
|
106
|
+
<Date fhirData={dateTime} isBlack />
|
|
107
|
+
</Value>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
icon={fhirIcons}
|
|
111
|
+
/>
|
|
112
|
+
}
|
|
113
|
+
bodyContent={
|
|
114
|
+
<Body>
|
|
115
|
+
{rootItems && (
|
|
116
|
+
<div className="overflow-auto">
|
|
117
|
+
<Items fhirVersion={fhirVersion} data={rootItems} />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</Body>
|
|
121
|
+
}
|
|
122
|
+
onClick={onClick}
|
|
123
|
+
rawOnClick={rawOnClick}
|
|
124
|
+
/>
|
|
257
125
|
</Root>
|
|
258
126
|
);
|
|
259
127
|
};
|
|
@@ -15,6 +15,9 @@ import r4Example1 from '../../../fixtures/r4/resources/questionnaire/example1.js
|
|
|
15
15
|
import r4Example2 from '../../../fixtures/r4/resources/questionnaire/example2.json';
|
|
16
16
|
import r4Example3 from '../../../fixtures/r4/resources/questionnaire/example3.json';
|
|
17
17
|
|
|
18
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
19
|
+
import QuestionnaireIcon from '../../../assets/containers/Questionnaire/questionnaire.svg';
|
|
20
|
+
|
|
18
21
|
export default { title: 'Questionnaire' };
|
|
19
22
|
|
|
20
23
|
export const DefaultVisualizationDSTU2 = () => {
|
|
@@ -23,6 +26,7 @@ export const DefaultVisualizationDSTU2 = () => {
|
|
|
23
26
|
<Questionnaire
|
|
24
27
|
fhirResource={fhirResource}
|
|
25
28
|
fhirVersion={fhirVersions.DSTU2}
|
|
29
|
+
fhirIcons={require('../../../assets/containers/Questionnaire/questionnaire.svg')}
|
|
26
30
|
/>
|
|
27
31
|
);
|
|
28
32
|
};
|
|
@@ -33,6 +37,7 @@ export const Example2OfDSTU2 = () => {
|
|
|
33
37
|
<Questionnaire
|
|
34
38
|
fhirResource={fhirResource}
|
|
35
39
|
fhirVersion={fhirVersions.DSTU2}
|
|
40
|
+
fhirIcons={QuestionnaireIcon}
|
|
36
41
|
/>
|
|
37
42
|
);
|
|
38
43
|
};
|
|
@@ -43,6 +48,7 @@ export const Example3OfDSTU2 = () => {
|
|
|
43
48
|
<Questionnaire
|
|
44
49
|
fhirResource={fhirResource}
|
|
45
50
|
fhirVersion={fhirVersions.DSTU2}
|
|
51
|
+
fhirIcons={fhirIcons}
|
|
46
52
|
/>
|
|
47
53
|
);
|
|
48
54
|
};
|
|
@@ -53,6 +59,7 @@ export const Example1OfSTU3 = () => {
|
|
|
53
59
|
<Questionnaire
|
|
54
60
|
fhirResource={fhirResource}
|
|
55
61
|
fhirVersion={fhirVersions.STU3}
|
|
62
|
+
fhirIcons={false}
|
|
56
63
|
/>
|
|
57
64
|
);
|
|
58
65
|
};
|
|
@@ -63,6 +70,7 @@ export const Example2OfSTU3 = () => {
|
|
|
63
70
|
<Questionnaire
|
|
64
71
|
fhirResource={fhirResource}
|
|
65
72
|
fhirVersion={fhirVersions.STU3}
|
|
73
|
+
fhirIcons={'random text'}
|
|
66
74
|
/>
|
|
67
75
|
);
|
|
68
76
|
};
|
|
@@ -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 Questionnaire from './Questionnaire';
|
|
5
5
|
import fhirVersions from '../fhirResourceVersions';
|
|
@@ -13,7 +13,151 @@ import stu3Example2 from '../../../fixtures/stu3/resources/questionnaire/example
|
|
|
13
13
|
import r4Example1 from '../../../fixtures/r4/resources/questionnaire/example1.json';
|
|
14
14
|
import r4Example2 from '../../../fixtures/r4/resources/questionnaire/example2.json';
|
|
15
15
|
|
|
16
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
17
|
+
|
|
16
18
|
describe('Questionnaire should render component correctly', () => {
|
|
19
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
20
|
+
const defaultProps = {
|
|
21
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
22
|
+
fhirResource: dstu2Example1,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
26
|
+
const headerIcon = getByAltText('questionnaire');
|
|
27
|
+
|
|
28
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
32
|
+
const defaultProps = {
|
|
33
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
34
|
+
fhirResource: dstu2Example1,
|
|
35
|
+
fhirIcons: false,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const { getByTestId } = render(<Questionnaire {...defaultProps} />);
|
|
39
|
+
const headerIcon = getByTestId('placeholder');
|
|
40
|
+
|
|
41
|
+
expect(headerIcon).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
45
|
+
const defaultProps = {
|
|
46
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
47
|
+
fhirResource: dstu2Example1,
|
|
48
|
+
fhirIcons: (
|
|
49
|
+
<img
|
|
50
|
+
src={require('../assets/containers/Questionnaire/questionnaire.svg')}
|
|
51
|
+
alt="clipboard and pen"
|
|
52
|
+
/>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
57
|
+
const headerIcon = getByAltText('clipboard and pen');
|
|
58
|
+
|
|
59
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
63
|
+
const defaultProps = {
|
|
64
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
65
|
+
fhirResource: dstu2Example1,
|
|
66
|
+
fhirIcons: fhirIcons,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
70
|
+
const headerIcon = getByAltText('clipboard and pen');
|
|
71
|
+
|
|
72
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
76
|
+
const avatarSrc =
|
|
77
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
78
|
+
const defaultProps = {
|
|
79
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
80
|
+
fhirResource: dstu2Example1,
|
|
81
|
+
fhirIcons: avatarSrc,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
85
|
+
const headerIcon = getByAltText('header icon');
|
|
86
|
+
|
|
87
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
91
|
+
const defaultProps = {
|
|
92
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
93
|
+
fhirResource: dstu2Example1,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
97
|
+
const headerIcon = getByAltText('questionnaire');
|
|
98
|
+
|
|
99
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
103
|
+
const defaultProps = {
|
|
104
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
105
|
+
fhirResource: dstu2Example1,
|
|
106
|
+
fhirIcons: false,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const { getByTestId } = render(<Questionnaire {...defaultProps} />);
|
|
110
|
+
const headerIcon = getByTestId('placeholder');
|
|
111
|
+
|
|
112
|
+
expect(headerIcon).toBeTruthy();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
116
|
+
const defaultProps = {
|
|
117
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
118
|
+
fhirResource: dstu2Example1,
|
|
119
|
+
fhirIcons: (
|
|
120
|
+
<img
|
|
121
|
+
src={require('../assets/containers/Questionnaire/questionnaire.svg')}
|
|
122
|
+
alt="clipboard and pen"
|
|
123
|
+
/>
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
128
|
+
const headerIcon = getByAltText('clipboard and pen');
|
|
129
|
+
|
|
130
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
134
|
+
const defaultProps = {
|
|
135
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
136
|
+
fhirResource: dstu2Example1,
|
|
137
|
+
fhirIcons: fhirIcons,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
141
|
+
const headerIcon = getByAltText('clipboard and pen');
|
|
142
|
+
|
|
143
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
147
|
+
const avatarSrc =
|
|
148
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
149
|
+
const defaultProps = {
|
|
150
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
151
|
+
fhirResource: dstu2Example1,
|
|
152
|
+
fhirIcons: avatarSrc,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const { getByAltText } = render(<Questionnaire {...defaultProps} />);
|
|
156
|
+
const headerIcon = getByAltText('header icon');
|
|
157
|
+
|
|
158
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
159
|
+
});
|
|
160
|
+
|
|
17
161
|
it('should render component correctly with DSTU2 source data', () => {
|
|
18
162
|
const defaultProps = {
|
|
19
163
|
fhirResource: dstu2Example1,
|
|
@@ -34,16 +178,16 @@ describe('Questionnaire should render component correctly', () => {
|
|
|
34
178
|
|
|
35
179
|
// contain id and test of questions of subgroup
|
|
36
180
|
expect(String(getByTestId('linkId-2.1').textContent).trim()).toEqual(
|
|
37
|
-
'
|
|
181
|
+
'What is your gender?',
|
|
38
182
|
);
|
|
39
183
|
expect(String(getByTestId('linkId-2.2').textContent).trim()).toEqual(
|
|
40
|
-
'
|
|
184
|
+
'What is your date of birth?',
|
|
41
185
|
);
|
|
42
186
|
expect(String(getByTestId('linkId-2.3').textContent).trim()).toEqual(
|
|
43
|
-
'
|
|
187
|
+
'What is your country of birth?',
|
|
44
188
|
);
|
|
45
189
|
expect(String(getByTestId('linkId-2.4').textContent).trim()).toEqual(
|
|
46
|
-
'
|
|
190
|
+
'What is your marital status?',
|
|
47
191
|
);
|
|
48
192
|
});
|
|
49
193
|
|
|
@@ -90,21 +234,21 @@ describe('Questionnaire should render component correctly', () => {
|
|
|
90
234
|
|
|
91
235
|
// contain subgroup description
|
|
92
236
|
expect(String(getByTestId('linkId-2').textContent).trim()).toContain(
|
|
93
|
-
'
|
|
237
|
+
'General questions',
|
|
94
238
|
);
|
|
95
239
|
|
|
96
240
|
// contain id and test of questions of subgroup
|
|
97
241
|
expect(String(getByTestId('linkId-2.1').textContent).trim()).toContain(
|
|
98
|
-
'
|
|
242
|
+
'What is your gender?',
|
|
99
243
|
);
|
|
100
244
|
expect(String(getByTestId('linkId-2.2').textContent).trim()).toEqual(
|
|
101
|
-
'
|
|
245
|
+
'What is your date of birth?',
|
|
102
246
|
);
|
|
103
247
|
expect(String(getByTestId('linkId-2.3').textContent).trim()).toEqual(
|
|
104
|
-
'
|
|
248
|
+
'What is your country of birth?',
|
|
105
249
|
);
|
|
106
250
|
expect(String(getByTestId('linkId-2.4').textContent).trim()).toEqual(
|
|
107
|
-
'
|
|
251
|
+
'What is your marital status?',
|
|
108
252
|
);
|
|
109
253
|
});
|
|
110
254
|
|
|
@@ -151,21 +295,21 @@ describe('Questionnaire should render component correctly', () => {
|
|
|
151
295
|
|
|
152
296
|
// contain subgroup description
|
|
153
297
|
expect(String(getByTestId('linkId-2').textContent).trim()).toContain(
|
|
154
|
-
'
|
|
298
|
+
'General questions',
|
|
155
299
|
);
|
|
156
300
|
|
|
157
301
|
// contain id and test of questions of subgroup
|
|
158
302
|
expect(String(getByTestId('linkId-2.1').textContent).trim()).toContain(
|
|
159
|
-
'
|
|
303
|
+
'What is your gender?',
|
|
160
304
|
);
|
|
161
305
|
expect(String(getByTestId('linkId-2.2').textContent).trim()).toEqual(
|
|
162
|
-
'
|
|
306
|
+
'What is your date of birth?',
|
|
163
307
|
);
|
|
164
308
|
expect(String(getByTestId('linkId-2.3').textContent).trim()).toEqual(
|
|
165
|
-
'
|
|
309
|
+
'What is your country of birth?',
|
|
166
310
|
);
|
|
167
311
|
expect(String(getByTestId('linkId-2.4').textContent).trim()).toEqual(
|
|
168
|
-
'
|
|
312
|
+
'What is your marital status?',
|
|
169
313
|
);
|
|
170
314
|
});
|
|
171
315
|
|
|
@@ -196,4 +340,39 @@ describe('Questionnaire should render component correctly', () => {
|
|
|
196
340
|
String(getByTestId('linkId-1.1.1.1.1').textContent).trim(),
|
|
197
341
|
).toContain('Angina Pectoris');
|
|
198
342
|
});
|
|
343
|
+
|
|
344
|
+
it('should fire custom onClick function', () => {
|
|
345
|
+
const defaultProps = {
|
|
346
|
+
fhirResource: r4Example1,
|
|
347
|
+
fhirVersion: fhirVersions.R4,
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const onClick = jest.fn();
|
|
351
|
+
const { getByRole } = render(
|
|
352
|
+
<Questionnaire {...defaultProps} onClick={onClick} />,
|
|
353
|
+
);
|
|
354
|
+
const accordion = getByRole('button');
|
|
355
|
+
fireEvent.click(accordion);
|
|
356
|
+
|
|
357
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
358
|
+
expect(attribute).not.toEqual('collapse');
|
|
359
|
+
expect(onClick).toHaveBeenCalled();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('should not fire custom onClick function', () => {
|
|
363
|
+
const defaultProps = {
|
|
364
|
+
fhirResource: r4Example1,
|
|
365
|
+
fhirVersion: fhirVersions.R4,
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const onClick = 'test';
|
|
369
|
+
const { getByRole } = render(
|
|
370
|
+
<Questionnaire {...defaultProps} onClick={onClick} />,
|
|
371
|
+
);
|
|
372
|
+
const accordion = getByRole('button');
|
|
373
|
+
fireEvent.click(accordion);
|
|
374
|
+
|
|
375
|
+
const attribute = accordion.getAttribute('data-bs-toggle');
|
|
376
|
+
expect(attribute).toEqual('collapse');
|
|
377
|
+
});
|
|
199
378
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Group from './Group';
|
|
4
|
+
import { getQuestionText } from './getQuestionText';
|
|
5
|
+
|
|
6
|
+
const Questions = ({ questions, prepareItems }) => {
|
|
7
|
+
if (!Array.isArray(questions) || questions.length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ul className="fhir-resource__Questionnaire-questions-list">
|
|
13
|
+
{questions.map((item, i) => {
|
|
14
|
+
const text = getQuestionText(item);
|
|
15
|
+
return (
|
|
16
|
+
text && (
|
|
17
|
+
<li
|
|
18
|
+
key={`questionnaire-questions-item-${i}`}
|
|
19
|
+
data-testid={`linkId-${item.linkId}`}
|
|
20
|
+
>
|
|
21
|
+
<div className="fhir-resource__Questionnaire-questions-list-element">
|
|
22
|
+
{text}
|
|
23
|
+
</div>
|
|
24
|
+
{item.item && item.item.length > 0 && (
|
|
25
|
+
<Group data={item.item} prepareItems={prepareItems} isChild />
|
|
26
|
+
)}
|
|
27
|
+
</li>
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
})}
|
|
31
|
+
</ul>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
Questions.propTypes = {
|
|
36
|
+
questions: PropTypes.array,
|
|
37
|
+
prepareItems: PropTypes.func.isRequired,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Questions;
|