@kenyaemr/esm-bed-management-app 1.0.1-pre.4 → 1.0.1-pre.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/26.js +1 -1
- package/dist/26.js.map +1 -1
- package/dist/294.js +1 -1
- package/dist/294.js.map +1 -1
- package/dist/360.js +1 -0
- package/dist/360.js.map +1 -0
- package/dist/452.js +1 -0
- package/dist/{884.js.map → 452.js.map} +1 -1
- package/dist/482.js +2 -0
- package/dist/482.js.LICENSE.txt +19 -0
- package/dist/482.js.map +1 -0
- package/dist/532.js +1 -0
- package/dist/532.js.map +1 -0
- package/dist/558.js +1 -1
- package/dist/558.js.map +1 -1
- package/dist/574.js +1 -1
- package/dist/663.js +2 -0
- package/dist/663.js.LICENSE.txt +44 -0
- package/dist/663.js.map +1 -0
- package/dist/666.js +1 -0
- package/dist/666.js.map +1 -0
- package/dist/708.js +2 -0
- package/dist/{330.js.LICENSE.txt → 708.js.LICENSE.txt} +0 -20
- package/dist/708.js.map +1 -0
- package/dist/763.js +2 -0
- package/dist/763.js.map +1 -0
- package/dist/774.js +1 -0
- package/dist/774.js.map +1 -0
- package/dist/815.js +1 -0
- package/dist/815.js.map +1 -0
- package/dist/847.js +1 -0
- package/dist/847.js.map +1 -0
- package/dist/898.js +1 -0
- package/dist/898.js.map +1 -0
- package/dist/931.js +1 -0
- package/dist/931.js.map +1 -0
- package/dist/935.js +1 -0
- package/dist/935.js.map +1 -0
- package/dist/esm-kenyaemr-bed-management-app.js +1 -1
- package/dist/esm-kenyaemr-bed-management-app.js.buildmanifest.json +207 -135
- package/dist/esm-kenyaemr-bed-management-app.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +4 -1
- package/src/bed-administration/bed-administration-table.scss +3 -0
- package/src/bed-administration/bed-administration-types.ts +8 -0
- package/src/bed-admission/active-patients/active-patients-table.component.tsx +13 -20
- package/src/bed-admission/active-patients/active-visits.resource.ts +1 -3
- package/src/bed-admission/active-patients/eligible-admissions.resource.ts +43 -0
- package/src/bed-admission/admitted-patients/active-admissions.resource.ts +5 -1
- package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +3 -3
- package/src/bed-admission/bed-admission-tabs.component.tsx +0 -1
- package/src/bed-admission/bed-admission.resource.ts +1 -1
- package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +2 -2
- package/src/bed-admission/bed-tag/bed-tag-administration-table.component.tsx +240 -0
- package/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx +146 -0
- package/src/bed-admission/bed-tag/delete-bed-tag.component.tsx +69 -0
- package/src/bed-admission/bed-tag/delete-bedForm.component.tsx +108 -0
- package/src/bed-admission/bed-tag/edit-tag-form.component.tsx +80 -0
- package/src/bed-admission/bed-tag/new-tag-form.component.tsx +83 -0
- package/src/bed-admission/bed-type/bed-type-admin-form.component.tsx +203 -0
- package/src/bed-admission/bed-type/bed-type-administration-table.component.tsx +246 -0
- package/src/bed-admission/bed-type/delete-bed-type.component.tsx +69 -0
- package/src/bed-admission/bed-type/deleteBedtypeForm.component.tsx +108 -0
- package/src/bed-admission/bed-type/edit-bed-type.component.tsx +80 -0
- package/src/bed-admission/bed-type/new-bed-type-form.component.tsx +87 -0
- package/src/bed-admission/types.ts +1 -3
- package/src/bed-admission/ward/new-ward-form.component.tsx +81 -0
- package/src/bed-admission/ward/ward-admin-form.component.tsx +193 -0
- package/src/bed-admission/ward/ward-administration-table.component.tsx +173 -0
- package/src/config-schema.ts +7 -1
- package/src/index.ts +21 -0
- package/src/root.component.tsx +6 -0
- package/src/routes.json +16 -1
- package/src/summary/summary.resource.ts +257 -1
- package/src/types.ts +23 -0
- package/src/workspace/allocate-bed-workspace.component.tsx +51 -18
- package/src/workspace/allocate-bed.scss +7 -0
- package/tsconfig.json +2 -1
- package/dist/187.js +0 -1
- package/dist/187.js.map +0 -1
- package/dist/207.js +0 -1
- package/dist/207.js.map +0 -1
- package/dist/283.js +0 -1
- package/dist/283.js.map +0 -1
- package/dist/330.js +0 -2
- package/dist/330.js.map +0 -1
- package/dist/352.js +0 -1
- package/dist/352.js.map +0 -1
- package/dist/404.js +0 -1
- package/dist/404.js.map +0 -1
- package/dist/455.js +0 -2
- package/dist/455.js.map +0 -1
- package/dist/629.js +0 -1
- package/dist/629.js.map +0 -1
- package/dist/707.js +0 -1
- package/dist/707.js.map +0 -1
- package/dist/800.js +0 -2
- package/dist/800.js.LICENSE.txt +0 -3
- package/dist/800.js.map +0 -1
- package/dist/884.js +0 -1
- package/dist/933.js +0 -1
- package/dist/933.js.map +0 -1
- package/dist/959.js +0 -1
- package/dist/959.js.map +0 -1
- /package/.yarn/versions/{6816f0d4.yml → 739e37b3.yml} +0 -0
- /package/dist/{455.js.LICENSE.txt → 763.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import React, { useMemo, useState } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
DataTable,
|
|
6
|
+
DataTableSkeleton,
|
|
7
|
+
InlineLoading,
|
|
8
|
+
Pagination,
|
|
9
|
+
Table,
|
|
10
|
+
TableBody,
|
|
11
|
+
TableCell,
|
|
12
|
+
TableContainer,
|
|
13
|
+
TableHead,
|
|
14
|
+
TableHeader,
|
|
15
|
+
TableRow,
|
|
16
|
+
Tile,
|
|
17
|
+
} from "@carbon/react";
|
|
18
|
+
import { Add, Edit, Delete } from "@carbon/react/icons";
|
|
19
|
+
import {
|
|
20
|
+
isDesktop as desktopLayout,
|
|
21
|
+
useLayoutType,
|
|
22
|
+
} from "@openmrs/esm-framework";
|
|
23
|
+
import { CardHeader, ErrorState } from "@openmrs/esm-patient-common-lib";
|
|
24
|
+
import type { BedTypeData } from "../../types";
|
|
25
|
+
import { useBedType } from "../../summary/summary.resource";
|
|
26
|
+
import Header from "../../header/header.component";
|
|
27
|
+
import BedTypeForm from "./new-bed-type-form.component";
|
|
28
|
+
import styles from "../../bed-administration/bed-administration-table.scss";
|
|
29
|
+
import EditBedTypeForm from "./edit-bed-type.component";
|
|
30
|
+
import DeleteBedType from "./delete-bed-type.component";
|
|
31
|
+
|
|
32
|
+
const BedTypeAdministrationTable: React.FC = () => {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
const headerTitle = t("bedType", "Bed Type");
|
|
35
|
+
const layout = useLayoutType();
|
|
36
|
+
const isTablet = layout === "tablet";
|
|
37
|
+
const responsiveSize = isTablet ? "lg" : "sm";
|
|
38
|
+
const isDesktop = desktopLayout(layout);
|
|
39
|
+
const [showEditBedModal, setShowEditBedModal] = useState(false);
|
|
40
|
+
const [isBedDataLoading] = useState(false);
|
|
41
|
+
const [showBedTypeModal, setAddBedTypeModal] = useState(false);
|
|
42
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
43
|
+
const [editData, setEditData] = useState<BedTypeData>();
|
|
44
|
+
const [showDeleteBedTypeModal, setDeleteBedTypeModal] = useState(false);
|
|
45
|
+
const [pageSize] = useState(10);
|
|
46
|
+
const { bedTypeData, isError, loading, validate, mutate } = useBedType();
|
|
47
|
+
const tableHeaders = [
|
|
48
|
+
{
|
|
49
|
+
header: t("name", "Name"),
|
|
50
|
+
key: "name",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
header: t("displayName", "Display Name"),
|
|
54
|
+
key: "displayName",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
header: t("description", "Description"),
|
|
58
|
+
key: "description",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "actions",
|
|
62
|
+
header: t("actions", "Actions"),
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const tableRows = useMemo(() => {
|
|
67
|
+
return bedTypeData?.map((entry) => ({
|
|
68
|
+
id: entry.uuid,
|
|
69
|
+
name: entry?.name,
|
|
70
|
+
displayName: entry?.displayName,
|
|
71
|
+
description: entry?.description,
|
|
72
|
+
actions: (
|
|
73
|
+
<>
|
|
74
|
+
<Button
|
|
75
|
+
enterDelayMs={300}
|
|
76
|
+
renderIcon={Edit}
|
|
77
|
+
onClick={(e) => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
setEditData(entry);
|
|
80
|
+
setShowEditBedModal(true);
|
|
81
|
+
setAddBedTypeModal(false);
|
|
82
|
+
setDeleteBedTypeModal(false);
|
|
83
|
+
}}
|
|
84
|
+
kind={"ghost"}
|
|
85
|
+
iconDescription={t("editBedType", "Edit Bed Type")}
|
|
86
|
+
hasIconOnly
|
|
87
|
+
size={responsiveSize}
|
|
88
|
+
tooltipAlignment="start"
|
|
89
|
+
/>
|
|
90
|
+
<Button
|
|
91
|
+
enterDelayMs={300}
|
|
92
|
+
renderIcon={Delete}
|
|
93
|
+
onClick={(e) => {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
setEditData(entry);
|
|
96
|
+
setShowEditBedModal(false);
|
|
97
|
+
setAddBedTypeModal(false);
|
|
98
|
+
setDeleteBedTypeModal(true);
|
|
99
|
+
}}
|
|
100
|
+
kind={"ghost"}
|
|
101
|
+
iconDescription={t("deleteBedTag", "Delete Bed Tag")}
|
|
102
|
+
hasIconOnly
|
|
103
|
+
size={responsiveSize}
|
|
104
|
+
tooltipAlignment="start"
|
|
105
|
+
/>
|
|
106
|
+
</>
|
|
107
|
+
),
|
|
108
|
+
}));
|
|
109
|
+
}, [responsiveSize, bedTypeData, t]);
|
|
110
|
+
|
|
111
|
+
if (isBedDataLoading || loading) {
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<Header route="Bed Type" />
|
|
115
|
+
<div className={styles.widgetCard}>
|
|
116
|
+
<DataTableSkeleton role="progressbar" compact={isDesktop} zebra />
|
|
117
|
+
</div>
|
|
118
|
+
</>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (isError) {
|
|
123
|
+
return (
|
|
124
|
+
<>
|
|
125
|
+
<Header route="Bed Type" />
|
|
126
|
+
<div className={styles.widgetCard}>
|
|
127
|
+
<ErrorState error={isError} headerTitle={headerTitle} />
|
|
128
|
+
</div>
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<>
|
|
135
|
+
<Header route="Bed Type" />
|
|
136
|
+
|
|
137
|
+
<div className={styles.widgetCard}>
|
|
138
|
+
{showBedTypeModal ? (
|
|
139
|
+
<BedTypeForm
|
|
140
|
+
onModalChange={setAddBedTypeModal}
|
|
141
|
+
showModal={showBedTypeModal}
|
|
142
|
+
mutate={mutate}
|
|
143
|
+
/>
|
|
144
|
+
) : null}
|
|
145
|
+
{showEditBedModal ? (
|
|
146
|
+
<EditBedTypeForm
|
|
147
|
+
onModalChange={setShowEditBedModal}
|
|
148
|
+
showModal={showEditBedModal}
|
|
149
|
+
editData={editData}
|
|
150
|
+
mutate={mutate}
|
|
151
|
+
/>
|
|
152
|
+
) : null}
|
|
153
|
+
{showDeleteBedTypeModal ? (
|
|
154
|
+
<DeleteBedType
|
|
155
|
+
onModalChange={setDeleteBedTypeModal}
|
|
156
|
+
showModal={showDeleteBedTypeModal}
|
|
157
|
+
editData={editData}
|
|
158
|
+
mutate={mutate}
|
|
159
|
+
/>
|
|
160
|
+
) : null}
|
|
161
|
+
<CardHeader title={headerTitle}>
|
|
162
|
+
<span className={styles.backgroundDataFetchingIndicator}>
|
|
163
|
+
<span>{validate ? <InlineLoading /> : null}</span>
|
|
164
|
+
</span>
|
|
165
|
+
{bedTypeData?.length ? (
|
|
166
|
+
<Button
|
|
167
|
+
kind="ghost"
|
|
168
|
+
renderIcon={(props) => <Add size={16} {...props} />}
|
|
169
|
+
onClick={() => setAddBedTypeModal(true)}
|
|
170
|
+
>
|
|
171
|
+
{t("addBedtype", "Add Bed Type")}
|
|
172
|
+
</Button>
|
|
173
|
+
) : null}
|
|
174
|
+
</CardHeader>
|
|
175
|
+
<DataTable
|
|
176
|
+
rows={tableRows}
|
|
177
|
+
headers={tableHeaders}
|
|
178
|
+
isSortable
|
|
179
|
+
size={isTablet ? "lg" : "sm"}
|
|
180
|
+
useZebraStyles
|
|
181
|
+
>
|
|
182
|
+
{({ rows, headers, getTableProps }) => (
|
|
183
|
+
<TableContainer>
|
|
184
|
+
<Table {...getTableProps()}>
|
|
185
|
+
<TableHead>
|
|
186
|
+
<TableRow>
|
|
187
|
+
{headers.map((header) => (
|
|
188
|
+
<TableHeader>
|
|
189
|
+
{header.header?.content ?? header.header}
|
|
190
|
+
</TableHeader>
|
|
191
|
+
))}
|
|
192
|
+
</TableRow>
|
|
193
|
+
</TableHead>
|
|
194
|
+
<TableBody>
|
|
195
|
+
{rows.map((row) => (
|
|
196
|
+
<TableRow key={row.id}>
|
|
197
|
+
{row.cells.map((cell) => (
|
|
198
|
+
<TableCell key={cell.id}>
|
|
199
|
+
{cell.value?.content ?? cell.value}
|
|
200
|
+
</TableCell>
|
|
201
|
+
))}
|
|
202
|
+
</TableRow>
|
|
203
|
+
))}
|
|
204
|
+
</TableBody>
|
|
205
|
+
</Table>
|
|
206
|
+
{rows.length === 0 ? (
|
|
207
|
+
<div className={styles.tileContainer}>
|
|
208
|
+
<Tile className={styles.tile}>
|
|
209
|
+
<div className={styles.tileContent}>
|
|
210
|
+
<p className={styles.content}>
|
|
211
|
+
{t("No data", "No data to display")}
|
|
212
|
+
</p>
|
|
213
|
+
<p className={styles.helper}>
|
|
214
|
+
{t("checkFilters", "Check the filters above")}
|
|
215
|
+
</p>
|
|
216
|
+
</div>
|
|
217
|
+
<p className={styles.separator}>{t("or", "or")}</p>
|
|
218
|
+
<Button
|
|
219
|
+
kind="ghost"
|
|
220
|
+
size="sm"
|
|
221
|
+
renderIcon={(props) => <Add size={16} {...props} />}
|
|
222
|
+
onClick={() => setAddBedTypeModal(true)}
|
|
223
|
+
>
|
|
224
|
+
{t("bedType", "Add Bed Type")}
|
|
225
|
+
</Button>
|
|
226
|
+
</Tile>
|
|
227
|
+
</div>
|
|
228
|
+
) : null}
|
|
229
|
+
<Pagination
|
|
230
|
+
page={currentPage}
|
|
231
|
+
pageSize={pageSize}
|
|
232
|
+
pageSizes={[10, 20, 30, 40, 50]}
|
|
233
|
+
totalItems={bedTypeData.length}
|
|
234
|
+
onChange={({ page, pageSize }) => {
|
|
235
|
+
setCurrentPage(page);
|
|
236
|
+
pageSize(pageSize);
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
</TableContainer>
|
|
240
|
+
)}
|
|
241
|
+
</DataTable>
|
|
242
|
+
</div>
|
|
243
|
+
</>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
export default BedTypeAdministrationTable;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { showToast, showNotification } from "@openmrs/esm-framework";
|
|
4
|
+
import { deleteBedType } from "../../summary/summary.resource";
|
|
5
|
+
import { BedTagDataAdministration } from "../../bed-administration/bed-administration-types";
|
|
6
|
+
import { BedTagData, Mutator } from "../../types";
|
|
7
|
+
import DeleteBedTypesForm from "./deleteBedtypeForm.component";
|
|
8
|
+
|
|
9
|
+
interface DeleteBedTypeFormProps {
|
|
10
|
+
showModal: boolean;
|
|
11
|
+
onModalChange: (showModal: boolean) => void;
|
|
12
|
+
editData: BedTagData;
|
|
13
|
+
mutate: Mutator;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DeleteBedType: React.FC<DeleteBedTypeFormProps> = ({
|
|
17
|
+
showModal,
|
|
18
|
+
onModalChange,
|
|
19
|
+
editData,
|
|
20
|
+
mutate,
|
|
21
|
+
}) => {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const headerTitle = t("deleteBedType", "Delete bed Type");
|
|
24
|
+
const handleDeleteQuestion = useCallback(
|
|
25
|
+
(formData: BedTagDataAdministration) => {
|
|
26
|
+
const bedUuid = editData.uuid;
|
|
27
|
+
const { name } = formData;
|
|
28
|
+
deleteBedType(bedUuid)
|
|
29
|
+
.then(() => {
|
|
30
|
+
showToast({
|
|
31
|
+
title: t("bedTypeDeleted", "Bed Type Deleted"),
|
|
32
|
+
kind: "success",
|
|
33
|
+
critical: true,
|
|
34
|
+
description:
|
|
35
|
+
name +
|
|
36
|
+
" " +
|
|
37
|
+
t("bedTypeDeleteSuccessMessage", "was deleted successfully."),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
mutate();
|
|
41
|
+
onModalChange(false);
|
|
42
|
+
})
|
|
43
|
+
.catch((error) => {
|
|
44
|
+
showNotification({
|
|
45
|
+
title: t("errorDeletingBedType", "Error deleting bed type"),
|
|
46
|
+
kind: "error",
|
|
47
|
+
critical: true,
|
|
48
|
+
description: error?.message,
|
|
49
|
+
});
|
|
50
|
+
onModalChange(false);
|
|
51
|
+
});
|
|
52
|
+
onModalChange(false);
|
|
53
|
+
},
|
|
54
|
+
[onModalChange, mutate, editData, t]
|
|
55
|
+
);
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<DeleteBedTypesForm
|
|
59
|
+
onModalChange={onModalChange}
|
|
60
|
+
showModal={showModal}
|
|
61
|
+
handleDeleteBedTag={handleDeleteQuestion}
|
|
62
|
+
headerTitle={headerTitle}
|
|
63
|
+
initialData={editData}
|
|
64
|
+
/>
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default DeleteBedType;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
ComposedModal,
|
|
8
|
+
ModalBody,
|
|
9
|
+
ModalFooter,
|
|
10
|
+
ModalHeader,
|
|
11
|
+
Stack,
|
|
12
|
+
InlineNotification,
|
|
13
|
+
} from "@carbon/react";
|
|
14
|
+
import { useTranslation } from "react-i18next";
|
|
15
|
+
import styles from "../../bed-administration/bed-administration-table.scss";
|
|
16
|
+
interface BedTagData {
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const BedTagAdministrationSchema = z.object({
|
|
21
|
+
name: z.string().max(255),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
interface BedTagAdministrationFormProps {
|
|
25
|
+
showModal: boolean;
|
|
26
|
+
onModalChange: (showModal: boolean) => void;
|
|
27
|
+
handleDeleteBedTag?: (formData: BedTagData) => void;
|
|
28
|
+
headerTitle: string;
|
|
29
|
+
initialData: BedTagData;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface ErrorType {
|
|
33
|
+
message: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const DeleteBedTypesForm: React.FC<BedTagAdministrationFormProps> = ({
|
|
37
|
+
showModal,
|
|
38
|
+
onModalChange,
|
|
39
|
+
handleDeleteBedTag,
|
|
40
|
+
headerTitle,
|
|
41
|
+
initialData,
|
|
42
|
+
}) => {
|
|
43
|
+
const { t } = useTranslation();
|
|
44
|
+
|
|
45
|
+
const [showErrorNotification, setShowErrorNotification] = useState(false);
|
|
46
|
+
const [formStateError, setFormStateError] = useState("");
|
|
47
|
+
|
|
48
|
+
const { handleSubmit } = useForm<BedTagData>({
|
|
49
|
+
mode: "all",
|
|
50
|
+
resolver: zodResolver(BedTagAdministrationSchema),
|
|
51
|
+
defaultValues: {
|
|
52
|
+
name: initialData.name || "",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const onSubmit = (formData: BedTagData) => {
|
|
57
|
+
const result = BedTagAdministrationSchema.safeParse(formData);
|
|
58
|
+
if (result.success) {
|
|
59
|
+
setShowErrorNotification(false);
|
|
60
|
+
if (handleDeleteBedTag) {
|
|
61
|
+
handleDeleteBedTag(formData);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onError = (error: { [key: string]: ErrorType }) => {
|
|
67
|
+
setFormStateError(Object.entries(error)[0][1].message);
|
|
68
|
+
setShowErrorNotification(true);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<ComposedModal
|
|
73
|
+
open={showModal}
|
|
74
|
+
onClose={() => onModalChange(false)}
|
|
75
|
+
preventCloseOnClickOutside
|
|
76
|
+
>
|
|
77
|
+
<ModalHeader title={headerTitle} />
|
|
78
|
+
<form onSubmit={handleSubmit(onSubmit, onError)}>
|
|
79
|
+
<ModalBody hasScrollingContent>
|
|
80
|
+
<Stack gap={3}>
|
|
81
|
+
<ModalBody>Are you sure you want to delete this bed tag?</ModalBody>
|
|
82
|
+
{showErrorNotification && (
|
|
83
|
+
<InlineNotification
|
|
84
|
+
lowContrast
|
|
85
|
+
title={t("error", "Error")}
|
|
86
|
+
style={{ minWidth: "100%", margin: "0rem", padding: "0rem" }}
|
|
87
|
+
role="alert"
|
|
88
|
+
kind="error"
|
|
89
|
+
subtitle={t("pleaseFillField", formStateError) + "."}
|
|
90
|
+
onClose={() => setShowErrorNotification(false)}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
</Stack>
|
|
94
|
+
</ModalBody>
|
|
95
|
+
<ModalFooter>
|
|
96
|
+
<Button onClick={() => onModalChange(false)} kind="secondary">
|
|
97
|
+
{t("cancel", "Cancel")}
|
|
98
|
+
</Button>
|
|
99
|
+
<Button type="submit" className={styles.deleteButton}>
|
|
100
|
+
<span>{t("delete", "Delete")}</span>
|
|
101
|
+
</Button>
|
|
102
|
+
</ModalFooter>
|
|
103
|
+
</form>
|
|
104
|
+
</ComposedModal>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export default DeleteBedTypesForm;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { showToast, showNotification } from "@openmrs/esm-framework";
|
|
4
|
+
|
|
5
|
+
import { editBedType, useBedType } from "../../summary/summary.resource";
|
|
6
|
+
import { BedTypeDataAdministration } from "../../bed-administration/bed-administration-types";
|
|
7
|
+
import { BedTypeData, Mutator } from "../../types";
|
|
8
|
+
import BedTypeAdministrationForm from "./bed-type-admin-form.component";
|
|
9
|
+
|
|
10
|
+
interface EditBedTypeFormProps {
|
|
11
|
+
showModal: boolean;
|
|
12
|
+
onModalChange: (showModal: boolean) => void;
|
|
13
|
+
editData: BedTypeData;
|
|
14
|
+
mutate: Mutator;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const EditBedTypeForm: React.FC<EditBedTypeFormProps> = ({
|
|
18
|
+
showModal,
|
|
19
|
+
onModalChange,
|
|
20
|
+
editData,
|
|
21
|
+
mutate,
|
|
22
|
+
}) => {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
const headerTitle = t("editBedType", "Edit Bed Type");
|
|
25
|
+
const { bedTypeData } = useBedType();
|
|
26
|
+
const availableBedTypes = bedTypeData ? bedTypeData : [];
|
|
27
|
+
const handleCreateQuestion = useCallback(
|
|
28
|
+
(formData: BedTypeDataAdministration) => {
|
|
29
|
+
const bedUuid = editData.uuid;
|
|
30
|
+
const { name, displayName, description } = formData;
|
|
31
|
+
const bedPayload = {
|
|
32
|
+
name,
|
|
33
|
+
displayName,
|
|
34
|
+
description,
|
|
35
|
+
};
|
|
36
|
+
editBedType({ bedPayload, bedTypeId: bedUuid })
|
|
37
|
+
.then(() => {
|
|
38
|
+
showToast({
|
|
39
|
+
title: t("formSaved", "Bed Type"),
|
|
40
|
+
kind: "success",
|
|
41
|
+
critical: true,
|
|
42
|
+
description:
|
|
43
|
+
bedPayload.name +
|
|
44
|
+
" " +
|
|
45
|
+
t("saveSuccessMessage", "was saved successfully."),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
mutate();
|
|
49
|
+
onModalChange(false);
|
|
50
|
+
})
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
showNotification({
|
|
53
|
+
title: t("errorCreatingForm", "Error creating bed"),
|
|
54
|
+
kind: "error",
|
|
55
|
+
critical: true,
|
|
56
|
+
description: error?.message,
|
|
57
|
+
});
|
|
58
|
+
onModalChange(false);
|
|
59
|
+
});
|
|
60
|
+
onModalChange(false);
|
|
61
|
+
},
|
|
62
|
+
[onModalChange, mutate, editData, t]
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<BedTypeAdministrationForm
|
|
68
|
+
onModalChange={onModalChange}
|
|
69
|
+
availableBedTypes={availableBedTypes}
|
|
70
|
+
showModal={showModal}
|
|
71
|
+
handleCreateQuestion={handleCreateQuestion}
|
|
72
|
+
headerTitle={headerTitle}
|
|
73
|
+
initialData={editData}
|
|
74
|
+
allLocations={[]}
|
|
75
|
+
/>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default EditBedTypeForm;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
|
|
4
|
+
import type { BedTypeData, Mutator } from "../../types";
|
|
5
|
+
import { useBedType } from "../../bed-administration/bed-administration.resource";
|
|
6
|
+
import { saveBedType, useLocationsByTag } from "../../summary/summary.resource";
|
|
7
|
+
import BedTypeAdministrationForm from "./bed-type-admin-form.component";
|
|
8
|
+
|
|
9
|
+
interface BedTypeFormProps {
|
|
10
|
+
showModal: boolean;
|
|
11
|
+
onModalChange: (showModal: boolean) => void;
|
|
12
|
+
mutate: Mutator;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const NewBedTypeForm: React.FC<BedTypeFormProps> = ({
|
|
16
|
+
showModal,
|
|
17
|
+
onModalChange,
|
|
18
|
+
mutate,
|
|
19
|
+
}) => {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const { admissionLocationTagUuid } = useConfig();
|
|
22
|
+
const { data: admissionLocations } = useLocationsByTag(
|
|
23
|
+
admissionLocationTagUuid
|
|
24
|
+
);
|
|
25
|
+
const headerTitle = t("addBedType", "Create Bed type");
|
|
26
|
+
const { bedTypes } = useBedType();
|
|
27
|
+
const availableBedTypes = bedTypes ? bedTypes : [];
|
|
28
|
+
|
|
29
|
+
const initialData: BedTypeData = {
|
|
30
|
+
uuid: "",
|
|
31
|
+
name: "",
|
|
32
|
+
displayName: "",
|
|
33
|
+
description: "",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleCreateQuestion = useCallback(
|
|
37
|
+
(formData: BedTypeData) => {
|
|
38
|
+
const { name, displayName, description } = formData;
|
|
39
|
+
|
|
40
|
+
const bedObject = {
|
|
41
|
+
name,
|
|
42
|
+
displayName,
|
|
43
|
+
description,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
saveBedType({ bedPayload: bedObject })
|
|
47
|
+
.then(() => {
|
|
48
|
+
showToast({
|
|
49
|
+
title: t("formCreated", "Add bed Type"),
|
|
50
|
+
kind: "success",
|
|
51
|
+
critical: true,
|
|
52
|
+
description: `Bed ${name} was created successfully.`,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
mutate();
|
|
56
|
+
onModalChange(false);
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
showNotification({
|
|
60
|
+
title: t("errorCreatingForm", "Error creating bed"),
|
|
61
|
+
kind: "error",
|
|
62
|
+
critical: true,
|
|
63
|
+
description: error?.message,
|
|
64
|
+
});
|
|
65
|
+
onModalChange(false);
|
|
66
|
+
});
|
|
67
|
+
onModalChange(false);
|
|
68
|
+
},
|
|
69
|
+
[onModalChange, mutate, t]
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<BedTypeAdministrationForm
|
|
75
|
+
onModalChange={onModalChange}
|
|
76
|
+
allLocations={admissionLocations}
|
|
77
|
+
availableBedTypes={availableBedTypes}
|
|
78
|
+
showModal={showModal}
|
|
79
|
+
handleCreateQuestion={handleCreateQuestion}
|
|
80
|
+
headerTitle={headerTitle}
|
|
81
|
+
initialData={initialData}
|
|
82
|
+
/>
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default NewBedTypeForm;
|
|
@@ -123,9 +123,7 @@ export interface UuidDisplay {
|
|
|
123
123
|
export interface patientDetailsProps {
|
|
124
124
|
name: string;
|
|
125
125
|
patientUuid: string;
|
|
126
|
-
encounter:
|
|
127
|
-
uuid: string;
|
|
128
|
-
};
|
|
126
|
+
encounter: string;
|
|
129
127
|
locationUuid: string;
|
|
130
128
|
locationTo: string;
|
|
131
129
|
locationFrom: string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
|
|
4
|
+
import { saveWard, useLocationsByTag } from "../../summary/summary.resource";
|
|
5
|
+
import { LocationTagData, Mutator } from "../../types";
|
|
6
|
+
import WardAdministrationForm from "./ward-admin-form.component";
|
|
7
|
+
|
|
8
|
+
interface WardFormProps {
|
|
9
|
+
showModal: boolean;
|
|
10
|
+
onModalChange: (showModal: boolean) => void;
|
|
11
|
+
mutate: Mutator;
|
|
12
|
+
}
|
|
13
|
+
const NewWardForm: React.FC<WardFormProps> = ({
|
|
14
|
+
showModal,
|
|
15
|
+
onModalChange,
|
|
16
|
+
mutate,
|
|
17
|
+
}) => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const { admissionLocationTagUuid } = useConfig();
|
|
20
|
+
const { data: admissionLocations } = useLocationsByTag(
|
|
21
|
+
admissionLocationTagUuid
|
|
22
|
+
);
|
|
23
|
+
const headerTitle = t("addWard", "Create new Ward");
|
|
24
|
+
const initialData: LocationTagData = {
|
|
25
|
+
uuid: "",
|
|
26
|
+
name: "",
|
|
27
|
+
tagLocation: {
|
|
28
|
+
display: "",
|
|
29
|
+
uuid: "",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleCreateQuestion = useCallback(
|
|
34
|
+
(formData: LocationTagData) => {
|
|
35
|
+
const { name, tagLocation } = formData;
|
|
36
|
+
const wardObject = {
|
|
37
|
+
name,
|
|
38
|
+
tags: [tagLocation.uuid],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
saveWard({ wardPayload: wardObject })
|
|
42
|
+
.then(() => {
|
|
43
|
+
showToast({
|
|
44
|
+
title: t("formCreated", "Add Ward"),
|
|
45
|
+
kind: "success",
|
|
46
|
+
critical: true,
|
|
47
|
+
description: `Ward ${name} was created successfully.`,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
mutate();
|
|
51
|
+
onModalChange(false);
|
|
52
|
+
})
|
|
53
|
+
.catch((error) => {
|
|
54
|
+
showNotification({
|
|
55
|
+
title: t("errorCreatingForm", "Error creating ward"),
|
|
56
|
+
kind: "error",
|
|
57
|
+
critical: true,
|
|
58
|
+
description: error?.message,
|
|
59
|
+
});
|
|
60
|
+
onModalChange(false);
|
|
61
|
+
});
|
|
62
|
+
onModalChange(false);
|
|
63
|
+
},
|
|
64
|
+
[onModalChange, mutate, t]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<WardAdministrationForm
|
|
70
|
+
onModalChange={onModalChange}
|
|
71
|
+
allLocations={admissionLocations}
|
|
72
|
+
showModal={showModal}
|
|
73
|
+
handleCreateQuestion={handleCreateQuestion}
|
|
74
|
+
headerTitle={headerTitle}
|
|
75
|
+
initialData={initialData}
|
|
76
|
+
/>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default NewWardForm;
|