@kenyaemr/esm-bed-management-app 1.0.1-pre.4 → 8.1.1-pre.116

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 (176) 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-types.ts +8 -0
  52. package/src/bed-administration/bed-administration.resource.ts +16 -18
  53. package/src/bed-administration/edit-bed-form.component.tsx +20 -31
  54. package/src/bed-administration/new-bed-form.component.tsx +28 -44
  55. package/src/bed-tag/bed-tag-administration-table.component.tsx +192 -0
  56. package/src/bed-tag/bed-tags-admin-form.component.tsx +127 -0
  57. package/src/bed-tag/edit-tag-form.component.tsx +72 -0
  58. package/src/bed-tag/new-tag-form.component.tsx +76 -0
  59. package/src/bed-type/bed-type-admin-form.component.tsx +166 -0
  60. package/src/bed-type/bed-type-administration-table.component.tsx +198 -0
  61. package/src/bed-type/edit-bed-type.component.tsx +72 -0
  62. package/src/bed-type/new-bed-type-form.component.tsx +80 -0
  63. package/src/card-header/card-header.component.tsx +20 -0
  64. package/src/card-header/card-header.scss +45 -0
  65. package/src/config-schema.ts +9 -17
  66. package/src/declarations.d.ts +5 -5
  67. package/src/empty-state/empty-state.component.tsx +6 -21
  68. package/src/empty-state/empty-state.scss +10 -10
  69. package/src/header/header.component.tsx +14 -23
  70. package/src/header/header.scss +11 -11
  71. package/src/header/illustration.component.tsx +3 -3
  72. package/src/home.component.tsx +4 -4
  73. package/src/index.ts +26 -40
  74. package/src/left-panel/left-panel.component.tsx +7 -17
  75. package/src/left-panel/left-panel.scss +8 -7
  76. package/src/left-panel-link.component.tsx +14 -24
  77. package/src/root.component.tsx +14 -10
  78. package/src/root.scss +2 -2
  79. package/src/routes.json +12 -2
  80. package/src/setup-tests.ts +1 -1
  81. package/src/summary/summary.component.tsx +16 -30
  82. package/src/summary/summary.resource.ts +169 -60
  83. package/src/summary/summary.scss +31 -29
  84. package/src/types.ts +50 -29
  85. package/src/ward-card/ward-card.component.tsx +5 -12
  86. package/src/ward-card/ward-card.scss +2 -2
  87. package/src/ward-with-beds/ward-with-beds.component.tsx +28 -47
  88. package/src/ward-with-beds/ward-with-beds.scss +5 -5
  89. package/translations/am.json +51 -0
  90. package/translations/ar.json +51 -0
  91. package/translations/en.json +48 -4
  92. package/translations/es.json +51 -0
  93. package/translations/fr.json +51 -0
  94. package/translations/he.json +51 -0
  95. package/translations/km.json +51 -0
  96. package/translations/zh.json +51 -0
  97. package/translations/zh_CN.json +51 -0
  98. package/tsconfig.json +3 -21
  99. package/webpack.config.js +1 -1
  100. package/.editorconfig +0 -12
  101. package/.eslintignore +0 -2
  102. package/.eslintrc +0 -37
  103. package/.husky/pre-commit +0 -4
  104. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  105. package/.idea/modules.xml +0 -8
  106. package/.idea/vcs.xml +0 -6
  107. package/.prettierignore +0 -14
  108. package/.turbo.json +0 -18
  109. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
  110. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
  111. package/.yarn/versions/6816f0d4.yml +0 -0
  112. package/LICENSE +0 -373
  113. package/dist/187.js +0 -1
  114. package/dist/187.js.map +0 -1
  115. package/dist/207.js +0 -1
  116. package/dist/207.js.map +0 -1
  117. package/dist/26.js +0 -2
  118. package/dist/26.js.map +0 -1
  119. package/dist/283.js +0 -1
  120. package/dist/283.js.map +0 -1
  121. package/dist/330.js +0 -2
  122. package/dist/330.js.map +0 -1
  123. package/dist/352.js +0 -1
  124. package/dist/352.js.map +0 -1
  125. package/dist/404.js +0 -1
  126. package/dist/404.js.map +0 -1
  127. package/dist/558.js +0 -2
  128. package/dist/558.js.LICENSE.txt +0 -14
  129. package/dist/558.js.map +0 -1
  130. package/dist/629.js +0 -1
  131. package/dist/629.js.map +0 -1
  132. package/dist/707.js +0 -1
  133. package/dist/707.js.map +0 -1
  134. package/dist/800.js +0 -2
  135. package/dist/800.js.map +0 -1
  136. package/dist/884.js +0 -1
  137. package/dist/884.js.map +0 -1
  138. package/dist/933.js +0 -1
  139. package/dist/933.js.map +0 -1
  140. package/dist/959.js +0 -1
  141. package/dist/959.js.map +0 -1
  142. package/dist/esm-kenyaemr-bed-management-app.js +0 -1
  143. package/dist/esm-kenyaemr-bed-management-app.js.map +0 -1
  144. package/i18next-parser.config.js +0 -89
  145. package/src/assets/landing-page.png +0 -0
  146. package/src/assets/logo.svg +0 -1
  147. package/src/bed-admission/active-patients/active-patients-table.component.tsx +0 -299
  148. package/src/bed-admission/active-patients/active-visits.resource.ts +0 -171
  149. package/src/bed-admission/active-patients/admission-action-button-styles.scss +0 -0
  150. package/src/bed-admission/active-patients/admission-action-button.component.tsx +0 -26
  151. package/src/bed-admission/active-patients/index.tsx +0 -15
  152. package/src/bed-admission/active-patients/patient-queues.resource.ts +0 -136
  153. package/src/bed-admission/active-patients/styles.scss +0 -284
  154. package/src/bed-admission/active-patients/view-action-menu.component.tsx +0 -33
  155. package/src/bed-admission/admitted-patients/active-admissions.resource.ts +0 -121
  156. package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +0 -280
  157. package/src/bed-admission/admitted-patients/admitted-patients.component.tsx +0 -22
  158. package/src/bed-admission/admitted-patients/location-combo-box.component.tsx +0 -55
  159. package/src/bed-admission/admitted-patients/styles.scss +0 -284
  160. package/src/bed-admission/bed-admission-tabs-styles.scss +0 -30
  161. package/src/bed-admission/bed-admission-tabs.component.tsx +0 -69
  162. package/src/bed-admission/bed-admission.component.tsx +0 -15
  163. package/src/bed-admission/bed-admission.resource.ts +0 -35
  164. package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +0 -101
  165. package/src/bed-admission/bed-layout/bed-layout.component.tsx +0 -64
  166. package/src/bed-admission/bed-layout/bed-layout.scss +0 -118
  167. package/src/bed-admission/bed-layout/min-bed-layout.component.tsx +0 -26
  168. package/src/bed-admission/createDashboardLink.tsx +0 -47
  169. package/src/bed-admission/discharged-patients/discharged-patients.componet.tsx +0 -19
  170. package/src/bed-admission/helpers/functions.ts +0 -102
  171. package/src/bed-admission/types.ts +0 -133
  172. package/src/workspace/allocate-bed-workspace.component.tsx +0 -141
  173. package/src/workspace/allocate-bed.scss +0 -117
  174. package/src/workspace/overlay.component.tsx +0 -55
  175. package/src/workspace/overlay.scss +0 -96
  176. /package/dist/{294.js.LICENSE.txt → 784.js.LICENSE.txt} +0 -0
@@ -1,14 +1,26 @@
1
- import useSWR from "swr";
2
- import { openmrsFetch } from "@openmrs/esm-framework";
3
- import type { AdmissionLocation, Bed, MappedBedData } from "../types";
4
-
5
- export const useLocationsByTag = (locationUuid: string) => {
6
- const locationsUrl = `/ws/rest/v1/location?tag=${locationUuid}&v=full`;
7
-
8
- const { data, error, isLoading, isValidating, mutate } = useSWR<
9
- { data },
10
- Error
11
- >(locationUuid ? locationsUrl : null, openmrsFetch);
1
+ import useSWR from 'swr';
2
+ import { type FetchResponse, openmrsFetch, useConfig } from '@openmrs/esm-framework';
3
+ import type {
4
+ AdmissionLocation,
5
+ Bed,
6
+ BedFetchResponse,
7
+ BedTagPayload,
8
+ BedTypePayload,
9
+ LocationFetchResponse,
10
+ MappedBedData,
11
+ Mutator,
12
+ } from '../types';
13
+ import { type BedManagementConfig } from '../config-schema';
14
+ import { useCallback, useEffect, useState } from 'react';
15
+
16
+ export const useLocationsWithAdmissionTag = () => {
17
+ const { admissionLocationTagName } = useConfig<BedManagementConfig>();
18
+ const locationsUrl = `/ws/rest/v1/location?tag=${admissionLocationTagName}&v=full`;
19
+
20
+ const { data, error, isLoading, isValidating, mutate } = useSWR<LocationFetchResponse, Error>(
21
+ admissionLocationTagName ? locationsUrl : null,
22
+ openmrsFetch,
23
+ );
12
24
 
13
25
  return {
14
26
  data: data?.data?.results ?? [],
@@ -19,33 +31,23 @@ export const useLocationsByTag = (locationUuid: string) => {
19
31
  };
20
32
  };
21
33
 
22
- export const getBedsForLocation = (locationUuid: string) => {
23
- const locationsUrl = `/ws/rest/v1/bed?locationUuid=${locationUuid}`;
24
-
25
- return openmrsFetch(locationsUrl, {
26
- method: "GET",
27
- }).then((res) => res?.data?.results ?? []);
28
- };
29
-
30
34
  export const useBedsForLocation = (locationUuid: string) => {
31
35
  const apiUrl = `/ws/rest/v1/bed?locationUuid=${locationUuid}&v=full`;
32
36
 
33
- const { data, isLoading, error } = useSWR<
34
- { data: { results: Array<Bed> } },
35
- Error
36
- >(locationUuid ? apiUrl : null, openmrsFetch);
37
-
38
- const mappedBedData: MappedBedData = (data?.data?.results ?? []).map(
39
- (bed) => ({
40
- id: bed.id,
41
- number: bed.bedNumber,
42
- name: bed.bedType?.displayName,
43
- description: bed.bedType?.description,
44
- status: bed.status,
45
- uuid: bed.uuid,
46
- })
37
+ const { data, isLoading, error } = useSWR<{ data: { results: Array<Bed> } }, Error>(
38
+ locationUuid ? apiUrl : null,
39
+ openmrsFetch,
47
40
  );
48
41
 
42
+ const mappedBedData: MappedBedData = (data?.data?.results ?? []).map((bed) => ({
43
+ id: bed.id,
44
+ number: bed.bedNumber,
45
+ name: bed.bedType?.displayName,
46
+ description: bed.bedType?.description,
47
+ status: bed.status,
48
+ uuid: bed.uuid,
49
+ }));
50
+
49
51
  return {
50
52
  bedData: mappedBedData,
51
53
  isLoading,
@@ -54,41 +56,65 @@ export const useBedsForLocation = (locationUuid: string) => {
54
56
  };
55
57
 
56
58
  export const useLocationName = (locationUuid: string) => {
57
- const apiUrl = `/ws/rest/v1/location/${locationUuid}`;
58
-
59
- const { data, isLoading } = useSWR<{ data }, Error>(
60
- locationUuid ? apiUrl : null,
61
- openmrsFetch
62
- );
59
+ const { data: allLocations, isLoading } = useLocationsWithAdmissionTag();
63
60
 
61
+ const location = allLocations.find((loc) => loc.uuid == locationUuid);
64
62
  return {
65
- name: data?.data?.display ?? null,
63
+ name: location?.display ?? null,
66
64
  isLoadingLocationData: isLoading,
67
65
  };
68
66
  };
69
67
 
70
- export const findBedByLocation = (locationUuid: string) => {
71
- const locationsUrl = `/ws/rest/v1/bed?locationUuid=${locationUuid}`;
72
- return openmrsFetch(locationsUrl, {
73
- method: "GET",
74
- });
75
- };
76
-
77
- export const useWards = (locationUuid: string) => {
78
- const locationsUrl = `/ws/rest/v1/location?tag=${locationUuid}&v=full`;
79
- const { data, error, isLoading, isValidating, mutate } = useSWR<
80
- { data },
81
- Error
82
- >(locationUuid ? locationsUrl : null, openmrsFetch);
68
+ export function useBedsGroupedByLocation() {
69
+ const { data: locations, isLoading: isLoadingLocations } = useLocationsWithAdmissionTag();
70
+ const [isLoading, setIsLoading] = useState(true);
71
+ const [isValidating, setIsValidating] = useState(true);
72
+ const [error, setError] = useState(null);
73
+ const [result, setResult] = useState([]);
74
+
75
+ useEffect(() => {
76
+ if (!isLoadingLocations && locations && isValidating) {
77
+ const fetchData = async () => {
78
+ const promises = locations.map(async (location) => {
79
+ const bedsUrl = `/ws/rest/v1/bed?locationUuid=${location.uuid}`;
80
+ const bedsFetchResult = await openmrsFetch<BedFetchResponse>(bedsUrl, {
81
+ method: 'GET',
82
+ });
83
+ if (bedsFetchResult.data.results.length) {
84
+ return bedsFetchResult.data.results.map((bed) => ({
85
+ ...bed,
86
+ location: location,
87
+ }));
88
+ }
89
+ return null;
90
+ });
91
+
92
+ const updatedWards = (await Promise.all(promises)).filter(Boolean);
93
+ setResult(updatedWards);
94
+ };
95
+ fetchData()
96
+ .catch((e) => {
97
+ setError(e);
98
+ })
99
+ .finally(() => {
100
+ setIsLoading(false);
101
+ setIsValidating(false);
102
+ });
103
+ }
104
+ }, [locations, isLoading]);
105
+
106
+ const mutate = useCallback(() => {
107
+ setIsValidating(true);
108
+ }, []);
83
109
 
84
110
  return {
85
- data,
111
+ data: result,
86
112
  error,
87
- isLoading,
113
+ isLoading: isLoading || isLoadingLocations,
88
114
  isValidating,
89
115
  mutate,
90
116
  };
91
- };
117
+ }
92
118
 
93
119
  export const useAdmissionLocations = () => {
94
120
  const locationsUrl = `/ws/rest/v1/admissionLocation?v=full`;
@@ -108,10 +134,10 @@ export const useAdmissionLocations = () => {
108
134
 
109
135
  export const useAdmissionLocationBedLayout = (locationUuid: string) => {
110
136
  const locationsUrl = `/ws/rest/v1/admissionLocation/${locationUuid}?v=full`;
111
- const { data, error, isLoading, isValidating, mutate } = useSWR<
112
- { data: AdmissionLocation },
113
- Error
114
- >(locationsUrl, openmrsFetch);
137
+ const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: AdmissionLocation }, Error>(
138
+ locationsUrl,
139
+ openmrsFetch,
140
+ );
115
141
 
116
142
  return {
117
143
  data: data?.data?.bedLayouts ?? [],
@@ -121,3 +147,86 @@ export const useAdmissionLocationBedLayout = (locationUuid: string) => {
121
147
  mutate,
122
148
  };
123
149
  };
150
+
151
+ export const useBedType = () => {
152
+ const url = `/ws/rest/v1/bedtype/`;
153
+ const { data, error, isLoading, isValidating, mutate } = useSWR<{ data }, Error>(url, openmrsFetch);
154
+ const results = data?.data?.results ? data?.data?.results : [];
155
+ return {
156
+ bedTypeData: results,
157
+ isError: error,
158
+ loading: isLoading,
159
+ validate: isValidating,
160
+ mutate,
161
+ };
162
+ };
163
+
164
+ export const useBedTag = () => {
165
+ const url = `/ws/rest/v1/bedTag/`;
166
+ const { data, error, isLoading, isValidating, mutate } = useSWR<{ data }, Error>(url, openmrsFetch);
167
+ const results = data?.data?.results ? data?.data?.results : [];
168
+ return {
169
+ bedTypeData: results,
170
+ isError: error,
171
+ loading: isLoading,
172
+ validate: isValidating,
173
+ mutate,
174
+ };
175
+ };
176
+ interface BedType {
177
+ name: string;
178
+ displayName: string;
179
+ description: string;
180
+ }
181
+ interface BedTag {
182
+ name: string;
183
+ }
184
+ export async function saveBedType({
185
+ bedTypePayload,
186
+ }: {
187
+ bedTypePayload: BedTypePayload;
188
+ }): Promise<FetchResponse<BedType>> {
189
+ const response: FetchResponse = await openmrsFetch(`/ws/rest/v1/bedtype`, {
190
+ method: 'POST',
191
+ headers: { 'Content-Type': 'application/json' },
192
+ body: bedTypePayload,
193
+ });
194
+ return response;
195
+ }
196
+
197
+ export async function saveBedTag({ bedTagPayload }: { bedTagPayload: BedTagPayload }): Promise<FetchResponse<BedTag>> {
198
+ const response: FetchResponse = await openmrsFetch(`/ws/rest/v1/bedTag/`, {
199
+ method: 'POST',
200
+ headers: { 'Content-Type': 'application/json' },
201
+ body: bedTagPayload,
202
+ });
203
+ return response;
204
+ }
205
+ export async function editBedType({
206
+ bedTypePayload,
207
+ bedTypeId,
208
+ }: {
209
+ bedTypePayload: BedTypePayload;
210
+ bedTypeId: string;
211
+ }): Promise<FetchResponse<BedType>> {
212
+ const response: FetchResponse = await openmrsFetch(`/ws/rest/v1/bedtype/${bedTypeId}`, {
213
+ method: 'POST',
214
+ headers: { 'Content-Type': 'application/json' },
215
+ body: bedTypePayload,
216
+ });
217
+ return response;
218
+ }
219
+ export async function editBedTag({
220
+ bedTagPayload,
221
+ bedTagId,
222
+ }: {
223
+ bedTagPayload: BedTagPayload;
224
+ bedTagId: string;
225
+ }): Promise<FetchResponse<BedType>> {
226
+ const response: FetchResponse = await openmrsFetch(`/ws/rest/v1/bedTag/${bedTagId}`, {
227
+ method: 'POST',
228
+ headers: { 'Content-Type': 'application/json' },
229
+ body: bedTagPayload,
230
+ });
231
+ return response;
232
+ }
@@ -2,58 +2,60 @@
2
2
  @use '@carbon/layout';
3
3
 
4
4
  .cardContainer {
5
- background-color: colors.$white-0;
6
- display: grid;
7
- grid-template-columns: repeat(3, minmax(0, 1fr));
8
- justify-content: space-between;
9
- padding: 1rem;
5
+ background-color: colors.$white-0;
6
+ display: grid;
7
+ grid-template-columns: repeat(3, minmax(0, 1fr));
8
+ justify-content: space-between;
9
+ padding: layout.$spacing-05;
10
10
  }
11
11
 
12
12
  .buttonMain {
13
- background-color: colors.$white-0;
14
- color: colors.$teal-60;
15
- cursor: text;
13
+ background-color: colors.$white-0;
14
+ color: colors.$teal-60;
15
+ cursor: text;
16
16
  }
17
17
 
18
18
  .sectionLoader {
19
- text-align: center;
19
+ text-align: center;
20
20
  }
21
21
 
22
22
  .buttonMain {
23
- &:active, &:focus, &:hover {
24
- color: colors.$teal-60 !important;
25
- background-color: colors.$white-0 !important;
26
- }
23
+ &:active,
24
+ &:focus,
25
+ &:hover {
26
+ color: colors.$teal-60 !important;
27
+ background-color: colors.$white-0 !important;
28
+ }
27
29
  }
28
30
 
29
31
  .inactiveMain {
30
- margin-bottom: 4rem;
32
+ margin-bottom: layout.$spacing-10;
31
33
  }
32
34
 
33
35
  .buttonContainer {
34
- display: flex;
36
+ display: flex;
35
37
  }
36
38
 
37
39
  .buttonItems {
38
- flex: auto;
40
+ flex: auto;
39
41
  }
40
42
 
41
43
  .pageHeaderContainer {
42
- display: flex;
43
- justify-content: space-between;
44
- align-items: center;
45
- padding: layout.$spacing-05;
46
- background-color: #ededed;
44
+ display: flex;
45
+ justify-content: space-between;
46
+ align-items: center;
47
+ padding: layout.$spacing-05;
48
+ background-color: #ededed;
47
49
  }
48
50
 
49
51
  .pageHeader {
50
- text-overflow: ellipsis;
51
- overflow: hidden;
52
- white-space: nowrap;
53
- font-size: 1.25rem;
54
- font-weight: 400;
55
- line-height: 1.4;
56
- letter-spacing: 0;
52
+ text-overflow: ellipsis;
53
+ overflow: hidden;
54
+ white-space: nowrap;
55
+ font-size: 1.25rem;
56
+ font-weight: 400;
57
+ line-height: 1.4;
58
+ letter-spacing: 0;
57
59
  }
58
60
 
59
61
  .link {
@@ -68,5 +70,5 @@
68
70
  }
69
71
 
70
72
  .loader {
71
- margin: 2rem;
73
+ margin: layout.$spacing-07;
72
74
  }
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { KeyedMutator } from "swr";
1
+ import type { KeyedMutator } from 'swr';
2
2
 
3
3
  export type Tag = {
4
4
  uuid: string;
@@ -14,6 +14,12 @@ export type Tag = {
14
14
  resourceVersion: string;
15
15
  };
16
16
 
17
+ export type LocationFetchResponse = {
18
+ data: {
19
+ results: Array<Location>;
20
+ };
21
+ };
22
+
17
23
  export type Location = {
18
24
  uuid: string;
19
25
  display: string;
@@ -68,22 +74,25 @@ export type Location = {
68
74
  beds: Bed[];
69
75
  };
70
76
 
77
+ export type BedFetchResponse = {
78
+ results: Array<Bed>;
79
+ };
80
+
71
81
  export interface Bed {
72
82
  id: number;
73
- bedId: number;
74
83
  uuid: string;
75
84
  bedNumber: string;
76
- bedType: {
77
- uuid: string;
78
- name: string;
79
- displayName: string;
80
- description: string;
81
- resourceVersion: string;
82
- };
85
+ bedType?: BedType;
83
86
  row: number;
84
87
  column: number;
85
- status: "AVAILABLE" | string;
86
- location: string;
88
+ status: 'AVAILABLE' | 'OCCUPIED';
89
+ }
90
+
91
+ export interface BedWithLocation extends Bed {
92
+ location: {
93
+ display: string;
94
+ uuid: string;
95
+ };
87
96
  }
88
97
 
89
98
  export interface BedType {
@@ -91,22 +100,42 @@ export interface BedType {
91
100
  name: string;
92
101
  displayName: string;
93
102
  description: string;
103
+ resourceVersion: string;
104
+ }
105
+
106
+ export interface BedFormData extends BedWithLocation {
107
+ description: string;
94
108
  }
95
109
 
96
- export interface InitialData {
110
+ export interface BedTypeData {
97
111
  uuid: string;
98
- bedNumber: string;
99
- status: string;
112
+ name: string;
113
+ displayName: string;
100
114
  description: string;
115
+ }
116
+
117
+ export interface BedTagData {
118
+ uuid: string;
119
+ name: string;
120
+ }
121
+
122
+ export interface BedPostPayload {
123
+ bedNumber: string;
124
+ bedType: string;
101
125
  row: number;
102
126
  column: number;
103
- location: {
104
- display: string;
105
- uuid: string;
106
- };
107
- bedType: {
108
- name: string;
109
- };
127
+ status: string;
128
+ locationUuid: string;
129
+ }
130
+
131
+ export interface BedTagPayload {
132
+ name: string;
133
+ }
134
+
135
+ export interface BedTypePayload {
136
+ name: string;
137
+ displayName: string;
138
+ description: string;
110
139
  }
111
140
 
112
141
  export type Mutator = KeyedMutator<{
@@ -139,14 +168,6 @@ export type MappedBedData = Array<{
139
168
  export interface BedDetails extends Bed {
140
169
  patient: null | {
141
170
  uuid: string;
142
- person: {
143
- gender: string;
144
- age: number;
145
- preferredName: {
146
- givenName: string;
147
- familyName: string;
148
- };
149
- };
150
171
  identifiers: Array<{ identifier: string }>;
151
172
  };
152
173
  }
@@ -1,6 +1,6 @@
1
- import React from "react";
2
- import { Layer, Tile } from "@carbon/react";
3
- import styles from "./ward-card.scss";
1
+ import React from 'react';
2
+ import { Layer, Tile } from '@carbon/react';
3
+ import styles from './ward-card.scss';
4
4
 
5
5
  interface WardCardProps {
6
6
  label: string;
@@ -12,16 +12,9 @@ interface WardCardProps {
12
12
  locationUuid?: string;
13
13
  }
14
14
 
15
- const WardCard: React.FC<WardCardProps> = ({
16
- children,
17
- headerLabel,
18
- label,
19
- value,
20
- }) => {
15
+ const WardCard: React.FC<WardCardProps> = ({ children, headerLabel, label, value }) => {
21
16
  return (
22
- <Layer
23
- className={`${children && styles.cardWithChildren} ${styles.container}`}
24
- >
17
+ <Layer className={`${children && styles.cardWithChildren} ${styles.container}`}>
25
18
  <Tile className={styles.tileContainer}>
26
19
  <div className={styles.tileHeader}>
27
20
  <div className={styles.headerLabelContainer}>
@@ -1,6 +1,6 @@
1
1
  @use '@carbon/colors';
2
2
  @use '@carbon/layout';
3
- @use "@carbon/type";
3
+ @use '@carbon/type';
4
4
 
5
5
  .container {
6
6
  flex-grow: 1;
@@ -36,7 +36,7 @@
36
36
  }
37
37
 
38
38
  .headerLabelContainer {
39
- margin-bottom: 1rem;
39
+ margin-bottom: layout.$spacing-05;
40
40
  }
41
41
 
42
42
  .link {
@@ -1,6 +1,6 @@
1
- import React, { useMemo, useState } from "react";
2
- import { useParams } from "react-router-dom";
3
- import { useTranslation } from "react-i18next";
1
+ import React, { useMemo, useState } from 'react';
2
+ import { useParams } from 'react-router-dom';
3
+ import { useTranslation } from 'react-i18next';
4
4
  import {
5
5
  Button,
6
6
  DataTable,
@@ -14,15 +14,12 @@ import {
14
14
  TableBody,
15
15
  TableCell,
16
16
  Tag,
17
- } from "@carbon/react";
18
- import { ArrowLeft } from "@carbon/react/icons";
19
- import { navigate, usePagination } from "@openmrs/esm-framework";
20
- import Header from "../header/header.component";
21
- import {
22
- useBedsForLocation,
23
- useLocationName,
24
- } from "../summary/summary.resource";
25
- import styles from "./ward-with-beds.scss";
17
+ } from '@carbon/react';
18
+ import { ArrowLeft } from '@carbon/react/icons';
19
+ import { navigate, usePagination } from '@openmrs/esm-framework';
20
+ import Header from '../header/header.component';
21
+ import { useBedsForLocation, useLocationName } from '../summary/summary.resource';
22
+ import styles from './ward-with-beds.scss';
26
23
 
27
24
  type RouteParams = { location: string };
28
25
 
@@ -33,11 +30,7 @@ const WardWithBeds: React.FC = () => {
33
30
  const { name } = useLocationName(location);
34
31
 
35
32
  const [pageSize, setPageSize] = useState(10);
36
- const {
37
- results: paginatedData,
38
- goTo,
39
- currentPage,
40
- } = usePagination(bedData, pageSize);
33
+ const { results: paginatedData, goTo, currentPage } = usePagination(bedData, pageSize);
41
34
 
42
35
  if (isLoading) {
43
36
  <p>Loading...</p>;
@@ -46,28 +39,28 @@ const WardWithBeds: React.FC = () => {
46
39
  const tableHeaders = [
47
40
  {
48
41
  id: 0,
49
- header: "ID",
50
- key: "id",
42
+ header: 'ID',
43
+ key: 'id',
51
44
  },
52
45
  {
53
46
  id: 1,
54
- header: "Number",
55
- key: "number",
47
+ header: 'Number',
48
+ key: 'number',
56
49
  },
57
50
  {
58
51
  id: 2,
59
- header: "Name",
60
- key: "name",
52
+ header: 'Name',
53
+ key: 'name',
61
54
  },
62
55
  {
63
56
  id: 3,
64
- header: "Description",
65
- key: "description",
57
+ header: 'Description',
58
+ key: 'description',
66
59
  },
67
60
  {
68
61
  id: 4,
69
- header: "Occupied",
70
- key: "occupied",
62
+ header: 'Occupied',
63
+ key: 'occupied',
71
64
  },
72
65
  ];
73
66
 
@@ -77,14 +70,14 @@ const WardWithBeds: React.FC = () => {
77
70
  if (condition) {
78
71
  return (
79
72
  <Tag type="green" size="md">
80
- {t("yes", "Yes")}
73
+ {t('yes', 'Yes')}
81
74
  </Tag>
82
75
  );
83
76
  }
84
77
 
85
78
  return (
86
79
  <Tag type="red" size="md">
87
- {t("no", "No")}
80
+ {t('no', 'No')}
88
81
  </Tag>
89
82
  );
90
83
  };
@@ -95,13 +88,13 @@ const WardWithBeds: React.FC = () => {
95
88
  number: bed.number,
96
89
  name: bed.name,
97
90
  description: bed.description,
98
- occupied: <CustomTag condition={bed?.status === "OCCUPIED"} />,
91
+ occupied: <CustomTag condition={bed?.status === 'OCCUPIED'} />,
99
92
  }));
100
93
  }, [paginatedData]);
101
94
 
102
95
  return (
103
96
  <>
104
- <Header route={name ? name : "--"} />
97
+ <Header route={name ? name : '--'} />
105
98
  {isLoading && (
106
99
  <div className={styles.container}>
107
100
  <DataTableSkeleton role="progressbar" zebra />
@@ -119,29 +112,19 @@ const WardWithBeds: React.FC = () => {
119
112
  navigate({
120
113
  to: `${window.getOpenmrsSpaBase()}bed-management`,
121
114
  })
122
- }
123
- >
115
+ }>
124
116
  <span>Return to summary</span>
125
117
  </Button>
126
118
  </div>
127
119
  <div className={styles.container}>
128
120
  <DataTable rows={tableRows} headers={tableHeaders} useZebraStyles>
129
- {({
130
- rows,
131
- headers,
132
- getHeaderProps,
133
- getRowProps,
134
- getTableProps,
135
- }) => (
121
+ {({ rows, headers, getHeaderProps, getRowProps, getTableProps }) => (
136
122
  <TableContainer>
137
123
  <Table {...getTableProps()}>
138
124
  <TableHead>
139
125
  <TableRow>
140
126
  {headers.map((header) => (
141
- <TableHeader
142
- key={header.key}
143
- {...getHeaderProps({ header })}
144
- >
127
+ <TableHeader key={header.key} {...getHeaderProps({ header })}>
145
128
  {header.header}
146
129
  </TableHeader>
147
130
  ))}
@@ -151,9 +134,7 @@ const WardWithBeds: React.FC = () => {
151
134
  {rows.map((row) => (
152
135
  <TableRow key={row.id} {...getRowProps({ row })}>
153
136
  {row.cells.map((cell) => (
154
- <TableCell key={cell.id}>
155
- {cell.value?.content ?? cell.value}
156
- </TableCell>
137
+ <TableCell key={cell.id}>{cell.value?.content ?? cell.value}</TableCell>
157
138
  ))}
158
139
  </TableRow>
159
140
  ))}