@kenyaemr/esm-bed-management-app 1.0.1-pre.7 → 8.1.1-pre.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/.turbo/turbo-build.log +36 -0
  2. package/README.md +6 -38
  3. package/dist/130.js +2 -0
  4. package/dist/{800.js.LICENSE.txt → 130.js.LICENSE.txt} +2 -0
  5. package/dist/130.js.map +1 -0
  6. package/dist/148.js +1 -0
  7. package/dist/148.js.map +1 -0
  8. package/dist/169.js +1 -0
  9. package/dist/169.js.map +1 -0
  10. package/dist/271.js +1 -0
  11. package/dist/319.js +1 -0
  12. package/dist/325.js +1 -0
  13. package/dist/325.js.map +1 -0
  14. package/dist/339.js +1 -0
  15. package/dist/339.js.map +1 -0
  16. package/dist/455.js +1 -1
  17. package/dist/455.js.LICENSE.txt +6 -0
  18. package/dist/455.js.map +1 -1
  19. package/dist/460.js +1 -0
  20. package/dist/501.js +1 -0
  21. package/dist/501.js.map +1 -0
  22. package/dist/542.js +1 -0
  23. package/dist/542.js.map +1 -0
  24. package/dist/574.js +1 -1
  25. package/dist/591.js +2 -0
  26. package/dist/{26.js.LICENSE.txt → 591.js.LICENSE.txt} +3 -3
  27. package/dist/591.js.map +1 -0
  28. package/dist/644.js +1 -0
  29. package/dist/757.js +1 -0
  30. package/dist/766.js +2 -0
  31. package/dist/{330.js.LICENSE.txt → 766.js.LICENSE.txt} +0 -9
  32. package/dist/766.js.map +1 -0
  33. package/dist/{294.js → 784.js} +2 -2
  34. package/dist/{294.js.map → 784.js.map} +1 -1
  35. package/dist/788.js +1 -0
  36. package/dist/807.js +1 -0
  37. package/dist/833.js +1 -0
  38. package/dist/main.js +1 -1
  39. package/dist/main.js.map +1 -1
  40. package/dist/openmrs-esm-bed-management-app.js +1 -0
  41. package/dist/{esm-kenyaemr-bed-management-app.js.buildmanifest.json → openmrs-esm-bed-management-app.js.buildmanifest.json} +202 -155
  42. package/dist/openmrs-esm-bed-management-app.js.map +1 -0
  43. package/dist/routes.json +1 -1
  44. package/jest.config.js +3 -0
  45. package/package.json +25 -82
  46. package/src/__mocks__/react-i18next.js +18 -14
  47. package/src/admin-card-link.component.tsx +7 -10
  48. package/src/bed-administration/bed-administration-form.component.tsx +65 -99
  49. package/src/bed-administration/bed-administration-table.component.tsx +68 -127
  50. package/src/bed-administration/bed-administration-table.scss +12 -16
  51. package/src/bed-administration/bed-administration.resource.ts +16 -18
  52. package/src/bed-administration/edit-bed-form.component.tsx +20 -31
  53. package/src/bed-administration/new-bed-form.component.tsx +28 -44
  54. package/src/{bed-admission/bed-tag → bed-tag}/bed-tag-administration-table.component.tsx +35 -60
  55. package/src/{bed-admission/bed-tag → bed-tag}/bed-tags-admin-form.component.tsx +30 -34
  56. package/src/{bed-admission/bed-tag → bed-tag}/edit-tag-form.component.tsx +17 -25
  57. package/src/{bed-admission/bed-tag → bed-tag}/new-tag-form.component.tsx +20 -27
  58. package/src/{bed-admission/bed-type → bed-type}/bed-type-admin-form.component.tsx +37 -44
  59. package/src/{bed-admission/bed-type → bed-type}/bed-type-administration-table.component.tsx +36 -60
  60. package/src/{bed-admission/bed-type → bed-type}/edit-bed-type.component.tsx +17 -25
  61. package/src/{bed-admission/bed-type → bed-type}/new-bed-type-form.component.tsx +21 -28
  62. package/src/card-header/card-header.component.tsx +20 -0
  63. package/src/card-header/card-header.scss +45 -0
  64. package/src/config-schema.ts +9 -17
  65. package/src/declarations.d.ts +5 -5
  66. package/src/empty-state/empty-state.component.tsx +6 -21
  67. package/src/empty-state/empty-state.scss +10 -10
  68. package/src/header/header.component.tsx +14 -23
  69. package/src/header/header.scss +11 -11
  70. package/src/header/illustration.component.tsx +3 -3
  71. package/src/home.component.tsx +4 -4
  72. package/src/index.ts +21 -48
  73. package/src/left-panel/left-panel.component.tsx +7 -17
  74. package/src/left-panel/left-panel.scss +8 -7
  75. package/src/left-panel-link.component.tsx +14 -24
  76. package/src/root.component.tsx +12 -12
  77. package/src/root.scss +2 -2
  78. package/src/routes.json +12 -12
  79. package/src/setup-tests.ts +1 -1
  80. package/src/summary/summary.component.tsx +16 -30
  81. package/src/summary/summary.resource.ts +116 -95
  82. package/src/summary/summary.scss +31 -29
  83. package/src/types.ts +50 -40
  84. package/src/ward-card/ward-card.component.tsx +5 -12
  85. package/src/ward-card/ward-card.scss +2 -2
  86. package/src/ward-with-beds/ward-with-beds.component.tsx +28 -47
  87. package/src/ward-with-beds/ward-with-beds.scss +5 -5
  88. package/translations/am.json +51 -0
  89. package/translations/ar.json +51 -0
  90. package/translations/en.json +48 -4
  91. package/translations/es.json +51 -0
  92. package/translations/fr.json +51 -0
  93. package/translations/he.json +51 -0
  94. package/translations/km.json +51 -0
  95. package/translations/zh.json +51 -0
  96. package/translations/zh_CN.json +51 -0
  97. package/tsconfig.json +3 -21
  98. package/webpack.config.js +1 -1
  99. package/.editorconfig +0 -12
  100. package/.eslintignore +0 -2
  101. package/.eslintrc +0 -37
  102. package/.husky/pre-commit +0 -4
  103. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  104. package/.idea/modules.xml +0 -8
  105. package/.idea/vcs.xml +0 -6
  106. package/.prettierignore +0 -14
  107. package/.turbo.json +0 -18
  108. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
  109. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
  110. package/.yarn/versions/cb9a89ac.yml +0 -0
  111. package/LICENSE +0 -373
  112. package/dist/187.js +0 -1
  113. package/dist/187.js.map +0 -1
  114. package/dist/207.js +0 -1
  115. package/dist/207.js.map +0 -1
  116. package/dist/26.js +0 -2
  117. package/dist/26.js.map +0 -1
  118. package/dist/283.js +0 -1
  119. package/dist/283.js.map +0 -1
  120. package/dist/330.js +0 -2
  121. package/dist/330.js.map +0 -1
  122. package/dist/352.js +0 -1
  123. package/dist/352.js.map +0 -1
  124. package/dist/404.js +0 -1
  125. package/dist/404.js.map +0 -1
  126. package/dist/558.js +0 -2
  127. package/dist/558.js.LICENSE.txt +0 -14
  128. package/dist/558.js.map +0 -1
  129. package/dist/629.js +0 -1
  130. package/dist/629.js.map +0 -1
  131. package/dist/707.js +0 -1
  132. package/dist/707.js.map +0 -1
  133. package/dist/800.js +0 -2
  134. package/dist/800.js.map +0 -1
  135. package/dist/850.js +0 -1
  136. package/dist/850.js.map +0 -1
  137. package/dist/884.js +0 -1
  138. package/dist/884.js.map +0 -1
  139. package/dist/933.js +0 -1
  140. package/dist/933.js.map +0 -1
  141. package/dist/esm-kenyaemr-bed-management-app.js +0 -1
  142. package/dist/esm-kenyaemr-bed-management-app.js.map +0 -1
  143. package/i18next-parser.config.js +0 -89
  144. package/src/assets/landing-page.png +0 -0
  145. package/src/assets/logo.svg +0 -1
  146. package/src/bed-admission/active-patients/active-patients-table.component.tsx +0 -299
  147. package/src/bed-admission/active-patients/active-visits.resource.ts +0 -171
  148. package/src/bed-admission/active-patients/admission-action-button-styles.scss +0 -0
  149. package/src/bed-admission/active-patients/admission-action-button.component.tsx +0 -26
  150. package/src/bed-admission/active-patients/index.tsx +0 -15
  151. package/src/bed-admission/active-patients/patient-queues.resource.ts +0 -136
  152. package/src/bed-admission/active-patients/styles.scss +0 -284
  153. package/src/bed-admission/active-patients/view-action-menu.component.tsx +0 -33
  154. package/src/bed-admission/admitted-patients/active-admissions.resource.ts +0 -121
  155. package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +0 -280
  156. package/src/bed-admission/admitted-patients/admitted-patients.component.tsx +0 -22
  157. package/src/bed-admission/admitted-patients/location-combo-box.component.tsx +0 -55
  158. package/src/bed-admission/admitted-patients/styles.scss +0 -284
  159. package/src/bed-admission/bed-admission-tabs-styles.scss +0 -30
  160. package/src/bed-admission/bed-admission-tabs.component.tsx +0 -69
  161. package/src/bed-admission/bed-admission.component.tsx +0 -15
  162. package/src/bed-admission/bed-admission.resource.ts +0 -35
  163. package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +0 -101
  164. package/src/bed-admission/bed-layout/bed-layout.component.tsx +0 -64
  165. package/src/bed-admission/bed-layout/bed-layout.scss +0 -118
  166. package/src/bed-admission/bed-layout/min-bed-layout.component.tsx +0 -26
  167. package/src/bed-admission/createDashboardLink.tsx +0 -47
  168. package/src/bed-admission/discharged-patients/discharged-patients.componet.tsx +0 -19
  169. package/src/bed-admission/helpers/functions.ts +0 -102
  170. package/src/bed-admission/types.ts +0 -133
  171. package/src/workspace/allocate-bed-workspace.component.tsx +0 -141
  172. package/src/workspace/allocate-bed.scss +0 -117
  173. package/src/workspace/overlay.component.tsx +0 -55
  174. package/src/workspace/overlay.scss +0 -96
  175. /package/dist/{294.js.LICENSE.txt → 784.js.LICENSE.txt} +0 -0
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useMemo, useState } from "react";
2
- import { useTranslation } from "react-i18next";
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 "@carbon/react";
20
- import { Add, Edit } from "@carbon/react/icons";
21
- import {
22
- isDesktop as desktopLayout,
23
- useConfig,
24
- useLayoutType,
25
- usePagination,
26
- } from "@openmrs/esm-framework";
27
- import { CardHeader, ErrorState } from "@openmrs/esm-patient-common-lib";
28
- import type { InitialData, Location } from "../types";
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("wardAllocation", "Ward Allocation");
32
+ const headerTitle = t('wardAllocation', 'Ward Allocation');
38
33
  const layout = useLayoutType();
39
- const isTablet = layout === "tablet";
40
- const responsiveSize = isTablet ? "lg" : "sm";
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 [wardsGroupedByLocations, setWardsGroupedByLocation] = useState<
45
- Array<Location>
46
- >([]);
47
- const [isBedDataLoading, setIsBedDataLoading] = useState(false);
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<InitialData>();
51
- const [filterOption, setFilterOption] = useState("ALL");
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("yes", "Yes")}
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("no", "No")}
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 bedsMappedToLocation = wardsGroupedByLocations?.length
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 === "ALL"
86
- ? bedsMappedToLocation
87
- : bedsMappedToLocation.filter((bed) => bed.status === filterOption) ?? [],
88
- currentPageSize
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: "bedNumber",
117
- header: t("bedId", "Bed ID"),
81
+ key: 'bedNumber',
82
+ header: t('bedId', 'Bed ID'),
118
83
  },
119
84
  {
120
- key: "location",
121
- header: t("location", "Location"),
85
+ key: 'location',
86
+ header: t('location', 'Location'),
122
87
  },
123
88
  {
124
- key: "occupancyStatus",
125
- header: t("occupancyStatus", "Occupied"),
89
+ key: 'occupancyStatus',
90
+ header: t('occupancyStatus', 'Occupied'),
126
91
  },
127
92
  {
128
- key: "allocationStatus",
129
- header: t("allocationStatus", "Allocated"),
93
+ key: 'allocationStatus',
94
+ header: t('allocationStatus', 'Allocated'),
130
95
  },
131
96
  {
132
- key: "actions",
133
- header: t("actions", "Actions"),
97
+ key: 'actions',
98
+ header: t('actions', 'Actions'),
134
99
  },
135
100
  ];
136
101
 
137
102
  const tableRows = useMemo(() => {
138
- return results.map((ward) => ({
139
- id: ward.uuid,
140
- bedNumber: ward.bedNumber,
141
- location: ward.location.display,
142
- occupancyStatus: <CustomTag condition={ward?.status === "OCCUPIED"} />,
143
- allocationStatus: <CustomTag condition={ward.location?.uuid} />,
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(ward);
116
+ setEditData(bed);
152
117
  setShowEditBedModal(true);
153
118
  setShowAddBedModal(false);
154
119
  }}
155
- kind={"ghost"}
156
- iconDescription={t("editBed", "Edit Bed")}
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 ((isBedDataLoading || isLoading) && !wardsGroupedByLocations.length) {
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={"All"}
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={["All", "Available", "Occupied"]}
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
- {t("No data", "No data to display")}
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("or", "or")}</p>
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={pageSizes?.length > 0 ? pageSizes : [10]}
299
- totalItems={bedsMappedToLocation.length ?? 0}
241
+ pageSizes={[10, 20, 30, 40, 50]}
242
+ totalItems={wardsGroupedByLocations.length}
300
243
  onChange={({ pageSize, page }) => {
301
- if (pageSize !== currentPageSize) {
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: 1.5rem;
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 1rem;
31
- margin-top: 2rem;
32
- margin-left: 0.5rem;
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: 1rem;
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: 3rem 0;
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: 0.5rem;
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: 1.5rem auto;
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: 0.5rem;
100
+ right: layout.$spacing-03;
105
101
  margin-left: -50%;
106
102
  }
107
103
 
108
104
  &::after {
109
- left: 0.5rem;
105
+ left: layout.$spacing-03;
110
106
  margin-right: -50%;
111
107
  }
112
- }
108
+ }
@@ -1,6 +1,7 @@
1
- import { useMemo } from "react";
2
- import useSWR from "swr";
3
- import { FetchResponse, openmrsFetch } from "@openmrs/esm-framework";
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: "POST",
17
- headers: { "Content-Type": "application/json" },
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
- `/ws/rest/v1/bed/${bedId}`,
52
- {
53
- method: "POST",
54
- headers: { "Content-Type": "application/json" },
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 "react";
2
- import { useTranslation } from "react-i18next";
3
- import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
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 { InitialData, Mutator } from "../types";
6
- import { useBedType, editBed } from "./bed-administration.resource";
7
- import BedAdministrationForm from "./bed-administration-form.component";
8
- import { BedAdministrationData } from "./bed-administration-types";
9
- import { useLocationsByTag } from "../summary/summary.resource";
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: InitialData;
15
- mutate: Mutator;
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 { admissionLocationTagUuid } = useConfig();
26
- const { data: admissionLocations } = useLocationsByTag(
27
- admissionLocationTagUuid
28
- );
20
+ const { data: admissionLocations } = useLocationsWithAdmissionTag();
29
21
 
30
- const headerTitle = t("editBed", "Edit bed");
31
- const occupancyStatuses = ["Available", "Occupied"];
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("formSaved", "Bed saved"),
59
- kind: "success",
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("errorCreatingForm", "Error creating bed"),
73
- kind: "error",
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 "react";
2
- import { useTranslation } from "react-i18next";
3
- import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
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 { InitialData, Mutator } from "../types";
6
- import { useBedType, saveBed } from "./bed-administration.resource";
7
- import BedAdministrationForm from "./bed-administration-form.component";
8
- import { useLocationsByTag } from "../summary/summary.resource";
9
- import { BedAdministrationData } from "./bed-administration-types";
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: Mutator;
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 { admissionLocationTagUuid } = useConfig();
24
- const { data: admissionLocations } = useLocationsByTag(
25
- admissionLocationTagUuid
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: InitialData = {
33
- uuid: "",
34
- bedNumber: "",
35
- status: "",
36
- description: "",
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("formCreated", "New bed created"),
74
- kind: "success",
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("errorCreatingForm", "Error creating bed"),
85
- kind: "error",
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 (