@kenyaemr/esm-icu-app 5.4.5-pre.1142
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 +6 -0
- package/dist/1072.js +1 -0
- package/dist/1072.js.map +1 -0
- package/dist/1148.js +1 -0
- package/dist/1148.js.map +1 -0
- package/dist/1156.js +1 -0
- package/dist/1156.js.map +1 -0
- package/dist/1278.js +1 -0
- package/dist/1278.js.map +1 -0
- package/dist/1442.js +1 -0
- package/dist/1442.js.map +1 -0
- package/dist/1466.js +1 -0
- package/dist/1466.js.map +1 -0
- package/dist/15.js +1 -0
- package/dist/15.js.map +1 -0
- package/dist/1568.js +1 -0
- package/dist/1568.js.map +1 -0
- package/dist/1620.js +1 -0
- package/dist/1620.js.map +1 -0
- package/dist/1668.js +1 -0
- package/dist/1668.js.map +1 -0
- package/dist/1789.js +1 -0
- package/dist/1789.js.map +1 -0
- package/dist/1831.js +1 -0
- package/dist/1831.js.map +1 -0
- package/dist/1844.js +1 -0
- package/dist/1844.js.map +1 -0
- package/dist/1946.js +1 -0
- package/dist/1946.js.map +1 -0
- package/dist/2007.js +1 -0
- package/dist/2007.js.map +1 -0
- package/dist/2115.js +1 -0
- package/dist/2115.js.map +1 -0
- package/dist/2152.js +1 -0
- package/dist/2152.js.map +1 -0
- package/dist/2202.js +1 -0
- package/dist/2202.js.map +1 -0
- package/dist/2231.js +1 -0
- package/dist/2231.js.map +1 -0
- package/dist/2394.js +1 -0
- package/dist/2394.js.map +1 -0
- package/dist/2507.js +1 -0
- package/dist/2507.js.map +1 -0
- package/dist/2516.js +1 -0
- package/dist/2516.js.map +1 -0
- package/dist/2534.js +1 -0
- package/dist/2534.js.map +1 -0
- package/dist/2537.js +1 -0
- package/dist/2537.js.map +1 -0
- package/dist/2556.js +1 -0
- package/dist/2556.js.map +1 -0
- package/dist/2648.js +1 -0
- package/dist/2648.js.map +1 -0
- package/dist/2795.js +1 -0
- package/dist/2795.js.map +1 -0
- package/dist/2842.js +1 -0
- package/dist/2842.js.map +1 -0
- package/dist/2916.js +1 -0
- package/dist/2916.js.map +1 -0
- package/dist/2924.js +1 -0
- package/dist/2924.js.map +1 -0
- package/dist/2947.js +1 -0
- package/dist/2947.js.map +1 -0
- package/dist/3032.js +1 -0
- package/dist/3032.js.map +1 -0
- package/dist/3137.js +1 -0
- package/dist/3137.js.map +1 -0
- package/dist/3285.js +1 -0
- package/dist/3285.js.map +1 -0
- package/dist/3335.js +1 -0
- package/dist/3335.js.map +1 -0
- package/dist/3378.js +1 -0
- package/dist/3378.js.map +1 -0
- package/dist/3381.js +1 -0
- package/dist/3381.js.map +1 -0
- package/dist/3504.js +1 -0
- package/dist/3504.js.map +1 -0
- package/dist/356.js +1 -0
- package/dist/356.js.map +1 -0
- package/dist/3569.js +1 -0
- package/dist/3569.js.map +1 -0
- package/dist/3723.js +1 -0
- package/dist/3723.js.map +1 -0
- package/dist/3745.js +1 -0
- package/dist/3745.js.map +1 -0
- package/dist/3747.js +1 -0
- package/dist/3747.js.map +1 -0
- package/dist/3802.js +1 -0
- package/dist/3802.js.map +1 -0
- package/dist/3813.js +1 -0
- package/dist/3813.js.map +1 -0
- package/dist/393.js +6 -0
- package/dist/393.js.map +1 -0
- package/dist/3953.js +1 -0
- package/dist/3953.js.map +1 -0
- package/dist/3989.js +1 -0
- package/dist/3989.js.map +1 -0
- package/dist/4178.js +1 -0
- package/dist/4178.js.map +1 -0
- package/dist/4487.js +11 -0
- package/dist/4487.js.map +1 -0
- package/dist/4588.js +1 -0
- package/dist/4588.js.map +1 -0
- package/dist/4612.js +1 -0
- package/dist/4612.js.map +1 -0
- package/dist/4637.js +1 -0
- package/dist/4637.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/4817.js +1 -0
- package/dist/4817.js.map +1 -0
- package/dist/4818.js +1 -0
- package/dist/4818.js.map +1 -0
- package/dist/500.js +1 -0
- package/dist/500.js.map +1 -0
- package/dist/5086.js +1 -0
- package/dist/5086.js.map +1 -0
- package/dist/5117.js +1 -0
- package/dist/5117.js.map +1 -0
- package/dist/5361.js +1 -0
- package/dist/5361.js.map +1 -0
- package/dist/5366.js +1 -0
- package/dist/5366.js.map +1 -0
- package/dist/5598.js +1 -0
- package/dist/5598.js.map +1 -0
- package/dist/5676.js +1 -0
- package/dist/5676.js.map +1 -0
- package/dist/5731.js +5 -0
- package/dist/5731.js.map +1 -0
- package/dist/5792.js +1 -0
- package/dist/5792.js.map +1 -0
- package/dist/5825.js +1 -0
- package/dist/5825.js.map +1 -0
- package/dist/5932.js +1 -0
- package/dist/5932.js.map +1 -0
- package/dist/5941.js +1 -0
- package/dist/5941.js.map +1 -0
- package/dist/5967.js +1 -0
- package/dist/5967.js.map +1 -0
- package/dist/6104.js +1 -0
- package/dist/6104.js.map +1 -0
- package/dist/624.js +1 -0
- package/dist/624.js.map +1 -0
- package/dist/6259.js +1 -0
- package/dist/6259.js.map +1 -0
- package/dist/6288.js +1 -0
- package/dist/6288.js.map +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/6337.js +1 -0
- package/dist/6337.js.map +1 -0
- package/dist/6427.js +1 -0
- package/dist/6427.js.map +1 -0
- package/dist/6478.js +7 -0
- package/dist/6478.js.map +1 -0
- package/dist/6508.js +1 -0
- package/dist/6508.js.map +1 -0
- package/dist/6567.js +1 -0
- package/dist/6567.js.map +1 -0
- package/dist/6634.js +1 -0
- package/dist/6634.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/7022.js +1 -0
- package/dist/7022.js.map +1 -0
- package/dist/7085.js +1 -0
- package/dist/7085.js.map +1 -0
- package/dist/7209.js +1 -0
- package/dist/7209.js.map +1 -0
- package/dist/7235.js +1 -0
- package/dist/7235.js.map +1 -0
- package/dist/7360.js +1 -0
- package/dist/7360.js.map +1 -0
- package/dist/7453.js +1 -0
- package/dist/7453.js.map +1 -0
- package/dist/7454.js +1 -0
- package/dist/7454.js.map +1 -0
- package/dist/7478.js +1 -0
- package/dist/7478.js.map +1 -0
- package/dist/7782.js +1 -0
- package/dist/7782.js.map +1 -0
- package/dist/7887.js +1 -0
- package/dist/7887.js.map +1 -0
- package/dist/8028.js +1 -0
- package/dist/8028.js.map +1 -0
- package/dist/8196.js +1 -0
- package/dist/8196.js.map +1 -0
- package/dist/820.js +1 -0
- package/dist/820.js.map +1 -0
- package/dist/8458.js +1 -0
- package/dist/8458.js.map +1 -0
- package/dist/8472.js +1 -0
- package/dist/8472.js.map +1 -0
- package/dist/8607.js +1 -0
- package/dist/8607.js.map +1 -0
- package/dist/8762.js +1 -0
- package/dist/8762.js.map +1 -0
- package/dist/8924.js +1 -0
- package/dist/8924.js.map +1 -0
- package/dist/8990.js +1 -0
- package/dist/8990.js.map +1 -0
- package/dist/9060.js +1 -0
- package/dist/9060.js.map +1 -0
- package/dist/9061.js +1 -0
- package/dist/9061.js.map +1 -0
- package/dist/9087.js +1 -0
- package/dist/9087.js.map +1 -0
- package/dist/9425.js +1 -0
- package/dist/9520.js +1 -0
- package/dist/9520.js.map +1 -0
- package/dist/9547.js +1 -0
- package/dist/9547.js.map +1 -0
- package/dist/9612.js +1 -0
- package/dist/9612.js.map +1 -0
- package/dist/9771.js +1 -0
- package/dist/9771.js.map +1 -0
- package/dist/9774.js +1 -0
- package/dist/9774.js.map +1 -0
- package/dist/9806.js +1 -0
- package/dist/9806.js.map +1 -0
- package/dist/992.js +1 -0
- package/dist/992.js.map +1 -0
- package/dist/997.js +1 -0
- package/dist/997.js.map +1 -0
- package/dist/kenyaemr-esm-icu-app.js +3 -0
- package/dist/kenyaemr-esm-icu-app.js.buildmanifest.json +3063 -0
- package/dist/kenyaemr-esm-icu-app.js.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -0
- package/dist/routes.json +1 -0
- package/package.json +49 -0
- package/rspack.config.js +1 -0
- package/src/components/bed-board/icu-bed-board.component.tsx +173 -0
- package/src/components/bed-board/icu-bed-board.scss +228 -0
- package/src/components/header/header.component.tsx +25 -0
- package/src/components/header/header.scss +24 -0
- package/src/components/patient-table/icu-patient-table.component.tsx +232 -0
- package/src/components/patient-table/icu-patient-table.scss +91 -0
- package/src/components/side-menu/left-panel.component.tsx +23 -0
- package/src/components/side-menu/left-panel.scss +7 -0
- package/src/components/summary/icu-summary-tiles.component.tsx +154 -0
- package/src/components/summary/icu-summary-tiles.scss +116 -0
- package/src/config-schema.ts +33 -0
- package/src/context/icu-census.context.tsx +68 -0
- package/src/dashboard-link.component.tsx +41 -0
- package/src/dashboard-link.scss +6 -0
- package/src/declarations.d.ts +2 -0
- package/src/icu-dashboard.component.tsx +28 -0
- package/src/icu-dashboard.scss +401 -0
- package/src/icu-embedded-dashboard.component.tsx +15 -0
- package/src/index.ts +59 -0
- package/src/left-panel-link.component.tsx +44 -0
- package/src/left-panel-link.scss +11 -0
- package/src/resources/icu-admission.resource.ts +546 -0
- package/src/root.component.tsx +29 -0
- package/src/root.scss +11 -0
- package/src/routes.json +38 -0
- package/src/types/icu-bed.types.ts +91 -0
- package/src/types/icu-census-patient.types.ts +24 -0
- package/src/types/icu-patient.types.ts +37 -0
- package/src/utils/icu-census.helpers.ts +31 -0
- package/src/utils/icu-day-label.ts +11 -0
- package/translations/am.json +48 -0
- package/translations/en.json +48 -0
- package/translations/fr.json +48 -0
- package/translations/sw.json +48 -0
- package/tsconfig.json +5 -0
- package/webpack.config.js +1 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import useSWR from 'swr';
|
|
4
|
+
|
|
5
|
+
import { type IcuConfig } from '../config-schema';
|
|
6
|
+
import { formatBedLabel, type IcuManagedBed, type OpenmrsBedStatus } from '../types/icu-bed.types';
|
|
7
|
+
import { emptyCareFlags, type IcuPatientSummary, type IcuWardSummary } from '../types/icu-patient.types';
|
|
8
|
+
|
|
9
|
+
type OpenmrsTag = { uuid?: string; display?: string; name?: string };
|
|
10
|
+
|
|
11
|
+
type OpenmrsLocation = {
|
|
12
|
+
uuid: string;
|
|
13
|
+
display?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
tags?: OpenmrsTag[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type OpenmrsIdentifier = {
|
|
19
|
+
uuid?: string;
|
|
20
|
+
identifier?: string;
|
|
21
|
+
display?: string;
|
|
22
|
+
preferred?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type OpenmrsPerson = {
|
|
26
|
+
uuid?: string;
|
|
27
|
+
display?: string;
|
|
28
|
+
gender?: string;
|
|
29
|
+
age?: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type OpenmrsBedPatient = {
|
|
33
|
+
uuid: string;
|
|
34
|
+
display?: string;
|
|
35
|
+
identifiers?: OpenmrsIdentifier[];
|
|
36
|
+
person?: OpenmrsPerson;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type OpenmrsBedTagMap = {
|
|
40
|
+
uuid?: string;
|
|
41
|
+
bedTag?: { uuid?: string; name?: string; display?: string };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type OpenmrsBedLayout = {
|
|
45
|
+
rowNumber?: number;
|
|
46
|
+
columnNumber?: number;
|
|
47
|
+
bedNumber?: string;
|
|
48
|
+
bedId?: number;
|
|
49
|
+
bedUuid?: string;
|
|
50
|
+
uuid?: string;
|
|
51
|
+
status?: string;
|
|
52
|
+
bedType?: { uuid?: string; name?: string; displayName?: string; description?: string };
|
|
53
|
+
location?: OpenmrsLocation | string;
|
|
54
|
+
patients?: OpenmrsBedPatient[];
|
|
55
|
+
bedTagMaps?: OpenmrsBedTagMap[];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type AdmissionLocationListItem = {
|
|
59
|
+
ward: OpenmrsLocation;
|
|
60
|
+
totalBeds?: number;
|
|
61
|
+
occupiedBeds?: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type AdmissionLocationDetail = {
|
|
65
|
+
ward: OpenmrsLocation;
|
|
66
|
+
totalBeds?: number;
|
|
67
|
+
occupiedBeds?: number;
|
|
68
|
+
bedLayouts?: OpenmrsBedLayout[];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type OpenmrsVisit = {
|
|
72
|
+
uuid: string;
|
|
73
|
+
startDatetime?: string;
|
|
74
|
+
stopDatetime?: string | null;
|
|
75
|
+
location?: OpenmrsLocation;
|
|
76
|
+
patient?: OpenmrsBedPatient;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type IcuCensusFetchResult = {
|
|
80
|
+
beds: IcuManagedBed[];
|
|
81
|
+
patients: IcuPatientSummary[];
|
|
82
|
+
wardSummary: IcuWardSummary;
|
|
83
|
+
icuWards: Array<{ uuid: string; display: string }>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Compact reps: request only what we render. `v=full` and `person:full` pull
|
|
87
|
+
// heavy nested payloads (addresses, attributes, encounters …) we never use.
|
|
88
|
+
const LOCATION_REP = 'custom:(uuid,display,name,tags:(uuid,display,name))';
|
|
89
|
+
|
|
90
|
+
const PATIENT_REP =
|
|
91
|
+
'custom:(uuid,display,identifiers:(uuid,identifier,display,preferred),person:(uuid,display,gender,age))';
|
|
92
|
+
|
|
93
|
+
const ADMISSION_LIST_REP = `custom:(ward:${LOCATION_REP},totalBeds,occupiedBeds)`;
|
|
94
|
+
|
|
95
|
+
const ADMISSION_LAYOUT_REP =
|
|
96
|
+
`custom:(ward:${LOCATION_REP},totalBeds,occupiedBeds,` +
|
|
97
|
+
`bedLayouts:(rowNumber,columnNumber,bedNumber,bedId,bedUuid,status,` +
|
|
98
|
+
`location:${LOCATION_REP},bedType:(uuid,name,displayName,description),` +
|
|
99
|
+
`patients:${PATIENT_REP},bedTagMaps:(uuid,bedTag:(uuid,name,display))))`;
|
|
100
|
+
|
|
101
|
+
const VISIT_REP = `custom:(uuid,startDatetime,stopDatetime,location:${LOCATION_REP},patient:${PATIENT_REP})`;
|
|
102
|
+
|
|
103
|
+
function tagMatches(tag: OpenmrsTag | undefined, tagUuid: string, tagName: string): boolean {
|
|
104
|
+
if (!tag) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (tag.uuid && tagUuid && tag.uuid === tagUuid) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
const name = (tag.name || tag.display || '').trim().toLowerCase();
|
|
111
|
+
const target = tagName.trim().toLowerCase();
|
|
112
|
+
if (!name || !target) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return name === target || name.includes(target) || target.includes(name);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function locationHasIcuTag(location: OpenmrsLocation | undefined, tagUuid: string, tagName: string): boolean {
|
|
119
|
+
if (!location?.tags?.length) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return location.tags.some((tag) => tagMatches(tag, tagUuid, tagName));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* True when a ward is an ICU candidate by tag UUID/name OR display name
|
|
127
|
+
* (covers facilities where admissionLocation omits tags on list payloads).
|
|
128
|
+
*/
|
|
129
|
+
function isIcuWardCandidate(ward: OpenmrsLocation | undefined, tagUuid: string, tagName: string): boolean {
|
|
130
|
+
if (!ward?.uuid) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (locationHasIcuTag(ward, tagUuid, tagName)) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
const display = `${ward.display || ''} ${ward.name || ''}`.trim().toLowerCase();
|
|
137
|
+
const target = tagName.trim().toLowerCase();
|
|
138
|
+
if (target && (display === target || display.includes(target))) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return /icu|intensive\s*care/.test(display);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function pickIdentifier(patient: OpenmrsBedPatient): string {
|
|
145
|
+
const ids = patient.identifiers ?? [];
|
|
146
|
+
const preferred = ids.find((i) => i.preferred) ?? ids[0];
|
|
147
|
+
if (!preferred) {
|
|
148
|
+
return '—';
|
|
149
|
+
}
|
|
150
|
+
if (preferred.identifier) {
|
|
151
|
+
return preferred.identifier;
|
|
152
|
+
}
|
|
153
|
+
if (preferred.display) {
|
|
154
|
+
const parts = preferred.display.split('=');
|
|
155
|
+
return (parts[parts.length - 1] || preferred.display).trim();
|
|
156
|
+
}
|
|
157
|
+
return '—';
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function parseBedNumber(bedNumber: string | undefined): number {
|
|
161
|
+
if (!bedNumber) {
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
const match = bedNumber.match(/(\d+)/);
|
|
165
|
+
return match ? Number.parseInt(match[1], 10) : 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function normalizeStatus(status: string | undefined): OpenmrsBedStatus {
|
|
169
|
+
if (!status) {
|
|
170
|
+
return 'AVAILABLE';
|
|
171
|
+
}
|
|
172
|
+
return String(status).toUpperCase();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function mapLocation(
|
|
176
|
+
layoutLocation: OpenmrsLocation | string | undefined,
|
|
177
|
+
ward: OpenmrsLocation,
|
|
178
|
+
tagName: string,
|
|
179
|
+
): IcuManagedBed['location'] {
|
|
180
|
+
if (typeof layoutLocation === 'object' && layoutLocation?.uuid) {
|
|
181
|
+
return {
|
|
182
|
+
uuid: layoutLocation.uuid,
|
|
183
|
+
display: layoutLocation.display || layoutLocation.name || ward.display || 'ICU',
|
|
184
|
+
tags: (layoutLocation.tags ?? ward.tags ?? [])
|
|
185
|
+
.map((t) => t.display || t.name || tagName)
|
|
186
|
+
.filter(Boolean) as string[],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
uuid: ward.uuid,
|
|
191
|
+
display: ward.display || ward.name || 'ICU Ward',
|
|
192
|
+
tags: (ward.tags ?? []).map((t) => t.display || t.name || tagName).filter(Boolean) as string[],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function mapPatientFromBed(
|
|
197
|
+
patient: OpenmrsBedPatient,
|
|
198
|
+
bed: IcuManagedBed,
|
|
199
|
+
ward: OpenmrsLocation,
|
|
200
|
+
admissionDate?: string,
|
|
201
|
+
): IcuPatientSummary {
|
|
202
|
+
const displayName = patient.person?.display || patient.display || 'Unknown patient';
|
|
203
|
+
return {
|
|
204
|
+
patientUuid: patient.uuid,
|
|
205
|
+
displayName,
|
|
206
|
+
identifier: pickIdentifier(patient),
|
|
207
|
+
bedLabel: formatBedLabel(bed.bedNumber),
|
|
208
|
+
bedNumber: parseBedNumber(bed.bedNumber),
|
|
209
|
+
admissionDate: admissionDate || '',
|
|
210
|
+
diagnosis: '—',
|
|
211
|
+
locationUuid: bed.location.uuid ?? ward.uuid,
|
|
212
|
+
locationDisplay: bed.location.display,
|
|
213
|
+
...emptyCareFlags(),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function mapLayoutToBeds(
|
|
218
|
+
detail: AdmissionLocationDetail,
|
|
219
|
+
tagName: string,
|
|
220
|
+
): {
|
|
221
|
+
beds: IcuManagedBed[];
|
|
222
|
+
patients: IcuPatientSummary[];
|
|
223
|
+
} {
|
|
224
|
+
const ward = detail.ward;
|
|
225
|
+
const beds: IcuManagedBed[] = [];
|
|
226
|
+
const patients: IcuPatientSummary[] = [];
|
|
227
|
+
|
|
228
|
+
for (const layout of detail.bedLayouts ?? []) {
|
|
229
|
+
const bedUuid = layout.bedUuid || layout.uuid;
|
|
230
|
+
if (!bedUuid) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const layoutPatients = layout.patients ?? [];
|
|
234
|
+
const primary = layoutPatients[0];
|
|
235
|
+
const status = normalizeStatus(layout.status);
|
|
236
|
+
const bed: IcuManagedBed = {
|
|
237
|
+
uuid: bedUuid,
|
|
238
|
+
bedId: layout.bedId,
|
|
239
|
+
bedNumber: layout.bedNumber || '—',
|
|
240
|
+
row: layout.rowNumber ?? 0,
|
|
241
|
+
column: layout.columnNumber ?? 0,
|
|
242
|
+
status:
|
|
243
|
+
primary || layoutPatients.length > 0 ? 'OCCUPIED' : status === 'OCCUPIED' && !primary ? 'AVAILABLE' : status,
|
|
244
|
+
location: mapLocation(layout.location, ward, tagName),
|
|
245
|
+
bedType: {
|
|
246
|
+
uuid: layout.bedType?.uuid,
|
|
247
|
+
name: layout.bedType?.name || layout.bedType?.displayName || 'standard',
|
|
248
|
+
displayName: layout.bedType?.displayName || layout.bedType?.name || 'Standard',
|
|
249
|
+
description: layout.bedType?.description,
|
|
250
|
+
},
|
|
251
|
+
bedTags: (layout.bedTagMaps ?? [])
|
|
252
|
+
.map((m) => ({
|
|
253
|
+
uuid: m.bedTag?.uuid,
|
|
254
|
+
name: m.bedTag?.name || m.bedTag?.display || '',
|
|
255
|
+
}))
|
|
256
|
+
.filter((t) => t.name),
|
|
257
|
+
patientUuid: primary?.uuid,
|
|
258
|
+
};
|
|
259
|
+
beds.push(bed);
|
|
260
|
+
for (const p of layoutPatients) {
|
|
261
|
+
patients.push(mapPatientFromBed(p, bed, ward));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return { beds, patients };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function summarize(beds: IcuManagedBed[], wards: OpenmrsLocation[]): IcuWardSummary {
|
|
269
|
+
let occupied = 0;
|
|
270
|
+
let available = 0;
|
|
271
|
+
let reserved = 0;
|
|
272
|
+
for (const bed of beds) {
|
|
273
|
+
const s = String(bed.status).toUpperCase();
|
|
274
|
+
if (s === 'OCCUPIED' || bed.patientUuid) {
|
|
275
|
+
occupied += 1;
|
|
276
|
+
} else if (s === 'RESERVED') {
|
|
277
|
+
reserved += 1;
|
|
278
|
+
} else {
|
|
279
|
+
available += 1;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
totalBeds: beds.length,
|
|
284
|
+
occupied,
|
|
285
|
+
available,
|
|
286
|
+
reserved,
|
|
287
|
+
wardNames: wards.map((w) => w.display || w.name || w.uuid),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function mergeWards(...lists: OpenmrsLocation[][]): OpenmrsLocation[] {
|
|
292
|
+
const map = new Map<string, OpenmrsLocation>();
|
|
293
|
+
for (const list of lists) {
|
|
294
|
+
for (const ward of list) {
|
|
295
|
+
if (!ward?.uuid) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const existing = map.get(ward.uuid);
|
|
299
|
+
if (!existing) {
|
|
300
|
+
map.set(ward.uuid, ward);
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if ((!existing.tags || existing.tags.length === 0) && ward.tags?.length) {
|
|
304
|
+
map.set(ward.uuid, { ...existing, ...ward, tags: ward.tags });
|
|
305
|
+
} else {
|
|
306
|
+
map.set(ward.uuid, { ...existing, ...ward, tags: existing.tags?.length ? existing.tags : ward.tags });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return [...map.values()];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async function loadWardsByTag(tagUuid: string): Promise<OpenmrsLocation[]> {
|
|
314
|
+
if (!tagUuid) {
|
|
315
|
+
return [];
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
const locRes = await openmrsFetch<{ results?: OpenmrsLocation[] }>(
|
|
319
|
+
`${restBaseUrl}/location?tag=${encodeURIComponent(tagUuid)}&v=${LOCATION_REP}`,
|
|
320
|
+
);
|
|
321
|
+
return locRes.data?.results ?? [];
|
|
322
|
+
} catch {
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async function loadAdmissionLocationList(): Promise<AdmissionLocationListItem[]> {
|
|
328
|
+
try {
|
|
329
|
+
const listRes = await openmrsFetch<{ results?: AdmissionLocationListItem[] }>(
|
|
330
|
+
`${restBaseUrl}/admissionLocation?v=${ADMISSION_LIST_REP}`,
|
|
331
|
+
);
|
|
332
|
+
return listRes.data?.results ?? [];
|
|
333
|
+
} catch {
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function loadAdmissionLocationDetail(wardUuid: string): Promise<AdmissionLocationDetail | null> {
|
|
339
|
+
try {
|
|
340
|
+
const res = await openmrsFetch<AdmissionLocationDetail>(
|
|
341
|
+
`${restBaseUrl}/admissionLocation/${wardUuid}?v=${ADMISSION_LAYOUT_REP}`,
|
|
342
|
+
);
|
|
343
|
+
return res.data;
|
|
344
|
+
} catch {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Active visits sitting on ICU wards where Bed Management has not assigned a
|
|
351
|
+
* physical bed yet. Runs only when the bed layout produced zero patients for
|
|
352
|
+
* a ward — otherwise every render would do the extra visit round-trip.
|
|
353
|
+
*/
|
|
354
|
+
async function loadVisitPatientsForWards(
|
|
355
|
+
wards: OpenmrsLocation[],
|
|
356
|
+
knownPatientUuids: Set<string>,
|
|
357
|
+
tagName: string,
|
|
358
|
+
): Promise<{ beds: IcuManagedBed[]; patients: IcuPatientSummary[] }> {
|
|
359
|
+
if (!wards.length) {
|
|
360
|
+
return { beds: [], patients: [] };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const wardByUuid = new Map(wards.map((w) => [w.uuid, w]));
|
|
364
|
+
const beds: IcuManagedBed[] = [];
|
|
365
|
+
const patients: IcuPatientSummary[] = [];
|
|
366
|
+
|
|
367
|
+
const perLocation = await Promise.all(
|
|
368
|
+
wards.map(async (ward) => {
|
|
369
|
+
try {
|
|
370
|
+
const res = await openmrsFetch<{ results?: OpenmrsVisit[] }>(
|
|
371
|
+
`${restBaseUrl}/visit?location=${ward.uuid}&includeInactive=false&v=${VISIT_REP}&limit=100`,
|
|
372
|
+
);
|
|
373
|
+
return res.data?.results ?? [];
|
|
374
|
+
} catch {
|
|
375
|
+
return [] as OpenmrsVisit[];
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
);
|
|
379
|
+
const visits = perLocation.flat();
|
|
380
|
+
|
|
381
|
+
let unassignedIndex = 0;
|
|
382
|
+
for (const visit of visits) {
|
|
383
|
+
const patient = visit.patient;
|
|
384
|
+
if (!patient?.uuid || knownPatientUuids.has(patient.uuid)) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (visit.stopDatetime) {
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const loc = visit.location;
|
|
391
|
+
const ward = (loc?.uuid && wardByUuid.get(loc.uuid)) || (loc?.uuid ? loc : undefined) || wards[0];
|
|
392
|
+
if (!ward) {
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
unassignedIndex += 1;
|
|
397
|
+
const bed: IcuManagedBed = {
|
|
398
|
+
uuid: `visit-unassigned-${visit.uuid}`,
|
|
399
|
+
bedNumber: `Unassigned-${unassignedIndex}`,
|
|
400
|
+
row: 0,
|
|
401
|
+
column: unassignedIndex,
|
|
402
|
+
status: 'OCCUPIED',
|
|
403
|
+
location: mapLocation(loc, ward, tagName),
|
|
404
|
+
bedType: {
|
|
405
|
+
name: 'unassigned',
|
|
406
|
+
displayName: 'No bed assigned',
|
|
407
|
+
},
|
|
408
|
+
bedTags: [{ name: 'Visit only' }],
|
|
409
|
+
patientUuid: patient.uuid,
|
|
410
|
+
};
|
|
411
|
+
beds.push(bed);
|
|
412
|
+
patients.push(mapPatientFromBed(patient, bed, ward, visit.startDatetime));
|
|
413
|
+
knownPatientUuids.add(patient.uuid);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return { beds, patients };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Loads real ICU beds + inpatients from Bed Management admissionLocation APIs,
|
|
421
|
+
* plus active visits on ICU locations only for wards missing bed-layout patients.
|
|
422
|
+
*/
|
|
423
|
+
export async function fetchIcuCensus(tagUuid: string, tagName: string): Promise<IcuCensusFetchResult> {
|
|
424
|
+
// 1 + 2 in parallel: bed inventory and tagged locations (no waterfall).
|
|
425
|
+
const [admissionItems, taggedLocations] = await Promise.all([loadAdmissionLocationList(), loadWardsByTag(tagUuid)]);
|
|
426
|
+
|
|
427
|
+
const fromAdmission = admissionItems
|
|
428
|
+
.map((item) => item.ward)
|
|
429
|
+
.filter((w): w is OpenmrsLocation => Boolean(w?.uuid) && isIcuWardCandidate(w, tagUuid, tagName));
|
|
430
|
+
|
|
431
|
+
let icuWards = mergeWards(fromAdmission, taggedLocations);
|
|
432
|
+
|
|
433
|
+
if (icuWards.length === 0) {
|
|
434
|
+
icuWards = mergeWards(
|
|
435
|
+
admissionItems
|
|
436
|
+
.map((item) => item.ward)
|
|
437
|
+
.filter(
|
|
438
|
+
(w): w is OpenmrsLocation =>
|
|
439
|
+
Boolean(w?.uuid) && /icu|intensive\s*care/i.test(`${w.display || ''} ${w.name || ''}`),
|
|
440
|
+
),
|
|
441
|
+
taggedLocations,
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (icuWards.length === 0) {
|
|
446
|
+
return {
|
|
447
|
+
beds: [],
|
|
448
|
+
patients: [],
|
|
449
|
+
wardSummary: { totalBeds: 0, occupied: 0, available: 0, reserved: 0, wardNames: [] },
|
|
450
|
+
icuWards: [],
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const details = await Promise.all(icuWards.map((ward) => loadAdmissionLocationDetail(ward.uuid)));
|
|
455
|
+
|
|
456
|
+
const beds: IcuManagedBed[] = [];
|
|
457
|
+
const patients: IcuPatientSummary[] = [];
|
|
458
|
+
const wardsWithDetail: OpenmrsLocation[] = [];
|
|
459
|
+
const knownPatientUuids = new Set<string>();
|
|
460
|
+
const wardsMissingPatients: OpenmrsLocation[] = [];
|
|
461
|
+
|
|
462
|
+
for (let i = 0; i < details.length; i++) {
|
|
463
|
+
const detail = details[i];
|
|
464
|
+
const fallbackWard = icuWards[i];
|
|
465
|
+
if (!detail?.ward) {
|
|
466
|
+
if (fallbackWard) {
|
|
467
|
+
wardsWithDetail.push(fallbackWard);
|
|
468
|
+
wardsMissingPatients.push(fallbackWard);
|
|
469
|
+
}
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
wardsWithDetail.push(detail.ward);
|
|
473
|
+
const mapped = mapLayoutToBeds(detail, tagName);
|
|
474
|
+
beds.push(...mapped.beds);
|
|
475
|
+
let addedForWard = 0;
|
|
476
|
+
for (const p of mapped.patients) {
|
|
477
|
+
if (!knownPatientUuids.has(p.patientUuid)) {
|
|
478
|
+
patients.push(p);
|
|
479
|
+
knownPatientUuids.add(p.patientUuid);
|
|
480
|
+
addedForWard += 1;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (addedForWard === 0) {
|
|
484
|
+
wardsMissingPatients.push(detail.ward);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Only hit /visit for wards whose bed layout produced no patients.
|
|
489
|
+
if (wardsMissingPatients.length > 0) {
|
|
490
|
+
const visitOnly = await loadVisitPatientsForWards(wardsMissingPatients, knownPatientUuids, tagName);
|
|
491
|
+
beds.push(...visitOnly.beds);
|
|
492
|
+
patients.push(...visitOnly.patients);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
beds.sort(
|
|
496
|
+
(a, b) =>
|
|
497
|
+
a.row - b.row || a.column - b.column || a.bedNumber.localeCompare(b.bedNumber, undefined, { numeric: true }),
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
const wardsForSummary = wardsWithDetail.length ? wardsWithDetail : icuWards;
|
|
501
|
+
|
|
502
|
+
return {
|
|
503
|
+
beds,
|
|
504
|
+
patients,
|
|
505
|
+
wardSummary: summarize(beds, wardsForSummary),
|
|
506
|
+
icuWards: wardsForSummary.map((w) => ({ uuid: w.uuid, display: w.display || w.name || w.uuid })),
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export function useIcuCensusData() {
|
|
511
|
+
const config = useConfig<IcuConfig>();
|
|
512
|
+
const tagUuid = config.icuLocationTagUuid;
|
|
513
|
+
const tagName = config.icuLocationTagName ?? 'ICU Ward';
|
|
514
|
+
|
|
515
|
+
const key = tagUuid || tagName ? ['icu-census', tagUuid, tagName] : null;
|
|
516
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR(key, () => fetchIcuCensus(tagUuid, tagName), {
|
|
517
|
+
// Fewer refetches; instant paint from cache; no focus-storm on tab switch.
|
|
518
|
+
keepPreviousData: true,
|
|
519
|
+
revalidateOnFocus: false,
|
|
520
|
+
revalidateIfStale: false,
|
|
521
|
+
dedupingInterval: 60_000,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
const empty = useMemo(
|
|
525
|
+
(): IcuCensusFetchResult => ({
|
|
526
|
+
beds: [],
|
|
527
|
+
patients: [],
|
|
528
|
+
wardSummary: { totalBeds: 0, occupied: 0, available: 0, reserved: 0, wardNames: [] },
|
|
529
|
+
icuWards: [],
|
|
530
|
+
}),
|
|
531
|
+
[],
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
return {
|
|
535
|
+
beds: data?.beds ?? empty.beds,
|
|
536
|
+
patients: data?.patients ?? empty.patients,
|
|
537
|
+
wardSummary: data?.wardSummary ?? empty.wardSummary,
|
|
538
|
+
icuWards: data?.icuWards ?? empty.icuWards,
|
|
539
|
+
isLoading,
|
|
540
|
+
isValidating,
|
|
541
|
+
error,
|
|
542
|
+
mutate,
|
|
543
|
+
tagUuid,
|
|
544
|
+
tagName,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLeftNav } from '@openmrs/esm-framework';
|
|
3
|
+
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
|
4
|
+
import LeftPanel from './components/side-menu/left-panel.component';
|
|
5
|
+
import IcuDashboard from './icu-dashboard.component';
|
|
6
|
+
import styles from './root.scss';
|
|
7
|
+
|
|
8
|
+
const IcuRoot: React.FC = () => {
|
|
9
|
+
const spaBasePath = globalThis.spaBase;
|
|
10
|
+
const icuBasename = `${globalThis.getOpenmrsSpaBase()}icu`;
|
|
11
|
+
|
|
12
|
+
useLeftNav({
|
|
13
|
+
name: 'icu-left-panel-slot',
|
|
14
|
+
basePath: spaBasePath,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<BrowserRouter basename={icuBasename}>
|
|
19
|
+
<LeftPanel />
|
|
20
|
+
<main className={styles.container}>
|
|
21
|
+
<Routes>
|
|
22
|
+
<Route path="/" element={<IcuDashboard standalone />} />
|
|
23
|
+
</Routes>
|
|
24
|
+
</main>
|
|
25
|
+
</BrowserRouter>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default IcuRoot;
|
package/src/root.scss
ADDED
package/src/routes.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.openmrs.org/routes.schema.json",
|
|
3
|
+
"backendDependencies": {
|
|
4
|
+
"webservices.rest": ">=2.24.0"
|
|
5
|
+
},
|
|
6
|
+
"pages": [
|
|
7
|
+
{
|
|
8
|
+
"component": "root",
|
|
9
|
+
"route": "icu"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"extensions": [
|
|
13
|
+
{
|
|
14
|
+
"component": "icuLeftPanelLink",
|
|
15
|
+
"name": "icu-left-panel-link",
|
|
16
|
+
"slot": "icu-left-panel-slot"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"component": "icuHomeDashboardLink",
|
|
20
|
+
"name": "icu-home-dashboard-link",
|
|
21
|
+
"slot": "homepage-dashboard-slot",
|
|
22
|
+
"meta": {
|
|
23
|
+
"name": "icu",
|
|
24
|
+
"slot": "icu-dashboard-slot",
|
|
25
|
+
"title": "ICU"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"component": "icuEmbeddedDashboard",
|
|
30
|
+
"name": "icu-dashboard-root",
|
|
31
|
+
"slot": "icu-dashboard-slot"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"modals": [],
|
|
35
|
+
"workspaces2": [],
|
|
36
|
+
"workspaceWindows2": [],
|
|
37
|
+
"workspaceGroups2": []
|
|
38
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenMRS Bed Management shape (what ICU will link to later).
|
|
3
|
+
*
|
|
4
|
+
* Creating a bed in Bed Management typically records:
|
|
5
|
+
* - bedNumber
|
|
6
|
+
* - row / column (layout grid)
|
|
7
|
+
* - location (OpenMRS Location)
|
|
8
|
+
* - location tag(s) — e.g. tag display name "ICU" scopes beds for this module
|
|
9
|
+
* - occupancy status (AVAILABLE | OCCUPIED | …)
|
|
10
|
+
* - bedType
|
|
11
|
+
* - bedTag (optional labels)
|
|
12
|
+
*
|
|
13
|
+
* Link strategy (backend phase):
|
|
14
|
+
* 1. Resolve ICU location(s) via location tag (config: `icuLocationTagName` / UUID).
|
|
15
|
+
* 2. Load beds: GET /ws/rest/v1/bed?locationUuid=… or admissionLocation/{wardUuid}.
|
|
16
|
+
* 3. Map occupancy + patient assignment from bed layout.
|
|
17
|
+
* 4. Transfer = unassign/assign bed APIs used by bed-management SPA.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Occupancy status values used by OpenMRS bed module (and demo). */
|
|
21
|
+
export type OpenmrsBedStatus = 'AVAILABLE' | 'OCCUPIED' | 'RESERVED' | string;
|
|
22
|
+
|
|
23
|
+
export type IcuBedType = {
|
|
24
|
+
/** OpenMRS bed type uuid (empty in demo until API linked). */
|
|
25
|
+
uuid?: string;
|
|
26
|
+
name: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type IcuBedTag = {
|
|
32
|
+
uuid?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type IcuLocationRef = {
|
|
37
|
+
/** OpenMRS location uuid. */
|
|
38
|
+
uuid?: string;
|
|
39
|
+
display: string;
|
|
40
|
+
/** Location tags that qualify this location as ICU (e.g. "ICU"). */
|
|
41
|
+
tags: string[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* One physical bed — mirrors Bed / BedLayout from bed-management + clinical-view types.
|
|
46
|
+
*/
|
|
47
|
+
export type IcuManagedBed = {
|
|
48
|
+
/** Local demo id or OpenMRS bed uuid when linked. */
|
|
49
|
+
uuid: string;
|
|
50
|
+
/** OpenMRS bed id (numeric) when known. */
|
|
51
|
+
bedId?: number;
|
|
52
|
+
bedNumber: string;
|
|
53
|
+
row: number;
|
|
54
|
+
column: number;
|
|
55
|
+
status: OpenmrsBedStatus;
|
|
56
|
+
location: IcuLocationRef;
|
|
57
|
+
bedType: IcuBedType;
|
|
58
|
+
bedTags: IcuBedTag[];
|
|
59
|
+
/** Patient currently assigned (if OCCUPIED). */
|
|
60
|
+
patientUuid?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Convenience label for UI (“Bed 3” or bare number). */
|
|
64
|
+
export function formatBedLabel(bedNumber: string): string {
|
|
65
|
+
if (/^bed\s/i.test(bedNumber)) {
|
|
66
|
+
return bedNumber;
|
|
67
|
+
}
|
|
68
|
+
return `Bed ${bedNumber}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function toOpenmrsStatus(demoStatus: 'available' | 'occupied' | 'reserved'): OpenmrsBedStatus {
|
|
72
|
+
switch (demoStatus) {
|
|
73
|
+
case 'occupied':
|
|
74
|
+
return 'OCCUPIED';
|
|
75
|
+
case 'reserved':
|
|
76
|
+
return 'RESERVED';
|
|
77
|
+
default:
|
|
78
|
+
return 'AVAILABLE';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function fromOpenmrsStatus(status: OpenmrsBedStatus): 'available' | 'occupied' | 'reserved' {
|
|
83
|
+
const s = String(status).toUpperCase();
|
|
84
|
+
if (s === 'OCCUPIED') {
|
|
85
|
+
return 'occupied';
|
|
86
|
+
}
|
|
87
|
+
if (s === 'RESERVED') {
|
|
88
|
+
return 'reserved';
|
|
89
|
+
}
|
|
90
|
+
return 'available';
|
|
91
|
+
}
|