@kenyaemr/esm-bed-management-app 1.0.1-pre.11 → 1.0.1-pre.17
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/283.js +1 -1
- package/dist/283.js.map +1 -1
- package/dist/429.js +2 -0
- package/dist/429.js.map +1 -0
- package/dist/65.js +1 -0
- package/dist/65.js.map +1 -0
- package/dist/705.js +2 -0
- package/dist/705.js.map +1 -0
- package/dist/746.js +1 -0
- package/dist/746.js.map +1 -0
- package/dist/775.js +1 -0
- package/dist/775.js.map +1 -0
- package/dist/800.js +1 -1
- package/dist/800.js.LICENSE.txt +1 -1
- package/dist/800.js.map +1 -1
- package/dist/815.js +1 -0
- package/dist/815.js.map +1 -0
- package/dist/884.js +1 -1
- package/dist/esm-kenyaemr-bed-management-app.js +1 -1
- package/dist/esm-kenyaemr-bed-management-app.js.buildmanifest.json +111 -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 +3 -3
- package/src/bed-administration/bed-administration-table.scss +3 -0
- package/src/bed-admission/active-patients/active-patients-table.component.tsx +10 -8
- package/src/bed-admission/active-patients/eligible-admissions.resource.ts +43 -0
- package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +1 -1
- package/src/bed-admission/bed-admission.resource.ts +0 -17
- package/src/bed-admission/bed-tag/bed-tag-administration-table.component.tsx +32 -9
- package/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx +16 -1
- 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 +1 -1
- package/src/bed-admission/bed-type/bed-type-admin-form.component.tsx +33 -3
- package/src/bed-admission/bed-type/bed-type-administration-table.component.tsx +31 -7
- 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 +1 -1
- package/src/bed-admission/types.ts +1 -3
- package/src/config-schema.ts +4 -8
- package/src/summary/summary.resource.ts +138 -30
- package/src/workspace/allocate-bed-workspace.component.tsx +24 -38
- package/dist/207.js +0 -1
- package/dist/207.js.map +0 -1
- package/dist/330.js +0 -2
- package/dist/330.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/637.js +0 -1
- package/dist/637.js.map +0 -1
- package/dist/850.js +0 -1
- package/dist/850.js.map +0 -1
- package/dist/933.js +0 -1
- package/dist/933.js.map +0 -1
- /package/.yarn/versions/{3d353a50.yml → c39e27d0.yml} +0 -0
- /package/dist/{455.js.LICENSE.txt → 429.js.LICENSE.txt} +0 -0
- /package/dist/{330.js.LICENSE.txt → 705.js.LICENSE.txt} +0 -0
|
@@ -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 { deleteBedTag, useBedTag } from "../../summary/summary.resource";
|
|
5
|
+
import { BedTagDataAdministration } from "../../bed-administration/bed-administration-types";
|
|
6
|
+
import { BedTagData, Mutator } from "../../types";
|
|
7
|
+
import DeleteBedTagsForm from "./delete-bedForm.component";
|
|
8
|
+
|
|
9
|
+
interface DeleteBedTagFormProps {
|
|
10
|
+
showModal: boolean;
|
|
11
|
+
onModalChange: (showModal: boolean) => void;
|
|
12
|
+
editData: BedTagData;
|
|
13
|
+
mutate: Mutator;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DeleteBedTag: React.FC<DeleteBedTagFormProps> = ({
|
|
17
|
+
showModal,
|
|
18
|
+
onModalChange,
|
|
19
|
+
editData,
|
|
20
|
+
mutate,
|
|
21
|
+
}) => {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const headerTitle = t("deleteBedTag", "Delete bed Tag");
|
|
24
|
+
const handleDeleteQuestion = useCallback(
|
|
25
|
+
(formData: BedTagDataAdministration) => {
|
|
26
|
+
const bedUuid = editData.uuid;
|
|
27
|
+
const { name } = formData;
|
|
28
|
+
deleteBedTag(bedUuid)
|
|
29
|
+
.then(() => {
|
|
30
|
+
showToast({
|
|
31
|
+
title: t("bedTagDeleted", "Bed Tag Deleted"),
|
|
32
|
+
kind: "success",
|
|
33
|
+
critical: true,
|
|
34
|
+
description:
|
|
35
|
+
name +
|
|
36
|
+
" " +
|
|
37
|
+
t("bedTagDeleteSuccessMessage", "was deleted successfully."),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
mutate();
|
|
41
|
+
onModalChange(false);
|
|
42
|
+
})
|
|
43
|
+
.catch((error) => {
|
|
44
|
+
showNotification({
|
|
45
|
+
title: t("errorDeletingBedTag", "Error deleting bed tag"),
|
|
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
|
+
<DeleteBedTagsForm
|
|
59
|
+
onModalChange={onModalChange}
|
|
60
|
+
showModal={showModal}
|
|
61
|
+
handleDeleteBedTag={handleDeleteQuestion}
|
|
62
|
+
headerTitle={headerTitle}
|
|
63
|
+
initialData={editData}
|
|
64
|
+
/>
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default DeleteBedTag;
|
|
@@ -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 styles from "../../bed-administration/bed-administration-table.scss";
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
ComposedModal,
|
|
9
|
+
ModalBody,
|
|
10
|
+
ModalFooter,
|
|
11
|
+
ModalHeader,
|
|
12
|
+
Stack,
|
|
13
|
+
InlineNotification,
|
|
14
|
+
} from "@carbon/react";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
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 DeleteBedTagsForm: 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 DeleteBedTagsForm;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
-
import { showToast, showNotification
|
|
3
|
+
import { showToast, showNotification } from "@openmrs/esm-framework";
|
|
4
4
|
|
|
5
5
|
import { editBedTag, useBedTag } from "../../summary/summary.resource";
|
|
6
6
|
import { BedTagDataAdministration } from "../../bed-administration/bed-administration-types";
|
|
@@ -20,11 +20,38 @@ import { Location } from "@openmrs/esm-framework";
|
|
|
20
20
|
import type { BedType, BedTypeData } from "../../types";
|
|
21
21
|
|
|
22
22
|
const BedTypeAdministrationSchema = z.object({
|
|
23
|
-
name: z
|
|
24
|
-
|
|
23
|
+
name: z
|
|
24
|
+
.string()
|
|
25
|
+
.max(255)
|
|
26
|
+
.refine(
|
|
27
|
+
(value) => {
|
|
28
|
+
return (
|
|
29
|
+
typeof value === "string" &&
|
|
30
|
+
value.trim().length > 0 &&
|
|
31
|
+
!/\d/.test(value)
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
message: "Bed Name must be a non-empty string without numbers",
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
displayName: z
|
|
39
|
+
.string()
|
|
40
|
+
.max(255)
|
|
41
|
+
.refine(
|
|
42
|
+
(value) => {
|
|
43
|
+
return (
|
|
44
|
+
typeof value === "string" &&
|
|
45
|
+
value.trim().length > 0 &&
|
|
46
|
+
!/\d/.test(value)
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
message: "Display name must be a non-empty string without numbers",
|
|
51
|
+
}
|
|
52
|
+
),
|
|
25
53
|
description: z.string().max(255),
|
|
26
54
|
});
|
|
27
|
-
|
|
28
55
|
interface BedAdministrationFormProps {
|
|
29
56
|
showModal: boolean;
|
|
30
57
|
onModalChange: (showModal: boolean) => void;
|
|
@@ -92,6 +119,7 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
92
119
|
<Controller
|
|
93
120
|
name="name"
|
|
94
121
|
control={control}
|
|
122
|
+
rules={{ required: true }}
|
|
95
123
|
render={({ field, fieldState }) => (
|
|
96
124
|
<>
|
|
97
125
|
<TextInput
|
|
@@ -109,6 +137,7 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
109
137
|
<Controller
|
|
110
138
|
name="displayName"
|
|
111
139
|
control={control}
|
|
140
|
+
rules={{ required: true }}
|
|
112
141
|
render={({ field, fieldState }) => (
|
|
113
142
|
<>
|
|
114
143
|
<TextInput
|
|
@@ -126,6 +155,7 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
126
155
|
<Controller
|
|
127
156
|
name="description"
|
|
128
157
|
control={control}
|
|
158
|
+
rules={{ required: true }}
|
|
129
159
|
render={({ field, fieldState }) => (
|
|
130
160
|
<>
|
|
131
161
|
<TextArea
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useState } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
@@ -15,10 +15,9 @@ import {
|
|
|
15
15
|
TableRow,
|
|
16
16
|
Tile,
|
|
17
17
|
} from "@carbon/react";
|
|
18
|
-
import { Add, Edit } from "@carbon/react/icons";
|
|
18
|
+
import { Add, Edit, Delete } from "@carbon/react/icons";
|
|
19
19
|
import {
|
|
20
20
|
isDesktop as desktopLayout,
|
|
21
|
-
useConfig,
|
|
22
21
|
useLayoutType,
|
|
23
22
|
} from "@openmrs/esm-framework";
|
|
24
23
|
import { CardHeader, ErrorState } from "@openmrs/esm-patient-common-lib";
|
|
@@ -28,6 +27,7 @@ import Header from "../../header/header.component";
|
|
|
28
27
|
import BedTypeForm from "./new-bed-type-form.component";
|
|
29
28
|
import styles from "../../bed-administration/bed-administration-table.scss";
|
|
30
29
|
import EditBedTypeForm from "./edit-bed-type.component";
|
|
30
|
+
import DeleteBedType from "./delete-bed-type.component";
|
|
31
31
|
|
|
32
32
|
const BedTypeAdministrationTable: React.FC = () => {
|
|
33
33
|
const { t } = useTranslation();
|
|
@@ -37,14 +37,13 @@ const BedTypeAdministrationTable: React.FC = () => {
|
|
|
37
37
|
const responsiveSize = isTablet ? "lg" : "sm";
|
|
38
38
|
const isDesktop = desktopLayout(layout);
|
|
39
39
|
const [showEditBedModal, setShowEditBedModal] = useState(false);
|
|
40
|
-
const [isBedDataLoading
|
|
40
|
+
const [isBedDataLoading] = useState(false);
|
|
41
41
|
const [showBedTypeModal, setAddBedTypeModal] = useState(false);
|
|
42
42
|
const [currentPage, setCurrentPage] = useState(1);
|
|
43
43
|
const [editData, setEditData] = useState<BedTypeData>();
|
|
44
|
+
const [showDeleteBedTypeModal, setDeleteBedTypeModal] = useState(false);
|
|
44
45
|
const [pageSize] = useState(10);
|
|
45
46
|
const { bedTypeData, isError, loading, validate, mutate } = useBedType();
|
|
46
|
-
const [currentPageSize, setPageSize] = useState(10);
|
|
47
|
-
const pageSizes = [10, 20, 30, 40, 50];
|
|
48
47
|
const tableHeaders = [
|
|
49
48
|
{
|
|
50
49
|
header: t("name", "Name"),
|
|
@@ -80,6 +79,7 @@ const BedTypeAdministrationTable: React.FC = () => {
|
|
|
80
79
|
setEditData(entry);
|
|
81
80
|
setShowEditBedModal(true);
|
|
82
81
|
setAddBedTypeModal(false);
|
|
82
|
+
setDeleteBedTypeModal(false);
|
|
83
83
|
}}
|
|
84
84
|
kind={"ghost"}
|
|
85
85
|
iconDescription={t("editBedType", "Edit Bed Type")}
|
|
@@ -87,6 +87,22 @@ const BedTypeAdministrationTable: React.FC = () => {
|
|
|
87
87
|
size={responsiveSize}
|
|
88
88
|
tooltipAlignment="start"
|
|
89
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
|
+
/>
|
|
90
106
|
</>
|
|
91
107
|
),
|
|
92
108
|
}));
|
|
@@ -134,6 +150,14 @@ const BedTypeAdministrationTable: React.FC = () => {
|
|
|
134
150
|
mutate={mutate}
|
|
135
151
|
/>
|
|
136
152
|
) : null}
|
|
153
|
+
{showDeleteBedTypeModal ? (
|
|
154
|
+
<DeleteBedType
|
|
155
|
+
onModalChange={setDeleteBedTypeModal}
|
|
156
|
+
showModal={showDeleteBedTypeModal}
|
|
157
|
+
editData={editData}
|
|
158
|
+
mutate={mutate}
|
|
159
|
+
/>
|
|
160
|
+
) : null}
|
|
137
161
|
<CardHeader title={headerTitle}>
|
|
138
162
|
<span className={styles.backgroundDataFetchingIndicator}>
|
|
139
163
|
<span>{validate ? <InlineLoading /> : null}</span>
|
|
@@ -209,7 +233,7 @@ const BedTypeAdministrationTable: React.FC = () => {
|
|
|
209
233
|
totalItems={bedTypeData.length}
|
|
210
234
|
onChange={({ page, pageSize }) => {
|
|
211
235
|
setCurrentPage(page);
|
|
212
|
-
|
|
236
|
+
pageSize(pageSize);
|
|
213
237
|
}}
|
|
214
238
|
/>
|
|
215
239
|
</TableContainer>
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
-
import { showToast, showNotification
|
|
3
|
+
import { showToast, showNotification } from "@openmrs/esm-framework";
|
|
4
4
|
|
|
5
5
|
import { editBedType, useBedType } from "../../summary/summary.resource";
|
|
6
6
|
import { BedTypeDataAdministration } from "../../bed-administration/bed-administration-types";
|
|
@@ -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;
|
package/src/config-schema.ts
CHANGED
|
@@ -18,14 +18,10 @@ export const configSchema = {
|
|
|
18
18
|
_description: "UUID for the inpatient visit",
|
|
19
19
|
_default: false,
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
patientListForAdmissionUrl: {
|
|
22
22
|
_type: Type.String,
|
|
23
|
-
_description:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
admissionFormUuid: {
|
|
27
|
-
_type: Type.String,
|
|
28
|
-
_description: "UUID for the admission form",
|
|
29
|
-
_default: "e958f902-64df-4819-afd4-7fb061f59308",
|
|
23
|
+
_description:
|
|
24
|
+
"Endpoint for fetching list of patients eligible for ward admission",
|
|
25
|
+
_default: "",
|
|
30
26
|
},
|
|
31
27
|
};
|