@ampath/esm-dha-workflow-app 4.0.0-next.68 → 4.0.0-next.69
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/dist/110.js +1 -0
- package/dist/110.js.map +1 -0
- package/dist/125.js +1 -1
- package/dist/264.js +1 -1
- package/dist/321.js +1 -1
- package/dist/474.js +1 -0
- package/dist/474.js.map +1 -0
- package/dist/547.js +1 -0
- package/dist/547.js.map +1 -0
- package/dist/605.js +1 -1
- package/dist/744.js +1 -1
- package/dist/752.js +1 -1
- package/dist/826.js +1 -1
- package/dist/826.js.map +1 -1
- package/dist/93.js +1 -1
- package/dist/93.js.map +1 -1
- package/dist/968.js +1 -0
- package/dist/968.js.map +1 -0
- package/dist/975.js +1 -1
- package/dist/986.js +1 -1
- package/dist/esm-dha-workflow-app.js +1 -1
- package/dist/esm-dha-workflow-app.js.buildmanifest.json +115 -66
- 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/admissions/admission-request-list/admission-request-list.scss +0 -0
- package/src/admissions/admission-request-list/admission-request-list.tsx +134 -0
- package/src/admissions/admissions-dashboard.component.scss +15 -0
- package/src/admissions/admissions-dashboard.component.tsx +147 -0
- package/src/admissions/admissions.resource.ts +101 -0
- package/src/admissions/admitted-list/admitted-patients-list.tsx +130 -0
- package/src/admissions/constants/index.ts +33 -0
- package/src/admissions/discharged-list/discharged-list.scss +0 -0
- package/src/admissions/discharged-list/discharged-list.tsx +58 -0
- package/src/admissions/modal/admit-elsewhere/admit-elsewhere.modal.scss +23 -0
- package/src/admissions/modal/admit-elsewhere/admit-elsewhere.modal.tsx +156 -0
- package/src/admissions/modal/admit-patient/admit-patient.modal.scss +0 -0
- package/src/admissions/modal/admit-patient/admit-patient.modal.tsx +109 -0
- package/src/admissions/modal/bed-swap/bed-swap.modal.scss +0 -0
- package/src/admissions/modal/bed-swap/bed-swap.modal.tsx +102 -0
- package/src/admissions/modal/cancel-admission-request/cancel-admission-request.scss +11 -0
- package/src/admissions/modal/cancel-admission-request/cancel-admission-request.tsx +103 -0
- package/src/admissions/modal/discharge/discharge-patient.modal.scss +13 -0
- package/src/admissions/modal/discharge/discharge-patient.modal.tsx +84 -0
- package/src/admissions/types/index.ts +192 -0
- package/src/dashboard-meta/admissions-dashboard.meta.ts +6 -0
- package/src/index.ts +7 -0
- package/src/root.component.tsx +2 -0
- package/src/routes.json +17 -0
- package/src/service-queues/service-queue/stats/stat-card/stat-card.component.tsx +5 -2
- package/src/shared/ui/stat-card/start-card.component.tsx +0 -0
- package/dist/838.js +0 -1
- package/dist/838.js.map +0 -1
- package/dist/863.js +0 -1
- package/dist/863.js.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ComboBox, Modal, ModalBody, Select, SelectItem, TextArea } from "@carbon/react";
|
|
2
|
+
import React, { useMemo, useRef, useState } from "react";
|
|
3
|
+
import styles from './admit-elsewhere.modal.scss'
|
|
4
|
+
import { Location, Patient, showSnackbar, useLocations, useSession, Visit } from "@openmrs/esm-framework";
|
|
5
|
+
import { AdmitPatientDto } from "../../types";
|
|
6
|
+
import { AdmissionConcepts, AdmissionEncounterTypeUuids } from "../../constants";
|
|
7
|
+
import { admitPatientElseWhere } from "../../admissions.resource";
|
|
8
|
+
interface AdmitElsewhereModalProps {
|
|
9
|
+
open: boolean;
|
|
10
|
+
patient: Patient;
|
|
11
|
+
visit: Visit;
|
|
12
|
+
onModalClose: () => void;
|
|
13
|
+
onSuccessfullTransfer: () => void;
|
|
14
|
+
}
|
|
15
|
+
const AdmitElsewhereModal: React.FC<AdmitElsewhereModalProps> = ({ open, onModalClose, onSuccessfullTransfer, patient, visit }) => {
|
|
16
|
+
const [transferLocation, setTransferLocation] = useState<string>();
|
|
17
|
+
const locations = useLocations();
|
|
18
|
+
const session = useSession();
|
|
19
|
+
const userLocation = session.sessionLocation;
|
|
20
|
+
const reasonRef = useRef<string>();
|
|
21
|
+
const locationsOptions = useMemo(() => generateLocationOption(), [locations]);
|
|
22
|
+
function generateLocationOption() {
|
|
23
|
+
return locations.filter((l)=>{
|
|
24
|
+
if(!userLocation){
|
|
25
|
+
return true;
|
|
26
|
+
}else{
|
|
27
|
+
return l.uuid !== userLocation.uuid;
|
|
28
|
+
}
|
|
29
|
+
}).map((l: Location) => {
|
|
30
|
+
return {
|
|
31
|
+
id: l.uuid,
|
|
32
|
+
text: l.display,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const handleTransfer = async () => {
|
|
37
|
+
if(!validateTransferPayload()){
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const transferPatientDto = generateAdmitPatientPayload();
|
|
42
|
+
await admitPatientElseWhere(transferPatientDto);
|
|
43
|
+
showSnackbar({
|
|
44
|
+
kind: 'success',
|
|
45
|
+
title: 'Transfer Request Successful',
|
|
46
|
+
subtitle: 'Patient Transfer Request was Successful',
|
|
47
|
+
});
|
|
48
|
+
onSuccessfullTransfer();
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.log({ error });
|
|
51
|
+
showSnackbar({
|
|
52
|
+
kind: 'error',
|
|
53
|
+
title: 'Transfer Request failed',
|
|
54
|
+
subtitle: error.message ?? 'Patient Transfer Request failed'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
};
|
|
59
|
+
const validateTransferPayload = ():boolean=>{
|
|
60
|
+
if(!transferLocation){
|
|
61
|
+
showSnackbar({
|
|
62
|
+
kind: 'error',
|
|
63
|
+
title: 'Transfer Location missing',
|
|
64
|
+
subtitle: 'Please select the location to transfer patient'
|
|
65
|
+
});
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if(!reasonRef.current){
|
|
69
|
+
showSnackbar({
|
|
70
|
+
kind: 'error',
|
|
71
|
+
title: 'Missing Transfer reason',
|
|
72
|
+
subtitle: 'Please enter the transfer reason'
|
|
73
|
+
});
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
const generateAdmitPatientPayload = (): AdmitPatientDto => {
|
|
79
|
+
return {
|
|
80
|
+
patient: patient.uuid,
|
|
81
|
+
encounterType: {
|
|
82
|
+
uuid: AdmissionEncounterTypeUuids.TRANSFER_REQUEST_ENCOUNTER_TYPE_UUID
|
|
83
|
+
},
|
|
84
|
+
location: userLocation.uuid,
|
|
85
|
+
obs: [
|
|
86
|
+
{
|
|
87
|
+
"concept": AdmissionConcepts.INPATIENT_DISPOSITION_CONSTRUCT_UUID,
|
|
88
|
+
"groupMembers": [
|
|
89
|
+
{
|
|
90
|
+
"concept": AdmissionConcepts.INTERNAL_TRANSFER_LOCATION_UUID,
|
|
91
|
+
"value": transferLocation
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"concept": AdmissionConcepts.INPATIENT_PATIENT_DISPOSITION_UUID,
|
|
95
|
+
"value": AdmissionConcepts.TRANSFER_OUT_UUID
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"concept": AdmissionConcepts.CLINICAL_NOTES_UUID,
|
|
99
|
+
"value": reasonRef.current
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
visit: visit.uuid
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const handleReasonText = (reason: string) => {
|
|
108
|
+
reasonRef.current = reason;
|
|
109
|
+
};
|
|
110
|
+
const locationChangeHandler = (location: { selectedItem: { id: string; text: string } }) => {
|
|
111
|
+
const l = location.selectedItem.id;
|
|
112
|
+
setTransferLocation(l);
|
|
113
|
+
};
|
|
114
|
+
return <>
|
|
115
|
+
<Modal
|
|
116
|
+
modalHeading="Transfer Elsewhere"
|
|
117
|
+
open={open}
|
|
118
|
+
size="md"
|
|
119
|
+
onSecondarySubmit={() => onModalClose()}
|
|
120
|
+
onRequestClose={() => onModalClose()}
|
|
121
|
+
onRequestSubmit={handleTransfer}
|
|
122
|
+
primaryButtonText="Send Admission Request"
|
|
123
|
+
secondaryButtonText="Cancel"
|
|
124
|
+
>
|
|
125
|
+
<ModalBody>
|
|
126
|
+
<div className={styles.admitModalLayout}>
|
|
127
|
+
<div className={styles.admitModalContentSection}>
|
|
128
|
+
<div className={styles.formRow}>
|
|
129
|
+
<ComboBox
|
|
130
|
+
onChange={locationChangeHandler}
|
|
131
|
+
id="visit-type-combobox"
|
|
132
|
+
items={locationsOptions}
|
|
133
|
+
itemToString={(item) => (item ? item.text : '')}
|
|
134
|
+
titleText="Select Transfer Location"
|
|
135
|
+
className={styles.locationSelect}
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
<div className={styles.formRow}>
|
|
139
|
+
<TextArea
|
|
140
|
+
enableCounter
|
|
141
|
+
helperText=""
|
|
142
|
+
id="transfer-reason"
|
|
143
|
+
labelText="Transfer Reason"
|
|
144
|
+
maxCount={500}
|
|
145
|
+
placeholder=""
|
|
146
|
+
rows={4}
|
|
147
|
+
onChange={(e) => handleReasonText(e.target.value)}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</ModalBody>
|
|
153
|
+
</Modal>
|
|
154
|
+
</>
|
|
155
|
+
}
|
|
156
|
+
export default AdmitElsewhereModal;
|
|
File without changes
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { AdmitPatientDto, AssignBedToPatientDto, BedLayout, Disposition } from "../../types";
|
|
3
|
+
import { Modal, ModalBody, Select, SelectItem } from "@carbon/react";
|
|
4
|
+
import { Encounter, Patient, showSnackbar, useSession } from "@openmrs/esm-framework";
|
|
5
|
+
import styles from './admit-patient.modal.scss';
|
|
6
|
+
import { AdmissionEncounterTypeUuids } from "../../constants";
|
|
7
|
+
import { admitPatientToWard, assignBedToPatient } from "../../admissions.resource";
|
|
8
|
+
interface AdmitPatientModalProps {
|
|
9
|
+
open: boolean;
|
|
10
|
+
disposition: Disposition;
|
|
11
|
+
onModalClose: () => void;
|
|
12
|
+
bedLayouts: BedLayout[];
|
|
13
|
+
onSuccessfullAdmission: () => void;
|
|
14
|
+
}
|
|
15
|
+
const AdmitPatientModal: React.FC<AdmitPatientModalProps> = ({ onModalClose, open, disposition, bedLayouts, onSuccessfullAdmission }) => {
|
|
16
|
+
const [selectedBedId, setSelectedBedId] = useState<number>();
|
|
17
|
+
const session = useSession();
|
|
18
|
+
const location = session.sessionLocation;
|
|
19
|
+
|
|
20
|
+
const admitPatient = async () => {
|
|
21
|
+
try{
|
|
22
|
+
const admitPatientDto = generateAdmitPatientPayload();
|
|
23
|
+
const resp = await admitPatientToWard(admitPatientDto);
|
|
24
|
+
|
|
25
|
+
showSnackbar({
|
|
26
|
+
kind: 'success',
|
|
27
|
+
title: 'Admission Successfull',
|
|
28
|
+
subtitle: 'Patient Successfully Admitted',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//assign bed to patient
|
|
32
|
+
const assignBedDto = generateAssignBedPayload(resp);
|
|
33
|
+
await assignBedToPatient(selectedBedId,assignBedDto);
|
|
34
|
+
|
|
35
|
+
showSnackbar({
|
|
36
|
+
kind: 'success',
|
|
37
|
+
title: 'Bed Assignment Successfull',
|
|
38
|
+
subtitle: `Patient Successfully assigned bed ${selectedBedId}`,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
onSuccessfullAdmission();
|
|
42
|
+
|
|
43
|
+
}catch(error){
|
|
44
|
+
console.log({error});
|
|
45
|
+
showSnackbar({
|
|
46
|
+
kind: 'error',
|
|
47
|
+
title: 'Bed Assignment failed',
|
|
48
|
+
subtitle: error.message ?? 'Bed Assignment failed'
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
};
|
|
54
|
+
const bedSelectedHandler = (bedId: number) => {
|
|
55
|
+
setSelectedBedId(bedId);
|
|
56
|
+
};
|
|
57
|
+
const generateAdmitPatientPayload = (): AdmitPatientDto=>{
|
|
58
|
+
return {
|
|
59
|
+
patient: disposition.patient.uuid,
|
|
60
|
+
encounterType: {
|
|
61
|
+
uuid: AdmissionEncounterTypeUuids.ADMIT_ENCOUNTER_TYPE_UUID
|
|
62
|
+
},
|
|
63
|
+
location: location.uuid,
|
|
64
|
+
obs: [],
|
|
65
|
+
visit: disposition.visit.uuid
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const generateAssignBedPayload = (admissionEncounter: Encounter): AssignBedToPatientDto=>{
|
|
69
|
+
return {
|
|
70
|
+
patientUuid: disposition.patient.uuid,
|
|
71
|
+
encounterUuid: admissionEncounter.uuid
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return <>
|
|
75
|
+
<Modal
|
|
76
|
+
modalHeading="Admit Patient"
|
|
77
|
+
open={open}
|
|
78
|
+
size="md"
|
|
79
|
+
onSecondarySubmit={() => onModalClose()}
|
|
80
|
+
onRequestClose={() => onModalClose()}
|
|
81
|
+
onRequestSubmit={admitPatient}
|
|
82
|
+
primaryButtonText="Admit"
|
|
83
|
+
secondaryButtonText="Cancel"
|
|
84
|
+
>
|
|
85
|
+
<ModalBody>
|
|
86
|
+
<div className={styles.serveModalLayout}>
|
|
87
|
+
<div className={styles.serveModalContentSection}>
|
|
88
|
+
<div className={styles.formRow}>
|
|
89
|
+
<Select
|
|
90
|
+
id="ward-beds"
|
|
91
|
+
labelText="Beds"
|
|
92
|
+
onChange={($event) => bedSelectedHandler(parseInt($event.target.value))}
|
|
93
|
+
>
|
|
94
|
+
<SelectItem value="" text="Select" />;
|
|
95
|
+
{bedLayouts &&
|
|
96
|
+
bedLayouts.filter((bl)=>{
|
|
97
|
+
return bl.status === 'AVAILABLE'
|
|
98
|
+
}).map((bl) => {
|
|
99
|
+
return <SelectItem value={bl.bedId} text={`${bl.bedNumber} (${bl.status})`} />;
|
|
100
|
+
})}
|
|
101
|
+
</Select>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</ModalBody>
|
|
106
|
+
</Modal>
|
|
107
|
+
</>
|
|
108
|
+
}
|
|
109
|
+
export default AdmitPatientModal;
|
|
File without changes
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Modal, ModalBody, Select, SelectItem } from "@carbon/react";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { AssignBedToPatientDto, BedLayout, BedSwapDto, Disposition } from "../../types";
|
|
4
|
+
import styles from './bed-swap.modal.scss';
|
|
5
|
+
import { AdmissionEncounterTypeUuids } from "../../constants";
|
|
6
|
+
import { Encounter,Person, showSnackbar, useSession } from "@openmrs/esm-framework";
|
|
7
|
+
import { assignBedToPatient, bedSwapRequest } from "../../admissions.resource";
|
|
8
|
+
interface BedSwapModalProps {
|
|
9
|
+
open: boolean;
|
|
10
|
+
disposition: Disposition;
|
|
11
|
+
person: Person;
|
|
12
|
+
onModalClose: () => void;
|
|
13
|
+
bedLayouts: BedLayout[];
|
|
14
|
+
onSuccessfullBedSwap: () => void;
|
|
15
|
+
}
|
|
16
|
+
const BedSwapModal: React.FC<BedSwapModalProps> = ({open,onModalClose,onSuccessfullBedSwap,bedLayouts,disposition,person})=>{
|
|
17
|
+
const [selectedBedId, setSelectedBedId] = useState<number>();
|
|
18
|
+
const session = useSession();
|
|
19
|
+
const location = session.sessionLocation;
|
|
20
|
+
|
|
21
|
+
const swapBed = async ()=>{
|
|
22
|
+
|
|
23
|
+
try{
|
|
24
|
+
const bedSwapPayload = generateBedSwapRequestDto();
|
|
25
|
+
const resp = await bedSwapRequest(bedSwapPayload);
|
|
26
|
+
|
|
27
|
+
//assign bed to patient
|
|
28
|
+
const assignBedDto = generateAssignBedPayload(resp);
|
|
29
|
+
await assignBedToPatient(selectedBedId,assignBedDto);
|
|
30
|
+
showSnackbar({
|
|
31
|
+
kind: 'success',
|
|
32
|
+
title: 'Bed swap Successfull',
|
|
33
|
+
subtitle: `Patient Successfully assigned bed ${selectedBedId}`,
|
|
34
|
+
});
|
|
35
|
+
onSuccessfullBedSwap();
|
|
36
|
+
}catch(error){
|
|
37
|
+
console.log({error});
|
|
38
|
+
showSnackbar({
|
|
39
|
+
kind: 'error',
|
|
40
|
+
title: 'Bed Assignment failed',
|
|
41
|
+
subtitle: error.message ?? 'Bed Assignment failed'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
const generateAssignBedPayload = (assignEncounter: Encounter): AssignBedToPatientDto=>{
|
|
48
|
+
return {
|
|
49
|
+
patientUuid: person.uuid,
|
|
50
|
+
encounterUuid: assignEncounter.uuid
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const handleBedChange = (bedId: number)=>{
|
|
54
|
+
setSelectedBedId(bedId);
|
|
55
|
+
}
|
|
56
|
+
const generateBedSwapRequestDto = (): BedSwapDto => {
|
|
57
|
+
return {
|
|
58
|
+
"patient": person.uuid,
|
|
59
|
+
"encounterType": {
|
|
60
|
+
"uuid": AdmissionEncounterTypeUuids.BED_ASSIGNMENT_ENCOUNTER_TYPE_UUID,
|
|
61
|
+
},
|
|
62
|
+
"location": location.uuid,
|
|
63
|
+
"obs": [],
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return <>
|
|
68
|
+
<Modal
|
|
69
|
+
modalHeading="Swap Beds"
|
|
70
|
+
open={open}
|
|
71
|
+
size="md"
|
|
72
|
+
onSecondarySubmit={() => onModalClose()}
|
|
73
|
+
onRequestClose={() => onModalClose()}
|
|
74
|
+
onRequestSubmit={swapBed}
|
|
75
|
+
primaryButtonText="Swap Beds"
|
|
76
|
+
secondaryButtonText="Cancel"
|
|
77
|
+
>
|
|
78
|
+
<ModalBody>
|
|
79
|
+
<div className={styles.serveModalLayout}>
|
|
80
|
+
<div className={styles.serveModalContentSection}>
|
|
81
|
+
<div className={styles.formRow}>
|
|
82
|
+
<Select
|
|
83
|
+
id="ward-beds"
|
|
84
|
+
labelText="Beds"
|
|
85
|
+
onChange={($event) => handleBedChange(parseInt($event.target.value))}
|
|
86
|
+
>
|
|
87
|
+
<SelectItem value="" text="Select" />;
|
|
88
|
+
{bedLayouts &&
|
|
89
|
+
bedLayouts.filter((bl)=>{
|
|
90
|
+
return bl.status === 'AVAILABLE'
|
|
91
|
+
}).map((bl) => {
|
|
92
|
+
return <SelectItem value={bl.bedId} text={`${bl.bedNumber} (${bl.status})`} />;
|
|
93
|
+
})}
|
|
94
|
+
</Select>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</ModalBody>
|
|
99
|
+
</Modal>
|
|
100
|
+
</>
|
|
101
|
+
}
|
|
102
|
+
export default BedSwapModal;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { useRef } from "react"
|
|
2
|
+
import styles from './cancel-admission-request.scss';
|
|
3
|
+
import { Button, Modal, ModalBody, TextArea } from "@carbon/react";
|
|
4
|
+
import { CancelAdmissionDto, Disposition } from "../../types";
|
|
5
|
+
import { showSnackbar, useSession } from "@openmrs/esm-framework";
|
|
6
|
+
import { AdmissionConcepts, AdmissionEncounterTypeUuids } from "../../constants";
|
|
7
|
+
import { cancelAdmissionRequest } from "../../admissions.resource";
|
|
8
|
+
|
|
9
|
+
interface CancelAdmissionRequestModalProps {
|
|
10
|
+
open: boolean;
|
|
11
|
+
admissionRequest: Disposition;
|
|
12
|
+
onModalClose: () => void;
|
|
13
|
+
onCancelAdmission: () => void;
|
|
14
|
+
}
|
|
15
|
+
const CancelAdmissionRequestModal: React.FC<CancelAdmissionRequestModalProps> = ({ open, admissionRequest, onCancelAdmission, onModalClose }) => {
|
|
16
|
+
const reasonRef = useRef<string>();
|
|
17
|
+
const session = useSession();
|
|
18
|
+
const location = session.sessionLocation;
|
|
19
|
+
const handleReasonText = (reason: string) => {
|
|
20
|
+
reasonRef.current = reason;
|
|
21
|
+
};
|
|
22
|
+
const handleCancelRequest = async () => {
|
|
23
|
+
try {
|
|
24
|
+
const cancelAdmissionDto = generateCancelAdmissionRequestDto();
|
|
25
|
+
const resp = await cancelAdmissionRequest(cancelAdmissionDto);
|
|
26
|
+
if (resp) {
|
|
27
|
+
showSnackbar({
|
|
28
|
+
kind: 'success',
|
|
29
|
+
title: 'Cancel request successfull',
|
|
30
|
+
subtitle: 'Admission request succesfully cancelled',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
onCancelAdmission();
|
|
34
|
+
|
|
35
|
+
} catch (error) {
|
|
36
|
+
|
|
37
|
+
showSnackbar({
|
|
38
|
+
kind: 'error',
|
|
39
|
+
title: 'Bed Assignment failed',
|
|
40
|
+
subtitle: error.message ?? 'Bed Assignment failed'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
};
|
|
47
|
+
const generateCancelAdmissionRequestDto = (): CancelAdmissionDto => {
|
|
48
|
+
return {
|
|
49
|
+
"patient": admissionRequest.patient.uuid,
|
|
50
|
+
"encounterType": {
|
|
51
|
+
"uuid": AdmissionEncounterTypeUuids.CANCEL_ADT_ENCOUNTER_TYPE_UUID,
|
|
52
|
+
},
|
|
53
|
+
"location": location.uuid,
|
|
54
|
+
"obs": [
|
|
55
|
+
{
|
|
56
|
+
"concept": AdmissionConcepts.CLINICAL_NOTES_UUID,
|
|
57
|
+
"value": reasonRef.current
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"concept": AdmissionConcepts.ADMISSION_TO_HOSPITAL_DECISION_UUID,
|
|
61
|
+
"value": {
|
|
62
|
+
"uuid": AdmissionConcepts.ADMISSION_DENIED_UUID
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"visit": admissionRequest.visit.uuid
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return <>
|
|
71
|
+
<Modal
|
|
72
|
+
modalHeading="Cancel Admission Request"
|
|
73
|
+
open={open}
|
|
74
|
+
size="md"
|
|
75
|
+
onSecondarySubmit={onModalClose}
|
|
76
|
+
onRequestClose={onModalClose}
|
|
77
|
+
onRequestSubmit={handleCancelRequest}
|
|
78
|
+
primaryButtonText="Cancel Admission Request"
|
|
79
|
+
secondaryButtonText="Cancel"
|
|
80
|
+
>
|
|
81
|
+
<ModalBody>
|
|
82
|
+
<div className={styles.cancelAdmissionLayout}>
|
|
83
|
+
<div className={styles.contentSection}>
|
|
84
|
+
<div className={styles.formRow}>
|
|
85
|
+
<TextArea
|
|
86
|
+
enableCounter
|
|
87
|
+
helperText=""
|
|
88
|
+
id="cancel-reason"
|
|
89
|
+
labelText="Cancel Reason"
|
|
90
|
+
maxCount={500}
|
|
91
|
+
placeholder=""
|
|
92
|
+
rows={4}
|
|
93
|
+
onChange={(e) => handleReasonText(e.target.value)}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</ModalBody>
|
|
99
|
+
</Modal>
|
|
100
|
+
</>
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default CancelAdmissionRequestModal;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { DischargePatientDto, Disposition, UnAssignBedDto } from "../../types";
|
|
3
|
+
import { Modal, ModalBody } from "@carbon/react";
|
|
4
|
+
import styles from './discharge-patient.modal.scss';
|
|
5
|
+
import { AdmissionEncounterTypeUuids } from "../../constants";
|
|
6
|
+
import { Person, showSnackbar, useSession } from "@openmrs/esm-framework";
|
|
7
|
+
import { dischargePatientFromWard, unassignBed } from "../../admissions.resource";
|
|
8
|
+
interface DischargeModalProps {
|
|
9
|
+
open: boolean;
|
|
10
|
+
admissionRequest: Disposition & {bedId: number; person: Person};
|
|
11
|
+
onModalClose: () => void;
|
|
12
|
+
onDischarge: () => void;
|
|
13
|
+
}
|
|
14
|
+
const DischargeModal: React.FC<DischargeModalProps> = ({ open, admissionRequest, onModalClose, onDischarge}) => {
|
|
15
|
+
const session = useSession();
|
|
16
|
+
const location = session.sessionLocation;
|
|
17
|
+
const handleDischarge = async () => {
|
|
18
|
+
try {
|
|
19
|
+
const dischargeDto = generateDischargePatientRequestDto();
|
|
20
|
+
await dischargePatientFromWard(dischargeDto);
|
|
21
|
+
showSnackbar({
|
|
22
|
+
kind: 'success',
|
|
23
|
+
title: 'Discharge request successfull',
|
|
24
|
+
subtitle: 'Patient Succesfully discharged from ward',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// unassign bed
|
|
28
|
+
const unAssignBedDto = generateUnassignBedDto();
|
|
29
|
+
await unassignBed(unAssignBedDto);
|
|
30
|
+
|
|
31
|
+
showSnackbar({
|
|
32
|
+
kind: 'success',
|
|
33
|
+
title: 'Bed Unassigned successfull',
|
|
34
|
+
subtitle: `Bed ${admissionRequest.bedId} successfully unassigned`,
|
|
35
|
+
});
|
|
36
|
+
onDischarge();
|
|
37
|
+
|
|
38
|
+
} catch (error) {
|
|
39
|
+
debugger;
|
|
40
|
+
showSnackbar({
|
|
41
|
+
kind: 'error',
|
|
42
|
+
title: 'Patient Discharge failed',
|
|
43
|
+
subtitle: 'Patient Discharge failed',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const generateDischargePatientRequestDto = (): DischargePatientDto => {
|
|
48
|
+
return {
|
|
49
|
+
"patient": admissionRequest.person.uuid,
|
|
50
|
+
"encounterType": {
|
|
51
|
+
"uuid": AdmissionEncounterTypeUuids.DISCHARGE_ENCOUNTER_TYPE_UUID,
|
|
52
|
+
},
|
|
53
|
+
"location": location.uuid,
|
|
54
|
+
"obs": [],
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const generateUnassignBedDto = (): UnAssignBedDto => {
|
|
58
|
+
return {
|
|
59
|
+
patientUuid: admissionRequest.person.uuid,
|
|
60
|
+
bedId: admissionRequest.bedId
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return <>
|
|
64
|
+
<Modal
|
|
65
|
+
modalHeading="Discharge"
|
|
66
|
+
open={open}
|
|
67
|
+
size="md"
|
|
68
|
+
onSecondarySubmit={onModalClose}
|
|
69
|
+
onRequestClose={onModalClose}
|
|
70
|
+
onRequestSubmit={handleDischarge}
|
|
71
|
+
primaryButtonText="Discharge"
|
|
72
|
+
secondaryButtonText="Cancel"
|
|
73
|
+
>
|
|
74
|
+
<ModalBody>
|
|
75
|
+
<div className={styles.dischargeLayout}>
|
|
76
|
+
<div className={styles.contentSection}>
|
|
77
|
+
<h5>Are you sure you want to discharge Patient from Ward?</h5>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</ModalBody>
|
|
81
|
+
</Modal>
|
|
82
|
+
</>
|
|
83
|
+
}
|
|
84
|
+
export default DischargeModal;
|