@openmrs/esm-fast-data-entry-app 1.0.1-pre.17 → 1.0.1-pre.21
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/dist/132.js +1 -1
- package/dist/229.js +1 -0
- package/dist/255.js +1 -1
- package/dist/32.js +1 -1
- package/dist/574.js +1 -1
- package/dist/617.js +1 -1
- package/dist/640.js +1 -0
- package/dist/804.js +1 -1
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +65 -42
- package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
- package/package.json +3 -3
- package/src/CancelModal.tsx +48 -0
- package/src/CompleteModal.tsx +46 -0
- package/src/FormBootstrap.tsx +3 -0
- package/src/context/FormWorkflowReducer.ts +4 -0
- package/src/context/GroupFormWorkflowContext.tsx +31 -2
- package/src/context/GroupFormWorkflowReducer.ts +127 -1
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +15 -82
- package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +11 -398
- package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +227 -0
- package/src/group-form-entry-workflow/SessionDetailsForm.tsx +122 -0
- package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +107 -0
- package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +105 -0
- package/src/group-form-entry-workflow/attendance-table/index.ts +1 -0
- package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +1 -9
- package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +0 -3
- package/src/hooks/useGetSystemSetting.ts +38 -0
- package/src/hooks/useStartVisit.ts +83 -0
- package/translations/en.json +7 -1
- package/dist/906.js +0 -1
|
@@ -12,10 +12,13 @@ const initialFormState = {
|
|
|
12
12
|
workflowState: "NEW_GROUP_SESSION",
|
|
13
13
|
groupUuid: null,
|
|
14
14
|
groupName: null,
|
|
15
|
+
groupMembers: [],
|
|
15
16
|
activePatientUuid: null,
|
|
16
17
|
activeEncounterUuid: null,
|
|
18
|
+
activeVisitUuid: null,
|
|
17
19
|
patientUuids: [],
|
|
18
20
|
encounters: {},
|
|
21
|
+
visits: {},
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
const reducer = (state, action) => {
|
|
@@ -50,6 +53,8 @@ const reducer = (state, action) => {
|
|
|
50
53
|
activePatientUuid: activePatientUuid,
|
|
51
54
|
activeEncounterUuid:
|
|
52
55
|
thisSavedForm?.encounters?.[activePatientUuid] || null,
|
|
56
|
+
activeVisitUuid:
|
|
57
|
+
thisSavedForm?.visits?.[activePatientUuid] || null,
|
|
53
58
|
},
|
|
54
59
|
},
|
|
55
60
|
};
|
|
@@ -84,8 +89,13 @@ const reducer = (state, action) => {
|
|
|
84
89
|
action.group.cohortMembers?.map(
|
|
85
90
|
(member) => member?.patient?.uuid
|
|
86
91
|
) ?? [],
|
|
92
|
+
groupMembers:
|
|
93
|
+
action.group.cohortMembers?.map(
|
|
94
|
+
(member) => member?.patient?.uuid
|
|
95
|
+
) ?? [],
|
|
87
96
|
activePatientUuid: null,
|
|
88
97
|
activeEncounterUuid: null,
|
|
98
|
+
activeVisitUuid: null,
|
|
89
99
|
},
|
|
90
100
|
},
|
|
91
101
|
};
|
|
@@ -102,8 +112,10 @@ const reducer = (state, action) => {
|
|
|
102
112
|
groupUuid: null,
|
|
103
113
|
groupName: null,
|
|
104
114
|
patientUuids: [],
|
|
115
|
+
groupMembers: [],
|
|
105
116
|
activePatientUuid: null,
|
|
106
117
|
activeEncounterUuid: null,
|
|
118
|
+
activeVisitUuid: null,
|
|
107
119
|
},
|
|
108
120
|
},
|
|
109
121
|
};
|
|
@@ -125,6 +137,10 @@ const reducer = (state, action) => {
|
|
|
125
137
|
state.forms[state.activeFormUuid].encounters[
|
|
126
138
|
state.forms[state.activeFormUuid].patientUuids?.[0]
|
|
127
139
|
] || null,
|
|
140
|
+
activeVisitUuid:
|
|
141
|
+
state.forms[state.activeFormUuid].visits[
|
|
142
|
+
state.forms[state.activeFormUuid].patientUuids?.[0]
|
|
143
|
+
] || null,
|
|
128
144
|
workflowState: "EDIT_FORM",
|
|
129
145
|
},
|
|
130
146
|
},
|
|
@@ -132,7 +148,47 @@ const reducer = (state, action) => {
|
|
|
132
148
|
persistData(newState);
|
|
133
149
|
return newState;
|
|
134
150
|
}
|
|
151
|
+
case "ADD_PATIENT_UUID": {
|
|
152
|
+
if (
|
|
153
|
+
state.forms[state.activeFormUuid].patientUuids.includes(
|
|
154
|
+
action.patientUuid
|
|
155
|
+
)
|
|
156
|
+
) {
|
|
157
|
+
return state;
|
|
158
|
+
}
|
|
135
159
|
|
|
160
|
+
const newState = {
|
|
161
|
+
...state,
|
|
162
|
+
forms: {
|
|
163
|
+
...state.forms,
|
|
164
|
+
[state.activeFormUuid]: {
|
|
165
|
+
...state.forms[state.activeFormUuid],
|
|
166
|
+
patientUuids: [
|
|
167
|
+
...state.forms[state.activeFormUuid].patientUuids,
|
|
168
|
+
action.patientUuid,
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
persistData(newState);
|
|
174
|
+
return newState;
|
|
175
|
+
}
|
|
176
|
+
case "REMOVE_PATIENT_UUID": {
|
|
177
|
+
const newState = {
|
|
178
|
+
...state,
|
|
179
|
+
forms: {
|
|
180
|
+
...state.forms,
|
|
181
|
+
[state.activeFormUuid]: {
|
|
182
|
+
...state.forms[state.activeFormUuid],
|
|
183
|
+
patientUuids: state.forms[
|
|
184
|
+
state.activeFormUuid
|
|
185
|
+
].patientUuids?.filter((uuid) => action.patientUuid !== uuid),
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
persistData(newState);
|
|
190
|
+
return newState;
|
|
191
|
+
}
|
|
136
192
|
case "SAVE_ENCOUNTER": {
|
|
137
193
|
const thisForm = state.forms[state.activeFormUuid];
|
|
138
194
|
if (thisForm.workflowState === "SUBMIT_FOR_COMPLETE") {
|
|
@@ -166,6 +222,7 @@ const reducer = (state, action) => {
|
|
|
166
222
|
},
|
|
167
223
|
activePatientUuid: nextPatientUuid,
|
|
168
224
|
activeEncounterUuid: thisForm.encounters[nextPatientUuid] || null,
|
|
225
|
+
activeVisitUuid: thisForm.visits[nextPatientUuid] || null,
|
|
169
226
|
workflowState: "EDIT_FORM",
|
|
170
227
|
},
|
|
171
228
|
},
|
|
@@ -183,6 +240,8 @@ const reducer = (state, action) => {
|
|
|
183
240
|
...state.forms[state.activeFormUuid],
|
|
184
241
|
activeEncounterUuid:
|
|
185
242
|
state.forms[state.activeFormUuid].encounters[action.patientUuid],
|
|
243
|
+
activeVisitUuid:
|
|
244
|
+
state.forms[state.activeFormUuid].visits[action.patientUuid],
|
|
186
245
|
activePatientUuid: action.patientUuid,
|
|
187
246
|
workflowState: "EDIT_FORM",
|
|
188
247
|
},
|
|
@@ -191,6 +250,46 @@ const reducer = (state, action) => {
|
|
|
191
250
|
persistData(newState);
|
|
192
251
|
return newState;
|
|
193
252
|
}
|
|
253
|
+
case "VALIDATE_FOR_NEXT":
|
|
254
|
+
// this state should not be persisted
|
|
255
|
+
window.dispatchEvent(
|
|
256
|
+
new CustomEvent("ampath-form-action", {
|
|
257
|
+
detail: {
|
|
258
|
+
formUuid: state.activeFormUuid,
|
|
259
|
+
patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
|
|
260
|
+
action: "validateForm",
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
return {
|
|
265
|
+
...state,
|
|
266
|
+
forms: {
|
|
267
|
+
...state.forms,
|
|
268
|
+
[state.activeFormUuid]: {
|
|
269
|
+
...state.forms[state.activeFormUuid],
|
|
270
|
+
workflowState: "VALIDATE_FOR_NEXT",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
case "UPDATE_VISIT_UUID":
|
|
275
|
+
// this state should not be persisted
|
|
276
|
+
// we don't pers
|
|
277
|
+
return {
|
|
278
|
+
...state,
|
|
279
|
+
forms: {
|
|
280
|
+
...state.forms,
|
|
281
|
+
[state.activeFormUuid]: {
|
|
282
|
+
...state.forms[state.activeFormUuid],
|
|
283
|
+
visits: {
|
|
284
|
+
...state.forms[state.activeFormUuid].visits,
|
|
285
|
+
[state.forms[state.activeFormUuid].activePatientUuid]:
|
|
286
|
+
action.visitUuid,
|
|
287
|
+
},
|
|
288
|
+
activeVisitUuid: action.visitUuid,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
|
|
194
293
|
case "SUBMIT_FOR_NEXT":
|
|
195
294
|
// this state should not be persisted
|
|
196
295
|
window.dispatchEvent(
|
|
@@ -233,6 +332,28 @@ const reducer = (state, action) => {
|
|
|
233
332
|
},
|
|
234
333
|
},
|
|
235
334
|
};
|
|
335
|
+
|
|
336
|
+
case "VALIDATE_FOR_COMPLETE":
|
|
337
|
+
// this state should not be persisted
|
|
338
|
+
window.dispatchEvent(
|
|
339
|
+
new CustomEvent("ampath-form-action", {
|
|
340
|
+
detail: {
|
|
341
|
+
formUuid: state.activeFormUuid,
|
|
342
|
+
patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
|
|
343
|
+
action: "validateForm",
|
|
344
|
+
},
|
|
345
|
+
})
|
|
346
|
+
);
|
|
347
|
+
return {
|
|
348
|
+
...state,
|
|
349
|
+
forms: {
|
|
350
|
+
...state.forms,
|
|
351
|
+
[state.activeFormUuid]: {
|
|
352
|
+
...state.forms[state.activeFormUuid],
|
|
353
|
+
workflowState: "VALIDATE_FOR_COMPLETE",
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
};
|
|
236
357
|
case "SUBMIT_FOR_COMPLETE":
|
|
237
358
|
// this state should not be persisted
|
|
238
359
|
window.dispatchEvent(
|
|
@@ -262,6 +383,7 @@ const reducer = (state, action) => {
|
|
|
262
383
|
[state.activeFormUuid]: {
|
|
263
384
|
...state.forms[state.activeFormUuid],
|
|
264
385
|
activeEncounterUuid: null,
|
|
386
|
+
activVisitUuid: null,
|
|
265
387
|
activePatientUuid: null,
|
|
266
388
|
workflowState: "REVIEW",
|
|
267
389
|
},
|
|
@@ -278,7 +400,9 @@ const reducer = (state, action) => {
|
|
|
278
400
|
activeFormUuid: null,
|
|
279
401
|
};
|
|
280
402
|
persistData(newState);
|
|
281
|
-
|
|
403
|
+
//eslint-disable-next-line
|
|
404
|
+
navigate({ to: "${openmrsSpaBase}/forms" });
|
|
405
|
+
return { ...newState, formDestroyed: true };
|
|
282
406
|
}
|
|
283
407
|
case "CLOSE_SESSION": {
|
|
284
408
|
const newState = {
|
|
@@ -286,6 +410,8 @@ const reducer = (state, action) => {
|
|
|
286
410
|
activeFormUuid: null,
|
|
287
411
|
};
|
|
288
412
|
persistData(newState);
|
|
413
|
+
//eslint-disable-next-line
|
|
414
|
+
navigate({ to: "${openmrsSpaBase}/forms" });
|
|
289
415
|
return newState;
|
|
290
416
|
}
|
|
291
417
|
default:
|
|
@@ -3,15 +3,8 @@ import {
|
|
|
3
3
|
getGlobalStore,
|
|
4
4
|
useStore,
|
|
5
5
|
} from "@openmrs/esm-framework";
|
|
6
|
-
import {
|
|
7
|
-
Button,
|
|
8
|
-
ComposedModal,
|
|
9
|
-
ModalBody,
|
|
10
|
-
ModalFooter,
|
|
11
|
-
ModalHeader,
|
|
12
|
-
} from "@carbon/react";
|
|
6
|
+
import { Button } from "@carbon/react";
|
|
13
7
|
import React, { useContext, useState } from "react";
|
|
14
|
-
import { useNavigate } from "react-router-dom";
|
|
15
8
|
import FormBootstrap from "../FormBootstrap";
|
|
16
9
|
import PatientCard from "../patient-card/PatientCard";
|
|
17
10
|
import styles from "./styles.scss";
|
|
@@ -22,83 +15,15 @@ import FormWorkflowContext, {
|
|
|
22
15
|
} from "../context/FormWorkflowContext";
|
|
23
16
|
import WorkflowReview from "./workflow-review";
|
|
24
17
|
import PatientBanner from "./patient-banner";
|
|
18
|
+
import CompleteModal from "../CompleteModal";
|
|
19
|
+
import CancelModal from "../CancelModal";
|
|
25
20
|
|
|
26
21
|
const formStore = getGlobalStore("ampath-form-state");
|
|
27
22
|
|
|
28
|
-
const CancelModal = ({ open, setOpen }) => {
|
|
29
|
-
const { destroySession, closeSession } = useContext(FormWorkflowContext);
|
|
30
|
-
const { t } = useTranslation();
|
|
31
|
-
const navigate = useNavigate();
|
|
32
|
-
|
|
33
|
-
const discard = async () => {
|
|
34
|
-
await destroySession();
|
|
35
|
-
setOpen(false);
|
|
36
|
-
navigate("../");
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const saveAndClose = async () => {
|
|
40
|
-
await closeSession();
|
|
41
|
-
setOpen(false);
|
|
42
|
-
navigate("../");
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<ComposedModal open={open}>
|
|
47
|
-
<ModalHeader>{t("areYouSure", "Are you sure?")}</ModalHeader>
|
|
48
|
-
<ModalBody>
|
|
49
|
-
{t(
|
|
50
|
-
"cancelExplanation",
|
|
51
|
-
"You will lose any unsaved changes on the current form. Do you want to discard the current session?"
|
|
52
|
-
)}
|
|
53
|
-
</ModalBody>
|
|
54
|
-
<ModalFooter>
|
|
55
|
-
<Button kind="secondary" onClick={() => setOpen(false)}>
|
|
56
|
-
{t("cancel", "Cancel")}
|
|
57
|
-
</Button>
|
|
58
|
-
<Button kind="danger" onClick={discard}>
|
|
59
|
-
{t("discard", "Discard")}
|
|
60
|
-
</Button>
|
|
61
|
-
<Button kind="primary" onClick={saveAndClose}>
|
|
62
|
-
{t("saveSession", "Save Session")}
|
|
63
|
-
</Button>
|
|
64
|
-
</ModalFooter>
|
|
65
|
-
</ComposedModal>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const CompleteModal = ({ open, setOpen }) => {
|
|
70
|
-
const { submitForComplete } = useContext(FormWorkflowContext);
|
|
71
|
-
const { t } = useTranslation();
|
|
72
|
-
|
|
73
|
-
const completeSession = () => {
|
|
74
|
-
submitForComplete();
|
|
75
|
-
setOpen(false);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<ComposedModal open={open}>
|
|
80
|
-
<ModalHeader>{t("areYouSure", "Are you sure?")}</ModalHeader>
|
|
81
|
-
<ModalBody>
|
|
82
|
-
{t(
|
|
83
|
-
"saveExplanation",
|
|
84
|
-
"Do you want to save the current form and exit the workflow?"
|
|
85
|
-
)}
|
|
86
|
-
</ModalBody>
|
|
87
|
-
<ModalFooter>
|
|
88
|
-
<Button kind="secondary" onClick={() => setOpen(false)}>
|
|
89
|
-
{t("cancel", "Cancel")}
|
|
90
|
-
</Button>
|
|
91
|
-
<Button kind="primary" onClick={completeSession}>
|
|
92
|
-
{t("complete", "Complete")}
|
|
93
|
-
</Button>
|
|
94
|
-
</ModalFooter>
|
|
95
|
-
</ComposedModal>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
23
|
const WorkflowNavigationButtons = () => {
|
|
24
|
+
const context = useContext(FormWorkflowContext);
|
|
100
25
|
const { activeFormUuid, submitForNext, workflowState, destroySession } =
|
|
101
|
-
|
|
26
|
+
context;
|
|
102
27
|
const store = useStore(formStore);
|
|
103
28
|
const formState = store[activeFormUuid];
|
|
104
29
|
const navigationDisabled = formState !== "ready";
|
|
@@ -132,8 +57,16 @@ const WorkflowNavigationButtons = () => {
|
|
|
132
57
|
{t("cancel", "Cancel")}
|
|
133
58
|
</Button>
|
|
134
59
|
</div>
|
|
135
|
-
<CancelModal
|
|
136
|
-
|
|
60
|
+
<CancelModal
|
|
61
|
+
open={cancelModalOpen}
|
|
62
|
+
setOpen={setCancelModalOpen}
|
|
63
|
+
context={context}
|
|
64
|
+
/>
|
|
65
|
+
<CompleteModal
|
|
66
|
+
open={completeModalOpen}
|
|
67
|
+
setOpen={setCompleteModalOpen}
|
|
68
|
+
context={context}
|
|
69
|
+
/>
|
|
137
70
|
</>
|
|
138
71
|
);
|
|
139
72
|
};
|