@openmrs/esm-fast-data-entry-app 1.0.1-pre.8 → 1.0.1-pre.85
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/README.md +21 -2
- package/dist/132.js +1 -0
- package/dist/168.js +1 -0
- package/dist/229.js +1 -0
- package/dist/247.js +1 -0
- package/dist/255.js +1 -0
- package/dist/294.js +2 -0
- package/dist/294.js.LICENSE.txt +9 -0
- package/dist/32.js +1 -0
- package/dist/327.js +1 -0
- package/dist/403.js +2 -0
- package/dist/403.js.LICENSE.txt +14 -0
- package/dist/553.js +2 -0
- package/dist/553.js.LICENSE.txt +14 -0
- package/dist/574.js +1 -0
- package/dist/595.js +2 -0
- package/dist/595.js.LICENSE.txt +3 -0
- package/dist/617.js +1 -0
- package/dist/658.js +2 -0
- package/dist/658.js.LICENSE.txt +27 -0
- package/dist/68.js +2 -0
- package/dist/68.js.LICENSE.txt +21 -0
- package/dist/74.js +1 -0
- package/dist/757.js +1 -0
- package/dist/776.js +1 -0
- package/dist/804.js +1 -0
- package/dist/820.js +1 -0
- package/dist/935.js +2 -0
- package/dist/935.js.LICENSE.txt +19 -0
- package/dist/main.js +1 -0
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +612 -0
- package/dist/openmrs-esm-fast-data-entry-app.old +1 -0
- package/jest.config.json +2 -1
- package/package.json +9 -9
- package/src/CancelModal.tsx +48 -0
- package/src/CompleteModal.tsx +46 -0
- package/src/FormBootstrap.tsx +18 -3
- package/src/add-group-modal/AddGroupModal.tsx +80 -27
- package/src/add-group-modal/styles.scss +14 -4
- package/src/config-schema.ts +22 -0
- package/src/context/FormWorkflowContext.tsx +13 -1
- package/src/context/FormWorkflowReducer.ts +13 -3
- package/src/context/GroupFormWorkflowContext.tsx +41 -6
- package/src/context/GroupFormWorkflowReducer.ts +170 -12
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +67 -101
- package/src/form-entry-workflow/styles.scss +2 -1
- package/src/forms-page/FormsPage.tsx +8 -3
- package/src/forms-page/forms-table/FormsTable.tsx +11 -5
- package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +13 -400
- package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +247 -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-banner/GroupBanner.test.tsx → group-display-header/GroupDisplayHeader.test.tsx} +2 -2
- package/src/group-form-entry-workflow/{group-banner/GroupBanner.tsx → group-display-header/GroupDisplayHeader.tsx} +23 -5
- package/src/group-form-entry-workflow/group-display-header/index.ts +3 -0
- package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +61 -28
- package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +5 -0
- package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +65 -8
- package/src/group-form-entry-workflow/group-search/group-search.scss +8 -6
- package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +11 -7
- package/src/group-form-entry-workflow/styles.scss +12 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useGetPatient.ts +1 -1
- package/src/hooks/useGetSystemSetting.ts +38 -0
- package/src/hooks/usePostEndpoint.ts +70 -0
- package/src/hooks/useSearchEndpoint.ts +120 -0
- package/src/hooks/useStartVisit.ts +92 -0
- package/src/patient-card/styles.scss +1 -0
- package/tools/i18next-parser.config.js +93 -0
- package/translations/en.json +27 -9
- package/translations/fr.json +50 -0
- package/.editorconfig +0 -12
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -10
- package/.husky/pre-push +0 -1
- package/.prettierignore +0 -14
- package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
- package/.yarn/versions/7ee3eceb.yml +0 -0
- package/src/group-form-entry-workflow/group-banner/index.ts +0 -3
- package/src/group-form-entry-workflow/group-search/mock-group-data.ts +0 -79
- package/src/group-form-entry-workflow/group-search/useGroupSearch.ts +0 -14
- package/src/hooks/usePostCohort.ts +0 -18
- /package/src/group-form-entry-workflow/{group-banner → group-display-header}/styles.scss +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getGlobalStore,
|
|
3
|
+
useConfig,
|
|
4
|
+
useSession,
|
|
5
|
+
useStore,
|
|
6
|
+
} from "@openmrs/esm-framework";
|
|
7
|
+
import { Button } from "@carbon/react";
|
|
8
|
+
import React, { useCallback, useContext, useEffect, useState } from "react";
|
|
9
|
+
import PatientCard from "../patient-card/PatientCard";
|
|
10
|
+
import styles from "./styles.scss";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
12
|
+
import GroupFormWorkflowContext from "../context/GroupFormWorkflowContext";
|
|
13
|
+
import FormBootstrap from "../FormBootstrap";
|
|
14
|
+
import useStartVisit from "../hooks/useStartVisit";
|
|
15
|
+
import CompleteModal from "../CompleteModal";
|
|
16
|
+
import CancelModal from "../CancelModal";
|
|
17
|
+
|
|
18
|
+
const formStore = getGlobalStore("ampath-form-state");
|
|
19
|
+
|
|
20
|
+
const WorkflowNavigationButtons = () => {
|
|
21
|
+
const context = useContext(GroupFormWorkflowContext);
|
|
22
|
+
const {
|
|
23
|
+
activeFormUuid,
|
|
24
|
+
submitForNext,
|
|
25
|
+
patientUuids,
|
|
26
|
+
activePatientUuid,
|
|
27
|
+
workflowState,
|
|
28
|
+
} = context;
|
|
29
|
+
const store = useStore(formStore);
|
|
30
|
+
const formState = store[activeFormUuid];
|
|
31
|
+
const navigationDisabled =
|
|
32
|
+
(formState !== "ready" || workflowState !== "EDIT_FORM") &&
|
|
33
|
+
formState !== "readyWithValidationErrors";
|
|
34
|
+
const [cancelModalOpen, setCancelModalOpen] = useState(false);
|
|
35
|
+
const [completeModalOpen, setCompleteModalOpen] = useState(false);
|
|
36
|
+
const { t } = useTranslation();
|
|
37
|
+
|
|
38
|
+
const isLastPatient =
|
|
39
|
+
activePatientUuid === patientUuids[patientUuids.length - 1];
|
|
40
|
+
|
|
41
|
+
const handleClickNext = () => {
|
|
42
|
+
if (
|
|
43
|
+
workflowState === "EDIT_FORM" ||
|
|
44
|
+
formState === "readyWithValidationErrors"
|
|
45
|
+
) {
|
|
46
|
+
submitForNext();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<div className={styles.rightPanelActionButtons}>
|
|
53
|
+
<Button
|
|
54
|
+
kind="primary"
|
|
55
|
+
onClick={handleClickNext}
|
|
56
|
+
disabled={navigationDisabled}
|
|
57
|
+
>
|
|
58
|
+
{isLastPatient
|
|
59
|
+
? t("saveForm", "Save Form")
|
|
60
|
+
: t("nextPatient", "Next Patient")}
|
|
61
|
+
</Button>
|
|
62
|
+
<Button kind="secondary" onClick={() => setCompleteModalOpen(true)}>
|
|
63
|
+
{t("saveAndComplete", "Save & Complete")}
|
|
64
|
+
</Button>
|
|
65
|
+
<Button kind="tertiary" onClick={() => setCancelModalOpen(true)}>
|
|
66
|
+
{t("cancel", "Cancel")}
|
|
67
|
+
</Button>
|
|
68
|
+
</div>
|
|
69
|
+
<CancelModal
|
|
70
|
+
open={cancelModalOpen}
|
|
71
|
+
setOpen={setCancelModalOpen}
|
|
72
|
+
context={context}
|
|
73
|
+
/>
|
|
74
|
+
<CompleteModal
|
|
75
|
+
open={completeModalOpen}
|
|
76
|
+
setOpen={setCompleteModalOpen}
|
|
77
|
+
context={context}
|
|
78
|
+
validateFirst={false}
|
|
79
|
+
/>
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const GroupSessionWorkspace = () => {
|
|
85
|
+
const { groupSessionConcepts } = useConfig();
|
|
86
|
+
const { t } = useTranslation();
|
|
87
|
+
const {
|
|
88
|
+
patientUuids,
|
|
89
|
+
activePatientUuid,
|
|
90
|
+
encounters,
|
|
91
|
+
activeEncounterUuid,
|
|
92
|
+
activeVisitUuid,
|
|
93
|
+
activeFormUuid,
|
|
94
|
+
saveEncounter,
|
|
95
|
+
activeSessionMeta,
|
|
96
|
+
groupVisitTypeUuid,
|
|
97
|
+
updateVisitUuid,
|
|
98
|
+
submitForNext,
|
|
99
|
+
workflowState,
|
|
100
|
+
} = useContext(GroupFormWorkflowContext);
|
|
101
|
+
|
|
102
|
+
const { sessionLocation } = useSession();
|
|
103
|
+
const [encounter, setEncounter] = useState(null);
|
|
104
|
+
const [visit, setVisit] = useState(null);
|
|
105
|
+
|
|
106
|
+
const {
|
|
107
|
+
saveVisit,
|
|
108
|
+
updateEncounter,
|
|
109
|
+
success: visitSaveSuccess,
|
|
110
|
+
} = useStartVisit({
|
|
111
|
+
showSuccessNotification: false,
|
|
112
|
+
showErrorNotification: true,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// 0. user clicks "next patient" in WorkflowNavigationButtons
|
|
116
|
+
// which triggers submitForNext() if workflowState === "EDIT_FORM"
|
|
117
|
+
|
|
118
|
+
// 1. save the new visit uuid and start form submission
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (
|
|
121
|
+
visitSaveSuccess &&
|
|
122
|
+
visitSaveSuccess.data.patient.uuid === activePatientUuid
|
|
123
|
+
) {
|
|
124
|
+
setVisit(visitSaveSuccess.data);
|
|
125
|
+
// Update visit UUID on workflow
|
|
126
|
+
updateVisitUuid(visitSaveSuccess.data.uuid);
|
|
127
|
+
}
|
|
128
|
+
}, [
|
|
129
|
+
visitSaveSuccess,
|
|
130
|
+
updateVisitUuid,
|
|
131
|
+
activeVisitUuid,
|
|
132
|
+
activePatientUuid,
|
|
133
|
+
visit,
|
|
134
|
+
setVisit,
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
// 2. If there's no active visit, trigger the creation of a new one
|
|
138
|
+
const handleEncounterCreate = useCallback(
|
|
139
|
+
(payload) => {
|
|
140
|
+
// Create a visit with the same date as the encounter being saved
|
|
141
|
+
if (!activeVisitUuid) {
|
|
142
|
+
saveVisit({
|
|
143
|
+
patientUuid: activePatientUuid,
|
|
144
|
+
startDatetime: activeSessionMeta.sessionDate,
|
|
145
|
+
stopDatetime: activeSessionMeta.sessionDate,
|
|
146
|
+
visitType: groupVisitTypeUuid,
|
|
147
|
+
location: sessionLocation?.uuid,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const obsTime = new Date(activeSessionMeta.sessionDate);
|
|
151
|
+
payload.obs.forEach((item, index) => {
|
|
152
|
+
payload.obs[index] = {
|
|
153
|
+
...item,
|
|
154
|
+
groupMembers: item.groupMembers?.map((mem) => ({
|
|
155
|
+
...mem,
|
|
156
|
+
obsDatetime: obsTime.toISOString(),
|
|
157
|
+
})),
|
|
158
|
+
obsDatetime: obsTime.toISOString(),
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
// If this is a newly created encounter and visit, add session concepts to encounter payload.
|
|
162
|
+
if (!activeVisitUuid) {
|
|
163
|
+
Object.entries(groupSessionConcepts).forEach(([field, uuid]) => {
|
|
164
|
+
payload.obs.push({
|
|
165
|
+
concept: uuid,
|
|
166
|
+
value: activeSessionMeta?.[field],
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
payload.location = sessionLocation?.uuid;
|
|
171
|
+
payload.encounterDatetime = obsTime.toISOString();
|
|
172
|
+
},
|
|
173
|
+
[
|
|
174
|
+
activePatientUuid,
|
|
175
|
+
activeVisitUuid,
|
|
176
|
+
activeSessionMeta,
|
|
177
|
+
groupSessionConcepts,
|
|
178
|
+
groupVisitTypeUuid,
|
|
179
|
+
saveVisit,
|
|
180
|
+
sessionLocation,
|
|
181
|
+
]
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// 3. Update encounter so that it belongs to the created visit
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (encounter && visit && encounter.patient?.uuid === visit.patient?.uuid) {
|
|
187
|
+
updateEncounter({ uuid: encounter.uuid, visit: visit.uuid });
|
|
188
|
+
}
|
|
189
|
+
}, [encounter, updateEncounter, visit]);
|
|
190
|
+
|
|
191
|
+
// 4. Once form has been posted, save the new encounter uuid so we can edit it later
|
|
192
|
+
const handlePostResponse = useCallback(
|
|
193
|
+
(encounter) => {
|
|
194
|
+
if (encounter && encounter.uuid) {
|
|
195
|
+
saveEncounter(encounter.uuid);
|
|
196
|
+
setEncounter(encounter);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
[saveEncounter]
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const switchPatient = useCallback(
|
|
203
|
+
(patientUuid) => {
|
|
204
|
+
submitForNext(patientUuid);
|
|
205
|
+
},
|
|
206
|
+
[submitForNext]
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
if (workflowState === "NEW_GROUP_SESSION") return null;
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<div className={styles.workspace}>
|
|
213
|
+
<div className={styles.formMainContent}>
|
|
214
|
+
<div className={styles.formContainer}>
|
|
215
|
+
<FormBootstrap
|
|
216
|
+
patientUuid={activePatientUuid}
|
|
217
|
+
encounterUuid={activeEncounterUuid}
|
|
218
|
+
{...{
|
|
219
|
+
formUuid: activeFormUuid,
|
|
220
|
+
handlePostResponse,
|
|
221
|
+
handleEncounterCreate,
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
<div className={styles.rightPanel}>
|
|
226
|
+
<h4>{t("formsFilled", "Forms filled")}</h4>
|
|
227
|
+
<div className={styles.patientCardsSection}>
|
|
228
|
+
{patientUuids?.map((patientUuid) => (
|
|
229
|
+
<PatientCard
|
|
230
|
+
key={patientUuid}
|
|
231
|
+
{...{
|
|
232
|
+
patientUuid,
|
|
233
|
+
activePatientUuid,
|
|
234
|
+
editEncounter: switchPatient,
|
|
235
|
+
encounters,
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
238
|
+
))}
|
|
239
|
+
</div>
|
|
240
|
+
<WorkflowNavigationButtons />
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export default GroupSessionWorkspace;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Layer,
|
|
3
|
+
Tile,
|
|
4
|
+
TextInput,
|
|
5
|
+
TextArea,
|
|
6
|
+
DatePicker,
|
|
7
|
+
DatePickerInput,
|
|
8
|
+
} from "@carbon/react";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import styles from "./styles.scss";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
12
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
13
|
+
import { AttendanceTable } from "./attendance-table";
|
|
14
|
+
|
|
15
|
+
const SessionDetailsForm = () => {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const {
|
|
18
|
+
register,
|
|
19
|
+
formState: { errors },
|
|
20
|
+
control,
|
|
21
|
+
} = useFormContext();
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className={styles.formSection}>
|
|
25
|
+
<h4>{t("sessionDetails", "1. Session details")}</h4>
|
|
26
|
+
<div>
|
|
27
|
+
<p>
|
|
28
|
+
{t(
|
|
29
|
+
"allFieldsRequired",
|
|
30
|
+
"All fields are required unless marked optional"
|
|
31
|
+
)}
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
<Layer>
|
|
35
|
+
<Tile className={styles.formSectionTile}>
|
|
36
|
+
<Layer>
|
|
37
|
+
<div
|
|
38
|
+
style={{
|
|
39
|
+
display: "flex",
|
|
40
|
+
flexDirection: "column",
|
|
41
|
+
rowGap: "1.5rem",
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<TextInput
|
|
45
|
+
id="text"
|
|
46
|
+
type="text"
|
|
47
|
+
labelText={t("sessionName", "Session Name")}
|
|
48
|
+
{...register("sessionName", { required: true })}
|
|
49
|
+
invalid={errors.sessionName}
|
|
50
|
+
invalidText={"This field is required"}
|
|
51
|
+
/>
|
|
52
|
+
<TextInput
|
|
53
|
+
id="text"
|
|
54
|
+
type="text"
|
|
55
|
+
labelText={t("practitionerName", "Practitioner Name")}
|
|
56
|
+
{...register("practitionerName", { required: true })}
|
|
57
|
+
invalid={errors.practitionerName}
|
|
58
|
+
invalidText={"This field is required"}
|
|
59
|
+
/>
|
|
60
|
+
<Controller
|
|
61
|
+
name="sessionDate"
|
|
62
|
+
control={control}
|
|
63
|
+
rules={{ required: true }}
|
|
64
|
+
render={({ field }) => (
|
|
65
|
+
<DatePicker
|
|
66
|
+
datePickerType="single"
|
|
67
|
+
size="md"
|
|
68
|
+
maxDate={new Date()}
|
|
69
|
+
{...field}
|
|
70
|
+
>
|
|
71
|
+
<DatePickerInput
|
|
72
|
+
id="session-date"
|
|
73
|
+
labelText={t("sessionDate", "Session Date")}
|
|
74
|
+
placeholder="mm/dd/yyyy"
|
|
75
|
+
size="md"
|
|
76
|
+
invalid={errors.sessionDate}
|
|
77
|
+
invalidText={"This field is required"}
|
|
78
|
+
/>
|
|
79
|
+
</DatePicker>
|
|
80
|
+
)}
|
|
81
|
+
/>
|
|
82
|
+
<TextArea
|
|
83
|
+
id="text"
|
|
84
|
+
type="text"
|
|
85
|
+
labelText={t("sessionNotes", "Session Notes")}
|
|
86
|
+
{...register("sessionNotes", { required: true })}
|
|
87
|
+
invalid={errors.sessionNotes}
|
|
88
|
+
invalidText={"This field is required"}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</Layer>
|
|
92
|
+
</Tile>
|
|
93
|
+
</Layer>
|
|
94
|
+
<h4>{t("sessionParticipants", "2. Session participants")}</h4>
|
|
95
|
+
<div>
|
|
96
|
+
<p>
|
|
97
|
+
{t(
|
|
98
|
+
"markAbsentPatients",
|
|
99
|
+
"The patients in this group. Patients that are not present in the session should be marked as absent."
|
|
100
|
+
)}
|
|
101
|
+
</p>
|
|
102
|
+
</div>
|
|
103
|
+
<Layer>
|
|
104
|
+
<Tile className={styles.formSectionTile}>
|
|
105
|
+
<Layer>
|
|
106
|
+
<div
|
|
107
|
+
style={{
|
|
108
|
+
display: "flex",
|
|
109
|
+
flexDirection: "column",
|
|
110
|
+
rowGap: "1.5rem",
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
<AttendanceTable />
|
|
114
|
+
</div>
|
|
115
|
+
</Layer>
|
|
116
|
+
</Tile>
|
|
117
|
+
</Layer>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default SessionDetailsForm;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Button } from "@carbon/react";
|
|
2
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
3
|
+
import styles from "./styles.scss";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import GroupFormWorkflowContext from "../context/GroupFormWorkflowContext";
|
|
6
|
+
import { FormProvider, useForm, useFormContext } from "react-hook-form";
|
|
7
|
+
import CancelModal from "../CancelModal";
|
|
8
|
+
import SessionDetailsForm from "./SessionDetailsForm";
|
|
9
|
+
|
|
10
|
+
const NewGroupWorkflowButtons = () => {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const context = useContext(GroupFormWorkflowContext);
|
|
13
|
+
const { workflowState, patientUuids } = context;
|
|
14
|
+
const [cancelModalOpen, setCancelModalOpen] = useState(false);
|
|
15
|
+
if (workflowState !== "NEW_GROUP_SESSION") return null;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<div className={styles.rightPanelActionButtons}>
|
|
20
|
+
<Button kind="secondary" type="submit" disabled={!patientUuids.length}>
|
|
21
|
+
{t("createNewSession", "Create New Session")}
|
|
22
|
+
</Button>
|
|
23
|
+
<Button
|
|
24
|
+
kind="tertiary"
|
|
25
|
+
onClick={() => {
|
|
26
|
+
setCancelModalOpen(true);
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{t("cancel", "Cancel")}
|
|
30
|
+
</Button>
|
|
31
|
+
</div>
|
|
32
|
+
<CancelModal
|
|
33
|
+
open={cancelModalOpen}
|
|
34
|
+
setOpen={setCancelModalOpen}
|
|
35
|
+
context={context}
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const GroupIdField = () => {
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
const {
|
|
44
|
+
register,
|
|
45
|
+
formState: { errors },
|
|
46
|
+
setValue,
|
|
47
|
+
} = useFormContext();
|
|
48
|
+
const { activeGroupUuid } = useContext(GroupFormWorkflowContext);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (activeGroupUuid) setValue("groupUuid", activeGroupUuid);
|
|
52
|
+
}, [activeGroupUuid, setValue]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<input
|
|
57
|
+
hidden
|
|
58
|
+
{...register("groupUuid", {
|
|
59
|
+
value: activeGroupUuid,
|
|
60
|
+
required: t("chooseGroupError", "Please choose a group."),
|
|
61
|
+
})}
|
|
62
|
+
/>
|
|
63
|
+
{errors.groupUuid && !activeGroupUuid && (
|
|
64
|
+
<div className={styles.formError}>
|
|
65
|
+
{errors.groupUuid.message as string}
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const SessionMetaWorkspace = () => {
|
|
73
|
+
const { t } = useTranslation();
|
|
74
|
+
const { setSessionMeta, workflowState } = useContext(
|
|
75
|
+
GroupFormWorkflowContext
|
|
76
|
+
);
|
|
77
|
+
const methods = useForm();
|
|
78
|
+
|
|
79
|
+
const onSubmit = (data) => {
|
|
80
|
+
const { sessionDate, ...rest } = data;
|
|
81
|
+
setSessionMeta({ ...rest, sessionDate: sessionDate[0] });
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (workflowState !== "NEW_GROUP_SESSION") return null;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<FormProvider {...methods}>
|
|
88
|
+
<form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
89
|
+
<div className={styles.workspace}>
|
|
90
|
+
<div className={styles.formMainContent}>
|
|
91
|
+
<div className={styles.formContainer}>
|
|
92
|
+
<SessionDetailsForm />
|
|
93
|
+
</div>
|
|
94
|
+
<div className={styles.rightPanel}>
|
|
95
|
+
<h4>{t("newGroupSession", "New Group Session")}</h4>
|
|
96
|
+
<GroupIdField />
|
|
97
|
+
<hr style={{ width: "100%" }} />
|
|
98
|
+
<NewGroupWorkflowButtons />
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</form>
|
|
103
|
+
</FormProvider>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default SessionMetaWorkspace;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Checkbox,
|
|
5
|
+
SkeletonText,
|
|
6
|
+
Table,
|
|
7
|
+
TableHead,
|
|
8
|
+
TableRow,
|
|
9
|
+
TableHeader,
|
|
10
|
+
TableBody,
|
|
11
|
+
TableCell,
|
|
12
|
+
} from "@carbon/react";
|
|
13
|
+
import { useTranslation } from "react-i18next";
|
|
14
|
+
import GroupFormWorkflowContext from "../../context/GroupFormWorkflowContext";
|
|
15
|
+
import { useGetPatient } from "../../hooks";
|
|
16
|
+
|
|
17
|
+
const PatientRow = ({ patientUuid }) => {
|
|
18
|
+
const patient = useGetPatient(patientUuid);
|
|
19
|
+
const { patientUuids, addPatientUuid, removePatientUuid } = useContext(
|
|
20
|
+
GroupFormWorkflowContext
|
|
21
|
+
);
|
|
22
|
+
const givenName = patient?.name?.[0]?.given?.[0];
|
|
23
|
+
const familyName = patient?.name?.[0]?.family;
|
|
24
|
+
const identifier = patient?.identifier?.[0]?.value;
|
|
25
|
+
|
|
26
|
+
const handleOnChange = (e, { checked }) => {
|
|
27
|
+
if (checked) {
|
|
28
|
+
addPatientUuid(patientUuid);
|
|
29
|
+
} else {
|
|
30
|
+
removePatientUuid(patientUuid);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (!patient) {
|
|
35
|
+
return (
|
|
36
|
+
<TableRow>
|
|
37
|
+
<TableCell>
|
|
38
|
+
<SkeletonText />
|
|
39
|
+
</TableCell>
|
|
40
|
+
<TableCell>
|
|
41
|
+
<SkeletonText />
|
|
42
|
+
</TableCell>
|
|
43
|
+
<TableCell>
|
|
44
|
+
<Checkbox diabled />
|
|
45
|
+
</TableCell>
|
|
46
|
+
</TableRow>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<TableRow>
|
|
52
|
+
<TableCell>
|
|
53
|
+
{patient.display ||
|
|
54
|
+
patient.displayName ||
|
|
55
|
+
[givenName, familyName].join(" ")}
|
|
56
|
+
</TableCell>
|
|
57
|
+
<TableCell>{identifier}</TableCell>
|
|
58
|
+
<TableCell>
|
|
59
|
+
<Checkbox
|
|
60
|
+
checked={patientUuids.includes(patientUuid)}
|
|
61
|
+
labelText={patientUuid}
|
|
62
|
+
hideLabel
|
|
63
|
+
id={`${identifier}-attendance-checkbox`}
|
|
64
|
+
onChange={handleOnChange}
|
|
65
|
+
/>
|
|
66
|
+
</TableCell>
|
|
67
|
+
</TableRow>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const AttendanceTable = () => {
|
|
72
|
+
const { t } = useTranslation();
|
|
73
|
+
const { activeGroupUuid, activeGroupMembers } = useContext(
|
|
74
|
+
GroupFormWorkflowContext
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const headers = [
|
|
78
|
+
t("name", "Name"),
|
|
79
|
+
t("identifier", "Patient ID"),
|
|
80
|
+
t("patientIsPresent", "Patient is present"),
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
if (!activeGroupUuid) {
|
|
84
|
+
return <div>{t("selectGroupFirst", "Please select a group first")}</div>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Table>
|
|
89
|
+
<TableHead>
|
|
90
|
+
<TableRow>
|
|
91
|
+
{headers.map((header, index) => (
|
|
92
|
+
<TableHeader key={index}>{header}</TableHeader>
|
|
93
|
+
))}
|
|
94
|
+
</TableRow>
|
|
95
|
+
</TableHead>
|
|
96
|
+
<TableBody>
|
|
97
|
+
{activeGroupMembers.map((patientUuid, index) => (
|
|
98
|
+
<PatientRow {...{ patientUuid }} key={index} />
|
|
99
|
+
))}
|
|
100
|
+
</TableBody>
|
|
101
|
+
</Table>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default AttendanceTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttendanceTable } from "./AttendanceTable";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@testing-library/react";
|
|
3
|
-
import
|
|
3
|
+
import GroupDisplayHeader from "./GroupDisplayHeader";
|
|
4
4
|
|
|
5
5
|
describe("PatientBanner", () => {
|
|
6
6
|
it("renders placeholder information when no data is present", () => {
|
|
7
|
-
render(<
|
|
7
|
+
render(<GroupDisplayHeader />);
|
|
8
8
|
});
|
|
9
9
|
});
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Button } from "@carbon/react";
|
|
3
|
+
import { Events, Close } from "@carbon/react/icons";
|
|
3
4
|
import styles from "./styles.scss";
|
|
4
5
|
import { useTranslation } from "react-i18next";
|
|
5
6
|
import GroupFormWorkflowContext from "../../context/GroupFormWorkflowContext";
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
const {
|
|
9
|
-
|
|
8
|
+
const GroupDisplayHeader = () => {
|
|
9
|
+
const {
|
|
10
|
+
activeGroupName,
|
|
11
|
+
activeGroupUuid,
|
|
12
|
+
patientUuids,
|
|
13
|
+
activeSessionMeta,
|
|
14
|
+
unsetGroup,
|
|
15
|
+
destroySession,
|
|
16
|
+
} = useContext(GroupFormWorkflowContext);
|
|
10
17
|
const { t } = useTranslation();
|
|
11
18
|
|
|
12
19
|
if (!activeGroupUuid) {
|
|
@@ -38,8 +45,19 @@ const GroupBanner = () => {
|
|
|
38
45
|
</div>
|
|
39
46
|
</div>
|
|
40
47
|
)}
|
|
48
|
+
<span style={{ flexGrow: 1 }} />
|
|
49
|
+
<span>
|
|
50
|
+
<Button kind="ghost" onClick={() => unsetGroup()}>
|
|
51
|
+
{t("changeGroup", "Choose a different group")} <Close size={20} />
|
|
52
|
+
</Button>
|
|
53
|
+
</span>
|
|
54
|
+
<span>
|
|
55
|
+
<Button kind="ghost" onClick={() => destroySession()}>
|
|
56
|
+
{t("cancel", "Cancel")} <Close size={20} />
|
|
57
|
+
</Button>
|
|
58
|
+
</span>
|
|
41
59
|
</div>
|
|
42
60
|
);
|
|
43
61
|
};
|
|
44
62
|
|
|
45
|
-
export default
|
|
63
|
+
export default GroupDisplayHeader;
|