@kenyaemr/esm-morgue-app 5.4.2-pre.2297 → 5.4.2-pre.2305
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 +10 -10
- package/dist/201.js +1 -1
- package/dist/201.js.map +1 -1
- package/dist/398.js +1 -1
- package/dist/398.js.map +1 -1
- package/dist/{826.js → 579.js} +2 -2
- package/dist/{826.js.map → 579.js.map} +1 -1
- package/dist/632.js +1 -1
- package/dist/632.js.map +1 -1
- package/dist/633.js +1 -1
- package/dist/633.js.map +1 -1
- package/dist/{146.js → 989.js} +2 -2
- package/dist/989.js.map +1 -0
- package/dist/kenyaemr-esm-morgue-app.js +1 -1
- package/dist/kenyaemr-esm-morgue-app.js.buildmanifest.json +73 -73
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/bed-layout/discharged/discharged-bed-layout.component.tsx +32 -3
- package/src/bed-layout/discharged/discharged-bed-layout.resource.ts +22 -12
- package/src/bed-linelist-view/admitted/admitted-bed-linelist-view.component.tsx +1 -0
- package/src/bed-linelist-view/discharged/discharged-bed-line-view.component.tsx +0 -1
- package/src/config-schema.ts +0 -6
- package/src/forms/admit-deceased-person-workspace/admit-deceased-person.resource.ts +117 -75
- package/src/forms/admit-deceased-person-workspace/admit-deceased-person.scss +1 -1
- package/src/forms/admit-deceased-person-workspace/admit-deceased-person.workspace.tsx +15 -14
- package/src/forms/discharge-deceased-person-workspace/discharge-body.resource.ts +124 -26
- package/src/forms/discharge-deceased-person-workspace/discharge-body.workspace.tsx +188 -82
- package/src/forms/dispose-deceased-person-workspace/dispose-deceased-person.workspace.tsx +133 -48
- package/src/home/home.component.tsx +7 -2
- package/src/home/home.resource.ts +1 -1
- package/src/switcher/content-switcher.component.tsx +0 -1
- package/src/types/index.ts +1 -4
- package/src/utils/utils.ts +23 -39
- package/dist/146.js.map +0 -1
- /package/dist/{826.js.LICENSE.txt → 579.js.LICENSE.txt} +0 -0
- /package/dist/{146.js.LICENSE.txt → 989.js.LICENSE.txt} +0 -0
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"action-buttons","component":"actionBarButtons","slot":"mortuary-action-buttons-slot","meta":{"fullWidth":false,"privileges":["o3 : View Mortuary Dashboard","o3 : Admit Body to Mortuary","o3 : Edit Mortuary Records","o3 : Discharge Body from Mortuary","o3 : View Mortuary Compartments","o3 : Swap Mortuary Compartments","o3 : View Mortuary Billing","o3 : Process Mortuary Payments","o3 : View Mortuary Reports","o3 : Generate Mortuary Reports"]}},{"name":"deceased-banner-info","component":"bannerInfo","slot":"deceased-banner-info-slot","meta":{"fullWidth":false}},{"component":"root","name":"morgue-dashboard-root","slot":"morgue-dashboard-slot","meta":{"privileges":["o3 : View Mortuary Dashboard"]}}],"workspaces":[{"name":"patient-additional-info-form","component":"patientAdditionalInfoForm","title":"add more details","type":"other-form"},{"name":"discharge-body-form","component":"dischargeBodyForm","title":"discharge body form","type":"other-form"},{"name":"admit-body-form","component":"admitBodyForm","title":"Admission form","type":"other-form"},{"name":"swap-unit-form","component":"swapForm","title":"Swap form","type":"other-form"},{"name":"admit-deceased-person-form","component":"admitDeceasedPersonForm","title":"Admit Deceased Person","type":"other-form"},{"name":"mortuary-form-entry","component":"mortuaryFormEntry","title":"Mortuary Form Entry","type":"form","width":"extra-wide","canMaximize":true,"canHide":true},{"name":"dispose-deceased-person-form","component":"disposeDeceasedPersonForm","title":"Dispose Deceased Person","type":"other-form"}],"pages":[{"component":"root","route":"morgue"}],"version":"5.4.2-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"action-buttons","component":"actionBarButtons","slot":"mortuary-action-buttons-slot","meta":{"fullWidth":false,"privileges":["o3 : View Mortuary Dashboard","o3 : Admit Body to Mortuary","o3 : Edit Mortuary Records","o3 : Discharge Body from Mortuary","o3 : View Mortuary Compartments","o3 : Swap Mortuary Compartments","o3 : View Mortuary Billing","o3 : Process Mortuary Payments","o3 : View Mortuary Reports","o3 : Generate Mortuary Reports"]}},{"name":"deceased-banner-info","component":"bannerInfo","slot":"deceased-banner-info-slot","meta":{"fullWidth":false}},{"component":"root","name":"morgue-dashboard-root","slot":"morgue-dashboard-slot","meta":{"privileges":["o3 : View Mortuary Dashboard"]}}],"workspaces":[{"name":"patient-additional-info-form","component":"patientAdditionalInfoForm","title":"add more details","type":"other-form"},{"name":"discharge-body-form","component":"dischargeBodyForm","title":"discharge body form","type":"other-form"},{"name":"admit-body-form","component":"admitBodyForm","title":"Admission form","type":"other-form"},{"name":"swap-unit-form","component":"swapForm","title":"Swap form","type":"other-form"},{"name":"admit-deceased-person-form","component":"admitDeceasedPersonForm","title":"Admit Deceased Person","type":"other-form"},{"name":"mortuary-form-entry","component":"mortuaryFormEntry","title":"Mortuary Form Entry","type":"form","width":"extra-wide","canMaximize":true,"canHide":true},{"name":"dispose-deceased-person-form","component":"disposeDeceasedPersonForm","title":"Dispose Deceased Person","type":"other-form"}],"pages":[{"component":"root","route":"morgue"}],"version":"5.4.2-pre.2305"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { InlineLoading } from '@carbon/react';
|
|
3
|
+
import { DataTableSkeleton, InlineLoading, Pagination } from '@carbon/react';
|
|
4
4
|
import { launchWorkspace, useConfig } from '@openmrs/esm-framework';
|
|
5
5
|
import styles from '../bed-layout.scss';
|
|
6
6
|
import { type MortuaryLocationResponse } from '../../types';
|
|
@@ -31,6 +31,11 @@ const DischargedBedLayout: React.FC<BedLayoutProps> = ({
|
|
|
31
31
|
dischargedPatientUuids,
|
|
32
32
|
isLoading: encountersLoading,
|
|
33
33
|
error: encountersError,
|
|
34
|
+
currentPage,
|
|
35
|
+
totalCount,
|
|
36
|
+
currPageSize,
|
|
37
|
+
setCurrPageSize,
|
|
38
|
+
goTo,
|
|
34
39
|
} = useMortuaryDischargeEncounter(morgueDischargeEncounterTypeUuid, AdmittedDeceasedPatient);
|
|
35
40
|
|
|
36
41
|
const {
|
|
@@ -51,6 +56,13 @@ const DischargedBedLayout: React.FC<BedLayoutProps> = ({
|
|
|
51
56
|
}
|
|
52
57
|
};
|
|
53
58
|
|
|
59
|
+
const handlePageSizeChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
|
60
|
+
const newPageSize = parseInt(event.target.value, 10);
|
|
61
|
+
setCurrPageSize(newPageSize);
|
|
62
|
+
// Reset to first page when changing page size
|
|
63
|
+
goTo(1);
|
|
64
|
+
};
|
|
65
|
+
|
|
54
66
|
if (isLoading || encountersLoading || patientsLoading) {
|
|
55
67
|
return (
|
|
56
68
|
<div className={styles.loadingContainer}>
|
|
@@ -69,8 +81,8 @@ const DischargedBedLayout: React.FC<BedLayoutProps> = ({
|
|
|
69
81
|
|
|
70
82
|
if (!dischargedPatients || dischargedPatients.length === 0) {
|
|
71
83
|
return (
|
|
72
|
-
<div className={styles.
|
|
73
|
-
<
|
|
84
|
+
<div className={styles.loadingContainer}>
|
|
85
|
+
<DataTableSkeleton columnCount={5} rowCount={5} zebra />
|
|
74
86
|
</div>
|
|
75
87
|
);
|
|
76
88
|
}
|
|
@@ -102,6 +114,23 @@ const DischargedBedLayout: React.FC<BedLayoutProps> = ({
|
|
|
102
114
|
);
|
|
103
115
|
})}
|
|
104
116
|
</div>
|
|
117
|
+
|
|
118
|
+
<div className={styles.paginationFooter}>
|
|
119
|
+
<Pagination
|
|
120
|
+
page={currentPage || 1}
|
|
121
|
+
totalItems={totalCount || 0}
|
|
122
|
+
pageSize={currPageSize}
|
|
123
|
+
pageSizes={[10, 20, 50, 100]}
|
|
124
|
+
onChange={({ page, pageSize }: { page: number; pageSize: number }) => {
|
|
125
|
+
if (pageSize !== currPageSize) {
|
|
126
|
+
setCurrPageSize(pageSize);
|
|
127
|
+
goTo(1);
|
|
128
|
+
} else {
|
|
129
|
+
goTo(page);
|
|
130
|
+
}
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
105
134
|
</div>
|
|
106
135
|
);
|
|
107
136
|
};
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FetchResponse,
|
|
3
|
-
fhirBaseUrl,
|
|
4
|
-
openmrsFetch,
|
|
5
|
-
restBaseUrl,
|
|
6
|
-
useFhirFetchAll,
|
|
7
|
-
useFhirPagination,
|
|
8
|
-
} from '@openmrs/esm-framework';
|
|
1
|
+
import { FetchResponse, fhirBaseUrl, openmrsFetch, restBaseUrl, useFhirPagination } from '@openmrs/esm-framework';
|
|
9
2
|
import useSWR from 'swr';
|
|
10
|
-
import { type Patient,
|
|
3
|
+
import { type Patient, MortuaryLocationResponse, Entry } from '../../types';
|
|
11
4
|
import { useMemo, useState } from 'react';
|
|
12
5
|
import { parseDisplayText } from '../../utils/utils';
|
|
6
|
+
import { usePaginationInfo } from '@openmrs/esm-patient-common-lib';
|
|
13
7
|
|
|
14
8
|
export const useMortuaryDischargeEncounter = (
|
|
15
9
|
dischargeEncounterTypeUuid: string,
|
|
16
10
|
admissionLocation: MortuaryLocationResponse,
|
|
17
11
|
) => {
|
|
18
|
-
const
|
|
12
|
+
const [currPageSize, setCurrPageSize] = useState(100);
|
|
19
13
|
const locationUuid = admissionLocation?.ward?.uuid;
|
|
20
|
-
|
|
14
|
+
|
|
21
15
|
const urls = !admissionLocation
|
|
22
16
|
? null
|
|
23
17
|
: `${fhirBaseUrl}/Encounter?_summary=data&type=${dischargeEncounterTypeUuid}&location=${locationUuid}`;
|
|
18
|
+
|
|
24
19
|
const { data, isLoading, error, paginated, currentPage, goTo, totalCount, currentPageSize, mutate } =
|
|
25
20
|
useFhirPagination<Entry>(urls, currPageSize);
|
|
26
21
|
|
|
22
|
+
const currentItems = useMemo(() => {
|
|
23
|
+
if (!data) {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
return data.length;
|
|
27
|
+
}, [data]);
|
|
28
|
+
|
|
29
|
+
const { pageSizes: calculatedPageSizes, itemsDisplayed } = usePaginationInfo(
|
|
30
|
+
currPageSize,
|
|
31
|
+
totalCount || 0,
|
|
32
|
+
currentPage || 1,
|
|
33
|
+
currentItems,
|
|
34
|
+
);
|
|
35
|
+
|
|
27
36
|
const dischargedPatientUuids = useMemo(() => {
|
|
28
37
|
if (!data) {
|
|
29
38
|
return [];
|
|
@@ -67,7 +76,8 @@ export const useMortuaryDischargeEncounter = (
|
|
|
67
76
|
error: error,
|
|
68
77
|
paginated,
|
|
69
78
|
currentPage,
|
|
70
|
-
pageSizes,
|
|
79
|
+
pageSizes: calculatedPageSizes,
|
|
80
|
+
itemsDisplayed,
|
|
71
81
|
goTo,
|
|
72
82
|
currPageSize,
|
|
73
83
|
setCurrPageSize,
|
package/src/config-schema.ts
CHANGED
|
@@ -108,11 +108,6 @@ export const configSchema = {
|
|
|
108
108
|
_description: 'Encounter UUID for autopsy',
|
|
109
109
|
_default: '32b61a73-4971-4fc0-b20b-9a30176317e2',
|
|
110
110
|
},
|
|
111
|
-
nextOfKinNamesUuid: {
|
|
112
|
-
_type: Type.String,
|
|
113
|
-
_description: 'UUID for next of kin names concept',
|
|
114
|
-
_default: '830bef6d-b01f-449d-9f8d-ac0fede8dbd3',
|
|
115
|
-
},
|
|
116
111
|
courtOrderCaseNumberUuid: {
|
|
117
112
|
_type: Type.String,
|
|
118
113
|
_description: 'UUID for court order case number concept',
|
|
@@ -170,7 +165,6 @@ export type ConfigObject = {
|
|
|
170
165
|
adminUuid: string;
|
|
171
166
|
autopsyFormUuid: string;
|
|
172
167
|
autopsyEncounterFormUuid: string;
|
|
173
|
-
nextOfKinNamesUuid: string;
|
|
174
168
|
courtOrderCaseNumberUuid: string;
|
|
175
169
|
serialNumberUuid: string;
|
|
176
170
|
};
|
|
@@ -26,6 +26,7 @@ import { z } from 'zod';
|
|
|
26
26
|
import dayjs from 'dayjs';
|
|
27
27
|
import { customRepProps } from '../../constants';
|
|
28
28
|
import { BillingConfig, ConfigObject } from '../../config-schema';
|
|
29
|
+
import { parseDischargeDateTime } from '../../utils/utils';
|
|
29
30
|
|
|
30
31
|
export const useVisitType = () => {
|
|
31
32
|
const customRepresentation = 'custom:(uuid,display,name)';
|
|
@@ -132,6 +133,56 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
132
133
|
morgueAdmissionEncounterTypeUuid,
|
|
133
134
|
} = useConfig<ConfigObject>();
|
|
134
135
|
|
|
136
|
+
const createDisposalMortuaryEncounter = useCallback(
|
|
137
|
+
async (visit: Visit, data: z.infer<typeof disposeSchema>, encounterDateTime: Date) => {
|
|
138
|
+
const obs = [];
|
|
139
|
+
|
|
140
|
+
if (data.courtOrderCaseNumber && data.courtOrderCaseNumber.trim() !== '' && courtOrderCaseNumberUuid) {
|
|
141
|
+
obs.push({
|
|
142
|
+
concept: courtOrderCaseNumberUuid,
|
|
143
|
+
value: data.courtOrderCaseNumber.trim(),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (data.serialNumber && data.serialNumber.trim() !== '' && serialNumberUuid) {
|
|
148
|
+
obs.push({
|
|
149
|
+
concept: serialNumberUuid,
|
|
150
|
+
value: data.serialNumber.trim(),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const encounterPayload = {
|
|
155
|
+
encounterDatetime: encounterDateTime.toISOString(),
|
|
156
|
+
patient: visit?.patient?.uuid,
|
|
157
|
+
encounterType: morgueDischargeEncounterTypeUuid,
|
|
158
|
+
location: visit?.location?.uuid,
|
|
159
|
+
encounterProviders: [
|
|
160
|
+
{
|
|
161
|
+
provider: currentProvider?.uuid,
|
|
162
|
+
encounterRole: emrConfiguration?.clinicianEncounterRole?.uuid,
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
visit: visit?.uuid,
|
|
166
|
+
...(obs.length > 0 && { obs }),
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
return openmrsFetch<Encounter>(`${restBaseUrl}/encounter`, {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
headers: {
|
|
172
|
+
'content-type': 'application/json',
|
|
173
|
+
},
|
|
174
|
+
body: encounterPayload,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
[
|
|
178
|
+
currentProvider?.uuid,
|
|
179
|
+
emrConfiguration?.clinicianEncounterRole?.uuid,
|
|
180
|
+
courtOrderCaseNumberUuid,
|
|
181
|
+
serialNumberUuid,
|
|
182
|
+
morgueDischargeEncounterTypeUuid,
|
|
183
|
+
],
|
|
184
|
+
);
|
|
185
|
+
|
|
135
186
|
const createMortuaryAdmissionEncounter = useCallback(
|
|
136
187
|
async (
|
|
137
188
|
patientUuid: string,
|
|
@@ -150,20 +201,21 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
150
201
|
}: z.infer<typeof deceasedPatientAdmitSchema>,
|
|
151
202
|
) => {
|
|
152
203
|
const obs = [];
|
|
153
|
-
|
|
154
|
-
|
|
204
|
+
|
|
205
|
+
if (tagNumber && tagNumber.trim() !== '' && tagNumberUuid) {
|
|
206
|
+
obs.push({ concept: tagNumberUuid, value: tagNumber.trim() });
|
|
155
207
|
}
|
|
156
|
-
if (obNumber) {
|
|
157
|
-
obs.push({ concept: obNumberUuid, value: obNumber });
|
|
208
|
+
if (obNumber && obNumber.trim() !== '' && obNumberUuid) {
|
|
209
|
+
obs.push({ concept: obNumberUuid, value: obNumber.trim() });
|
|
158
210
|
}
|
|
159
|
-
if (policeName) {
|
|
160
|
-
obs.push({ concept: policeNameUuid, value: policeName });
|
|
211
|
+
if (policeName && policeName.trim() !== '' && policeNameUuid) {
|
|
212
|
+
obs.push({ concept: policeNameUuid, value: policeName.trim() });
|
|
161
213
|
}
|
|
162
|
-
if (policeIDNo) {
|
|
163
|
-
obs.push({ concept: policeIDNumber, value: policeIDNo });
|
|
214
|
+
if (policeIDNo && policeIDNo.trim() !== '' && policeIDNumber) {
|
|
215
|
+
obs.push({ concept: policeIDNumber, value: policeIDNo.trim() });
|
|
164
216
|
}
|
|
165
|
-
if (dischargeArea) {
|
|
166
|
-
obs.push({ concept: dischargeAreaUuid, value: dischargeArea });
|
|
217
|
+
if (dischargeArea && dischargeArea.trim() !== '' && dischargeAreaUuid) {
|
|
218
|
+
obs.push({ concept: dischargeAreaUuid, value: dischargeArea.trim() });
|
|
167
219
|
}
|
|
168
220
|
|
|
169
221
|
const visitAttributes = [];
|
|
@@ -206,30 +258,19 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
206
258
|
policeNameUuid,
|
|
207
259
|
tagNumberUuid,
|
|
208
260
|
morgueAdmissionEncounterTypeUuid,
|
|
209
|
-
nextOfKinNameUuid,
|
|
210
|
-
courtOrderCaseNumberUuid,
|
|
211
|
-
serialNumberUuid,
|
|
212
|
-
morgueDischargeEncounterTypeUuid,
|
|
213
|
-
visitPaymentMethodAttributeUuid,
|
|
214
|
-
burialPermitNumberUuid,
|
|
215
261
|
],
|
|
216
262
|
);
|
|
217
263
|
|
|
218
|
-
const
|
|
219
|
-
async (visit: Visit, data: z.infer<typeof
|
|
264
|
+
const createDischargeMortuaryEncounter = useCallback(
|
|
265
|
+
async (visit: Visit, data: z.infer<typeof dischargeSchema>, encounterDateTime: Date) => {
|
|
220
266
|
const obs = [];
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (data.courtOrderCaseNumber) {
|
|
225
|
-
obs.push({ concept: courtOrderCaseNumberUuid, value: data.courtOrderCaseNumber });
|
|
226
|
-
}
|
|
227
|
-
if (data.serialNumber) {
|
|
228
|
-
obs.push({ concept: serialNumberUuid, value: data.serialNumber });
|
|
267
|
+
|
|
268
|
+
if (data.burialPermitNumber && data.burialPermitNumber.trim() !== '' && burialPermitNumberUuid) {
|
|
269
|
+
obs.push({ concept: burialPermitNumberUuid, value: data.burialPermitNumber.trim() });
|
|
229
270
|
}
|
|
230
271
|
|
|
231
272
|
const encounterPayload = {
|
|
232
|
-
encounterDatetime:
|
|
273
|
+
encounterDatetime: encounterDateTime.toISOString(),
|
|
233
274
|
patient: visit?.patient?.uuid,
|
|
234
275
|
encounterType: morgueDischargeEncounterTypeUuid,
|
|
235
276
|
location: visit?.location?.uuid,
|
|
@@ -240,8 +281,9 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
240
281
|
},
|
|
241
282
|
],
|
|
242
283
|
visit: visit?.uuid,
|
|
243
|
-
obs
|
|
284
|
+
...(obs.length > 0 && { obs }),
|
|
244
285
|
};
|
|
286
|
+
|
|
245
287
|
return openmrsFetch<Encounter>(`${restBaseUrl}/encounter`, {
|
|
246
288
|
method: 'POST',
|
|
247
289
|
headers: {
|
|
@@ -250,9 +292,13 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
250
292
|
body: encounterPayload,
|
|
251
293
|
});
|
|
252
294
|
},
|
|
253
|
-
[
|
|
295
|
+
[
|
|
296
|
+
burialPermitNumberUuid,
|
|
297
|
+
currentProvider?.uuid,
|
|
298
|
+
emrConfiguration?.clinicianEncounterRole?.uuid,
|
|
299
|
+
morgueDischargeEncounterTypeUuid,
|
|
300
|
+
],
|
|
254
301
|
);
|
|
255
|
-
|
|
256
302
|
const assignDeceasedToCompartment = useCallback(
|
|
257
303
|
async (patientUuid: string, bedId: number, encounterUuid: string) =>
|
|
258
304
|
openmrsFetch(`${restBaseUrl}/beds/${bedId}`, {
|
|
@@ -284,38 +330,6 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
284
330
|
[assignDeceasedToCompartment, createMortuaryAdmissionEncounter],
|
|
285
331
|
);
|
|
286
332
|
|
|
287
|
-
const createDischargeMortuaryEncounter = useCallback(
|
|
288
|
-
async (visit: Visit, data: z.infer<typeof dischargeSchema>) => {
|
|
289
|
-
const obs = [];
|
|
290
|
-
if (data.burialPermitNumber) {
|
|
291
|
-
obs.push({ concept: burialPermitNumberUuid, value: data.burialPermitNumber });
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const encounterPayload = {
|
|
295
|
-
encounterDatetime: data?.dateOfDischarge,
|
|
296
|
-
patient: visit?.patient?.uuid,
|
|
297
|
-
encounterType: morgueDischargeEncounterTypeUuid,
|
|
298
|
-
location: visit?.location,
|
|
299
|
-
encounterProviders: [
|
|
300
|
-
{
|
|
301
|
-
provider: currentProvider?.uuid,
|
|
302
|
-
encounterRole: emrConfiguration?.clinicianEncounterRole?.uuid,
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
visit: visit?.uuid,
|
|
306
|
-
obs: obs.length > 0 ? obs : undefined,
|
|
307
|
-
};
|
|
308
|
-
return openmrsFetch<Encounter>(`${restBaseUrl}/encounter`, {
|
|
309
|
-
method: 'POST',
|
|
310
|
-
headers: {
|
|
311
|
-
'content-type': 'application/json',
|
|
312
|
-
},
|
|
313
|
-
body: encounterPayload,
|
|
314
|
-
});
|
|
315
|
-
},
|
|
316
|
-
[burialPermitNumberUuid, currentProvider?.uuid, emrConfiguration?.clinicianEncounterRole?.uuid],
|
|
317
|
-
);
|
|
318
|
-
|
|
319
333
|
const removeDeceasedFromCompartment = useCallback(
|
|
320
334
|
async (patientUuid: string, bedId: number) =>
|
|
321
335
|
openmrsFetch(`${restBaseUrl}/beds/${bedId}?patientUuid=${patientUuid}`, {
|
|
@@ -325,12 +339,13 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
325
339
|
);
|
|
326
340
|
|
|
327
341
|
const endCurrentVisit = useCallback(
|
|
328
|
-
async (currentVisit: Visit, queueEntry: MappedVisitQueueEntry,
|
|
342
|
+
async (currentVisit: Visit, queueEntry: MappedVisitQueueEntry, stopDateTime: Date) => {
|
|
329
343
|
const abortController = new AbortController();
|
|
344
|
+
|
|
330
345
|
const response = await updateVisit(
|
|
331
346
|
currentVisit.uuid,
|
|
332
347
|
{
|
|
333
|
-
stopDatetime:
|
|
348
|
+
stopDatetime: stopDateTime,
|
|
334
349
|
},
|
|
335
350
|
abortController,
|
|
336
351
|
);
|
|
@@ -349,22 +364,49 @@ export const useMortuaryOperation = (location?: string) => {
|
|
|
349
364
|
|
|
350
365
|
const dischargeBody = useCallback(
|
|
351
366
|
async (visit: Visit, queueEntry: MappedVisitQueueEntry, bedId: number, data: z.infer<typeof dischargeSchema>) => {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
367
|
+
try {
|
|
368
|
+
const dischargeDateTime = parseDischargeDateTime({
|
|
369
|
+
...data,
|
|
370
|
+
dateOfDischarge: data.dateOfDischarge ?? new Date(),
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const dischargeEncounter = await createDischargeMortuaryEncounter(visit, data, dischargeDateTime);
|
|
374
|
+
|
|
375
|
+
const compartment = await removeDeceasedFromCompartment(visit?.patient?.uuid, bedId);
|
|
376
|
+
|
|
377
|
+
const visitStopTime = new Date(dischargeDateTime.getTime() + 60000); // 1 minute after discharge
|
|
378
|
+
|
|
379
|
+
await endCurrentVisit(visit, queueEntry, visitStopTime);
|
|
380
|
+
|
|
381
|
+
return { dischargeEncounter, compartment };
|
|
382
|
+
} catch (error) {
|
|
383
|
+
throw error;
|
|
384
|
+
}
|
|
356
385
|
},
|
|
357
|
-
[createDischargeMortuaryEncounter, endCurrentVisit, removeDeceasedFromCompartment],
|
|
386
|
+
[createDischargeMortuaryEncounter, endCurrentVisit, removeDeceasedFromCompartment, parseDischargeDateTime],
|
|
358
387
|
);
|
|
359
|
-
|
|
360
388
|
const disposeBody = useCallback(
|
|
361
389
|
async (visit: Visit, queueEntry: MappedVisitQueueEntry, bedId: number, data: z.infer<typeof disposeSchema>) => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
390
|
+
try {
|
|
391
|
+
const disposalDateTime = parseDischargeDateTime({
|
|
392
|
+
...data,
|
|
393
|
+
dateOfDischarge: data.dateOfDischarge ?? new Date(),
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
const disposeEncounter = await createDisposalMortuaryEncounter(visit, data, disposalDateTime);
|
|
397
|
+
|
|
398
|
+
const compartment = await removeDeceasedFromCompartment(visit?.patient?.uuid, bedId);
|
|
399
|
+
|
|
400
|
+
const visitStopTime = new Date(disposalDateTime.getTime() + 60000);
|
|
401
|
+
|
|
402
|
+
await endCurrentVisit(visit, queueEntry, visitStopTime);
|
|
403
|
+
|
|
404
|
+
return { disposeEncounter, compartment };
|
|
405
|
+
} catch (error) {
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
366
408
|
},
|
|
367
|
-
[createDisposalMortuaryEncounter, endCurrentVisit, removeDeceasedFromCompartment],
|
|
409
|
+
[createDisposalMortuaryEncounter, endCurrentVisit, removeDeceasedFromCompartment, parseDischargeDateTime],
|
|
368
410
|
);
|
|
369
411
|
|
|
370
412
|
const createEncounterForCompartmentSwap = useCallback(
|
|
@@ -229,7 +229,6 @@ const AdmitDeceasedPerson: React.FC<AdmitDeceasedPersonProps> = ({
|
|
|
229
229
|
<DeceasedPatientHeader patientData={patientData} />
|
|
230
230
|
<ResponsiveWrapper>
|
|
231
231
|
<FormGroup legendText="">
|
|
232
|
-
<Column></Column>
|
|
233
232
|
<Column>
|
|
234
233
|
<Controller
|
|
235
234
|
name="dateOfAdmission"
|
|
@@ -335,33 +334,35 @@ const AdmitDeceasedPerson: React.FC<AdmitDeceasedPersonProps> = ({
|
|
|
335
334
|
control={control}
|
|
336
335
|
name="availableCompartment"
|
|
337
336
|
render={({ field }) => (
|
|
338
|
-
<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
name="availableCompartment"
|
|
342
|
-
valueSelected={field.value}
|
|
343
|
-
onChange={field.onChange}>
|
|
344
|
-
{filteredBeds.map((bed, index) => (
|
|
345
|
-
<div key={index} className={styles.compartmentOption}>
|
|
337
|
+
<div className={styles.radioButtonGroup}>
|
|
338
|
+
{filteredBeds.map((bed) => (
|
|
339
|
+
<div key={bed.bedId} className={styles.compartmentOption}>
|
|
346
340
|
<div className={styles.radioButtonWrapper}>
|
|
347
341
|
<RadioButton
|
|
348
342
|
className={styles.radioButton}
|
|
349
|
-
id={`compartment-${
|
|
343
|
+
id={`compartment-${bed.bedId}`}
|
|
350
344
|
labelText={bed.bedNumber}
|
|
351
345
|
value={bed.bedId}
|
|
346
|
+
name="availableCompartment"
|
|
347
|
+
checked={field.value === bed.bedId}
|
|
348
|
+
onChange={(value, name, event) => {
|
|
349
|
+
field.onChange(bed.bedId);
|
|
350
|
+
}}
|
|
352
351
|
/>
|
|
353
352
|
</div>
|
|
354
353
|
<div className={styles.compartmentTags}>
|
|
355
|
-
|
|
356
|
-
{bed.bedType?.
|
|
357
|
-
|
|
354
|
+
{bed.bedType && (
|
|
355
|
+
<Tag type={bed.bedType?.display === 'VIP' ? 'green' : 'blue'} size="sm">
|
|
356
|
+
{bed.bedType?.displayName || ''}
|
|
357
|
+
</Tag>
|
|
358
|
+
)}
|
|
358
359
|
<Tag type={bed.status === 'AVAILABLE' ? 'green' : 'red'} size="sm">
|
|
359
360
|
{bed?.status || ''}
|
|
360
361
|
</Tag>
|
|
361
362
|
</div>
|
|
362
363
|
</div>
|
|
363
364
|
))}
|
|
364
|
-
</
|
|
365
|
+
</div>
|
|
365
366
|
)}
|
|
366
367
|
/>
|
|
367
368
|
</>
|