@openmrs/esm-fast-data-entry-app 1.0.1-pre.17 → 1.0.1-pre.176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/README.md +21 -2
  2. package/__mocks__/react-i18next.js +9 -14
  3. package/dist/101.js +1 -0
  4. package/dist/101.js.map +1 -0
  5. package/dist/132.js +1 -1
  6. package/dist/143.js +1 -0
  7. package/dist/143.js.map +1 -0
  8. package/dist/188.js +1 -0
  9. package/dist/188.js.map +1 -0
  10. package/dist/197.js +1 -0
  11. package/dist/219.js +1 -0
  12. package/dist/219.js.map +1 -0
  13. package/dist/221.js +1 -0
  14. package/dist/221.js.map +1 -0
  15. package/dist/259.js +1 -0
  16. package/dist/259.js.map +1 -0
  17. package/dist/29.js +2 -0
  18. package/dist/29.js.LICENSE.txt +3 -0
  19. package/dist/29.js.map +1 -0
  20. package/dist/300.js +1 -0
  21. package/dist/31.js +2 -0
  22. package/dist/{569.js.LICENSE.txt → 31.js.LICENSE.txt} +9 -6
  23. package/dist/31.js.map +1 -0
  24. package/dist/326.js +1 -0
  25. package/dist/326.js.map +1 -0
  26. package/dist/335.js +1 -0
  27. package/dist/367.js +1 -0
  28. package/dist/367.js.map +1 -0
  29. package/dist/480.js +1 -0
  30. package/dist/491.js +1 -0
  31. package/dist/491.js.map +1 -0
  32. package/dist/540.js +2 -0
  33. package/dist/540.js.map +1 -0
  34. package/dist/55.js +1 -0
  35. package/dist/564.js +1 -0
  36. package/dist/564.js.map +1 -0
  37. package/dist/602.js +1 -0
  38. package/dist/602.js.map +1 -0
  39. package/dist/626.js +2 -0
  40. package/dist/626.js.LICENSE.txt +9 -0
  41. package/dist/626.js.map +1 -0
  42. package/dist/652.js +1 -0
  43. package/dist/685.js +1 -0
  44. package/dist/685.js.map +1 -0
  45. package/dist/773.js +2 -0
  46. package/dist/{68.js.LICENSE.txt → 773.js.LICENSE.txt} +13 -2
  47. package/dist/773.js.map +1 -0
  48. package/dist/91.js +1 -0
  49. package/dist/91.js.map +1 -0
  50. package/dist/961.js +2 -0
  51. package/dist/961.js.map +1 -0
  52. package/dist/99.js +1 -0
  53. package/dist/99.js.map +1 -0
  54. package/dist/main.js +1 -1
  55. package/dist/main.js.map +1 -0
  56. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  57. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +403 -136
  58. package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -0
  59. package/dist/routes.json +1 -0
  60. package/jest.config.json +2 -1
  61. package/package.json +41 -38
  62. package/prettier.config.js +8 -0
  63. package/src/CancelModal.tsx +42 -0
  64. package/src/CompleteModal.tsx +35 -0
  65. package/src/FormBootstrap.tsx +39 -11
  66. package/src/Root.tsx +7 -12
  67. package/src/add-group-modal/AddGroupModal.tsx +107 -120
  68. package/src/add-group-modal/styles.scss +7 -3
  69. package/src/config-schema.ts +77 -16
  70. package/src/constant.ts +1 -1
  71. package/src/context/FormWorkflowContext.tsx +31 -32
  72. package/src/context/FormWorkflowReducer.ts +53 -67
  73. package/src/context/GroupFormWorkflowContext.tsx +56 -44
  74. package/src/context/GroupFormWorkflowReducer.ts +177 -68
  75. package/src/declarations.d.ts +4 -0
  76. package/src/empty-state/EmptyDataIllustration.tsx +4 -16
  77. package/src/empty-state/EmptyState.tsx +8 -13
  78. package/src/empty-state/styles.scss +14 -14
  79. package/src/form-entry-workflow/FormEntryWorkflow.tsx +78 -124
  80. package/src/form-entry-workflow/form-review-card/FormReviewCard.tsx +7 -7
  81. package/src/form-entry-workflow/form-review-card/index.ts +1 -1
  82. package/src/form-entry-workflow/form-review-card/styles.scss +9 -11
  83. package/src/form-entry-workflow/index.ts +1 -1
  84. package/src/form-entry-workflow/patient-banner/PatientBanner.test.tsx +5 -5
  85. package/src/form-entry-workflow/patient-banner/PatientBanner.tsx +14 -27
  86. package/src/form-entry-workflow/patient-banner/index.ts +1 -1
  87. package/src/form-entry-workflow/patient-banner/styles.scss +11 -12
  88. package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +19 -28
  89. package/src/form-entry-workflow/patient-search-header/index.ts +1 -1
  90. package/src/form-entry-workflow/patient-search-header/styles.scss +13 -10
  91. package/src/form-entry-workflow/styles.scss +13 -14
  92. package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +13 -11
  93. package/src/form-entry-workflow/workflow-review/index.ts +1 -1
  94. package/src/form-entry-workflow/workflow-review/styles.scss +0 -4
  95. package/src/forms-app-menu-link.tsx +4 -6
  96. package/src/forms-page/FormsPage.tsx +24 -47
  97. package/src/forms-page/forms-table/FormsTable.tsx +33 -47
  98. package/src/forms-page/forms-table/index.ts +1 -1
  99. package/src/forms-page/forms-table/styles.scss +4 -5
  100. package/src/forms-page/index.ts +1 -1
  101. package/src/forms-page/styles.scss +3 -5
  102. package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +15 -402
  103. package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +207 -0
  104. package/src/group-form-entry-workflow/SessionDetailsForm.tsx +154 -0
  105. package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +99 -0
  106. package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +130 -0
  107. package/src/group-form-entry-workflow/attendance-table/index.ts +1 -0
  108. package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +41 -0
  109. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.test.tsx +5 -5
  110. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +14 -30
  111. package/src/group-form-entry-workflow/group-display-header/index.ts +1 -1
  112. package/src/group-form-entry-workflow/group-display-header/styles.scss +20 -20
  113. package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +24 -35
  114. package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +13 -15
  115. package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +22 -38
  116. package/src/group-form-entry-workflow/group-search/compact-group-result.scss +16 -17
  117. package/src/group-form-entry-workflow/group-search/compact-group-search.scss +7 -8
  118. package/src/group-form-entry-workflow/group-search/group-search.scss +20 -23
  119. package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +41 -18
  120. package/src/group-form-entry-workflow/group-search-header/index.ts +1 -1
  121. package/src/group-form-entry-workflow/group-search-header/styles.scss +8 -8
  122. package/src/group-form-entry-workflow/index.ts +1 -1
  123. package/src/group-form-entry-workflow/styles.scss +15 -17
  124. package/src/hooks/index.ts +7 -6
  125. package/src/hooks/useForm.ts +56 -0
  126. package/src/hooks/useFormState.ts +3 -3
  127. package/src/hooks/useGetAllForms.ts +7 -15
  128. package/src/hooks/useGetEncounter.ts +3 -3
  129. package/src/hooks/useGetPatient.ts +3 -3
  130. package/src/hooks/useGetPatients.ts +32 -0
  131. package/src/hooks/useGetSystemSetting.ts +36 -0
  132. package/src/hooks/useKeyPress.ts +5 -5
  133. package/src/hooks/usePostEndpoint.ts +16 -10
  134. package/src/hooks/useSearchEndpoint.ts +23 -40
  135. package/src/hooks/useStartVisit.ts +82 -0
  136. package/src/index.ts +12 -76
  137. package/src/patient-card/PatientCard.tsx +8 -20
  138. package/src/patient-card/index.ts +1 -1
  139. package/src/patient-card/styles.scss +3 -4
  140. package/src/routes.json +24 -0
  141. package/src/setup-tests.ts +1 -1
  142. package/src/types.ts +20 -0
  143. package/tools/i18next-parser.config.js +93 -0
  144. package/translations/am.json +75 -0
  145. package/translations/ar.json +75 -0
  146. package/translations/en.json +32 -11
  147. package/translations/es.json +75 -0
  148. package/translations/fr.json +75 -0
  149. package/translations/he.json +75 -0
  150. package/translations/km.json +75 -0
  151. package/turbo.json +18 -0
  152. package/webpack.config.js +1 -1
  153. package/dist/247.js +0 -1
  154. package/dist/255.js +0 -1
  155. package/dist/294.js +0 -2
  156. package/dist/32.js +0 -1
  157. package/dist/327.js +0 -1
  158. package/dist/403.js +0 -2
  159. package/dist/403.js.LICENSE.txt +0 -14
  160. package/dist/553.js +0 -2
  161. package/dist/553.js.LICENSE.txt +0 -14
  162. package/dist/569.js +0 -2
  163. package/dist/574.js +0 -1
  164. package/dist/595.js +0 -2
  165. package/dist/595.js.LICENSE.txt +0 -1
  166. package/dist/617.js +0 -1
  167. package/dist/68.js +0 -2
  168. package/dist/776.js +0 -1
  169. package/dist/804.js +0 -1
  170. package/dist/820.js +0 -1
  171. package/dist/906.js +0 -1
  172. package/dist/935.js +0 -2
  173. package/dist/openmrs-esm-fast-data-entry-app.old +0 -1
  174. package/src/declarations.d.tsx +0 -2
  175. /package/dist/{294.js.LICENSE.txt → 540.js.LICENSE.txt} +0 -0
  176. /package/dist/{935.js.LICENSE.txt → 961.js.LICENSE.txt} +0 -0
@@ -1,33 +1,34 @@
1
- import { navigate } from "@openmrs/esm-framework";
2
- import { initialWorkflowState } from "./FormWorkflowContext";
1
+ import { navigate } from '@openmrs/esm-framework';
2
+ import { initialWorkflowState } from './FormWorkflowContext';
3
+ import { v4 as uuid } from 'uuid';
3
4
 
4
- export const fdeGroupWorkflowStorageVersion = "1.0.5";
5
- export const fdeGroupWorkflowStorageName =
6
- "openmrs:fastDataEntryGroupWorkflowState";
5
+ export const fdeGroupWorkflowStorageVersion = '1.0.5';
6
+ export const fdeGroupWorkflowStorageName = 'openmrs:fastDataEntryGroupWorkflowState';
7
7
  const persistData = (data) => {
8
- localStorage.setItem(fdeGroupWorkflowStorageName, JSON.stringify(data));
8
+ localStorage.setItem(fdeGroupWorkflowStorageName + ':' + data.userUuid, JSON.stringify(data));
9
9
  };
10
10
 
11
11
  const initialFormState = {
12
- workflowState: "NEW_GROUP_SESSION",
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,
19
+ activeSessionUuid: null,
17
20
  patientUuids: [],
18
21
  encounters: {},
22
+ visits: {},
19
23
  };
20
24
 
21
25
  const reducer = (state, action) => {
22
26
  switch (action.type) {
23
- case "INITIALIZE_WORKFLOW_STATE": {
24
- const savedData = localStorage.getItem(fdeGroupWorkflowStorageName);
27
+ case 'INITIALIZE_WORKFLOW_STATE': {
28
+ const savedData = localStorage.getItem(fdeGroupWorkflowStorageName + ':' + action.userUuid);
25
29
  const savedDataObject = savedData ? JSON.parse(savedData) : {};
26
30
  let newState: { [key: string]: unknown } = {};
27
- if (
28
- savedData &&
29
- savedDataObject["_storageVersion"] === fdeGroupWorkflowStorageVersion
30
- ) {
31
+ if (savedData && savedDataObject['_storageVersion'] === fdeGroupWorkflowStorageVersion) {
31
32
  // there is localStorage data and it is still valid
32
33
  const thisSavedForm = savedDataObject.forms?.[action.activeFormUuid];
33
34
  // set active patient to the last one we were on
@@ -37,6 +38,7 @@ const reducer = (state, action) => {
37
38
  thisSavedForm?.patientUuids?.[0] ||
38
39
  // something probably went wrong...
39
40
  null;
41
+ const activeSessionUuid = thisSavedForm?.activeSessionUuid || uuid();
40
42
  newState = {
41
43
  ...savedDataObject,
42
44
  // set current form to this one
@@ -48,8 +50,9 @@ const reducer = (state, action) => {
48
50
  ...initialFormState,
49
51
  ...thisSavedForm,
50
52
  activePatientUuid: activePatientUuid,
51
- activeEncounterUuid:
52
- thisSavedForm?.encounters?.[activePatientUuid] || null,
53
+ activeEncounterUuid: thisSavedForm?.encounters?.[activePatientUuid] || null,
54
+ activeVisitUuid: thisSavedForm?.visits?.[activePatientUuid] || null,
55
+ activeSessionUuid: activeSessionUuid,
53
56
  },
54
57
  },
55
58
  };
@@ -62,13 +65,14 @@ const reducer = (state, action) => {
62
65
  [action.activeFormUuid]: initialFormState,
63
66
  },
64
67
  activeFormUuid: action.activeFormUuid,
68
+ userUuid: action.userUuid,
65
69
  };
66
70
  }
67
71
  persistData(newState);
68
72
  return newState;
69
73
  }
70
74
 
71
- case "SET_GROUP": {
75
+ case 'SET_GROUP': {
72
76
  const newState = {
73
77
  ...state,
74
78
  forms: {
@@ -81,18 +85,19 @@ const reducer = (state, action) => {
81
85
  // this translation is not preferred
82
86
  // the only reason we tollerate it here is beause it should be the only time
83
87
  // we add cohort information to state
84
- action.group.cohortMembers?.map(
85
- (member) => member?.patient?.uuid
86
- ) ?? [],
88
+ action.group.cohortMembers?.map((member) => member?.patient?.uuid) ?? [],
89
+ groupMembers: action.group.cohortMembers?.map((member) => member?.patient?.uuid) ?? [],
87
90
  activePatientUuid: null,
88
91
  activeEncounterUuid: null,
92
+ activeVisitUuid: null,
93
+ activeSessionUuid: null,
89
94
  },
90
95
  },
91
96
  };
92
97
  persistData(newState);
93
98
  return newState;
94
99
  }
95
- case "UNSET_GROUP": {
100
+ case 'UNSET_GROUP': {
96
101
  const newState = {
97
102
  ...state,
98
103
  forms: {
@@ -102,15 +107,18 @@ const reducer = (state, action) => {
102
107
  groupUuid: null,
103
108
  groupName: null,
104
109
  patientUuids: [],
110
+ groupMembers: [],
105
111
  activePatientUuid: null,
106
112
  activeEncounterUuid: null,
113
+ activeVisitUuid: null,
114
+ activeSessionUuid: null,
107
115
  },
108
116
  },
109
117
  };
110
118
  persistData(newState);
111
119
  return newState;
112
120
  }
113
- case "SET_SESSION_META": {
121
+ case 'SET_SESSION_META': {
114
122
  // requires that group is already entered and contains patientUuids
115
123
  const newState = {
116
124
  ...state,
@@ -119,23 +127,54 @@ const reducer = (state, action) => {
119
127
  [state.activeFormUuid]: {
120
128
  ...state.forms[state.activeFormUuid],
121
129
  sessionMeta: action.meta,
122
- activePatientUuid:
123
- state.forms[state.activeFormUuid].patientUuids?.[0],
130
+ activePatientUuid: state.forms[state.activeFormUuid].patientUuids?.[0],
124
131
  activeEncounterUuid:
125
- state.forms[state.activeFormUuid].encounters[
126
- state.forms[state.activeFormUuid].patientUuids?.[0]
127
- ] || null,
128
- workflowState: "EDIT_FORM",
132
+ state.forms[state.activeFormUuid].encounters[state.forms[state.activeFormUuid].patientUuids?.[0]] || null,
133
+ activeVisitUuid:
134
+ state.forms[state.activeFormUuid].visits[state.forms[state.activeFormUuid].patientUuids?.[0]] || null,
135
+ activeSessionUuid: uuid(),
136
+ workflowState: 'EDIT_FORM',
129
137
  },
130
138
  },
131
139
  };
132
140
  persistData(newState);
133
141
  return newState;
134
142
  }
143
+ case 'ADD_PATIENT_UUID': {
144
+ if (state.forms[state.activeFormUuid].patientUuids.includes(action.patientUuid)) {
145
+ return state;
146
+ }
135
147
 
136
- case "SAVE_ENCOUNTER": {
148
+ const newState = {
149
+ ...state,
150
+ forms: {
151
+ ...state.forms,
152
+ [state.activeFormUuid]: {
153
+ ...state.forms[state.activeFormUuid],
154
+ patientUuids: [...state.forms[state.activeFormUuid].patientUuids, action.patientUuid],
155
+ },
156
+ },
157
+ };
158
+ persistData(newState);
159
+ return newState;
160
+ }
161
+ case 'REMOVE_PATIENT_UUID': {
162
+ const newState = {
163
+ ...state,
164
+ forms: {
165
+ ...state.forms,
166
+ [state.activeFormUuid]: {
167
+ ...state.forms[state.activeFormUuid],
168
+ patientUuids: state.forms[state.activeFormUuid].patientUuids?.filter((uuid) => action.patientUuid !== uuid),
169
+ },
170
+ },
171
+ };
172
+ persistData(newState);
173
+ return newState;
174
+ }
175
+ case 'SAVE_ENCOUNTER': {
137
176
  const thisForm = state.forms[state.activeFormUuid];
138
- if (thisForm.workflowState === "SUBMIT_FOR_COMPLETE") {
177
+ if (thisForm.workflowState === 'SUBMIT_FOR_COMPLETE') {
139
178
  const { [state.activeFormUuid]: activeForm, ...formRest } = state.forms;
140
179
  const newState = {
141
180
  ...state,
@@ -144,29 +183,30 @@ const reducer = (state, action) => {
144
183
  };
145
184
  persistData(newState);
146
185
  // eslint-disable-next-line
147
- navigate({ to: "${openmrsSpaBase}/forms" });
186
+ navigate({ to: '${openmrsSpaBase}/forms' });
148
187
  return newState;
149
- } else if (thisForm.workflowState === "SUBMIT_FOR_NEXT") {
150
- const nextPatientUuid =
151
- thisForm.patientUuids[
152
- Math.min(
153
- thisForm.patientUuids.indexOf(thisForm.activePatientUuid) + 1,
154
- thisForm.patientUuids.length - 1
155
- )
156
- ];
188
+ } else if (thisForm.workflowState === 'SUBMIT_FOR_NEXT') {
189
+ const nextPatientUuid = state.nextPatientUuid
190
+ ? state.nextPatientUuid
191
+ : thisForm.patientUuids[
192
+ Math.min(thisForm.patientUuids.indexOf(thisForm.activePatientUuid) + 1, thisForm.patientUuids.length - 1)
193
+ ];
194
+ const encounters = {
195
+ ...thisForm.encounters,
196
+ [thisForm.activePatientUuid]: action.encounterUuid,
197
+ };
157
198
  const newState = {
158
199
  ...state,
159
200
  forms: {
160
201
  ...state.forms,
161
202
  [state.activeFormUuid]: {
162
203
  ...thisForm,
163
- encounters: {
164
- ...thisForm.encounters,
165
- [thisForm.activePatientUuid]: action.encounterUuid,
166
- },
204
+ encounters,
167
205
  activePatientUuid: nextPatientUuid,
168
- activeEncounterUuid: thisForm.encounters[nextPatientUuid] || null,
169
- workflowState: "EDIT_FORM",
206
+ activeEncounterUuid: encounters[nextPatientUuid] || null,
207
+ activeVisitUuid: thisForm.visits[nextPatientUuid] || null,
208
+ activeSessionUuid: thisForm.activeSessionUuid,
209
+ workflowState: 'EDIT_FORM',
170
210
  },
171
211
  },
172
212
  };
@@ -174,33 +214,34 @@ const reducer = (state, action) => {
174
214
  return newState;
175
215
  } else return state;
176
216
  }
177
- case "EDIT_ENCOUNTER": {
217
+ case 'EDIT_ENCOUNTER': {
178
218
  const newState = {
179
219
  ...state,
180
220
  forms: {
181
221
  ...state.forms,
182
222
  [state.activeFormUuid]: {
183
223
  ...state.forms[state.activeFormUuid],
184
- activeEncounterUuid:
185
- state.forms[state.activeFormUuid].encounters[action.patientUuid],
224
+ activeEncounterUuid: state.forms[state.activeFormUuid].encounters[action.patientUuid],
225
+ activeVisitUuid: state.forms[state.activeFormUuid].visits[action.patientUuid],
186
226
  activePatientUuid: action.patientUuid,
187
- workflowState: "EDIT_FORM",
227
+ activeSessionUuid: action.activeSessionUuid,
228
+ workflowState: 'EDIT_FORM',
188
229
  },
189
230
  },
190
231
  };
191
232
  persistData(newState);
192
233
  return newState;
193
234
  }
194
- case "SUBMIT_FOR_NEXT":
235
+ case 'VALIDATE_FOR_NEXT':
195
236
  // this state should not be persisted
196
237
  window.dispatchEvent(
197
- new CustomEvent("ampath-form-action", {
238
+ new CustomEvent('ampath-form-action', {
198
239
  detail: {
199
240
  formUuid: state.activeFormUuid,
200
241
  patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
201
- action: "onSubmit",
242
+ action: 'validateForm',
202
243
  },
203
- })
244
+ }),
204
245
  );
205
246
  return {
206
247
  ...state,
@@ -208,20 +249,60 @@ const reducer = (state, action) => {
208
249
  ...state.forms,
209
250
  [state.activeFormUuid]: {
210
251
  ...state.forms[state.activeFormUuid],
211
- workflowState: "SUBMIT_FOR_NEXT",
252
+ workflowState: 'VALIDATE_FOR_NEXT',
212
253
  },
213
254
  },
214
255
  };
215
- case "SUBMIT_FOR_REVIEW":
256
+ case 'UPDATE_VISIT_UUID':
257
+ // this state should not be persisted
258
+ // we don't pers
259
+ return {
260
+ ...state,
261
+ forms: {
262
+ ...state.forms,
263
+ [state.activeFormUuid]: {
264
+ ...state.forms[state.activeFormUuid],
265
+ visits: {
266
+ ...state.forms[state.activeFormUuid].visits,
267
+ [state.forms[state.activeFormUuid].activePatientUuid]: action.visitUuid,
268
+ },
269
+ activeVisitUuid: action.visitUuid,
270
+ },
271
+ },
272
+ };
273
+
274
+ case 'SUBMIT_FOR_NEXT':
275
+ // this state should not be persisted
276
+ window.dispatchEvent(
277
+ new CustomEvent('ampath-form-action', {
278
+ detail: {
279
+ formUuid: state.activeFormUuid,
280
+ patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
281
+ action: 'onSubmit',
282
+ },
283
+ }),
284
+ );
285
+ return {
286
+ ...state,
287
+ forms: {
288
+ ...state.forms,
289
+ [state.activeFormUuid]: {
290
+ ...state.forms[state.activeFormUuid],
291
+ workflowState: 'SUBMIT_FOR_NEXT',
292
+ },
293
+ },
294
+ nextPatientUuid: action.nextPatientUuid,
295
+ };
296
+ case 'SUBMIT_FOR_REVIEW':
216
297
  // this state should not be persisted
217
298
  window.dispatchEvent(
218
- new CustomEvent("ampath-form-action", {
299
+ new CustomEvent('ampath-form-action', {
219
300
  detail: {
220
301
  formUuid: state.activeFormUuid,
221
302
  patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
222
- action: "onSubmit",
303
+ action: 'onSubmit',
223
304
  },
224
- })
305
+ }),
225
306
  );
226
307
  return {
227
308
  ...state,
@@ -229,20 +310,42 @@ const reducer = (state, action) => {
229
310
  ...state.forms,
230
311
  [state.activeFormUuid]: {
231
312
  ...state.forms[state.activeFormUuid],
232
- workflowState: "SUBMIT_FOR_REVIEW",
313
+ workflowState: 'SUBMIT_FOR_REVIEW',
233
314
  },
234
315
  },
235
316
  };
236
- case "SUBMIT_FOR_COMPLETE":
317
+
318
+ case 'VALIDATE_FOR_COMPLETE':
319
+ // this state should not be persisted
320
+ window.dispatchEvent(
321
+ new CustomEvent('ampath-form-action', {
322
+ detail: {
323
+ formUuid: state.activeFormUuid,
324
+ patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
325
+ action: 'validateForm',
326
+ },
327
+ }),
328
+ );
329
+ return {
330
+ ...state,
331
+ forms: {
332
+ ...state.forms,
333
+ [state.activeFormUuid]: {
334
+ ...state.forms[state.activeFormUuid],
335
+ workflowState: 'VALIDATE_FOR_COMPLETE',
336
+ },
337
+ },
338
+ };
339
+ case 'SUBMIT_FOR_COMPLETE':
237
340
  // this state should not be persisted
238
341
  window.dispatchEvent(
239
- new CustomEvent("ampath-form-action", {
342
+ new CustomEvent('ampath-form-action', {
240
343
  detail: {
241
344
  formUuid: state.activeFormUuid,
242
345
  patientUuid: state.forms[state.activeFormUuid].activePatientUuid,
243
- action: "onSubmit",
346
+ action: 'onSubmit',
244
347
  },
245
- })
348
+ }),
246
349
  );
247
350
  return {
248
351
  ...state,
@@ -250,11 +353,11 @@ const reducer = (state, action) => {
250
353
  ...state.forms,
251
354
  [state.activeFormUuid]: {
252
355
  ...state.forms[state.activeFormUuid],
253
- workflowState: "SUBMIT_FOR_COMPLETE",
356
+ workflowState: 'SUBMIT_FOR_COMPLETE',
254
357
  },
255
358
  },
256
359
  };
257
- case "GO_TO_REVIEW": {
360
+ case 'GO_TO_REVIEW': {
258
361
  const newState = {
259
362
  ...state,
260
363
  forms: {
@@ -262,15 +365,17 @@ const reducer = (state, action) => {
262
365
  [state.activeFormUuid]: {
263
366
  ...state.forms[state.activeFormUuid],
264
367
  activeEncounterUuid: null,
368
+ activVisitUuid: null,
265
369
  activePatientUuid: null,
266
- workflowState: "REVIEW",
370
+ activeSessionUuid: null,
371
+ workflowState: 'REVIEW',
267
372
  },
268
373
  },
269
374
  };
270
375
  persistData(newState);
271
376
  return newState;
272
377
  }
273
- case "DESTROY_SESSION": {
378
+ case 'DESTROY_SESSION': {
274
379
  const { [state.activeFormUuid]: activeForm, ...formRest } = state.forms;
275
380
  const newState = {
276
381
  ...state,
@@ -278,14 +383,18 @@ const reducer = (state, action) => {
278
383
  activeFormUuid: null,
279
384
  };
280
385
  persistData(newState);
281
- return newState;
386
+ //eslint-disable-next-line
387
+ navigate({ to: '${openmrsSpaBase}/forms' });
388
+ return { ...newState, formDestroyed: true };
282
389
  }
283
- case "CLOSE_SESSION": {
390
+ case 'CLOSE_SESSION': {
284
391
  const newState = {
285
392
  ...state,
286
393
  activeFormUuid: null,
287
394
  };
288
395
  persistData(newState);
396
+ //eslint-disable-next-line
397
+ navigate({ to: '${openmrsSpaBase}/forms' });
289
398
  return newState;
290
399
  }
291
400
  default:
@@ -0,0 +1,4 @@
1
+ declare module '@carbon/react';
2
+ declare module '*.css';
3
+ declare module '*.scss';
4
+ declare type SideNavProps = object;
@@ -1,6 +1,6 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
 
3
- export const EmptyDataIllustration = ({ width = "64", height = "64" }) => {
3
+ export const EmptyDataIllustration = ({ width = '64', height = '64' }) => {
4
4
  return (
5
5
  <svg width={width} height={height} viewBox="0 0 64 64">
6
6
  <title>Empty data illustration</title>
@@ -18,13 +18,7 @@ export const EmptyDataIllustration = ({ width = "64", height = "64" }) => {
18
18
  fill="#C6C6C6"
19
19
  />
20
20
  <circle fill="#C6C6C6" cx={17.636} cy={2.314} r={1.855} />
21
- <circle
22
- fill="#FFF"
23
- fillRule="nonzero"
24
- cx={17.636}
25
- cy={2.314}
26
- r={1.175}
27
- />
21
+ <circle fill="#FFF" fillRule="nonzero" cx={17.636} cy={2.314} r={1.175} />
28
22
  <path
29
23
  d="M55.893 53.995H24.544a.79.79 0 01-.788-.789V15.644a.79.79 0 01.788-.788h31.349a.79.79 0 01.788.788v37.562a.79.79 0 01-.788.789z"
30
24
  fill="#F4F4F4"
@@ -38,13 +32,7 @@ export const EmptyDataIllustration = ({ width = "64", height = "64" }) => {
38
32
  fill="#C6C6C6"
39
33
  />
40
34
  <circle fill="#C6C6C6" cx={40.218} cy={9.755} r={1.855} />
41
- <circle
42
- fill="#FFF"
43
- fillRule="nonzero"
44
- cx={40.218}
45
- cy={9.755}
46
- r={1.13}
47
- />
35
+ <circle fill="#FFF" fillRule="nonzero" cx={40.218} cy={9.755} r={1.13} />
48
36
  </g>
49
37
  </svg>
50
38
  );
@@ -1,25 +1,20 @@
1
- import React from "react";
2
- import { Tile, Layer } from "@carbon/react";
3
- import styles from "./styles.scss";
4
- import { useLayoutType } from "@openmrs/esm-framework";
5
- import { EmptyDataIllustration } from "./EmptyDataIllustration";
1
+ import React from 'react';
2
+ import { Tile, Layer } from '@carbon/react';
3
+ import styles from './styles.scss';
4
+ import { useLayoutType } from '@openmrs/esm-framework';
5
+ import { EmptyDataIllustration } from './EmptyDataIllustration';
6
6
 
7
7
  export interface EmptyStateProps {
8
8
  headerTitle: string;
9
9
  displayText: string;
10
10
  }
11
- const EmptyState: React.FC<EmptyStateProps> = ({
12
- headerTitle,
13
- displayText,
14
- }) => {
15
- const isTablet = useLayoutType() === "tablet";
11
+ const EmptyState: React.FC<EmptyStateProps> = ({ headerTitle, displayText }) => {
12
+ const isTablet = useLayoutType() === 'tablet';
16
13
 
17
14
  return (
18
15
  <Layer>
19
16
  <Tile className={styles.tile}>
20
- <div
21
- className={isTablet ? styles.tabletHeading : styles.desktopHeading}
22
- >
17
+ <div className={isTablet ? styles.tabletHeading : styles.desktopHeading}>
23
18
  <h4>{headerTitle}</h4>
24
19
  </div>
25
20
  <EmptyDataIllustration />
@@ -1,36 +1,36 @@
1
- @import "~@openmrs/esm-styleguide/src/vars";
2
- @import "~carbon-components/src/globals/scss/vars";
3
- @import "~carbon-components/src/globals/scss/mixins";
1
+ @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
4
4
 
5
5
  .action {
6
- margin-bottom: $spacing-03;
6
+ margin-bottom: layout.$spacing-03;
7
7
  }
8
8
 
9
9
  .content {
10
- @include carbon--type-style("productive-heading-01");
11
- color: $text-02;
12
- margin-top: $spacing-05;
13
- margin-bottom: $spacing-03;
10
+ @include type.type-style("heading-compact-01");
11
+ color: colors.$gray-70;
12
+ margin-top: layout.$spacing-05;
13
+ margin-bottom: layout.$spacing-03;
14
14
  }
15
15
 
16
16
  .desktopHeading {
17
17
  h4 {
18
- @include carbon--type-style('productive-heading-02');
19
- color: $text-02;
18
+ @include type.type-style('heading-compact-02');
19
+ color: colors.$gray-70;
20
20
  }
21
21
  }
22
22
 
23
23
  .tabletHeading {
24
24
  h4 {
25
- @include carbon--type-style('productive-heading-03');
26
- color: $text-02;
25
+ @include type.type-style('heading-03');
26
+ color: colors.$gray-70;
27
27
  }
28
28
  }
29
29
 
30
30
  .desktopHeading, .tabletHeading {
31
31
  text-align: left;
32
32
  text-transform: capitalize;
33
- margin-bottom: $spacing-05;
33
+ margin-bottom: layout.$spacing-05;
34
34
 
35
35
  h4:after {
36
36
  content: "";
@@ -51,5 +51,5 @@
51
51
 
52
52
  .tile {
53
53
  text-align: center;
54
- border: 1px solid $ui-03;
54
+ border: 1px solid colors.$gray-20;
55
55
  }