@openmrs/esm-fast-data-entry-app 1.0.1-pre.171 → 1.0.1-pre.180
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/__mocks__/react-i18next.js +9 -14
- package/dist/101.js +1 -1
- package/dist/101.js.map +1 -1
- package/dist/188.js.map +1 -1
- package/dist/219.js.map +1 -1
- package/dist/29.js +1 -1
- package/dist/29.js.map +1 -1
- package/dist/326.js.map +1 -1
- package/dist/564.js +1 -1
- package/dist/564.js.map +1 -1
- package/dist/893.js +1 -0
- package/dist/893.js.map +1 -0
- package/dist/91.js +1 -1
- package/dist/91.js.map +1 -1
- package/dist/941.js +2 -0
- package/dist/941.js.map +1 -0
- package/dist/99.js.map +1 -1
- package/dist/991.js +1 -0
- package/dist/991.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +105 -105
- package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +2 -4
- package/prettier.config.js +8 -0
- package/src/CancelModal.tsx +9 -15
- package/src/CompleteModal.tsx +7 -18
- package/src/FormBootstrap.tsx +9 -9
- package/src/Root.tsx +7 -12
- package/src/add-group-modal/AddGroupModal.tsx +46 -109
- package/src/config-schema.ts +35 -36
- package/src/constant.ts +1 -1
- package/src/context/FormWorkflowContext.tsx +26 -39
- package/src/context/FormWorkflowReducer.ts +50 -74
- package/src/context/GroupFormWorkflowContext.tsx +36 -61
- package/src/context/GroupFormWorkflowReducer.ts +69 -105
- package/src/declarations.d.ts +3 -3
- package/src/empty-state/EmptyDataIllustration.tsx +4 -16
- package/src/empty-state/EmptyState.tsx +8 -13
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +26 -44
- package/src/form-entry-workflow/form-review-card/FormReviewCard.tsx +7 -7
- package/src/form-entry-workflow/form-review-card/index.ts +1 -1
- package/src/form-entry-workflow/index.ts +1 -1
- package/src/form-entry-workflow/patient-banner/PatientBanner.test.tsx +5 -5
- package/src/form-entry-workflow/patient-banner/PatientBanner.tsx +14 -27
- package/src/form-entry-workflow/patient-banner/index.ts +1 -1
- package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +17 -26
- package/src/form-entry-workflow/patient-search-header/index.ts +1 -1
- package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +12 -12
- package/src/form-entry-workflow/workflow-review/index.ts +1 -1
- package/src/forms-app-menu-link.tsx +4 -6
- package/src/forms-page/FormsPage.tsx +22 -50
- package/src/forms-page/forms-table/FormsTable.tsx +22 -42
- package/src/forms-page/forms-table/index.ts +1 -1
- package/src/forms-page/index.ts +1 -1
- package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +8 -8
- package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +27 -58
- package/src/group-form-entry-workflow/SessionDetailsForm.tsx +43 -66
- package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +20 -28
- package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +13 -27
- package/src/group-form-entry-workflow/attendance-table/index.ts +1 -1
- package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +6 -12
- package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.test.tsx +5 -5
- package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +13 -21
- package/src/group-form-entry-workflow/group-display-header/index.ts +1 -1
- package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +24 -35
- package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +13 -15
- package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +22 -38
- package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +18 -25
- package/src/group-form-entry-workflow/group-search-header/index.ts +1 -1
- package/src/group-form-entry-workflow/index.ts +1 -1
- package/src/hooks/index.ts +7 -13
- package/src/hooks/useForm.ts +13 -30
- package/src/hooks/useFormState.ts +3 -3
- package/src/hooks/useGetAllForms.ts +5 -14
- package/src/hooks/useGetEncounter.ts +2 -2
- package/src/hooks/useGetPatient.ts +2 -2
- package/src/hooks/useGetPatients.ts +4 -6
- package/src/hooks/useGetSystemSetting.ts +3 -5
- package/src/hooks/useKeyPress.ts +5 -5
- package/src/hooks/usePostEndpoint.ts +8 -8
- package/src/hooks/useSearchEndpoint.ts +15 -38
- package/src/hooks/useStartVisit.ts +16 -27
- package/src/index.ts +8 -20
- package/src/patient-card/PatientCard.tsx +8 -20
- package/src/patient-card/index.ts +1 -1
- package/src/setup-tests.ts +1 -1
- package/tools/i18next-parser.config.js +19 -19
- package/webpack.config.js +1 -1
- package/dist/143.js +0 -1
- package/dist/143.js.map +0 -1
- package/dist/31.js +0 -2
- package/dist/31.js.map +0 -1
- package/dist/491.js +0 -1
- package/dist/491.js.map +0 -1
- /package/dist/{31.js.LICENSE.txt → 941.js.LICENSE.txt} +0 -0
|
@@ -1,54 +1,27 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
ComposedModal,
|
|
10
|
-
Button,
|
|
11
|
-
ModalHeader,
|
|
12
|
-
ModalFooter,
|
|
13
|
-
ModalBody,
|
|
14
|
-
TextInput,
|
|
15
|
-
FormLabel,
|
|
16
|
-
} from "@carbon/react";
|
|
17
|
-
import { TrashCan } from "@carbon/react/icons";
|
|
18
|
-
import { useTranslation } from "react-i18next";
|
|
19
|
-
import {
|
|
20
|
-
ExtensionSlot,
|
|
21
|
-
fetchCurrentPatient,
|
|
22
|
-
showToast,
|
|
23
|
-
useConfig,
|
|
24
|
-
usePatient,
|
|
25
|
-
} from "@openmrs/esm-framework";
|
|
26
|
-
import styles from "./styles.scss";
|
|
27
|
-
import GroupFormWorkflowContext from "../context/GroupFormWorkflowContext";
|
|
28
|
-
import { usePostCohort } from "../hooks";
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { ComposedModal, Button, ModalHeader, ModalFooter, ModalBody, TextInput, FormLabel } from '@carbon/react';
|
|
3
|
+
import { TrashCan } from '@carbon/react/icons';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { ExtensionSlot, fetchCurrentPatient, showToast, useConfig, usePatient } from '@openmrs/esm-framework';
|
|
6
|
+
import styles from './styles.scss';
|
|
7
|
+
import GroupFormWorkflowContext from '../context/GroupFormWorkflowContext';
|
|
8
|
+
import { usePostCohort } from '../hooks';
|
|
29
9
|
|
|
30
10
|
const MemExtension = React.memo(ExtensionSlot);
|
|
31
11
|
|
|
32
12
|
const PatientRow = ({ patient, removePatient }) => {
|
|
33
13
|
const { t } = useTranslation();
|
|
34
14
|
const { patient: patientInfo, error, isLoading } = usePatient(patient?.uuid);
|
|
35
|
-
const onClickHandler = useCallback(
|
|
36
|
-
() => removePatient(patient?.uuid),
|
|
37
|
-
[patient, removePatient]
|
|
38
|
-
);
|
|
15
|
+
const onClickHandler = useCallback(() => removePatient(patient?.uuid), [patient, removePatient]);
|
|
39
16
|
|
|
40
17
|
const patientDisplay = useMemo(() => {
|
|
41
|
-
if (isLoading || error || !patientInfo) return
|
|
18
|
+
if (isLoading || error || !patientInfo) return '';
|
|
42
19
|
|
|
43
20
|
const { identifier, name } = patientInfo;
|
|
44
|
-
const displayIdentifier = identifier?.[0]?.value ||
|
|
45
|
-
const givenNames = `${(name?.[0]?.given || []).join(
|
|
46
|
-
name?.[0]?.family || ""
|
|
47
|
-
}`;
|
|
21
|
+
const displayIdentifier = identifier?.[0]?.value || '';
|
|
22
|
+
const givenNames = `${(name?.[0]?.given || []).join(' ')} ${name?.[0]?.family || ''}`;
|
|
48
23
|
|
|
49
|
-
return `${displayIdentifier ? `${displayIdentifier} -` :
|
|
50
|
-
givenNames ? ` ${givenNames}` : ""
|
|
51
|
-
}`.trim();
|
|
24
|
+
return `${displayIdentifier ? `${displayIdentifier} -` : ''}${givenNames ? ` ${givenNames}` : ''}`.trim();
|
|
52
25
|
}, [isLoading, error, patientInfo]);
|
|
53
26
|
|
|
54
27
|
return (
|
|
@@ -62,7 +35,7 @@ const PatientRow = ({ patient, removePatient }) => {
|
|
|
62
35
|
renderIcon={TrashCan}
|
|
63
36
|
tooltipAlignment="start"
|
|
64
37
|
tooltipPosition="top"
|
|
65
|
-
iconDescription={t(
|
|
38
|
+
iconDescription={t('remove', 'Remove')}
|
|
66
39
|
/>
|
|
67
40
|
</span>
|
|
68
41
|
<span className={styles.patientName}>{patientDisplay}</span>
|
|
@@ -71,71 +44,50 @@ const PatientRow = ({ patient, removePatient }) => {
|
|
|
71
44
|
};
|
|
72
45
|
|
|
73
46
|
const NewGroupForm = (props) => {
|
|
74
|
-
const {
|
|
75
|
-
name,
|
|
76
|
-
setName,
|
|
77
|
-
patientList,
|
|
78
|
-
updatePatientList,
|
|
79
|
-
errors,
|
|
80
|
-
validate,
|
|
81
|
-
removePatient,
|
|
82
|
-
} = props;
|
|
47
|
+
const { name, setName, patientList, updatePatientList, errors, validate, removePatient } = props;
|
|
83
48
|
const { t } = useTranslation();
|
|
84
49
|
|
|
85
50
|
return (
|
|
86
51
|
<div
|
|
87
52
|
style={{
|
|
88
|
-
display:
|
|
89
|
-
flexDirection:
|
|
90
|
-
rowGap:
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'column',
|
|
55
|
+
rowGap: '1rem',
|
|
91
56
|
}}
|
|
92
57
|
>
|
|
93
58
|
<TextInput
|
|
94
|
-
labelText={t(
|
|
59
|
+
labelText={t('newGroupName', 'New Group Name')}
|
|
95
60
|
value={name}
|
|
96
61
|
onChange={(e) => setName(e.target.value)}
|
|
97
|
-
onBlur={() => validate(
|
|
62
|
+
onBlur={() => validate('name')}
|
|
98
63
|
/>
|
|
99
64
|
{errors?.name && (
|
|
100
65
|
<p className={styles.formError}>
|
|
101
|
-
{errors.name ===
|
|
102
|
-
? t("groupNameError", "Please enter a group name.")
|
|
103
|
-
: errors.name}
|
|
66
|
+
{errors.name === 'required' ? t('groupNameError', 'Please enter a group name.') : errors.name}
|
|
104
67
|
</p>
|
|
105
68
|
)}
|
|
106
69
|
<FormLabel>
|
|
107
|
-
{patientList.length} {t(
|
|
70
|
+
{patientList.length} {t('patientsInGroup', 'Patients in group')}
|
|
108
71
|
</FormLabel>
|
|
109
72
|
{errors?.patientList && (
|
|
110
|
-
<p className={styles.formError}>
|
|
111
|
-
{t("noPatientError", "Please enter at least one patient.")}
|
|
112
|
-
</p>
|
|
73
|
+
<p className={styles.formError}>{t('noPatientError', 'Please enter at least one patient.')}</p>
|
|
113
74
|
)}
|
|
114
75
|
{!errors?.patientList && (
|
|
115
76
|
<ul className={styles.patientList}>
|
|
116
77
|
{patientList?.map((patient, index) => (
|
|
117
|
-
<PatientRow
|
|
118
|
-
patient={patient}
|
|
119
|
-
removePatient={removePatient}
|
|
120
|
-
key={patient.uuid}
|
|
121
|
-
/>
|
|
78
|
+
<PatientRow patient={patient} removePatient={removePatient} key={patient.uuid} />
|
|
122
79
|
))}
|
|
123
80
|
</ul>
|
|
124
81
|
)}
|
|
125
82
|
|
|
126
|
-
<FormLabel>
|
|
127
|
-
{t(
|
|
128
|
-
"searchForPatientsToAddToGroup",
|
|
129
|
-
"Search for patients to add to group"
|
|
130
|
-
)}
|
|
131
|
-
</FormLabel>
|
|
83
|
+
<FormLabel>{t('searchForPatientsToAddToGroup', 'Search for patients to add to group')}</FormLabel>
|
|
132
84
|
<div className={styles.searchBar}>
|
|
133
85
|
<MemExtension
|
|
134
86
|
extensionSlotName="patient-search-bar-slot"
|
|
135
87
|
state={{
|
|
136
88
|
selectPatientAction: updatePatientList,
|
|
137
89
|
buttonProps: {
|
|
138
|
-
kind:
|
|
90
|
+
kind: 'secondary',
|
|
139
91
|
},
|
|
140
92
|
}}
|
|
141
93
|
/>
|
|
@@ -147,7 +99,7 @@ const NewGroupForm = (props) => {
|
|
|
147
99
|
const AddGroupModal = ({
|
|
148
100
|
patients = undefined,
|
|
149
101
|
isCreate = undefined,
|
|
150
|
-
groupName =
|
|
102
|
+
groupName = '',
|
|
151
103
|
cohortUuid = undefined,
|
|
152
104
|
isOpen,
|
|
153
105
|
onPostCancel,
|
|
@@ -163,30 +115,28 @@ const AddGroupModal = ({
|
|
|
163
115
|
|
|
164
116
|
const removePatient = useCallback(
|
|
165
117
|
(patientUuid: string) =>
|
|
166
|
-
setPatientList((patientList) =>
|
|
167
|
-
|
|
168
|
-
),
|
|
169
|
-
[setPatientList]
|
|
118
|
+
setPatientList((patientList) => patientList.filter((patient) => patient.uuid !== patientUuid)),
|
|
119
|
+
[setPatientList],
|
|
170
120
|
);
|
|
171
121
|
|
|
172
122
|
const validate = useCallback(
|
|
173
123
|
(field?: string | undefined) => {
|
|
174
124
|
let valid = true;
|
|
175
125
|
if (field) {
|
|
176
|
-
valid = field ===
|
|
126
|
+
valid = field === 'name' ? !!name : !!patientList.length;
|
|
177
127
|
setErrors((errors) => ({
|
|
178
128
|
...errors,
|
|
179
|
-
[field]: valid ? null :
|
|
129
|
+
[field]: valid ? null : 'required',
|
|
180
130
|
}));
|
|
181
131
|
} else {
|
|
182
132
|
if (!name) {
|
|
183
|
-
setErrors((errors) => ({ ...errors, name:
|
|
133
|
+
setErrors((errors) => ({ ...errors, name: 'required' }));
|
|
184
134
|
valid = false;
|
|
185
135
|
} else {
|
|
186
136
|
setErrors((errors) => ({ ...errors, name: null }));
|
|
187
137
|
}
|
|
188
138
|
if (!patientList.length) {
|
|
189
|
-
setErrors((errors) => ({ ...errors, patientList:
|
|
139
|
+
setErrors((errors) => ({ ...errors, patientList: 'required' }));
|
|
190
140
|
valid = false;
|
|
191
141
|
} else {
|
|
192
142
|
setErrors((errors) => ({ ...errors, patientList: null }));
|
|
@@ -194,15 +144,13 @@ const AddGroupModal = ({
|
|
|
194
144
|
}
|
|
195
145
|
return valid;
|
|
196
146
|
},
|
|
197
|
-
[name, patientList.length]
|
|
147
|
+
[name, patientList.length],
|
|
198
148
|
);
|
|
199
149
|
|
|
200
150
|
const updatePatientList = useCallback(
|
|
201
151
|
(patientUuid) => {
|
|
202
152
|
function getPatientName(patient) {
|
|
203
|
-
return [patient?.name?.[0]?.given, patient?.name?.[0]?.family].join(
|
|
204
|
-
" "
|
|
205
|
-
);
|
|
153
|
+
return [patient?.name?.[0]?.given, patient?.name?.[0]?.family].join(' ');
|
|
206
154
|
}
|
|
207
155
|
if (!patientList.find((p) => p.uuid === patientUuid)) {
|
|
208
156
|
fetchCurrentPatient(patientUuid).then((result) => {
|
|
@@ -210,15 +158,15 @@ const AddGroupModal = ({
|
|
|
210
158
|
setPatientList(
|
|
211
159
|
[...patientList, newPatient].sort((a, b) =>
|
|
212
160
|
getPatientName(a).localeCompare(getPatientName(b), undefined, {
|
|
213
|
-
sensitivity:
|
|
214
|
-
})
|
|
215
|
-
)
|
|
161
|
+
sensitivity: 'base',
|
|
162
|
+
}),
|
|
163
|
+
),
|
|
216
164
|
);
|
|
217
165
|
});
|
|
218
166
|
}
|
|
219
167
|
setErrors((errors) => ({ ...errors, patientList: null }));
|
|
220
168
|
},
|
|
221
|
-
[patientList, setPatientList]
|
|
169
|
+
[patientList, setPatientList],
|
|
222
170
|
);
|
|
223
171
|
|
|
224
172
|
const handleSubmit = () => {
|
|
@@ -256,20 +204,13 @@ const AddGroupModal = ({
|
|
|
256
204
|
useEffect(() => {
|
|
257
205
|
if (error) {
|
|
258
206
|
showToast({
|
|
259
|
-
kind:
|
|
260
|
-
title: t(
|
|
261
|
-
description:
|
|
262
|
-
error.message ??
|
|
263
|
-
t("unknownPostError", "An unknown error occurred while saving data"),
|
|
207
|
+
kind: 'error',
|
|
208
|
+
title: t('postError', 'POST Error'),
|
|
209
|
+
description: error.message ?? t('unknownPostError', 'An unknown error occurred while saving data'),
|
|
264
210
|
});
|
|
265
211
|
if (error.fieldErrors) {
|
|
266
212
|
setErrors(
|
|
267
|
-
Object.fromEntries(
|
|
268
|
-
Object.entries(error.fieldErrors).map(([key, value]) => [
|
|
269
|
-
key,
|
|
270
|
-
value?.[0]?.message,
|
|
271
|
-
])
|
|
272
|
-
)
|
|
213
|
+
Object.fromEntries(Object.entries(error.fieldErrors).map(([key, value]) => [key, value?.[0]?.message])),
|
|
273
214
|
);
|
|
274
215
|
}
|
|
275
216
|
}
|
|
@@ -278,11 +219,7 @@ const AddGroupModal = ({
|
|
|
278
219
|
return (
|
|
279
220
|
<div className={styles.modal}>
|
|
280
221
|
<ComposedModal open={isOpen} onClose={handleCancel}>
|
|
281
|
-
<ModalHeader>
|
|
282
|
-
{isCreate
|
|
283
|
-
? t("createNewGroup", "Create New Group")
|
|
284
|
-
: t("editGroup", "Edit Group")}
|
|
285
|
-
</ModalHeader>
|
|
222
|
+
<ModalHeader>{isCreate ? t('createNewGroup', 'Create New Group') : t('editGroup', 'Edit Group')}</ModalHeader>
|
|
286
223
|
<ModalBody>
|
|
287
224
|
<NewGroupForm
|
|
288
225
|
{...{
|
|
@@ -298,10 +235,10 @@ const AddGroupModal = ({
|
|
|
298
235
|
</ModalBody>
|
|
299
236
|
<ModalFooter>
|
|
300
237
|
<Button kind="secondary" onClick={handleCancel}>
|
|
301
|
-
{t(
|
|
238
|
+
{t('cancel', 'Cancel')}
|
|
302
239
|
</Button>
|
|
303
240
|
<Button kind="primary" onClick={handleSubmit}>
|
|
304
|
-
{isCreate ? t(
|
|
241
|
+
{isCreate ? t('createGroup', 'Create Group') : t('save', 'Save')}
|
|
305
242
|
</Button>
|
|
306
243
|
</ModalFooter>
|
|
307
244
|
</ComposedModal>
|
package/src/config-schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type } from
|
|
1
|
+
import { Type } from '@openmrs/esm-framework';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is the config schema.
|
|
@@ -8,44 +8,43 @@ import { Type } from "@openmrs/esm-framework";
|
|
|
8
8
|
export const configSchema = {
|
|
9
9
|
formCategories: {
|
|
10
10
|
_type: Type.Array,
|
|
11
|
-
_description:
|
|
12
|
-
"Organize forms into categories. A form can belong to multiple categories.",
|
|
11
|
+
_description: 'Organize forms into categories. A form can belong to multiple categories.',
|
|
13
12
|
_elements: {
|
|
14
13
|
name: {
|
|
15
14
|
_type: Type.String,
|
|
16
|
-
_description:
|
|
15
|
+
_description: 'Category name',
|
|
17
16
|
},
|
|
18
17
|
forms: {
|
|
19
18
|
_type: Type.Array,
|
|
20
|
-
_description:
|
|
19
|
+
_description: 'List of forms for this category.',
|
|
21
20
|
_elements: {
|
|
22
21
|
formUUID: {
|
|
23
22
|
_type: Type.UUID,
|
|
24
|
-
_description:
|
|
23
|
+
_description: 'UUID of form',
|
|
25
24
|
},
|
|
26
25
|
name: {
|
|
27
26
|
_type: Type.String,
|
|
28
|
-
_description:
|
|
27
|
+
_description: 'Name of form',
|
|
29
28
|
},
|
|
30
29
|
},
|
|
31
30
|
},
|
|
32
31
|
},
|
|
33
32
|
_default: [
|
|
34
33
|
{
|
|
35
|
-
name:
|
|
34
|
+
name: 'ICRC Forms',
|
|
36
35
|
forms: [
|
|
37
36
|
{
|
|
38
|
-
formUUID:
|
|
39
|
-
name:
|
|
37
|
+
formUUID: '0cefb866-110c-4f16-af58-560932a1db1f',
|
|
38
|
+
name: 'Adult Triage',
|
|
40
39
|
},
|
|
41
40
|
],
|
|
42
41
|
},
|
|
43
42
|
{
|
|
44
|
-
name:
|
|
43
|
+
name: 'Distress Scales',
|
|
45
44
|
forms: [
|
|
46
45
|
{
|
|
47
|
-
formUUID:
|
|
48
|
-
name:
|
|
46
|
+
formUUID: '9f26aad4-244a-46ca-be49-1196df1a8c9a',
|
|
47
|
+
name: 'POC Sample Form 1',
|
|
49
48
|
},
|
|
50
49
|
],
|
|
51
50
|
},
|
|
@@ -53,62 +52,62 @@ export const configSchema = {
|
|
|
53
52
|
},
|
|
54
53
|
formCategoriesToShow: {
|
|
55
54
|
_type: Type.Array,
|
|
56
|
-
_description:
|
|
55
|
+
_description: 'Forms to show by default on the forms app home page.',
|
|
57
56
|
_elements: {
|
|
58
57
|
_type: Type.String,
|
|
59
|
-
_description:
|
|
58
|
+
_description: 'Name of category',
|
|
60
59
|
},
|
|
61
|
-
_default: [
|
|
60
|
+
_default: ['ICRC Forms', 'Distress Scales'],
|
|
62
61
|
},
|
|
63
62
|
groupSessionConcepts: {
|
|
64
63
|
sessionName: {
|
|
65
64
|
_type: Type.UUID,
|
|
66
|
-
_description:
|
|
67
|
-
_default:
|
|
65
|
+
_description: 'UUID of concept for Session Name',
|
|
66
|
+
_default: 'e2559620-900b-4f66-ae41-0b9c4adfb654',
|
|
68
67
|
},
|
|
69
68
|
sessionDate: {
|
|
70
69
|
_type: Type.UUID,
|
|
71
|
-
_description:
|
|
72
|
-
_default:
|
|
70
|
+
_description: 'UUID of concept for Session Date',
|
|
71
|
+
_default: 'ceaca505-6dff-4940-8a43-8c060a0924d7',
|
|
73
72
|
},
|
|
74
73
|
practitionerName: {
|
|
75
74
|
_type: Type.UUID,
|
|
76
|
-
_description:
|
|
77
|
-
_default:
|
|
75
|
+
_description: 'UUID of concept for Practitioner Name',
|
|
76
|
+
_default: 'f1a2d58c-1a0e-4148-931a-aac224649fdc',
|
|
78
77
|
},
|
|
79
78
|
sessionNotes: {
|
|
80
79
|
_type: Type.UUID,
|
|
81
|
-
_description:
|
|
82
|
-
_default:
|
|
80
|
+
_description: 'UUID of concept for Session Notes',
|
|
81
|
+
_default: 'fa8fedc0-c066-4da3-8dc1-2ad8621fc480',
|
|
83
82
|
},
|
|
84
83
|
cohortTypeId: {
|
|
85
84
|
_type: Type.UUID,
|
|
86
|
-
_description:
|
|
87
|
-
_default:
|
|
85
|
+
_description: 'UUID of cohort type',
|
|
86
|
+
_default: 'eee9970e-7ca0-4e8c-a280-c33e9d5f6a04',
|
|
88
87
|
},
|
|
89
88
|
cohortId: {
|
|
90
89
|
_type: Type.UUID,
|
|
91
|
-
_description:
|
|
92
|
-
_default:
|
|
90
|
+
_description: 'UUID of concept for cohort identifier',
|
|
91
|
+
_default: '5461f231-7e59-4be8-93a4-6d49fd13c00a',
|
|
93
92
|
},
|
|
94
93
|
cohortName: {
|
|
95
94
|
_type: Type.UUID,
|
|
96
|
-
_description:
|
|
97
|
-
_default:
|
|
95
|
+
_description: 'UUID of concept for cohort name',
|
|
96
|
+
_default: '6029f289-92a6-4a68-80f1-3078d0152449',
|
|
98
97
|
},
|
|
99
98
|
sessionUuid: {
|
|
100
99
|
_type: Type.UUID,
|
|
101
|
-
_description:
|
|
102
|
-
_default:
|
|
100
|
+
_description: 'UUID of concept for session identifier',
|
|
101
|
+
_default: '6a803908-8a5b-4598-adea-19358c83529a',
|
|
103
102
|
},
|
|
104
103
|
},
|
|
105
104
|
specificQuestions: {
|
|
106
105
|
_type: Type.Array,
|
|
107
|
-
_description:
|
|
106
|
+
_description: 'List of specific questions to populate forms.',
|
|
108
107
|
_elements: {
|
|
109
108
|
forms: {
|
|
110
109
|
_type: Type.Array,
|
|
111
|
-
_description:
|
|
110
|
+
_description: 'List of form UUIDs for which the question applies.',
|
|
112
111
|
_elements: {
|
|
113
112
|
_type: Type.UUID,
|
|
114
113
|
},
|
|
@@ -116,8 +115,8 @@ export const configSchema = {
|
|
|
116
115
|
},
|
|
117
116
|
questionId: {
|
|
118
117
|
_type: Type.String,
|
|
119
|
-
_description:
|
|
120
|
-
_default:
|
|
118
|
+
_description: 'ID of the question.',
|
|
119
|
+
_default: '',
|
|
121
120
|
},
|
|
122
121
|
},
|
|
123
122
|
_default: [],
|
package/src/constant.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useReducer } from
|
|
2
|
-
import reducer from
|
|
3
|
-
import { useParams, useLocation } from
|
|
4
|
-
import useGetSystemSetting from
|
|
5
|
-
import { useSession } from
|
|
1
|
+
import React, { useEffect, useMemo, useReducer } from 'react';
|
|
2
|
+
import reducer from './FormWorkflowReducer';
|
|
3
|
+
import { useParams, useLocation } from 'react-router-dom';
|
|
4
|
+
import useGetSystemSetting from '../hooks/useGetSystemSetting';
|
|
5
|
+
import { useSession } from '@openmrs/esm-framework';
|
|
6
6
|
interface ParamTypes {
|
|
7
7
|
formUuid?: string;
|
|
8
8
|
}
|
|
@@ -44,46 +44,41 @@ const FormWorkflowContext = React.createContext({
|
|
|
44
44
|
const FormWorkflowProvider = ({ children }) => {
|
|
45
45
|
const { user } = useSession();
|
|
46
46
|
const { formUuid } = useParams() as ParamTypes;
|
|
47
|
-
const activeFormUuid = formUuid.split(
|
|
47
|
+
const activeFormUuid = formUuid.split('&')[0];
|
|
48
48
|
const { search } = useLocation();
|
|
49
|
-
const newPatientUuid = new URLSearchParams(search).get(
|
|
49
|
+
const newPatientUuid = new URLSearchParams(search).get('patientUuid');
|
|
50
50
|
const [state, dispatch] = useReducer(reducer, {
|
|
51
51
|
...initialWorkflowState,
|
|
52
52
|
...initialActions,
|
|
53
53
|
});
|
|
54
|
-
const systemSetting = useGetSystemSetting(
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
const singleSessionVisitTypeUuid =
|
|
58
|
-
systemSetting?.result?.data?.results?.[0]?.value;
|
|
54
|
+
const systemSetting = useGetSystemSetting('@openmrs/esm-fast-data-entry-app.groupSessionVisitTypeUuid');
|
|
55
|
+
const singleSessionVisitTypeUuid = systemSetting?.result?.data?.results?.[0]?.value;
|
|
59
56
|
|
|
60
57
|
const actions = useMemo(
|
|
61
58
|
() => ({
|
|
62
59
|
initializeWorkflowState: ({ activeFormUuid, newPatientUuid }) =>
|
|
63
60
|
dispatch({
|
|
64
|
-
type:
|
|
61
|
+
type: 'INITIALIZE_WORKFLOW_STATE',
|
|
65
62
|
activeFormUuid,
|
|
66
63
|
newPatientUuid,
|
|
67
64
|
userUuid: user.uuid,
|
|
68
65
|
}),
|
|
69
|
-
addPatient: (patientUuid) =>
|
|
70
|
-
|
|
71
|
-
openPatientSearch: () => dispatch({ type: "OPEN_PATIENT_SEARCH" }),
|
|
66
|
+
addPatient: (patientUuid) => dispatch({ type: 'ADD_PATIENT', patientUuid }),
|
|
67
|
+
openPatientSearch: () => dispatch({ type: 'OPEN_PATIENT_SEARCH' }),
|
|
72
68
|
saveEncounter: (encounterUuid) =>
|
|
73
69
|
dispatch({
|
|
74
|
-
type:
|
|
70
|
+
type: 'SAVE_ENCOUNTER',
|
|
75
71
|
encounterUuid,
|
|
76
72
|
}),
|
|
77
|
-
submitForNext: () => dispatch({ type:
|
|
78
|
-
submitForReview: () => dispatch({ type:
|
|
79
|
-
submitForComplete: () => dispatch({ type:
|
|
80
|
-
editEncounter: (patientUuid) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
closeSession: () => dispatch({ type: "CLOSE_SESSION" }),
|
|
73
|
+
submitForNext: () => dispatch({ type: 'SUBMIT_FOR_NEXT' }),
|
|
74
|
+
submitForReview: () => dispatch({ type: 'SUBMIT_FOR_REVIEW' }),
|
|
75
|
+
submitForComplete: () => dispatch({ type: 'SUBMIT_FOR_COMPLETE' }),
|
|
76
|
+
editEncounter: (patientUuid) => dispatch({ type: 'EDIT_ENCOUNTER', patientUuid }),
|
|
77
|
+
goToReview: () => dispatch({ type: 'GO_TO_REVIEW' }),
|
|
78
|
+
destroySession: () => dispatch({ type: 'DESTROY_SESSION' }),
|
|
79
|
+
closeSession: () => dispatch({ type: 'CLOSE_SESSION' }),
|
|
85
80
|
}),
|
|
86
|
-
[user]
|
|
81
|
+
[user],
|
|
87
82
|
);
|
|
88
83
|
|
|
89
84
|
// if formUuid isn't a part of state yet, grab it from the url params
|
|
@@ -99,21 +94,13 @@ const FormWorkflowProvider = ({ children }) => {
|
|
|
99
94
|
value={{
|
|
100
95
|
...state,
|
|
101
96
|
...actions,
|
|
102
|
-
workflowState:
|
|
103
|
-
state.forms?.[state.activeFormUuid]?.workflowState ??
|
|
104
|
-
initialWorkflowState.workflowState,
|
|
97
|
+
workflowState: state.forms?.[state.activeFormUuid]?.workflowState ?? initialWorkflowState.workflowState,
|
|
105
98
|
activePatientUuid:
|
|
106
|
-
state.forms?.[state.activeFormUuid]?.activePatientUuid ??
|
|
107
|
-
initialWorkflowState.activePatientUuid,
|
|
99
|
+
state.forms?.[state.activeFormUuid]?.activePatientUuid ?? initialWorkflowState.activePatientUuid,
|
|
108
100
|
activeEncounterUuid:
|
|
109
|
-
state.forms?.[state.activeFormUuid]?.activeEncounterUuid ??
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
state.forms?.[state.activeFormUuid]?.patientUuids ??
|
|
113
|
-
initialWorkflowState.patientUuids,
|
|
114
|
-
encounters:
|
|
115
|
-
state.forms?.[state.activeFormUuid]?.encounters ??
|
|
116
|
-
initialWorkflowState.encounters,
|
|
101
|
+
state.forms?.[state.activeFormUuid]?.activeEncounterUuid ?? initialWorkflowState.activeEncounterUuid,
|
|
102
|
+
patientUuids: state.forms?.[state.activeFormUuid]?.patientUuids ?? initialWorkflowState.patientUuids,
|
|
103
|
+
encounters: state.forms?.[state.activeFormUuid]?.encounters ?? initialWorkflowState.encounters,
|
|
117
104
|
singleSessionVisitTypeUuid,
|
|
118
105
|
}}
|
|
119
106
|
>
|