@kenyaemr/esm-bed-management-app 1.0.1-pre.7 → 8.0.2
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/.turbo/turbo-build.log +36 -0
- package/README.md +6 -38
- package/dist/130.js +2 -0
- package/dist/{800.js.LICENSE.txt → 130.js.LICENSE.txt} +2 -0
- package/dist/130.js.map +1 -0
- package/dist/148.js +1 -0
- package/dist/148.js.map +1 -0
- package/dist/169.js +1 -0
- package/dist/169.js.map +1 -0
- package/dist/271.js +1 -0
- package/dist/319.js +1 -0
- package/dist/325.js +1 -0
- package/dist/325.js.map +1 -0
- package/dist/339.js +1 -0
- package/dist/339.js.map +1 -0
- package/dist/455.js +1 -1
- package/dist/455.js.LICENSE.txt +6 -0
- package/dist/455.js.map +1 -1
- package/dist/460.js +1 -0
- package/dist/501.js +1 -0
- package/dist/501.js.map +1 -0
- package/dist/542.js +1 -0
- package/dist/542.js.map +1 -0
- package/dist/574.js +1 -1
- package/dist/591.js +2 -0
- package/dist/{26.js.LICENSE.txt → 591.js.LICENSE.txt} +3 -3
- package/dist/591.js.map +1 -0
- package/dist/644.js +1 -0
- package/dist/757.js +1 -0
- package/dist/766.js +2 -0
- package/dist/{330.js.LICENSE.txt → 766.js.LICENSE.txt} +0 -9
- package/dist/766.js.map +1 -0
- package/dist/{294.js → 784.js} +2 -2
- package/dist/{294.js.map → 784.js.map} +1 -1
- package/dist/788.js +1 -0
- package/dist/807.js +1 -0
- package/dist/833.js +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-bed-management-app.js +1 -0
- package/dist/{esm-kenyaemr-bed-management-app.js.buildmanifest.json → openmrs-esm-bed-management-app.js.buildmanifest.json} +202 -155
- package/dist/openmrs-esm-bed-management-app.js.map +1 -0
- package/dist/routes.json +1 -1
- package/jest.config.js +3 -0
- package/package-lock.json +5893 -0
- package/package.json +25 -83
- package/src/__mocks__/react-i18next.js +18 -14
- package/src/admin-card-link.component.tsx +7 -10
- package/src/bed-administration/bed-administration-form.component.tsx +65 -99
- package/src/bed-administration/bed-administration-table.component.tsx +68 -127
- package/src/bed-administration/bed-administration-table.scss +12 -16
- package/src/bed-administration/bed-administration.resource.ts +16 -18
- package/src/bed-administration/edit-bed-form.component.tsx +20 -31
- package/src/bed-administration/new-bed-form.component.tsx +28 -44
- package/src/{bed-admission/bed-tag → bed-tag}/bed-tag-administration-table.component.tsx +35 -60
- package/src/{bed-admission/bed-tag → bed-tag}/bed-tags-admin-form.component.tsx +30 -34
- package/src/{bed-admission/bed-tag → bed-tag}/edit-tag-form.component.tsx +17 -25
- package/src/{bed-admission/bed-tag → bed-tag}/new-tag-form.component.tsx +20 -27
- package/src/{bed-admission/bed-type → bed-type}/bed-type-admin-form.component.tsx +37 -44
- package/src/{bed-admission/bed-type → bed-type}/bed-type-administration-table.component.tsx +36 -60
- package/src/{bed-admission/bed-type → bed-type}/edit-bed-type.component.tsx +17 -25
- package/src/{bed-admission/bed-type → bed-type}/new-bed-type-form.component.tsx +21 -28
- package/src/card-header/card-header.component.tsx +20 -0
- package/src/card-header/card-header.scss +45 -0
- package/src/config-schema.ts +9 -17
- package/src/declarations.d.ts +5 -5
- package/src/empty-state/empty-state.component.tsx +6 -21
- package/src/empty-state/empty-state.scss +10 -10
- package/src/header/header.component.tsx +14 -23
- package/src/header/header.scss +11 -11
- package/src/header/illustration.component.tsx +3 -3
- package/src/home.component.tsx +4 -4
- package/src/index.ts +21 -48
- package/src/left-panel/left-panel.component.tsx +7 -17
- package/src/left-panel/left-panel.scss +8 -7
- package/src/left-panel-link.component.tsx +14 -24
- package/src/root.component.tsx +12 -12
- package/src/root.scss +2 -2
- package/src/routes.json +12 -12
- package/src/setup-tests.ts +1 -1
- package/src/summary/summary.component.tsx +16 -30
- package/src/summary/summary.resource.ts +116 -95
- package/src/summary/summary.scss +31 -29
- package/src/types.ts +50 -40
- package/src/ward-card/ward-card.component.tsx +5 -12
- package/src/ward-card/ward-card.scss +2 -2
- package/src/ward-with-beds/ward-with-beds.component.tsx +28 -47
- package/src/ward-with-beds/ward-with-beds.scss +5 -5
- package/translations/am.json +51 -0
- package/translations/ar.json +51 -0
- package/translations/en.json +48 -4
- package/translations/es.json +51 -0
- package/translations/fr.json +51 -0
- package/translations/he.json +51 -0
- package/translations/km.json +51 -0
- package/translations/zh.json +51 -0
- package/translations/zh_CN.json +51 -0
- package/tsconfig.json +3 -21
- package/webpack.config.js +1 -1
- package/.editorconfig +0 -12
- package/.eslintignore +0 -2
- package/.eslintrc +0 -37
- package/.husky/pre-commit +0 -4
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.prettierignore +0 -14
- package/.turbo.json +0 -18
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
- package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
- package/.yarn/versions/cb9a89ac.yml +0 -0
- package/LICENSE +0 -373
- 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/26.js +0 -2
- package/dist/26.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/558.js +0 -2
- package/dist/558.js.LICENSE.txt +0 -14
- package/dist/558.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.map +0 -1
- package/dist/850.js +0 -1
- package/dist/850.js.map +0 -1
- package/dist/884.js +0 -1
- package/dist/884.js.map +0 -1
- package/dist/933.js +0 -1
- package/dist/933.js.map +0 -1
- package/dist/esm-kenyaemr-bed-management-app.js +0 -1
- package/dist/esm-kenyaemr-bed-management-app.js.map +0 -1
- package/i18next-parser.config.js +0 -89
- package/src/assets/landing-page.png +0 -0
- package/src/assets/logo.svg +0 -1
- package/src/bed-admission/active-patients/active-patients-table.component.tsx +0 -299
- package/src/bed-admission/active-patients/active-visits.resource.ts +0 -171
- package/src/bed-admission/active-patients/admission-action-button-styles.scss +0 -0
- package/src/bed-admission/active-patients/admission-action-button.component.tsx +0 -26
- package/src/bed-admission/active-patients/index.tsx +0 -15
- package/src/bed-admission/active-patients/patient-queues.resource.ts +0 -136
- package/src/bed-admission/active-patients/styles.scss +0 -284
- package/src/bed-admission/active-patients/view-action-menu.component.tsx +0 -33
- package/src/bed-admission/admitted-patients/active-admissions.resource.ts +0 -121
- package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +0 -280
- package/src/bed-admission/admitted-patients/admitted-patients.component.tsx +0 -22
- package/src/bed-admission/admitted-patients/location-combo-box.component.tsx +0 -55
- package/src/bed-admission/admitted-patients/styles.scss +0 -284
- package/src/bed-admission/bed-admission-tabs-styles.scss +0 -30
- package/src/bed-admission/bed-admission-tabs.component.tsx +0 -69
- package/src/bed-admission/bed-admission.component.tsx +0 -15
- package/src/bed-admission/bed-admission.resource.ts +0 -35
- package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +0 -101
- package/src/bed-admission/bed-layout/bed-layout.component.tsx +0 -64
- package/src/bed-admission/bed-layout/bed-layout.scss +0 -118
- package/src/bed-admission/bed-layout/min-bed-layout.component.tsx +0 -26
- package/src/bed-admission/createDashboardLink.tsx +0 -47
- package/src/bed-admission/discharged-patients/discharged-patients.componet.tsx +0 -19
- package/src/bed-admission/helpers/functions.ts +0 -102
- package/src/bed-admission/types.ts +0 -133
- package/src/workspace/allocate-bed-workspace.component.tsx +0 -141
- package/src/workspace/allocate-bed.scss +0 -117
- package/src/workspace/overlay.component.tsx +0 -55
- package/src/workspace/overlay.scss +0 -96
- /package/dist/{294.js.LICENSE.txt → 784.js.LICENSE.txt} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from
|
|
2
|
-
import { useTranslation } from
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
5
5
|
DataTable,
|
|
@@ -16,39 +16,36 @@ import {
|
|
|
16
16
|
TableRow,
|
|
17
17
|
Tag,
|
|
18
18
|
Tile,
|
|
19
|
-
} from
|
|
20
|
-
import { Add, Edit } from
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import { findBedByLocation, useWards } from "../summary/summary.resource";
|
|
30
|
-
import EditBedForm from "./edit-bed-form.component";
|
|
31
|
-
import Header from "../header/header.component";
|
|
32
|
-
import NewBedForm from "./new-bed-form.component";
|
|
33
|
-
import styles from "./bed-administration-table.scss";
|
|
19
|
+
} from '@carbon/react';
|
|
20
|
+
import { Add, Edit } from '@carbon/react/icons';
|
|
21
|
+
import { ErrorState, isDesktop as desktopLayout, useLayoutType, usePagination } from '@openmrs/esm-framework';
|
|
22
|
+
import type { BedFormData } from '../types';
|
|
23
|
+
import { useBedsGroupedByLocation } from '../summary/summary.resource';
|
|
24
|
+
import EditBedForm from './edit-bed-form.component';
|
|
25
|
+
import Header from '../header/header.component';
|
|
26
|
+
import NewBedForm from './new-bed-form.component';
|
|
27
|
+
import styles from './bed-administration-table.scss';
|
|
28
|
+
import { CardHeader } from '../card-header/card-header.component';
|
|
34
29
|
|
|
35
30
|
const BedAdministrationTable: React.FC = () => {
|
|
36
31
|
const { t } = useTranslation();
|
|
37
|
-
const headerTitle = t(
|
|
32
|
+
const headerTitle = t('wardAllocation', 'Ward Allocation');
|
|
38
33
|
const layout = useLayoutType();
|
|
39
|
-
const isTablet = layout ===
|
|
40
|
-
const responsiveSize = isTablet ?
|
|
34
|
+
const isTablet = layout === 'tablet';
|
|
35
|
+
const responsiveSize = isTablet ? 'lg' : 'sm';
|
|
41
36
|
const isDesktop = desktopLayout(layout);
|
|
42
|
-
const { admissionLocationTagUuid } = useConfig();
|
|
43
37
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const {
|
|
39
|
+
data: wardsGroupedByLocations,
|
|
40
|
+
isLoading: isLoadingBeds,
|
|
41
|
+
isValidating,
|
|
42
|
+
mutate,
|
|
43
|
+
error,
|
|
44
|
+
} = useBedsGroupedByLocation();
|
|
48
45
|
const [showAddBedModal, setShowAddBedModal] = useState(false);
|
|
49
46
|
const [showEditBedModal, setShowEditBedModal] = useState(false);
|
|
50
|
-
const [editData, setEditData] = useState<
|
|
51
|
-
const [filterOption, setFilterOption] = useState(
|
|
47
|
+
const [editData, setEditData] = useState<BedFormData>();
|
|
48
|
+
const [filterOption, setFilterOption] = useState('ALL');
|
|
52
49
|
|
|
53
50
|
function CustomTag({ condition }: { condition: boolean }) {
|
|
54
51
|
const { t } = useTranslation();
|
|
@@ -56,14 +53,14 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
56
53
|
if (condition) {
|
|
57
54
|
return (
|
|
58
55
|
<Tag type="green" size="md">
|
|
59
|
-
{t(
|
|
56
|
+
{t('yes', 'Yes')}
|
|
60
57
|
</Tag>
|
|
61
58
|
);
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
return (
|
|
65
62
|
<Tag type="red" size="md">
|
|
66
|
-
{t(
|
|
63
|
+
{t('no', 'No')}
|
|
67
64
|
</Tag>
|
|
68
65
|
);
|
|
69
66
|
}
|
|
@@ -71,76 +68,44 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
71
68
|
const handleBedStatusChange = ({ selectedItem }: { selectedItem: string }) =>
|
|
72
69
|
setFilterOption(selectedItem.trim().toUpperCase());
|
|
73
70
|
|
|
74
|
-
const
|
|
75
|
-
? [].concat(...wardsGroupedByLocations)
|
|
76
|
-
: [];
|
|
77
|
-
|
|
78
|
-
const { data, isLoading, error, isValidating, mutate } = useWards(
|
|
79
|
-
admissionLocationTagUuid
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const [currentPageSize, setPageSize] = useState(10);
|
|
83
|
-
const pageSizes = [10, 20, 30, 40, 50];
|
|
71
|
+
const [pageSize, setPageSize] = useState(10);
|
|
84
72
|
const { results, currentPage, totalPages, goTo } = usePagination(
|
|
85
|
-
filterOption ===
|
|
86
|
-
?
|
|
87
|
-
:
|
|
88
|
-
|
|
73
|
+
filterOption === 'ALL'
|
|
74
|
+
? wardsGroupedByLocations
|
|
75
|
+
: wardsGroupedByLocations.filter((bed) => bed.status === filterOption) ?? [],
|
|
76
|
+
pageSize,
|
|
89
77
|
);
|
|
90
78
|
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
if (!isLoading && data) {
|
|
93
|
-
setIsBedDataLoading(true);
|
|
94
|
-
const fetchData = async () => {
|
|
95
|
-
const promises = data.data.results.map(async (ward) => {
|
|
96
|
-
const bedLocations = await findBedByLocation(ward.uuid);
|
|
97
|
-
if (bedLocations.data.results.length) {
|
|
98
|
-
return bedLocations.data.results.map((bed) => ({
|
|
99
|
-
...bed,
|
|
100
|
-
location: ward,
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
return null;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const updatedWards = (await Promise.all(promises)).filter(Boolean);
|
|
107
|
-
setWardsGroupedByLocation(updatedWards);
|
|
108
|
-
setIsBedDataLoading(false);
|
|
109
|
-
};
|
|
110
|
-
fetchData().finally(() => setIsBedDataLoading(false));
|
|
111
|
-
}
|
|
112
|
-
}, [data, isLoading, wardsGroupedByLocations.length]);
|
|
113
|
-
|
|
114
79
|
const tableHeaders = [
|
|
115
80
|
{
|
|
116
|
-
key:
|
|
117
|
-
header: t(
|
|
81
|
+
key: 'bedNumber',
|
|
82
|
+
header: t('bedId', 'Bed ID'),
|
|
118
83
|
},
|
|
119
84
|
{
|
|
120
|
-
key:
|
|
121
|
-
header: t(
|
|
85
|
+
key: 'location',
|
|
86
|
+
header: t('location', 'Location'),
|
|
122
87
|
},
|
|
123
88
|
{
|
|
124
|
-
key:
|
|
125
|
-
header: t(
|
|
89
|
+
key: 'occupancyStatus',
|
|
90
|
+
header: t('occupancyStatus', 'Occupied'),
|
|
126
91
|
},
|
|
127
92
|
{
|
|
128
|
-
key:
|
|
129
|
-
header: t(
|
|
93
|
+
key: 'allocationStatus',
|
|
94
|
+
header: t('allocationStatus', 'Allocated'),
|
|
130
95
|
},
|
|
131
96
|
{
|
|
132
|
-
key:
|
|
133
|
-
header: t(
|
|
97
|
+
key: 'actions',
|
|
98
|
+
header: t('actions', 'Actions'),
|
|
134
99
|
},
|
|
135
100
|
];
|
|
136
101
|
|
|
137
102
|
const tableRows = useMemo(() => {
|
|
138
|
-
return results.map((
|
|
139
|
-
id:
|
|
140
|
-
bedNumber:
|
|
141
|
-
location:
|
|
142
|
-
occupancyStatus: <CustomTag condition={
|
|
143
|
-
allocationStatus: <CustomTag condition={
|
|
103
|
+
return results.flat().map((bed) => ({
|
|
104
|
+
id: bed.uuid,
|
|
105
|
+
bedNumber: bed.bedNumber,
|
|
106
|
+
location: bed.location.display,
|
|
107
|
+
occupancyStatus: <CustomTag condition={bed?.status === 'OCCUPIED'} />,
|
|
108
|
+
allocationStatus: <CustomTag condition={Boolean(bed.location?.uuid)} />,
|
|
144
109
|
actions: (
|
|
145
110
|
<>
|
|
146
111
|
<Button
|
|
@@ -148,12 +113,12 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
148
113
|
renderIcon={Edit}
|
|
149
114
|
onClick={(e) => {
|
|
150
115
|
e.preventDefault();
|
|
151
|
-
setEditData(
|
|
116
|
+
setEditData(bed);
|
|
152
117
|
setShowEditBedModal(true);
|
|
153
118
|
setShowAddBedModal(false);
|
|
154
119
|
}}
|
|
155
|
-
kind={
|
|
156
|
-
iconDescription={t(
|
|
120
|
+
kind={'ghost'}
|
|
121
|
+
iconDescription={t('editBed', 'Edit Bed')}
|
|
157
122
|
hasIconOnly
|
|
158
123
|
size={responsiveSize}
|
|
159
124
|
tooltipAlignment="start"
|
|
@@ -163,7 +128,7 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
163
128
|
}));
|
|
164
129
|
}, [responsiveSize, results, t]);
|
|
165
130
|
|
|
166
|
-
if (
|
|
131
|
+
if (isLoadingBeds && !wardsGroupedByLocations.length) {
|
|
167
132
|
return (
|
|
168
133
|
<>
|
|
169
134
|
<Header route="Ward Allocation" />
|
|
@@ -193,13 +158,11 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
193
158
|
<div className={styles.filterContainer}>
|
|
194
159
|
<Dropdown
|
|
195
160
|
id="occupancyStatus"
|
|
196
|
-
initialSelectedItem={
|
|
161
|
+
initialSelectedItem={'All'}
|
|
197
162
|
label=""
|
|
198
|
-
titleText={
|
|
199
|
-
t("filterByOccupancyStatus", "Filter by occupancy status") + ":"
|
|
200
|
-
}
|
|
163
|
+
titleText={t('filterByOccupancyStatus', 'Filter by occupancy status') + ':'}
|
|
201
164
|
type="inline"
|
|
202
|
-
items={[
|
|
165
|
+
items={['All', 'Available', 'Occupied']}
|
|
203
166
|
onChange={handleBedStatusChange}
|
|
204
167
|
/>
|
|
205
168
|
</div>
|
|
@@ -207,11 +170,7 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
207
170
|
</div>
|
|
208
171
|
<div className={styles.widgetCard}>
|
|
209
172
|
{showAddBedModal ? (
|
|
210
|
-
<NewBedForm
|
|
211
|
-
onModalChange={setShowAddBedModal}
|
|
212
|
-
showModal={showAddBedModal}
|
|
213
|
-
mutate={mutate}
|
|
214
|
-
/>
|
|
173
|
+
<NewBedForm onModalChange={setShowAddBedModal} showModal={showAddBedModal} mutate={mutate} />
|
|
215
174
|
) : null}
|
|
216
175
|
{showEditBedModal ? (
|
|
217
176
|
<EditBedForm
|
|
@@ -229,28 +188,19 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
229
188
|
<Button
|
|
230
189
|
kind="ghost"
|
|
231
190
|
renderIcon={(props) => <Add size={16} {...props} />}
|
|
232
|
-
onClick={() => setShowAddBedModal(true)}
|
|
233
|
-
|
|
234
|
-
{t("addBed", "Add bed")}
|
|
191
|
+
onClick={() => setShowAddBedModal(true)}>
|
|
192
|
+
{t('addBed', 'Add bed')}
|
|
235
193
|
</Button>
|
|
236
194
|
) : null}
|
|
237
195
|
</CardHeader>
|
|
238
|
-
<DataTable
|
|
239
|
-
rows={tableRows}
|
|
240
|
-
headers={tableHeaders}
|
|
241
|
-
isSortable
|
|
242
|
-
size={isTablet ? "lg" : "sm"}
|
|
243
|
-
useZebraStyles
|
|
244
|
-
>
|
|
196
|
+
<DataTable rows={tableRows} headers={tableHeaders} isSortable size={isTablet ? 'lg' : 'sm'} useZebraStyles>
|
|
245
197
|
{({ rows, headers, getTableProps }) => (
|
|
246
198
|
<TableContainer>
|
|
247
199
|
<Table {...getTableProps()}>
|
|
248
200
|
<TableHead>
|
|
249
201
|
<TableRow>
|
|
250
202
|
{headers.map((header) => (
|
|
251
|
-
<TableHeader>
|
|
252
|
-
{header.header?.content ?? header.header}
|
|
253
|
-
</TableHeader>
|
|
203
|
+
<TableHeader>{header.header?.content ?? header.header}</TableHeader>
|
|
254
204
|
))}
|
|
255
205
|
</TableRow>
|
|
256
206
|
</TableHead>
|
|
@@ -258,9 +208,7 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
258
208
|
{rows.map((row) => (
|
|
259
209
|
<TableRow key={row.id}>
|
|
260
210
|
{row.cells.map((cell) => (
|
|
261
|
-
<TableCell key={cell.id}>
|
|
262
|
-
{cell.value?.content ?? cell.value}
|
|
263
|
-
</TableCell>
|
|
211
|
+
<TableCell key={cell.id}>{cell.value?.content ?? cell.value}</TableCell>
|
|
264
212
|
))}
|
|
265
213
|
</TableRow>
|
|
266
214
|
))}
|
|
@@ -270,21 +218,16 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
270
218
|
<div className={styles.tileContainer}>
|
|
271
219
|
<Tile className={styles.tile}>
|
|
272
220
|
<div className={styles.tileContent}>
|
|
273
|
-
<p className={styles.content}>
|
|
274
|
-
|
|
275
|
-
</p>
|
|
276
|
-
<p className={styles.helper}>
|
|
277
|
-
{t("checkFilters", "Check the filters above")}
|
|
278
|
-
</p>
|
|
221
|
+
<p className={styles.content}>{t('No data', 'No data to display')}</p>
|
|
222
|
+
<p className={styles.helper}>{t('checkFilters', 'Check the filters above')}</p>
|
|
279
223
|
</div>
|
|
280
|
-
<p className={styles.separator}>{t(
|
|
224
|
+
<p className={styles.separator}>{t('or', 'or')}</p>
|
|
281
225
|
<Button
|
|
282
226
|
kind="ghost"
|
|
283
227
|
size="sm"
|
|
284
228
|
renderIcon={(props) => <Add size={16} {...props} />}
|
|
285
|
-
onClick={() => setShowAddBedModal(true)}
|
|
286
|
-
|
|
287
|
-
{t("addBed", "Add bed")}
|
|
229
|
+
onClick={() => setShowAddBedModal(true)}>
|
|
230
|
+
{t('addBed', 'Add bed')}
|
|
288
231
|
</Button>
|
|
289
232
|
</Tile>
|
|
290
233
|
</div>
|
|
@@ -295,12 +238,10 @@ const BedAdministrationTable: React.FC = () => {
|
|
|
295
238
|
page={currentPage}
|
|
296
239
|
pageNumberText="Page Number"
|
|
297
240
|
pageSize={totalPages}
|
|
298
|
-
pageSizes={
|
|
299
|
-
totalItems={
|
|
241
|
+
pageSizes={[10, 20, 30, 40, 50]}
|
|
242
|
+
totalItems={wardsGroupedByLocations.length}
|
|
300
243
|
onChange={({ pageSize, page }) => {
|
|
301
|
-
|
|
302
|
-
setPageSize(pageSize);
|
|
303
|
-
}
|
|
244
|
+
setPageSize(pageSize);
|
|
304
245
|
if (page !== currentPage) {
|
|
305
246
|
goTo(page);
|
|
306
247
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
2
3
|
@use '@carbon/type';
|
|
3
4
|
|
|
4
5
|
.widgetCard {
|
|
5
6
|
border: 1px solid colors.$gray-20;
|
|
6
|
-
margin:
|
|
7
|
-
|
|
8
|
-
:global(.cds--modal-content) {
|
|
9
|
-
margin-bottom: unset;
|
|
10
|
-
}
|
|
7
|
+
margin: layout.$spacing-06;
|
|
11
8
|
|
|
12
9
|
@media (min-width: 66rem) {
|
|
13
10
|
:global(.cds--modal-container) {
|
|
@@ -20,16 +17,15 @@
|
|
|
20
17
|
:global(.cds--modal-container) {
|
|
21
18
|
max-height: 100%;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
.flexContainer {
|
|
28
24
|
display: flex;
|
|
29
25
|
justify-content: space-between;
|
|
30
|
-
padding: 0
|
|
31
|
-
margin-top:
|
|
32
|
-
margin-left:
|
|
26
|
+
padding: 0 layout.$spacing-05;
|
|
27
|
+
margin-top: layout.$spacing-07;
|
|
28
|
+
margin-left: layout.$spacing-03;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
.filterContainer {
|
|
@@ -40,7 +36,7 @@
|
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
:global(.cds--list-box__menu-icon) {
|
|
43
|
-
height:
|
|
39
|
+
height: layout.$spacing-05;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
|
|
@@ -53,7 +49,7 @@
|
|
|
53
49
|
.tileContainer {
|
|
54
50
|
background-color: colors.$white-0;
|
|
55
51
|
border-top: 1px solid colors.$gray-20;
|
|
56
|
-
padding:
|
|
52
|
+
padding: layout.$spacing-09 0;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
.tile {
|
|
@@ -73,7 +69,7 @@
|
|
|
73
69
|
.content {
|
|
74
70
|
@include type.type-style('heading-compact-02');
|
|
75
71
|
color: colors.$gray-70;
|
|
76
|
-
margin-bottom:
|
|
72
|
+
margin-bottom: layout.$spacing-03;
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
.helper {
|
|
@@ -85,7 +81,7 @@
|
|
|
85
81
|
@include type.type-style('body-compact-02');
|
|
86
82
|
color: colors.$gray-70;
|
|
87
83
|
width: 80%;
|
|
88
|
-
margin:
|
|
84
|
+
margin: layout.$spacing-06 auto;
|
|
89
85
|
overflow: hidden;
|
|
90
86
|
text-align: center;
|
|
91
87
|
|
|
@@ -101,12 +97,12 @@
|
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
&::before {
|
|
104
|
-
right:
|
|
100
|
+
right: layout.$spacing-03;
|
|
105
101
|
margin-left: -50%;
|
|
106
102
|
}
|
|
107
103
|
|
|
108
104
|
&::after {
|
|
109
|
-
left:
|
|
105
|
+
left: layout.$spacing-03;
|
|
110
106
|
margin-right: -50%;
|
|
111
107
|
}
|
|
112
|
-
}
|
|
108
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useMemo } from
|
|
2
|
-
import useSWR from
|
|
3
|
-
import { FetchResponse, openmrsFetch } from
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
|
|
4
|
+
import { type BedPostPayload } from '../types';
|
|
4
5
|
|
|
5
6
|
interface BedForm {
|
|
6
7
|
bedNumber: string;
|
|
@@ -11,10 +12,10 @@ interface BedForm {
|
|
|
11
12
|
locationUuid: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export async function saveBed({ bedPayload }): Promise<FetchResponse<BedForm>> {
|
|
15
|
+
export async function saveBed({ bedPayload }: { bedPayload: BedPostPayload }): Promise<FetchResponse<BedForm>> {
|
|
15
16
|
const response: FetchResponse = await openmrsFetch(`/ws/rest/v1/bed`, {
|
|
16
|
-
method:
|
|
17
|
-
headers: {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: { 'Content-Type': 'application/json' },
|
|
18
19
|
body: bedPayload,
|
|
19
20
|
});
|
|
20
21
|
return response;
|
|
@@ -22,10 +23,7 @@ export async function saveBed({ bedPayload }): Promise<FetchResponse<BedForm>> {
|
|
|
22
23
|
|
|
23
24
|
export function useBedType() {
|
|
24
25
|
const locationsUrl = `/ws/rest/v1/bedtype`;
|
|
25
|
-
const { data, error, isLoading } = useSWR<{ data }>(
|
|
26
|
-
locationsUrl,
|
|
27
|
-
openmrsFetch
|
|
28
|
-
);
|
|
26
|
+
const { data, error, isLoading } = useSWR<{ data }>(locationsUrl, openmrsFetch);
|
|
29
27
|
|
|
30
28
|
const bedTypes = useMemo(() => {
|
|
31
29
|
const rawData = data?.data?.results ?? [];
|
|
@@ -46,14 +44,14 @@ export function useBedType() {
|
|
|
46
44
|
export async function editBed({
|
|
47
45
|
bedPayload,
|
|
48
46
|
bedId,
|
|
47
|
+
}: {
|
|
48
|
+
bedPayload: BedPostPayload;
|
|
49
|
+
bedId: string;
|
|
49
50
|
}): Promise<FetchResponse<BedForm>> {
|
|
50
|
-
const response: FetchResponse = await openmrsFetch(
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
body: bedPayload,
|
|
56
|
-
}
|
|
57
|
-
);
|
|
51
|
+
const response: FetchResponse = await openmrsFetch(`/ws/rest/v1/bed/${bedId}`, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: { 'Content-Type': 'application/json' },
|
|
54
|
+
body: bedPayload,
|
|
55
|
+
});
|
|
58
56
|
return response;
|
|
59
57
|
}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
import React, { useCallback } from
|
|
2
|
-
import { useTranslation } from
|
|
3
|
-
import { showToast, showNotification
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { showToast, showNotification } from '@openmrs/esm-framework';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import { useBedType, editBed } from
|
|
7
|
-
import BedAdministrationForm from
|
|
8
|
-
import { BedAdministrationData } from
|
|
9
|
-
import {
|
|
5
|
+
import type { BedFormData } from '../types';
|
|
6
|
+
import { useBedType, editBed } from './bed-administration.resource';
|
|
7
|
+
import BedAdministrationForm from './bed-administration-form.component';
|
|
8
|
+
import { type BedAdministrationData } from './bed-administration-types';
|
|
9
|
+
import { useLocationsWithAdmissionTag } from '../summary/summary.resource';
|
|
10
10
|
|
|
11
11
|
interface EditBedFormProps {
|
|
12
12
|
showModal: boolean;
|
|
13
13
|
onModalChange: (showModal: boolean) => void;
|
|
14
|
-
editData:
|
|
15
|
-
mutate:
|
|
14
|
+
editData: BedFormData;
|
|
15
|
+
mutate: () => any;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const EditBedForm: React.FC<EditBedFormProps> = ({
|
|
19
|
-
showModal,
|
|
20
|
-
onModalChange,
|
|
21
|
-
editData,
|
|
22
|
-
mutate,
|
|
23
|
-
}) => {
|
|
18
|
+
const EditBedForm: React.FC<EditBedFormProps> = ({ showModal, onModalChange, editData, mutate }) => {
|
|
24
19
|
const { t } = useTranslation();
|
|
25
|
-
const {
|
|
26
|
-
const { data: admissionLocations } = useLocationsByTag(
|
|
27
|
-
admissionLocationTagUuid
|
|
28
|
-
);
|
|
20
|
+
const { data: admissionLocations } = useLocationsWithAdmissionTag();
|
|
29
21
|
|
|
30
|
-
const headerTitle = t(
|
|
31
|
-
const occupancyStatuses = [
|
|
22
|
+
const headerTitle = t('editBed', 'Edit bed');
|
|
23
|
+
const occupancyStatuses = ['Available', 'Occupied'];
|
|
32
24
|
const { bedTypes } = useBedType();
|
|
33
25
|
const availableBedTypes = bedTypes ? bedTypes : [];
|
|
34
26
|
const handleCreateQuestion = useCallback(
|
|
@@ -55,13 +47,10 @@ const EditBedForm: React.FC<EditBedFormProps> = ({
|
|
|
55
47
|
editBed({ bedPayload, bedId: bedUuid })
|
|
56
48
|
.then(() => {
|
|
57
49
|
showToast({
|
|
58
|
-
title: t(
|
|
59
|
-
kind:
|
|
50
|
+
title: t('formSaved', 'Bed saved'),
|
|
51
|
+
kind: 'success',
|
|
60
52
|
critical: true,
|
|
61
|
-
description:
|
|
62
|
-
bedPayload.bedNumber +
|
|
63
|
-
" " +
|
|
64
|
-
t("saveSuccessMessage", "was saved successfully."),
|
|
53
|
+
description: bedPayload.bedNumber + ' ' + t('saveSuccessMessage', 'was saved successfully.'),
|
|
65
54
|
});
|
|
66
55
|
|
|
67
56
|
mutate();
|
|
@@ -69,8 +58,8 @@ const EditBedForm: React.FC<EditBedFormProps> = ({
|
|
|
69
58
|
})
|
|
70
59
|
.catch((error) => {
|
|
71
60
|
showNotification({
|
|
72
|
-
title: t(
|
|
73
|
-
kind:
|
|
61
|
+
title: t('errorCreatingForm', 'Error creating bed'),
|
|
62
|
+
kind: 'error',
|
|
74
63
|
critical: true,
|
|
75
64
|
description: error?.message,
|
|
76
65
|
});
|
|
@@ -78,7 +67,7 @@ const EditBedForm: React.FC<EditBedFormProps> = ({
|
|
|
78
67
|
});
|
|
79
68
|
onModalChange(false);
|
|
80
69
|
},
|
|
81
|
-
[onModalChange, mutate, editData, t]
|
|
70
|
+
[onModalChange, mutate, editData, t],
|
|
82
71
|
);
|
|
83
72
|
|
|
84
73
|
return (
|
|
@@ -1,61 +1,45 @@
|
|
|
1
|
-
import React, { useCallback } from
|
|
2
|
-
import { useTranslation } from
|
|
3
|
-
import { showToast, showNotification
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { showToast, showNotification } from '@openmrs/esm-framework';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import { useBedType, saveBed } from
|
|
7
|
-
import BedAdministrationForm from
|
|
8
|
-
import {
|
|
9
|
-
import { BedAdministrationData } from
|
|
5
|
+
import type { BedFormData } from '../types';
|
|
6
|
+
import { useBedType, saveBed } from './bed-administration.resource';
|
|
7
|
+
import BedAdministrationForm from './bed-administration-form.component';
|
|
8
|
+
import { useLocationsWithAdmissionTag } from '../summary/summary.resource';
|
|
9
|
+
import { type BedAdministrationData } from './bed-administration-types';
|
|
10
10
|
|
|
11
11
|
interface NewBedFormProps {
|
|
12
12
|
showModal: boolean;
|
|
13
13
|
onModalChange: (showModal: boolean) => void;
|
|
14
|
-
mutate:
|
|
14
|
+
mutate: () => any;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const NewBedForm: React.FC<NewBedFormProps> = ({
|
|
18
|
-
showModal,
|
|
19
|
-
onModalChange,
|
|
20
|
-
mutate,
|
|
21
|
-
}) => {
|
|
17
|
+
const NewBedForm: React.FC<NewBedFormProps> = ({ showModal, onModalChange, mutate }) => {
|
|
22
18
|
const { t } = useTranslation();
|
|
23
|
-
const {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
const headerTitle = t("createNewBed", "Create a new bed");
|
|
28
|
-
const occupancyStatuses = ["Available", "Occupied"];
|
|
19
|
+
const { data: admissionLocations } = useLocationsWithAdmissionTag();
|
|
20
|
+
const headerTitle = t('createNewBed', 'Create a new bed');
|
|
21
|
+
const occupancyStatuses = ['Available', 'Occupied'];
|
|
29
22
|
const { bedTypes } = useBedType();
|
|
30
23
|
const availableBedTypes = bedTypes ? bedTypes : [];
|
|
31
24
|
|
|
32
|
-
const initialData:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
const initialData: BedFormData = {
|
|
26
|
+
id: 0,
|
|
27
|
+
uuid: '',
|
|
28
|
+
bedNumber: '',
|
|
29
|
+
status: null,
|
|
30
|
+
description: '',
|
|
37
31
|
row: 0,
|
|
38
32
|
column: 0,
|
|
39
33
|
location: {
|
|
40
|
-
display:
|
|
41
|
-
uuid:
|
|
42
|
-
},
|
|
43
|
-
bedType: {
|
|
44
|
-
name: "",
|
|
34
|
+
display: '',
|
|
35
|
+
uuid: '',
|
|
45
36
|
},
|
|
37
|
+
bedType: null,
|
|
46
38
|
};
|
|
47
39
|
|
|
48
40
|
const handleCreateQuestion = useCallback(
|
|
49
41
|
(formData: BedAdministrationData) => {
|
|
50
|
-
const {
|
|
51
|
-
bedId,
|
|
52
|
-
description,
|
|
53
|
-
occupancyStatus,
|
|
54
|
-
bedRow,
|
|
55
|
-
bedColumn,
|
|
56
|
-
location,
|
|
57
|
-
bedType,
|
|
58
|
-
} = formData;
|
|
42
|
+
const { bedId, description, occupancyStatus, bedRow, bedColumn, location, bedType } = formData;
|
|
59
43
|
|
|
60
44
|
const bedObject = {
|
|
61
45
|
bedNumber: bedId,
|
|
@@ -70,8 +54,8 @@ const NewBedForm: React.FC<NewBedFormProps> = ({
|
|
|
70
54
|
saveBed({ bedPayload: bedObject })
|
|
71
55
|
.then(() => {
|
|
72
56
|
showToast({
|
|
73
|
-
title: t(
|
|
74
|
-
kind:
|
|
57
|
+
title: t('formCreated', 'New bed created'),
|
|
58
|
+
kind: 'success',
|
|
75
59
|
critical: true,
|
|
76
60
|
description: `Bed ${bedId} was created successfully.`,
|
|
77
61
|
});
|
|
@@ -81,8 +65,8 @@ const NewBedForm: React.FC<NewBedFormProps> = ({
|
|
|
81
65
|
})
|
|
82
66
|
.catch((error) => {
|
|
83
67
|
showNotification({
|
|
84
|
-
title: t(
|
|
85
|
-
kind:
|
|
68
|
+
title: t('errorCreatingForm', 'Error creating bed'),
|
|
69
|
+
kind: 'error',
|
|
86
70
|
critical: true,
|
|
87
71
|
description: error?.message,
|
|
88
72
|
});
|
|
@@ -90,7 +74,7 @@ const NewBedForm: React.FC<NewBedFormProps> = ({
|
|
|
90
74
|
});
|
|
91
75
|
onModalChange(false);
|
|
92
76
|
},
|
|
93
|
-
[onModalChange, mutate, t]
|
|
77
|
+
[onModalChange, mutate, t],
|
|
94
78
|
);
|
|
95
79
|
|
|
96
80
|
return (
|