@openmrs/esm-fast-data-entry-app 1.0.1-pre.99 → 1.1.0
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/12.js +1 -0
- package/dist/12.js.map +1 -0
- package/dist/132.js +1 -0
- package/dist/151.js +2 -0
- package/dist/151.js.map +1 -0
- package/dist/195.js +1 -0
- package/dist/195.js.map +1 -0
- package/dist/197.js +1 -0
- package/dist/221.js +1 -0
- package/dist/221.js.map +1 -0
- package/dist/259.js +1 -0
- package/dist/259.js.map +1 -0
- package/dist/265.js +1 -0
- package/dist/265.js.map +1 -0
- package/dist/269.js +1 -0
- package/dist/269.js.map +1 -0
- package/dist/{574.js → 300.js} +1 -1
- package/dist/335.js +1 -0
- package/dist/367.js +1 -0
- package/dist/367.js.map +1 -0
- package/dist/384.js +1 -0
- package/dist/384.js.map +1 -0
- package/dist/{294.js → 540.js} +2 -2
- package/dist/{294.js.map → 540.js.map} +1 -1
- package/dist/55.js +1 -0
- package/dist/579.js +1 -0
- package/dist/579.js.map +1 -0
- package/dist/595.js +2 -0
- package/dist/{409.js.LICENSE.txt → 595.js.LICENSE.txt} +14 -6
- package/dist/595.js.map +1 -0
- package/dist/602.js +1 -0
- package/dist/602.js.map +1 -0
- package/dist/616.js +1 -0
- package/dist/616.js.map +1 -0
- package/dist/626.js +2 -0
- package/dist/626.js.map +1 -0
- package/dist/652.js +1 -0
- package/dist/77.js +1 -0
- package/dist/77.js.map +1 -0
- package/dist/773.js +2 -0
- package/dist/{897.js.LICENSE.txt → 773.js.LICENSE.txt} +13 -2
- package/dist/773.js.map +1 -0
- package/dist/88.js +1 -0
- package/dist/88.js.map +1 -0
- package/dist/930.js +1 -0
- package/dist/930.js.map +1 -0
- package/dist/961.js +2 -0
- package/dist/961.js.map +1 -0
- package/dist/983.js +1 -0
- package/dist/983.js.map +1 -0
- package/dist/99.js +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 +386 -154
- package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/jest.config.json +2 -1
- package/package.json +39 -36
- package/prettier.config.js +8 -0
- package/src/CancelModal.tsx +9 -15
- package/src/CompleteModal.tsx +7 -18
- package/src/FormBootstrap.tsx +31 -18
- package/src/Root.tsx +7 -12
- package/src/add-group-modal/AddGroupModal.tsx +73 -112
- package/src/add-group-modal/styles.scss +7 -3
- package/src/config-schema.ts +63 -24
- 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 +40 -59
- package/src/context/GroupFormWorkflowReducer.ts +84 -109
- package/src/declarations.d.ts +3 -0
- package/src/empty-state/EmptyDataIllustration.tsx +4 -16
- package/src/empty-state/EmptyState.tsx +8 -13
- package/src/empty-state/styles.scss +14 -14
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +43 -55
- 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/form-review-card/styles.scss +9 -11
- 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-banner/styles.scss +11 -12
- package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +19 -28
- package/src/form-entry-workflow/patient-search-header/index.ts +1 -1
- package/src/form-entry-workflow/patient-search-header/styles.scss +13 -10
- package/src/form-entry-workflow/styles.scss +11 -13
- package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +13 -11
- package/src/form-entry-workflow/workflow-review/index.ts +1 -1
- package/src/form-entry-workflow/workflow-review/styles.scss +0 -4
- package/src/forms-app-menu-link.tsx +4 -6
- package/src/forms-page/FormsPage.tsx +23 -51
- package/src/forms-page/forms-table/FormsTable.tsx +22 -42
- package/src/forms-page/forms-table/index.ts +1 -1
- package/src/forms-page/forms-table/styles.scss +4 -5
- package/src/forms-page/index.ts +1 -1
- package/src/forms-page/styles.scss +3 -5
- package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +9 -9
- package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +77 -117
- package/src/group-form-entry-workflow/SessionDetailsForm.tsx +73 -50
- package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +20 -28
- package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +15 -29
- package/src/group-form-entry-workflow/attendance-table/index.ts +1 -1
- package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +45 -0
- 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-display-header/styles.scss +20 -20
- 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/compact-group-result.scss +16 -17
- package/src/group-form-entry-workflow/group-search/compact-group-search.scss +7 -8
- package/src/group-form-entry-workflow/group-search/group-search.scss +20 -23
- package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +20 -21
- package/src/group-form-entry-workflow/group-search-header/index.ts +1 -1
- package/src/group-form-entry-workflow/group-search-header/styles.scss +8 -8
- package/src/group-form-entry-workflow/index.ts +1 -1
- package/src/group-form-entry-workflow/styles.scss +13 -16
- package/src/hooks/index.ts +7 -6
- package/src/hooks/useFormState.ts +3 -3
- package/src/hooks/useGetAllForms.ts +7 -15
- package/src/hooks/useGetEncounter.ts +3 -3
- 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 +10 -10
- package/src/hooks/useSearchEndpoint.ts +23 -40
- package/src/hooks/useSpecificQuestions.ts +75 -0
- package/src/hooks/useStartVisit.ts +18 -28
- package/src/index.ts +8 -20
- package/src/patient-card/PatientCard.tsx +8 -20
- package/src/patient-card/index.ts +1 -1
- package/src/patient-card/styles.scss +2 -4
- package/src/routes.json +2 -2
- package/src/setup-tests.ts +1 -1
- package/src/types.ts +25 -0
- package/tools/i18next-parser.config.js +19 -19
- package/translations/am.json +75 -0
- package/translations/ar.json +75 -0
- package/translations/en.json +7 -1
- package/translations/es.json +75 -0
- package/translations/fr.json +33 -8
- package/translations/he.json +75 -0
- package/translations/km.json +75 -0
- package/tsconfig.json +2 -1
- package/turbo.json +18 -0
- package/webpack.config.js +1 -1
- package/dist/136.js +0 -1
- package/dist/136.js.map +0 -1
- package/dist/141.js +0 -2
- package/dist/141.js.map +0 -1
- package/dist/233.js +0 -2
- package/dist/233.js.map +0 -1
- package/dist/242.js +0 -1
- package/dist/242.js.map +0 -1
- package/dist/327.js +0 -1
- package/dist/327.js.map +0 -1
- package/dist/387.js +0 -1
- package/dist/387.js.map +0 -1
- package/dist/405.js +0 -1
- package/dist/405.js.map +0 -1
- package/dist/409.js +0 -2
- package/dist/409.js.map +0 -1
- package/dist/431.js +0 -1
- package/dist/431.js.map +0 -1
- package/dist/559.js +0 -1
- package/dist/559.js.map +0 -1
- package/dist/757.js +0 -1
- package/dist/820.js +0 -1
- package/dist/820.js.map +0 -1
- package/dist/846.js +0 -1
- package/dist/846.js.map +0 -1
- package/dist/885.js +0 -1
- package/dist/885.js.map +0 -1
- package/dist/897.js +0 -2
- package/dist/897.js.map +0 -1
- package/dist/92.js +0 -1
- package/dist/92.js.map +0 -1
- package/dist/935.js +0 -2
- package/dist/935.js.map +0 -1
- package/src/declarations.d.tsx +0 -2
- /package/dist/{141.js.LICENSE.txt → 151.js.LICENSE.txt} +0 -0
- /package/dist/{294.js.LICENSE.txt → 540.js.LICENSE.txt} +0 -0
- /package/dist/{233.js.LICENSE.txt → 626.js.LICENSE.txt} +0 -0
- /package/dist/{935.js.LICENSE.txt → 961.js.LICENSE.txt} +0 -0
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { navigate } from
|
|
2
|
-
import { initialWorkflowState } from
|
|
1
|
+
import { navigate } from '@openmrs/esm-framework';
|
|
2
|
+
import { initialWorkflowState } from './FormWorkflowContext';
|
|
3
3
|
|
|
4
|
-
export const fdeWorkflowStorageVersion =
|
|
5
|
-
export const fdeWorkflowStorageName =
|
|
4
|
+
export const fdeWorkflowStorageVersion = '1.1.0';
|
|
5
|
+
export const fdeWorkflowStorageName = 'openmrs:fastDataEntryWorkflowState';
|
|
6
6
|
const persistData = (data) => {
|
|
7
|
-
localStorage.setItem(
|
|
8
|
-
fdeWorkflowStorageName + ":" + data.userUuid,
|
|
9
|
-
JSON.stringify(data)
|
|
10
|
-
);
|
|
7
|
+
localStorage.setItem(fdeWorkflowStorageName + ':' + data.userUuid, JSON.stringify(data));
|
|
11
8
|
};
|
|
12
9
|
|
|
13
10
|
const initialFormState = {
|
|
14
|
-
workflowState:
|
|
11
|
+
workflowState: 'NEW_PATIENT',
|
|
15
12
|
activePatientUuid: null,
|
|
16
13
|
activeEncounterUuid: null,
|
|
17
14
|
patientUuids: [],
|
|
@@ -20,23 +17,18 @@ const initialFormState = {
|
|
|
20
17
|
|
|
21
18
|
const reducer = (state, action) => {
|
|
22
19
|
switch (action.type) {
|
|
23
|
-
case
|
|
24
|
-
const savedData = localStorage.getItem(
|
|
25
|
-
fdeWorkflowStorageName + ":" + action.userUuid
|
|
26
|
-
);
|
|
20
|
+
case 'INITIALIZE_WORKFLOW_STATE': {
|
|
21
|
+
const savedData = localStorage.getItem(fdeWorkflowStorageName + ':' + action.userUuid);
|
|
27
22
|
const savedDataObject = savedData ? JSON.parse(savedData) : {};
|
|
28
23
|
let newState: { [key: string]: unknown } = {};
|
|
29
24
|
const newPatient = action.newPatientUuid
|
|
30
25
|
? {
|
|
31
26
|
activePatientUuid: action.newPatientUuid,
|
|
32
|
-
workflowState:
|
|
27
|
+
workflowState: 'EDIT_FORM',
|
|
33
28
|
}
|
|
34
29
|
: {};
|
|
35
30
|
|
|
36
|
-
if (
|
|
37
|
-
savedData &&
|
|
38
|
-
savedDataObject["_storageVersion"] === fdeWorkflowStorageVersion
|
|
39
|
-
) {
|
|
31
|
+
if (savedData && savedDataObject['_storageVersion'] === fdeWorkflowStorageVersion) {
|
|
40
32
|
// there is localStorage data and it is still valid
|
|
41
33
|
newState = {
|
|
42
34
|
...savedDataObject,
|
|
@@ -49,21 +41,15 @@ const reducer = (state, action) => {
|
|
|
49
41
|
...savedDataObject.forms[action.activeFormUuid],
|
|
50
42
|
// if we receive activePatientUuid from a query parameter use that one
|
|
51
43
|
...newPatient,
|
|
52
|
-
patientUuids:
|
|
53
|
-
savedDataObject.forms[action.activeFormUuid]?.patientUuids ||
|
|
54
|
-
initialFormState.patientUuids,
|
|
44
|
+
patientUuids: savedDataObject.forms[action.activeFormUuid]?.patientUuids || initialFormState.patientUuids,
|
|
55
45
|
},
|
|
56
46
|
},
|
|
57
47
|
};
|
|
58
48
|
if (
|
|
59
49
|
action.newPatientUuid &&
|
|
60
|
-
!newState.forms[action.activeFormUuid].patientUuids.includes(
|
|
61
|
-
action.newPatientUuid
|
|
62
|
-
)
|
|
50
|
+
!newState.forms[action.activeFormUuid].patientUuids.includes(action.newPatientUuid)
|
|
63
51
|
) {
|
|
64
|
-
newState.forms[action.activeFormUuid].patientUuids.push(
|
|
65
|
-
action.newPatientUuid
|
|
66
|
-
);
|
|
52
|
+
newState.forms[action.activeFormUuid].patientUuids.push(action.newPatientUuid);
|
|
67
53
|
}
|
|
68
54
|
} else {
|
|
69
55
|
// no localStorage data, or we should void it
|
|
@@ -80,27 +66,24 @@ const reducer = (state, action) => {
|
|
|
80
66
|
persistData(newState);
|
|
81
67
|
return { ...newState };
|
|
82
68
|
}
|
|
83
|
-
case
|
|
69
|
+
case 'ADD_PATIENT': {
|
|
84
70
|
const newState = {
|
|
85
71
|
...state,
|
|
86
72
|
forms: {
|
|
87
73
|
...state.forms,
|
|
88
74
|
[state.activeFormUuid]: {
|
|
89
75
|
...state.forms[state.activeFormUuid],
|
|
90
|
-
patientUuids: [
|
|
91
|
-
...state.forms[state.activeFormUuid].patientUuids,
|
|
92
|
-
action.patientUuid,
|
|
93
|
-
],
|
|
76
|
+
patientUuids: [...state.forms[state.activeFormUuid].patientUuids, action.patientUuid],
|
|
94
77
|
activePatientUuid: action.patientUuid,
|
|
95
78
|
activeEncounterUuid: null,
|
|
96
|
-
workflowState:
|
|
79
|
+
workflowState: 'EDIT_FORM',
|
|
97
80
|
},
|
|
98
81
|
},
|
|
99
82
|
};
|
|
100
83
|
persistData(newState);
|
|
101
84
|
return newState;
|
|
102
85
|
}
|
|
103
|
-
case
|
|
86
|
+
case 'OPEN_PATIENT_SEARCH': {
|
|
104
87
|
const newState = {
|
|
105
88
|
...state,
|
|
106
89
|
forms: {
|
|
@@ -109,7 +92,7 @@ const reducer = (state, action) => {
|
|
|
109
92
|
...state.forms[state.activeFormUuid],
|
|
110
93
|
activePatientUuid: null,
|
|
111
94
|
activeEncounterUuid: null,
|
|
112
|
-
workflowState:
|
|
95
|
+
workflowState: 'NEW_PATIENT',
|
|
113
96
|
},
|
|
114
97
|
},
|
|
115
98
|
};
|
|
@@ -117,11 +100,8 @@ const reducer = (state, action) => {
|
|
|
117
100
|
persistData(newState);
|
|
118
101
|
return newState;
|
|
119
102
|
}
|
|
120
|
-
case
|
|
121
|
-
if (
|
|
122
|
-
state.forms[state.activeFormUuid].workflowState ===
|
|
123
|
-
"SUBMIT_FOR_COMPLETE"
|
|
124
|
-
) {
|
|
103
|
+
case 'SAVE_ENCOUNTER': {
|
|
104
|
+
if (state.forms[state.activeFormUuid].workflowState === 'SUBMIT_FOR_COMPLETE') {
|
|
125
105
|
const { [state.activeFormUuid]: activeForm, ...formRest } = state.forms;
|
|
126
106
|
const newState = {
|
|
127
107
|
...state,
|
|
@@ -130,7 +110,7 @@ const reducer = (state, action) => {
|
|
|
130
110
|
};
|
|
131
111
|
persistData(newState);
|
|
132
112
|
// eslint-disable-next-line
|
|
133
|
-
navigate({ to:
|
|
113
|
+
navigate({ to: '${openmrsSpaBase}/forms' });
|
|
134
114
|
return newState;
|
|
135
115
|
} else {
|
|
136
116
|
const newState = {
|
|
@@ -141,18 +121,15 @@ const reducer = (state, action) => {
|
|
|
141
121
|
...state.forms[state.activeFormUuid],
|
|
142
122
|
encounters: {
|
|
143
123
|
...state.forms[state.activeFormUuid].encounters,
|
|
144
|
-
[state.forms[state.activeFormUuid].activePatientUuid]:
|
|
145
|
-
action.encounterUuid,
|
|
124
|
+
[state.forms[state.activeFormUuid].activePatientUuid]: action.encounterUuid,
|
|
146
125
|
},
|
|
147
126
|
activePatientUuid: null,
|
|
148
127
|
activeEncounterUuid: null,
|
|
149
128
|
workflowState:
|
|
150
|
-
state.forms[state.activeFormUuid].workflowState ===
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"SUBMIT_FOR_REVIEW"
|
|
155
|
-
? "REVIEW"
|
|
129
|
+
state.forms[state.activeFormUuid].workflowState === 'SUBMIT_FOR_NEXT'
|
|
130
|
+
? 'NEW_PATIENT'
|
|
131
|
+
: state.forms[state.activeFormUuid].workflowState === 'SUBMIT_FOR_REVIEW'
|
|
132
|
+
? 'REVIEW'
|
|
156
133
|
: state.forms[state.activeFormUuid].workflowState,
|
|
157
134
|
},
|
|
158
135
|
},
|
|
@@ -161,33 +138,32 @@ const reducer = (state, action) => {
|
|
|
161
138
|
return newState;
|
|
162
139
|
}
|
|
163
140
|
}
|
|
164
|
-
case
|
|
141
|
+
case 'EDIT_ENCOUNTER': {
|
|
165
142
|
const newState = {
|
|
166
143
|
...state,
|
|
167
144
|
forms: {
|
|
168
145
|
...state.forms,
|
|
169
146
|
[state.activeFormUuid]: {
|
|
170
147
|
...state.forms[state.activeFormUuid],
|
|
171
|
-
activeEncounterUuid:
|
|
172
|
-
state.forms[state.activeFormUuid].encounters[action.patientUuid],
|
|
148
|
+
activeEncounterUuid: state.forms[state.activeFormUuid].encounters[action.patientUuid],
|
|
173
149
|
activePatientUuid: action.patientUuid,
|
|
174
|
-
workflowState:
|
|
150
|
+
workflowState: 'EDIT_FORM',
|
|
175
151
|
},
|
|
176
152
|
},
|
|
177
153
|
};
|
|
178
154
|
persistData(newState);
|
|
179
155
|
return newState;
|
|
180
156
|
}
|
|
181
|
-
case
|
|
157
|
+
case 'SUBMIT_FOR_NEXT':
|
|
182
158
|
// this state should not be persisted
|
|
183
159
|
window.dispatchEvent(
|
|
184
|
-
new CustomEvent(
|
|
160
|
+
new CustomEvent('ampath-form-action', {
|
|
185
161
|
detail: {
|
|
186
162
|
formUuid: state.activeFormUuid,
|
|
187
163
|
patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
|
|
188
|
-
action:
|
|
164
|
+
action: 'onSubmit',
|
|
189
165
|
},
|
|
190
|
-
})
|
|
166
|
+
}),
|
|
191
167
|
);
|
|
192
168
|
return {
|
|
193
169
|
...state,
|
|
@@ -195,20 +171,20 @@ const reducer = (state, action) => {
|
|
|
195
171
|
...state.forms,
|
|
196
172
|
[state.activeFormUuid]: {
|
|
197
173
|
...state.forms[state.activeFormUuid],
|
|
198
|
-
workflowState:
|
|
174
|
+
workflowState: 'SUBMIT_FOR_NEXT',
|
|
199
175
|
},
|
|
200
176
|
},
|
|
201
177
|
};
|
|
202
|
-
case
|
|
178
|
+
case 'SUBMIT_FOR_REVIEW':
|
|
203
179
|
// this state should not be persisted
|
|
204
180
|
window.dispatchEvent(
|
|
205
|
-
new CustomEvent(
|
|
181
|
+
new CustomEvent('ampath-form-action', {
|
|
206
182
|
detail: {
|
|
207
183
|
formUuid: state.activeFormUuid,
|
|
208
184
|
patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
|
|
209
|
-
action:
|
|
185
|
+
action: 'onSubmit',
|
|
210
186
|
},
|
|
211
|
-
})
|
|
187
|
+
}),
|
|
212
188
|
);
|
|
213
189
|
return {
|
|
214
190
|
...state,
|
|
@@ -216,20 +192,20 @@ const reducer = (state, action) => {
|
|
|
216
192
|
...state.forms,
|
|
217
193
|
[state.activeFormUuid]: {
|
|
218
194
|
...state.forms[state.activeFormUuid],
|
|
219
|
-
workflowState:
|
|
195
|
+
workflowState: 'SUBMIT_FOR_REVIEW',
|
|
220
196
|
},
|
|
221
197
|
},
|
|
222
198
|
};
|
|
223
|
-
case
|
|
199
|
+
case 'SUBMIT_FOR_COMPLETE':
|
|
224
200
|
// this state should not be persisted
|
|
225
201
|
window.dispatchEvent(
|
|
226
|
-
new CustomEvent(
|
|
202
|
+
new CustomEvent('ampath-form-action', {
|
|
227
203
|
detail: {
|
|
228
204
|
formUuid: state.activeFormUuid,
|
|
229
205
|
patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
|
|
230
|
-
action:
|
|
206
|
+
action: 'onSubmit',
|
|
231
207
|
},
|
|
232
|
-
})
|
|
208
|
+
}),
|
|
233
209
|
);
|
|
234
210
|
return {
|
|
235
211
|
...state,
|
|
@@ -237,11 +213,11 @@ const reducer = (state, action) => {
|
|
|
237
213
|
...state.forms,
|
|
238
214
|
[state.activeFormUuid]: {
|
|
239
215
|
...state.forms[state.activeFormUuid],
|
|
240
|
-
workflowState:
|
|
216
|
+
workflowState: 'SUBMIT_FOR_COMPLETE',
|
|
241
217
|
},
|
|
242
218
|
},
|
|
243
219
|
};
|
|
244
|
-
case
|
|
220
|
+
case 'GO_TO_REVIEW': {
|
|
245
221
|
const newState = {
|
|
246
222
|
...state,
|
|
247
223
|
forms: {
|
|
@@ -250,14 +226,14 @@ const reducer = (state, action) => {
|
|
|
250
226
|
...state.forms[state.activeFormUuid],
|
|
251
227
|
activeEncounterUuid: null,
|
|
252
228
|
activePatientUuid: null,
|
|
253
|
-
workflowState:
|
|
229
|
+
workflowState: 'REVIEW',
|
|
254
230
|
},
|
|
255
231
|
},
|
|
256
232
|
};
|
|
257
233
|
persistData(newState);
|
|
258
234
|
return newState;
|
|
259
235
|
}
|
|
260
|
-
case
|
|
236
|
+
case 'DESTROY_SESSION': {
|
|
261
237
|
const { [state.activeFormUuid]: activeForm, ...formRest } = state.forms;
|
|
262
238
|
const newState = {
|
|
263
239
|
...state,
|
|
@@ -266,17 +242,17 @@ const reducer = (state, action) => {
|
|
|
266
242
|
};
|
|
267
243
|
persistData(newState);
|
|
268
244
|
//eslint-disable-next-line
|
|
269
|
-
navigate({ to:
|
|
245
|
+
navigate({ to: '${openmrsSpaBase}/forms' });
|
|
270
246
|
return newState;
|
|
271
247
|
}
|
|
272
|
-
case
|
|
248
|
+
case 'CLOSE_SESSION': {
|
|
273
249
|
const newState = {
|
|
274
250
|
...state,
|
|
275
251
|
activeFormUuid: null,
|
|
276
252
|
};
|
|
277
253
|
persistData(newState);
|
|
278
254
|
//eslint-disable-next-line
|
|
279
|
-
navigate({ to:
|
|
255
|
+
navigate({ to: '${openmrsSpaBase}/forms' });
|
|
280
256
|
return newState;
|
|
281
257
|
}
|
|
282
258
|
default:
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useReducer } from
|
|
2
|
-
import reducer from
|
|
3
|
-
import { useParams } from
|
|
4
|
-
import { Type, useSession } from
|
|
5
|
-
import useGetSystemSetting from
|
|
1
|
+
import React, { useEffect, useMemo, useReducer } from 'react';
|
|
2
|
+
import reducer from './GroupFormWorkflowReducer';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
4
|
+
import { type Type, useSession } from '@openmrs/esm-framework';
|
|
5
|
+
import useGetSystemSetting from '../hooks/useGetSystemSetting';
|
|
6
|
+
|
|
6
7
|
interface ParamTypes {
|
|
7
8
|
formUuid?: string;
|
|
8
9
|
}
|
|
@@ -12,6 +13,7 @@ export interface GroupType {
|
|
|
12
13
|
name: string;
|
|
13
14
|
members: Array<Type.Object>;
|
|
14
15
|
}
|
|
16
|
+
|
|
15
17
|
export interface MetaType {
|
|
16
18
|
sessionName: string;
|
|
17
19
|
sessionDate: string;
|
|
@@ -49,6 +51,7 @@ export const initialWorkflowState = {
|
|
|
49
51
|
workflowState: null, // pseudo field from state[activeFormUuid].workflowState
|
|
50
52
|
activePatientUuid: null, // pseudo field from state[activeFormUuid].activePatientUuid
|
|
51
53
|
activeEncounterUuid: null, // pseudo field from state[activeFormUuid].activeEncounterUuid
|
|
54
|
+
activeSessionUuid: null, // pseudo field from state[activeFormUuid].activeSessionUuid
|
|
52
55
|
activeVisitUuid: null, // pseudo field from state[activeFormUuid].activeVisitUuid
|
|
53
56
|
patientUuids: [], // pseudo field from state[activeFormUuid].patientUuids
|
|
54
57
|
encounters: {}, // pseudo field from state[activeFormUuid].encounters
|
|
@@ -74,10 +77,8 @@ const GroupFormWorkflowContext = React.createContext({
|
|
|
74
77
|
const GroupFormWorkflowProvider = ({ children }) => {
|
|
75
78
|
const { user } = useSession();
|
|
76
79
|
const { formUuid } = useParams() as ParamTypes;
|
|
77
|
-
const activeFormUuid = formUuid.split(
|
|
78
|
-
const systemSetting = useGetSystemSetting(
|
|
79
|
-
"@openmrs/esm-fast-data-entry-app.groupSessionVisitTypeUuid"
|
|
80
|
-
);
|
|
80
|
+
const activeFormUuid = formUuid.split('&')[0];
|
|
81
|
+
const systemSetting = useGetSystemSetting('@openmrs/esm-fast-data-entry-app.groupSessionVisitTypeUuid');
|
|
81
82
|
const groupVisitTypeUuid = systemSetting?.result?.data?.results?.[0]?.value;
|
|
82
83
|
const [state, dispatch] = useReducer(reducer, {
|
|
83
84
|
...initialWorkflowState,
|
|
@@ -88,37 +89,32 @@ const GroupFormWorkflowProvider = ({ children }) => {
|
|
|
88
89
|
() => ({
|
|
89
90
|
initializeWorkflowState: ({ activeFormUuid }) =>
|
|
90
91
|
dispatch({
|
|
91
|
-
type:
|
|
92
|
+
type: 'INITIALIZE_WORKFLOW_STATE',
|
|
92
93
|
activeFormUuid,
|
|
93
94
|
userUuid: user.uuid,
|
|
94
95
|
}),
|
|
95
|
-
setGroup: (group) => dispatch({ type:
|
|
96
|
-
unsetGroup: () => dispatch({ type:
|
|
97
|
-
setSessionMeta: (meta) => dispatch({ type:
|
|
98
|
-
addPatientUuid: (patientUuid) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
dispatch({ type: "REMOVE_PATIENT_UUID", patientUuid }),
|
|
102
|
-
openPatientSearch: () => dispatch({ type: "OPEN_PATIENT_SEARCH" }),
|
|
96
|
+
setGroup: (group) => dispatch({ type: 'SET_GROUP', group }),
|
|
97
|
+
unsetGroup: () => dispatch({ type: 'UNSET_GROUP' }),
|
|
98
|
+
setSessionMeta: (meta) => dispatch({ type: 'SET_SESSION_META', meta }),
|
|
99
|
+
addPatientUuid: (patientUuid) => dispatch({ type: 'ADD_PATIENT_UUID', patientUuid }),
|
|
100
|
+
removePatientUuid: (patientUuid) => dispatch({ type: 'REMOVE_PATIENT_UUID', patientUuid }),
|
|
101
|
+
openPatientSearch: () => dispatch({ type: 'OPEN_PATIENT_SEARCH' }),
|
|
103
102
|
saveEncounter: (encounterUuid) =>
|
|
104
103
|
dispatch({
|
|
105
|
-
type:
|
|
104
|
+
type: 'SAVE_ENCOUNTER',
|
|
106
105
|
encounterUuid,
|
|
107
106
|
}),
|
|
108
|
-
validateForNext: () => dispatch({ type:
|
|
109
|
-
validateForComplete: () => dispatch({ type:
|
|
110
|
-
updateVisitUuid: (visitUuid) =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
goToReview: () => dispatch({ type: "GO_TO_REVIEW" }),
|
|
118
|
-
destroySession: () => dispatch({ type: "DESTROY_SESSION" }),
|
|
119
|
-
closeSession: () => dispatch({ type: "CLOSE_SESSION" }),
|
|
107
|
+
validateForNext: () => dispatch({ type: 'VALIDATE_FOR_NEXT' }),
|
|
108
|
+
validateForComplete: () => dispatch({ type: 'VALIDATE_FOR_COMPLETE' }),
|
|
109
|
+
updateVisitUuid: (visitUuid) => dispatch({ type: 'UPDATE_VISIT_UUID', visitUuid }),
|
|
110
|
+
submitForNext: (nextPatientUuid) => dispatch({ type: 'SUBMIT_FOR_NEXT', nextPatientUuid }),
|
|
111
|
+
submitForComplete: () => dispatch({ type: 'SUBMIT_FOR_COMPLETE' }),
|
|
112
|
+
editEncounter: (patientUuid) => dispatch({ type: 'EDIT_ENCOUNTER', patientUuid }),
|
|
113
|
+
goToReview: () => dispatch({ type: 'GO_TO_REVIEW' }),
|
|
114
|
+
destroySession: () => dispatch({ type: 'DESTROY_SESSION' }),
|
|
115
|
+
closeSession: () => dispatch({ type: 'CLOSE_SESSION' }),
|
|
120
116
|
}),
|
|
121
|
-
[user]
|
|
117
|
+
[user],
|
|
122
118
|
);
|
|
123
119
|
|
|
124
120
|
// if formUuid isn't a part of state yet, grab it from the url params
|
|
@@ -135,36 +131,21 @@ const GroupFormWorkflowProvider = ({ children }) => {
|
|
|
135
131
|
groupVisitTypeUuid,
|
|
136
132
|
...state,
|
|
137
133
|
...actions,
|
|
138
|
-
workflowState:
|
|
139
|
-
|
|
140
|
-
initialWorkflowState.
|
|
134
|
+
workflowState: state.forms?.[state.activeFormUuid]?.workflowState ?? initialWorkflowState.workflowState,
|
|
135
|
+
activeSessionUuid:
|
|
136
|
+
state.forms?.[state.activeFormUuid]?.activeSessionUuid ?? initialWorkflowState.activeSessionUuid,
|
|
141
137
|
activePatientUuid:
|
|
142
|
-
state.forms?.[state.activeFormUuid]?.activePatientUuid ??
|
|
143
|
-
initialWorkflowState.activePatientUuid,
|
|
138
|
+
state.forms?.[state.activeFormUuid]?.activePatientUuid ?? initialWorkflowState.activePatientUuid,
|
|
144
139
|
activeEncounterUuid:
|
|
145
|
-
state.forms?.[state.activeFormUuid]?.activeEncounterUuid ??
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
state.forms?.[state.activeFormUuid]?.patientUuids ??
|
|
152
|
-
initialWorkflowState.patientUuids,
|
|
153
|
-
encounters:
|
|
154
|
-
state.forms?.[state.activeFormUuid]?.encounters ??
|
|
155
|
-
initialWorkflowState.encounters,
|
|
156
|
-
activeGroupUuid:
|
|
157
|
-
state.forms?.[state.activeFormUuid]?.groupUuid ??
|
|
158
|
-
initialWorkflowState.activeGroupUuid,
|
|
159
|
-
activeGroupName:
|
|
160
|
-
state.forms?.[state.activeFormUuid]?.groupName ??
|
|
161
|
-
initialWorkflowState.activeGroupName,
|
|
140
|
+
state.forms?.[state.activeFormUuid]?.activeEncounterUuid ?? initialWorkflowState.activeEncounterUuid,
|
|
141
|
+
activeVisitUuid: state.forms?.[state.activeFormUuid]?.activeVisitUuid ?? initialWorkflowState.activeVisitUuid,
|
|
142
|
+
patientUuids: state.forms?.[state.activeFormUuid]?.patientUuids ?? initialWorkflowState.patientUuids,
|
|
143
|
+
encounters: state.forms?.[state.activeFormUuid]?.encounters ?? initialWorkflowState.encounters,
|
|
144
|
+
activeGroupUuid: state.forms?.[state.activeFormUuid]?.groupUuid ?? initialWorkflowState.activeGroupUuid,
|
|
145
|
+
activeGroupName: state.forms?.[state.activeFormUuid]?.groupName ?? initialWorkflowState.activeGroupName,
|
|
162
146
|
activeGroupMembers:
|
|
163
|
-
state.forms?.[state.activeFormUuid]?.groupMembers ??
|
|
164
|
-
|
|
165
|
-
activeSessionMeta:
|
|
166
|
-
state.forms?.[state.activeFormUuid]?.sessionMeta ??
|
|
167
|
-
initialWorkflowState.activeSessionMeta,
|
|
147
|
+
state.forms?.[state.activeFormUuid]?.groupMembers ?? initialWorkflowState.activeGroupMembers,
|
|
148
|
+
activeSessionMeta: state.forms?.[state.activeFormUuid]?.sessionMeta ?? initialWorkflowState.activeSessionMeta,
|
|
168
149
|
}}
|
|
169
150
|
>
|
|
170
151
|
{children}
|