@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.
Files changed (98) hide show
  1. package/__mocks__/react-i18next.js +9 -14
  2. package/dist/101.js +1 -1
  3. package/dist/101.js.map +1 -1
  4. package/dist/188.js.map +1 -1
  5. package/dist/219.js.map +1 -1
  6. package/dist/29.js +1 -1
  7. package/dist/29.js.map +1 -1
  8. package/dist/326.js.map +1 -1
  9. package/dist/564.js +1 -1
  10. package/dist/564.js.map +1 -1
  11. package/dist/893.js +1 -0
  12. package/dist/893.js.map +1 -0
  13. package/dist/91.js +1 -1
  14. package/dist/91.js.map +1 -1
  15. package/dist/941.js +2 -0
  16. package/dist/941.js.map +1 -0
  17. package/dist/99.js.map +1 -1
  18. package/dist/991.js +1 -0
  19. package/dist/991.js.map +1 -0
  20. package/dist/main.js +1 -1
  21. package/dist/main.js.map +1 -1
  22. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  23. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +105 -105
  24. package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -1
  25. package/dist/routes.json +1 -1
  26. package/package.json +2 -4
  27. package/prettier.config.js +8 -0
  28. package/src/CancelModal.tsx +9 -15
  29. package/src/CompleteModal.tsx +7 -18
  30. package/src/FormBootstrap.tsx +9 -9
  31. package/src/Root.tsx +7 -12
  32. package/src/add-group-modal/AddGroupModal.tsx +46 -109
  33. package/src/config-schema.ts +35 -36
  34. package/src/constant.ts +1 -1
  35. package/src/context/FormWorkflowContext.tsx +26 -39
  36. package/src/context/FormWorkflowReducer.ts +50 -74
  37. package/src/context/GroupFormWorkflowContext.tsx +36 -61
  38. package/src/context/GroupFormWorkflowReducer.ts +69 -105
  39. package/src/declarations.d.ts +3 -3
  40. package/src/empty-state/EmptyDataIllustration.tsx +4 -16
  41. package/src/empty-state/EmptyState.tsx +8 -13
  42. package/src/form-entry-workflow/FormEntryWorkflow.tsx +26 -44
  43. package/src/form-entry-workflow/form-review-card/FormReviewCard.tsx +7 -7
  44. package/src/form-entry-workflow/form-review-card/index.ts +1 -1
  45. package/src/form-entry-workflow/index.ts +1 -1
  46. package/src/form-entry-workflow/patient-banner/PatientBanner.test.tsx +5 -5
  47. package/src/form-entry-workflow/patient-banner/PatientBanner.tsx +14 -27
  48. package/src/form-entry-workflow/patient-banner/index.ts +1 -1
  49. package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +17 -26
  50. package/src/form-entry-workflow/patient-search-header/index.ts +1 -1
  51. package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +12 -12
  52. package/src/form-entry-workflow/workflow-review/index.ts +1 -1
  53. package/src/forms-app-menu-link.tsx +4 -6
  54. package/src/forms-page/FormsPage.tsx +22 -50
  55. package/src/forms-page/forms-table/FormsTable.tsx +22 -42
  56. package/src/forms-page/forms-table/index.ts +1 -1
  57. package/src/forms-page/index.ts +1 -1
  58. package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +8 -8
  59. package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +27 -58
  60. package/src/group-form-entry-workflow/SessionDetailsForm.tsx +43 -66
  61. package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +20 -28
  62. package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +13 -27
  63. package/src/group-form-entry-workflow/attendance-table/index.ts +1 -1
  64. package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +6 -12
  65. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.test.tsx +5 -5
  66. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +13 -21
  67. package/src/group-form-entry-workflow/group-display-header/index.ts +1 -1
  68. package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +24 -35
  69. package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +13 -15
  70. package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +22 -38
  71. package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +18 -25
  72. package/src/group-form-entry-workflow/group-search-header/index.ts +1 -1
  73. package/src/group-form-entry-workflow/index.ts +1 -1
  74. package/src/hooks/index.ts +7 -13
  75. package/src/hooks/useForm.ts +13 -30
  76. package/src/hooks/useFormState.ts +3 -3
  77. package/src/hooks/useGetAllForms.ts +5 -14
  78. package/src/hooks/useGetEncounter.ts +2 -2
  79. package/src/hooks/useGetPatient.ts +2 -2
  80. package/src/hooks/useGetPatients.ts +4 -6
  81. package/src/hooks/useGetSystemSetting.ts +3 -5
  82. package/src/hooks/useKeyPress.ts +5 -5
  83. package/src/hooks/usePostEndpoint.ts +8 -8
  84. package/src/hooks/useSearchEndpoint.ts +15 -38
  85. package/src/hooks/useStartVisit.ts +16 -27
  86. package/src/index.ts +8 -20
  87. package/src/patient-card/PatientCard.tsx +8 -20
  88. package/src/patient-card/index.ts +1 -1
  89. package/src/setup-tests.ts +1 -1
  90. package/tools/i18next-parser.config.js +19 -19
  91. package/webpack.config.js +1 -1
  92. package/dist/143.js +0 -1
  93. package/dist/143.js.map +0 -1
  94. package/dist/31.js +0 -2
  95. package/dist/31.js.map +0 -1
  96. package/dist/491.js +0 -1
  97. package/dist/491.js.map +0 -1
  98. /package/dist/{31.js.LICENSE.txt → 941.js.LICENSE.txt} +0 -0
@@ -1,54 +1,27 @@
1
- import React, {
2
- useCallback,
3
- useContext,
4
- useEffect,
5
- useMemo,
6
- useState,
7
- } from "react";
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("remove", "Remove")}
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: "flex",
89
- flexDirection: "column",
90
- rowGap: "1rem",
53
+ display: 'flex',
54
+ flexDirection: 'column',
55
+ rowGap: '1rem',
91
56
  }}
92
57
  >
93
58
  <TextInput
94
- labelText={t("newGroupName", "New Group Name")}
59
+ labelText={t('newGroupName', 'New Group Name')}
95
60
  value={name}
96
61
  onChange={(e) => setName(e.target.value)}
97
- onBlur={() => validate("name")}
62
+ onBlur={() => validate('name')}
98
63
  />
99
64
  {errors?.name && (
100
65
  <p className={styles.formError}>
101
- {errors.name === "required"
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("patientsInGroup", "Patients in group")}
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: "secondary",
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
- patientList.filter((patient) => patient.uuid !== patientUuid)
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 === "name" ? !!name : !!patientList.length;
126
+ valid = field === 'name' ? !!name : !!patientList.length;
177
127
  setErrors((errors) => ({
178
128
  ...errors,
179
- [field]: valid ? null : "required",
129
+ [field]: valid ? null : 'required',
180
130
  }));
181
131
  } else {
182
132
  if (!name) {
183
- setErrors((errors) => ({ ...errors, name: "required" }));
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: "required" }));
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: "base",
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: "error",
260
- title: t("postError", "POST Error"),
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("cancel", "Cancel")}
238
+ {t('cancel', 'Cancel')}
302
239
  </Button>
303
240
  <Button kind="primary" onClick={handleSubmit}>
304
- {isCreate ? t("createGroup", "Create Group") : t("save", "Save")}
241
+ {isCreate ? t('createGroup', 'Create Group') : t('save', 'Save')}
305
242
  </Button>
306
243
  </ModalFooter>
307
244
  </ComposedModal>
@@ -1,4 +1,4 @@
1
- import { Type } from "@openmrs/esm-framework";
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: "Category name",
15
+ _description: 'Category name',
17
16
  },
18
17
  forms: {
19
18
  _type: Type.Array,
20
- _description: "List of forms for this category.",
19
+ _description: 'List of forms for this category.',
21
20
  _elements: {
22
21
  formUUID: {
23
22
  _type: Type.UUID,
24
- _description: "UUID of form",
23
+ _description: 'UUID of form',
25
24
  },
26
25
  name: {
27
26
  _type: Type.String,
28
- _description: "Name of form",
27
+ _description: 'Name of form',
29
28
  },
30
29
  },
31
30
  },
32
31
  },
33
32
  _default: [
34
33
  {
35
- name: "ICRC Forms",
34
+ name: 'ICRC Forms',
36
35
  forms: [
37
36
  {
38
- formUUID: "0cefb866-110c-4f16-af58-560932a1db1f",
39
- name: "Adult Triage",
37
+ formUUID: '0cefb866-110c-4f16-af58-560932a1db1f',
38
+ name: 'Adult Triage',
40
39
  },
41
40
  ],
42
41
  },
43
42
  {
44
- name: "Distress Scales",
43
+ name: 'Distress Scales',
45
44
  forms: [
46
45
  {
47
- formUUID: "9f26aad4-244a-46ca-be49-1196df1a8c9a",
48
- name: "POC Sample Form 1",
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: "Forms to show by default on the forms app home page.",
55
+ _description: 'Forms to show by default on the forms app home page.',
57
56
  _elements: {
58
57
  _type: Type.String,
59
- _description: "Name of category",
58
+ _description: 'Name of category',
60
59
  },
61
- _default: ["ICRC Forms", "Distress Scales"],
60
+ _default: ['ICRC Forms', 'Distress Scales'],
62
61
  },
63
62
  groupSessionConcepts: {
64
63
  sessionName: {
65
64
  _type: Type.UUID,
66
- _description: "UUID of concept for Session Name",
67
- _default: "e2559620-900b-4f66-ae41-0b9c4adfb654",
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: "UUID of concept for Session Date",
72
- _default: "ceaca505-6dff-4940-8a43-8c060a0924d7",
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: "UUID of concept for Practitioner Name",
77
- _default: "f1a2d58c-1a0e-4148-931a-aac224649fdc",
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: "UUID of concept for Session Notes",
82
- _default: "fa8fedc0-c066-4da3-8dc1-2ad8621fc480",
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: "UUID of cohort type",
87
- _default: "eee9970e-7ca0-4e8c-a280-c33e9d5f6a04",
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: "UUID of concept for cohort identifier",
92
- _default: "5461f231-7e59-4be8-93a4-6d49fd13c00a",
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: "UUID of concept for cohort name",
97
- _default: "6029f289-92a6-4a68-80f1-3078d0152449",
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: "UUID of concept for session identifier",
102
- _default: "6a803908-8a5b-4598-adea-19358c83529a",
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: "List of specific questions to populate forms.",
106
+ _description: 'List of specific questions to populate forms.',
108
107
  _elements: {
109
108
  forms: {
110
109
  _type: Type.Array,
111
- _description: "List of form UUIDs for which the question applies.",
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: "ID of the question.",
120
- _default: "",
118
+ _description: 'ID of the question.',
119
+ _default: '',
121
120
  },
122
121
  },
123
122
  _default: [],
package/src/constant.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const routes = {
2
- allForms: "all-forms",
2
+ allForms: 'all-forms',
3
3
  };
4
4
 
5
5
  export const spaBase = window.spaBase;
@@ -1,8 +1,8 @@
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";
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("&")[0];
47
+ const activeFormUuid = formUuid.split('&')[0];
48
48
  const { search } = useLocation();
49
- const newPatientUuid = new URLSearchParams(search).get("patientUuid");
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
- "@openmrs/esm-fast-data-entry-app.groupSessionVisitTypeUuid"
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: "INITIALIZE_WORKFLOW_STATE",
61
+ type: 'INITIALIZE_WORKFLOW_STATE',
65
62
  activeFormUuid,
66
63
  newPatientUuid,
67
64
  userUuid: user.uuid,
68
65
  }),
69
- addPatient: (patientUuid) =>
70
- dispatch({ type: "ADD_PATIENT", patientUuid }),
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: "SAVE_ENCOUNTER",
70
+ type: 'SAVE_ENCOUNTER',
75
71
  encounterUuid,
76
72
  }),
77
- submitForNext: () => dispatch({ type: "SUBMIT_FOR_NEXT" }),
78
- submitForReview: () => dispatch({ type: "SUBMIT_FOR_REVIEW" }),
79
- submitForComplete: () => dispatch({ type: "SUBMIT_FOR_COMPLETE" }),
80
- editEncounter: (patientUuid) =>
81
- dispatch({ type: "EDIT_ENCOUNTER", patientUuid }),
82
- goToReview: () => dispatch({ type: "GO_TO_REVIEW" }),
83
- destroySession: () => dispatch({ type: "DESTROY_SESSION" }),
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
- initialWorkflowState.activeEncounterUuid,
111
- patientUuids:
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
  >