@ampath/esm-dha-workflow-app 4.0.0-next.25 → 4.0.0-next.27

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.
@@ -28,4 +28,7 @@
28
28
  flex-direction: row;
29
29
  column-gap: 5px;
30
30
  margin-top: 15px;
31
+ }
32
+ .greenBtn{
33
+ background-color: #28a745;
31
34
  }
@@ -252,7 +252,7 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
252
252
  <div className={styles.actionSection}>
253
253
  {patients.length > 0 ? (
254
254
  <div className={styles.btnContainer}>
255
- <Button kind="secondary" onClick={sendToTriage}>
255
+ <Button className={styles.greenBtn} onClick={sendToTriage}>
256
256
  {loading ? <InlineLoading description="Sending To Triage..." /> : 'Send To Triage'}
257
257
  </Button>
258
258
  </div>
@@ -135,6 +135,9 @@ const RegistryComponent: React.FC<RegistryComponentProps> = () => {
135
135
  };
136
136
  const onSendToTriageModalClose = (modalCloseResp?: { success: boolean }) => {
137
137
  setDisplaytriageModal(false);
138
+ if (modalCloseResp && modalCloseResp.success) {
139
+ navigate('/triage');
140
+ }
138
141
  };
139
142
  const handleSendToTriageModalSubmit = () => {};
140
143
  const getPatient = (): HieClient => {
@@ -287,6 +287,8 @@ export type CreatePatientDto = {
287
287
  export type QueueEntryResult = {
288
288
  name: string;
289
289
  queue_entry_id: number;
290
+ priority_comment: string;
291
+ wait_time_in_min: number;
290
292
  queue_entry_uuid: string;
291
293
  service_uuid: string;
292
294
  location_id: number;
@@ -303,4 +305,5 @@ export type QueueEntryResult = {
303
305
  middle_name: string;
304
306
  status: string;
305
307
  visit_uuid: string;
308
+ queue_coming_from: string;
306
309
  };
@@ -4,6 +4,7 @@ import { type EndVisitDto, type QueueEntryResult } from '../../../registry/types
4
4
  import styles from './sign-off.modal.scss';
5
5
  import { showSnackbar } from '@openmrs/esm-framework';
6
6
  import { endVisit } from '../../../resources/visit.resource';
7
+ import { closeQueueEntry } from '../../service-queues.resource';
7
8
 
8
9
  interface SignOffEntryModalProps {
9
10
  open: boolean;
@@ -21,6 +22,7 @@ const SignOffEntryModal: React.FC<SignOffEntryModalProps> = ({
21
22
  const signOffEntry = async () => {
22
23
  const payload = getEndVisitPayload();
23
24
  try {
25
+ await removePatientFromQueue(currentQueueEntry);
24
26
  await endVisit(currentQueueEntry.visit_uuid, payload);
25
27
  showAlert('success', 'Visit Ended successfully', '');
26
28
  onSuccessfullSignOff();
@@ -40,6 +42,14 @@ const SignOffEntryModal: React.FC<SignOffEntryModalProps> = ({
40
42
  stopDatetime: new Date().toISOString(),
41
43
  };
42
44
  };
45
+ const removePatientFromQueue = async (currentQueueEntry: QueueEntryResult) => {
46
+ try {
47
+ await closeQueueEntry(currentQueueEntry.queue_entry_uuid);
48
+ showAlert('success', 'Patient removal from queue successfully!', '');
49
+ } catch (e) {
50
+ showAlert('error', 'Patient removal from queue failed!', '');
51
+ }
52
+ };
43
53
  return (
44
54
  <>
45
55
  <Modal
@@ -22,6 +22,7 @@ interface QueueListProps {
22
22
  handleTransitionPatient: (queueEntryResult: QueueEntryResult) => void;
23
23
  handleServePatient: (queueEntryResult: QueueEntryResult) => void;
24
24
  handleSignOff: (queueEntryResult: QueueEntryResult) => void;
25
+ handleRemovePatient: (queueEntryResult: QueueEntryResult) => void;
25
26
  }
26
27
 
27
28
  const QueueList: React.FC<QueueListProps> = ({
@@ -30,6 +31,7 @@ const QueueList: React.FC<QueueListProps> = ({
30
31
  handleTransitionPatient,
31
32
  handleServePatient,
32
33
  handleSignOff,
34
+ handleRemovePatient,
33
35
  }) => {
34
36
  const [checkIn, setCheckIn] = useState<boolean>(false);
35
37
  const handleCheckin = () => {
@@ -70,21 +72,21 @@ const QueueList: React.FC<QueueListProps> = ({
70
72
  <>
71
73
  <div className={styles.queueListLayout}>
72
74
  <div className={styles.actionHeader}>
73
- {checkIn ? (
74
- <>
75
- <Button kind="danger" onClick={handleCheckin}>
76
- {' '}
77
- Check Out
78
- </Button>
79
- </>
80
- ) : (
81
- <>
82
- <Button kind="primary" onClick={handleCheckin}>
83
- {' '}
84
- Check In
85
- </Button>
86
- </>
87
- )}
75
+ <>
76
+ {checkIn ? (
77
+ <>
78
+ <Button kind="danger" onClick={handleCheckin}>
79
+ Check Out
80
+ </Button>
81
+ </>
82
+ ) : (
83
+ <>
84
+ <Button kind="primary" onClick={handleCheckin}>
85
+ Check In
86
+ </Button>
87
+ </>
88
+ )}
89
+ </>
88
90
  </div>
89
91
  <div className={styles.tableSection}>
90
92
  <Table>
@@ -92,9 +94,11 @@ const QueueList: React.FC<QueueListProps> = ({
92
94
  <TableRow>
93
95
  <TableHeader>No</TableHeader>
94
96
  <TableHeader>Name</TableHeader>
97
+ <TableHeader>Coming From</TableHeader>
95
98
  <TableHeader>Ticket</TableHeader>
96
99
  <TableHeader>Status</TableHeader>
97
100
  <TableHeader>Priority</TableHeader>
101
+ <TableHeader>Wait Time</TableHeader>
98
102
  <TableHeader>Action</TableHeader>
99
103
  </TableRow>
100
104
  </TableHead>
@@ -113,6 +117,7 @@ const QueueList: React.FC<QueueListProps> = ({
113
117
  </>
114
118
  )}
115
119
  </TableCell>
120
+ <TableCell>{val.queue_coming_from}</TableCell>
116
121
  <TableCell>{val.queue_entry_id}</TableCell>
117
122
  <TableCell>
118
123
  <Tag size="md" type={getTagTypeByStatus(val.status)}>
@@ -124,6 +129,7 @@ const QueueList: React.FC<QueueListProps> = ({
124
129
  {val.priority}
125
130
  </Tag>
126
131
  </TableCell>
132
+ <TableCell>{`${val.wait_time_in_min} minute(s)`}</TableCell>
127
133
  <TableCell>
128
134
  {val.status === QueueEntryStatus.Waiting ? (
129
135
  <>
@@ -139,7 +145,7 @@ const QueueList: React.FC<QueueListProps> = ({
139
145
  <OverflowMenuItem itemText="Move" onClick={() => handleMovePatient(val)} />
140
146
  <OverflowMenuItem itemText="Transition" onClick={() => handleTransitionPatient(val)} />
141
147
  <OverflowMenuItem itemText="Sign Off" onClick={() => handleSignOff(val)} />
142
- <OverflowMenuItem itemText="Remove Patient" />
148
+ <OverflowMenuItem itemText="Remove Patient" onClick={() => handleRemovePatient(val)} />
143
149
  </OverflowMenu>
144
150
  </>
145
151
  ) : (
@@ -5,3 +5,10 @@
5
5
  padding: 15px 15px;
6
6
  row-gap: 15px;
7
7
  }
8
+ .headerAction{
9
+ display: flex;
10
+ flex-direction: row;
11
+ column-gap: 5px;
12
+ justify-content: flex-end;
13
+ padding: 10px 10px;
14
+ }
@@ -1,8 +1,8 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
2
  import { type QueueEntryResult } from '../../registry/types';
3
- import { useSession } from '@openmrs/esm-framework';
4
- import { getServiceQueueByLocationUuid } from '../service-queues.resource';
5
- import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@carbon/react';
3
+ import { showSnackbar, useSession } from '@openmrs/esm-framework';
4
+ import { closeQueueEntry, getServiceQueueByLocationUuid } from '../service-queues.resource';
5
+ import { Button, InlineLoading, Tab, TabList, TabPanel, TabPanels, Tabs } from '@carbon/react';
6
6
  import QueueList from '../queue-list/queue-list.component';
7
7
  import styles from './service-queue.component.scss';
8
8
  import MovePatientModal from '../modals/move/move-patient.component';
@@ -10,6 +10,7 @@ import TransitionPatientModal from '../modals/transition/transition-patient.comp
10
10
  import ServePatientModal from '../modals/serve/serve-patient.comppnent';
11
11
  import StatDetails from './stats/stat-details/stat-details.component';
12
12
  import SignOffEntryModal from '../modals/sign-off/sign-off.modal';
13
+ import { endVisit } from '../../resources/visit.resource';
13
14
 
14
15
  interface ServiceQueueComponentProps {
15
16
  serviceTypeUuid: string;
@@ -23,6 +24,7 @@ const ServiceQueueComponent: React.FC<ServiceQueueComponentProps> = ({ serviceTy
23
24
  const [displayTransitionModal, setDisplayTransitionModal] = useState<boolean>(false);
24
25
  const [displayServeModal, setDisplayServeModal] = useState<boolean>(false);
25
26
  const [displaySignOffModal, setDisplaySignOffModal] = useState<boolean>(false);
27
+ const [loading, setLoading] = useState<boolean>(false);
26
28
  const session = useSession();
27
29
  const locationUuid = session.sessionLocation.uuid;
28
30
 
@@ -47,8 +49,10 @@ const ServiceQueueComponent: React.FC<ServiceQueueComponentProps> = ({ serviceTy
47
49
  }, []);
48
50
 
49
51
  const getEntryQueues = async () => {
52
+ setLoading(true);
50
53
  const res = await getServiceQueueByLocationUuid(serviceTypeUuid, locationUuid);
51
54
  setQueueEntries(res);
55
+ setLoading(false);
52
56
  };
53
57
 
54
58
  if (!groupedByRoom) {
@@ -62,7 +66,7 @@ const ServiceQueueComponent: React.FC<ServiceQueueComponentProps> = ({ serviceTy
62
66
  setDisplayMoveModal(false);
63
67
  setDisplayTransitionModal(false);
64
68
  setDisplayServeModal(false);
65
- getEntryQueues();
69
+ handleRefresh();
66
70
  };
67
71
 
68
72
  const handleTransitionPatient = (queueEntry: QueueEntryResult) => {
@@ -93,6 +97,37 @@ const ServiceQueueComponent: React.FC<ServiceQueueComponentProps> = ({ serviceTy
93
97
 
94
98
  const onSuccessfullSignOff = () => {
95
99
  setDisplaySignOffModal(false);
100
+ handleRefresh();
101
+ };
102
+
103
+ const handleRefresh = () => {
104
+ getEntryQueues();
105
+ };
106
+
107
+ const handleRemovePatient = async (queueEntryResult: QueueEntryResult) => {
108
+ try {
109
+ await closeQueueEntry(queueEntryResult.queue_entry_uuid);
110
+ showSnackbar({
111
+ kind: 'success',
112
+ title: 'Patient removal from queue successfully!',
113
+ subtitle: '',
114
+ });
115
+ await endVisit(queueEntryResult.visit_uuid, {
116
+ stopDatetime: new Date().toISOString(),
117
+ });
118
+ showSnackbar({
119
+ kind: 'success',
120
+ title: 'Visit Ended successfully!',
121
+ subtitle: '',
122
+ });
123
+ handleRefresh();
124
+ } catch (e) {
125
+ showSnackbar({
126
+ kind: 'error',
127
+ title: 'Patient removal from queue failed!',
128
+ subtitle: e.message ?? '',
129
+ });
130
+ }
96
131
  };
97
132
 
98
133
  if (!serviceTypeUuid) {
@@ -114,6 +149,11 @@ const ServiceQueueComponent: React.FC<ServiceQueueComponentProps> = ({ serviceTy
114
149
  <></>
115
150
  )}
116
151
  </div>
152
+ <div className={styles.headerAction}>
153
+ <Button kind="tertiary" onClick={handleRefresh} disabled={loading}>
154
+ {loading ? <InlineLoading description="Refreshing..." /> : 'Refresh'}
155
+ </Button>
156
+ </div>
117
157
 
118
158
  <div className={styles.contentSection}>
119
159
  <Tabs>
@@ -135,6 +175,7 @@ const ServiceQueueComponent: React.FC<ServiceQueueComponentProps> = ({ serviceTy
135
175
  handleTransitionPatient={handleTransitionPatient}
136
176
  handleServePatient={handleServePatient}
137
177
  handleSignOff={handleSignOff}
178
+ handleRemovePatient={handleRemovePatient}
138
179
  />
139
180
  }
140
181
  </TabPanel>
@@ -158,3 +158,19 @@ export async function getServiceQueueByLocationUuid(
158
158
  const result = await response.json();
159
159
  return result.data;
160
160
  }
161
+
162
+ export async function closeQueueEntry(entryQueueUuid: string): Promise<QueueEntryResult[]> {
163
+ const queueEntryUrl = `${restBaseUrl}/queue-entry/${entryQueueUuid}`;
164
+ const params = {
165
+ endedAt: new Date().toISOString(),
166
+ };
167
+ const response = await openmrsFetch(queueEntryUrl, {
168
+ method: 'POST',
169
+ headers: {
170
+ 'content-type': 'application/json',
171
+ },
172
+ body: JSON.stringify(params),
173
+ });
174
+ const result = await response.json();
175
+ return result.data;
176
+ }