@openmrs/esm-service-queues-app 5.0.1-pre.2087
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 +40 -0
- package/LICENSE.md +401 -0
- package/README.md +23 -0
- package/__mocks__/active-visits.mock.ts +97 -0
- package/__mocks__/appointments-data.mock.ts +283 -0
- package/__mocks__/search.mock.ts +35 -0
- package/__mocks__/visits.mock.ts +42 -0
- package/dist/121.js +1 -0
- package/dist/121.js.map +1 -0
- package/dist/130.js +2 -0
- package/dist/130.js.LICENSE.txt +5 -0
- package/dist/130.js.map +1 -0
- package/dist/176.js +1 -0
- package/dist/176.js.map +1 -0
- package/dist/227.js +1 -0
- package/dist/227.js.map +1 -0
- package/dist/242.js +1 -0
- package/dist/242.js.map +1 -0
- package/dist/252.js +1 -0
- package/dist/252.js.map +1 -0
- package/dist/286.js +1 -0
- package/dist/286.js.map +1 -0
- package/dist/308.js +1 -0
- package/dist/308.js.map +1 -0
- package/dist/319.js +1 -0
- package/dist/328.js +1 -0
- package/dist/328.js.map +1 -0
- package/dist/330.js +1 -0
- package/dist/330.js.map +1 -0
- package/dist/364.js +1 -0
- package/dist/364.js.map +1 -0
- package/dist/425.js +1 -0
- package/dist/425.js.map +1 -0
- package/dist/457.js +1 -0
- package/dist/457.js.map +1 -0
- package/dist/469.js +1 -0
- package/dist/469.js.map +1 -0
- package/dist/521.js +1 -0
- package/dist/521.js.map +1 -0
- package/dist/53.js +1 -0
- package/dist/53.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/591.js +2 -0
- package/dist/591.js.LICENSE.txt +32 -0
- package/dist/591.js.map +1 -0
- package/dist/610.js +1 -0
- package/dist/610.js.map +1 -0
- package/dist/611.js +1 -0
- package/dist/611.js.map +1 -0
- package/dist/616.js +1 -0
- package/dist/616.js.map +1 -0
- package/dist/644.js +1 -0
- package/dist/644.js.map +1 -0
- package/dist/670.js +2 -0
- package/dist/670.js.LICENSE.txt +57 -0
- package/dist/670.js.map +1 -0
- package/dist/733.js +1 -0
- package/dist/733.js.map +1 -0
- package/dist/757.js +1 -0
- package/dist/764.js +1 -0
- package/dist/764.js.map +1 -0
- package/dist/766.js +1 -0
- package/dist/766.js.map +1 -0
- package/dist/784.js +2 -0
- package/dist/784.js.LICENSE.txt +9 -0
- package/dist/784.js.map +1 -0
- package/dist/788.js +1 -0
- package/dist/807.js +1 -0
- package/dist/833.js +1 -0
- package/dist/86.js +1 -0
- package/dist/86.js.map +1 -0
- package/dist/981.js +1 -0
- package/dist/981.js.map +1 -0
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-service-queues-app.js +1 -0
- package/dist/openmrs-esm-service-queues-app.js.buildmanifest.json +930 -0
- package/dist/openmrs-esm-service-queues-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.js +3 -0
- package/package.json +53 -0
- package/src/active-visits/active-visits-tab.component.tsx +71 -0
- package/src/active-visits/active-visits-tab.test.tsx +19 -0
- package/src/active-visits/active-visits-table.component.tsx +543 -0
- package/src/active-visits/active-visits-table.resource.ts +443 -0
- package/src/active-visits/active-visits-table.scss +271 -0
- package/src/active-visits/active-visits-table.test.tsx +131 -0
- package/src/active-visits/change-status-dialog.component.tsx +233 -0
- package/src/active-visits/change-status-dialog.scss +32 -0
- package/src/active-visits/change-status-dialog.test.tsx +107 -0
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +218 -0
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.scss +32 -0
- package/src/add-provider-queue-room/add-provider-queue-room.component.tsx +236 -0
- package/src/add-provider-queue-room/add-provider-queue-room.resource.tsx +76 -0
- package/src/add-provider-queue-room/add-provider-queue-room.scss +17 -0
- package/src/add-provider-queue-room/add-provider-queue-room.test.tsx +98 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +74 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx +46 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +15 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +42 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries.component.tsx +36 -0
- package/src/config-schema.ts +177 -0
- package/src/constants.ts +7 -0
- package/src/createDashboardLink.tsx +35 -0
- package/src/current-visit/current-visit-summary.component.tsx +38 -0
- package/src/current-visit/current-visit-summary.test.tsx +47 -0
- package/src/current-visit/current-visit.resource.ts +84 -0
- package/src/current-visit/current-visit.scss +34 -0
- package/src/current-visit/hooks/useVitalsConceptMetadata.tsx +101 -0
- package/src/current-visit/visit-details/biometrics-config-schema.ts +14 -0
- package/src/current-visit/visit-details/current-visit-details.component.tsx +96 -0
- package/src/current-visit/visit-details/triage-note.component.tsx +53 -0
- package/src/current-visit/visit-details/triage-note.scss +89 -0
- package/src/current-visit/visit-details/vitals-config-schema.ts +17 -0
- package/src/current-visit/visit-details/vitals.component.tsx +164 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +2 -0
- package/src/helpers/functions.ts +67 -0
- package/src/helpers/helpers.ts +170 -0
- package/src/helpers/time-helpers.ts +15 -0
- package/src/home.component.tsx +29 -0
- package/src/home.test.tsx +58 -0
- package/src/index.ts +100 -0
- package/src/overlay.component.tsx +46 -0
- package/src/overlay.scss +96 -0
- package/src/overlay.test.tsx +49 -0
- package/src/past-visit/past-visit-details/encounter-list.component.tsx +51 -0
- package/src/past-visit/past-visit-details/medications-list.component.tsx +95 -0
- package/src/past-visit/past-visit-details/notes-list.component.tsx +40 -0
- package/src/past-visit/past-visit-details/past-visit-summary.component.tsx +172 -0
- package/src/past-visit/past-visit-details/past-visit-summary.scss +58 -0
- package/src/past-visit/past-visit.component.tsx +37 -0
- package/src/past-visit/past-visit.resource.ts +83 -0
- package/src/past-visit/past-visit.scss +126 -0
- package/src/past-visit/past-visit.test.tsx +41 -0
- package/src/patient-info/appointment-details.component.tsx +98 -0
- package/src/patient-info/appointment-details.scss +34 -0
- package/src/patient-info/appointment-details.test.tsx +36 -0
- package/src/patient-info/appointments.resource.tsx +43 -0
- package/src/patient-info/contact-details.component.tsx +71 -0
- package/src/patient-info/contact-details.scss +31 -0
- package/src/patient-info/contact-details.test.tsx +94 -0
- package/src/patient-info/hooks/usePatientAttributes.tsx +42 -0
- package/src/patient-info/patient-info.component.tsx +78 -0
- package/src/patient-info/patient-info.scss +60 -0
- package/src/patient-info/patient-info.test.tsx +45 -0
- package/src/patient-queue-header/patient-queue-header.component.tsx +64 -0
- package/src/patient-queue-header/patient-queue-header.scss +88 -0
- package/src/patient-queue-header/patient-queue-illustration.component.tsx +22 -0
- package/src/patient-queue-metrics/clinic-metrics.component.tsx +93 -0
- package/src/patient-queue-metrics/clinic-metrics.resource.tsx +51 -0
- package/src/patient-queue-metrics/clinic-metrics.scss +11 -0
- package/src/patient-queue-metrics/clinic-metrics.test.tsx +87 -0
- package/src/patient-queue-metrics/metrics-card.component.tsx +64 -0
- package/src/patient-queue-metrics/metrics-card.scss +80 -0
- package/src/patient-queue-metrics/metrics-header.component.tsx +74 -0
- package/src/patient-queue-metrics/metrics-header.scss +22 -0
- package/src/patient-queue-metrics/queue-metrics.resource.ts +54 -0
- package/src/patient-search/advanced-search.component.tsx +190 -0
- package/src/patient-search/advanced-search.scss +154 -0
- package/src/patient-search/advanced-search.test.tsx +29 -0
- package/src/patient-search/basic-search.component.tsx +112 -0
- package/src/patient-search/basic-search.scss +139 -0
- package/src/patient-search/basic-search.test.tsx +23 -0
- package/src/patient-search/empty-data-illustration.component.tsx +41 -0
- package/src/patient-search/hooks/useActivePatientEnrollment.tsx +29 -0
- package/src/patient-search/hooks/useDefaultLocation.tsx +14 -0
- package/src/patient-search/hooks/usePatients.tsx +25 -0
- package/src/patient-search/hooks/useQueueLocations.tsx +20 -0
- package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +36 -0
- package/src/patient-search/hooks/useScheduledVisits.tsx +50 -0
- package/src/patient-search/patient-scheduled-visits.component.tsx +350 -0
- package/src/patient-search/patient-scheduled-visits.scss +131 -0
- package/src/patient-search/patient-scheduled-visits.test.tsx +55 -0
- package/src/patient-search/patient-search.component.tsx +64 -0
- package/src/patient-search/search-illustration.component.tsx +27 -0
- package/src/patient-search/search-results.component.tsx +75 -0
- package/src/patient-search/search-results.scss +80 -0
- package/src/patient-search/search-results.test.tsx +77 -0
- package/src/patient-search/search.resource.ts +10 -0
- package/src/patient-search/visit-form/base-visit-type.component.tsx +82 -0
- package/src/patient-search/visit-form/base-visit-type.scss +100 -0
- package/src/patient-search/visit-form/base-visit-type.test.tsx +41 -0
- package/src/patient-search/visit-form/queue.resource.ts +73 -0
- package/src/patient-search/visit-form/recommended-visit-type.component.tsx +38 -0
- package/src/patient-search/visit-form/visit-form.component.tsx +366 -0
- package/src/patient-search/visit-form/visit-form.scss +96 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx +160 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.scss +21 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx +67 -0
- package/src/queue-entry-table-components/actions-menu.component.tsx +51 -0
- package/src/queue-entry-table-components/actions-menu.scss +3 -0
- package/src/queue-entry-table-components/edit-entry.component.tsx +28 -0
- package/src/queue-entry-table-components/edit-entry.scss +14 -0
- package/src/queue-entry-table-components/open-chart.component.tsx +33 -0
- package/src/queue-entry-table-components/open-chart.resource.tsx +14 -0
- package/src/queue-entry-table-components/open-chart.scss +14 -0
- package/src/queue-entry-table-components/status-icon.component.tsx +17 -0
- package/src/queue-entry-table-components/transition-entry.component.tsx +53 -0
- package/src/queue-entry-table-components/transition-entry.scss +22 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +230 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.scss +110 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.test.tsx +118 -0
- package/src/queue-patient-linelists/queue-linelist-filter.component.tsx +172 -0
- package/src/queue-patient-linelists/queue-linelist-filter.scss +63 -0
- package/src/queue-patient-linelists/queue-linelist-filter.test.tsx +76 -0
- package/src/queue-patient-linelists/queue-linelist.component.tsx +29 -0
- package/src/queue-patient-linelists/queue-linelist.resource.tsx +84 -0
- package/src/queue-patient-linelists/queue-linelist.test.tsx +22 -0
- package/src/queue-patient-linelists/queue-services-table.component.tsx +63 -0
- package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +300 -0
- package/src/queue-patient-linelists/scheduled-appointments-table.test.tsx +42 -0
- package/src/queue-rooms/queue-room-form.component.tsx +168 -0
- package/src/queue-rooms/queue-room-form.test.tsx +65 -0
- package/src/queue-rooms/queue-room.resource.tsx +20 -0
- package/src/queue-rooms/queue-room.scss +58 -0
- package/src/queue-screen/queue-screen.component.tsx +47 -0
- package/src/queue-screen/queue-screen.scss +39 -0
- package/src/queue-screen/queue-screen.test.tsx +47 -0
- package/src/queue-screen/useActiveTickets.tsx +13 -0
- package/src/queue-services/queue-service-form.component.tsx +183 -0
- package/src/queue-services/queue-service-form.test.tsx +56 -0
- package/src/queue-services/queue-service.resource.tsx +38 -0
- package/src/queue-services/queue-service.scss +54 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +95 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.resource.tsx +93 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.scss +8 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.test.tsx +44 -0
- package/src/root.component.tsx +28 -0
- package/src/root.scss +15 -0
- package/src/root.test.tsx +28 -0
- package/src/routes.json +91 -0
- package/src/side-menu/nav-group/createNavGroup.tsx +17 -0
- package/src/side-menu/nav-group/nav-group.component.tsx +24 -0
- package/src/side-menu/nav-group/nav-group.test.tsx +32 -0
- package/src/side-menu/nav-group/nav-group.ts +10 -0
- package/src/side-menu/side-menu.component.tsx +6 -0
- package/src/side-menu/side-menu.test.tsx +17 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +174 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.scss +12 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.test.tsx +95 -0
- package/src/transition-queue-entry/transition-queue-entry.resource.ts +16 -0
- package/src/types/index.ts +434 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +298 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +93 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.scss +108 -0
- package/translations/am.json +258 -0
- package/translations/en.json +258 -0
- package/translations/es.json +258 -0
- package/translations/fr.json +258 -0
- package/translations/he.json +262 -0
- package/translations/km.json +258 -0
- package/tsconfig.json +5 -0
- package/webpack.config.js +1 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Form,
|
|
6
|
+
InlineNotification,
|
|
7
|
+
ModalBody,
|
|
8
|
+
ModalFooter,
|
|
9
|
+
ModalHeader,
|
|
10
|
+
Select,
|
|
11
|
+
SelectItem,
|
|
12
|
+
RadioButtonGroup,
|
|
13
|
+
RadioButton,
|
|
14
|
+
} from '@carbon/react';
|
|
15
|
+
import { ConfigObject, showNotification, showToast, useConfig } from '@openmrs/esm-framework';
|
|
16
|
+
import {
|
|
17
|
+
addQueueEntry,
|
|
18
|
+
usePriority,
|
|
19
|
+
useServices,
|
|
20
|
+
useStatus,
|
|
21
|
+
useVisitQueueEntries,
|
|
22
|
+
} from '../active-visits/active-visits-table.resource';
|
|
23
|
+
import styles from './add-patient-toqueue-dialog.scss';
|
|
24
|
+
import { ActiveVisit, useMissingQueueEntries } from '../visits-missing-inqueue/visits-missing-inqueue.resource';
|
|
25
|
+
import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
|
|
26
|
+
|
|
27
|
+
interface AddVisitToQueueDialogProps {
|
|
28
|
+
visitDetails: ActiveVisit;
|
|
29
|
+
closeModal: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const AddVisitToQueue: React.FC<AddVisitToQueueDialogProps> = ({ visitDetails, closeModal }) => {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
|
|
35
|
+
const visitUuid = visitDetails?.visitUuid;
|
|
36
|
+
const [queueUuid, setQueueUuid] = useState('');
|
|
37
|
+
const patientUuid = visitDetails?.patientUuid;
|
|
38
|
+
const patientName = visitDetails?.name;
|
|
39
|
+
const patientAge = visitDetails?.age;
|
|
40
|
+
const patientSex = visitDetails?.gender;
|
|
41
|
+
const { priorities } = usePriority();
|
|
42
|
+
const { statuses, isLoading } = useStatus();
|
|
43
|
+
const [selectedQueueLocation, setSelectedQueueLocation] = useState('');
|
|
44
|
+
const { services } = useServices(selectedQueueLocation);
|
|
45
|
+
const { queueLocations } = useQueueLocations();
|
|
46
|
+
const [isMissingPriority, setIsMissingPriority] = useState(false);
|
|
47
|
+
const [isMissingService, setIsMissingService] = useState(false);
|
|
48
|
+
const config = useConfig() as ConfigObject;
|
|
49
|
+
const { mutate } = useVisitQueueEntries('', selectedQueueLocation);
|
|
50
|
+
const [priority, setPriority] = useState(config.concepts.defaultPriorityConceptUuid);
|
|
51
|
+
const { mutateQueueEntries } = useMissingQueueEntries();
|
|
52
|
+
|
|
53
|
+
const addVisitToQueue = useCallback(() => {
|
|
54
|
+
if (!queueUuid) {
|
|
55
|
+
setIsMissingService(true);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
setIsMissingService(false);
|
|
59
|
+
|
|
60
|
+
if (!priority) {
|
|
61
|
+
setIsMissingPriority(true);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setIsMissingPriority(false);
|
|
65
|
+
const emergencyPriorityConceptUuid = config.concepts.emergencyPriorityConceptUuid;
|
|
66
|
+
const sortWeight = priority === emergencyPriorityConceptUuid ? 1.0 : 0.0;
|
|
67
|
+
const status = config.concepts.defaultStatusConceptUuid;
|
|
68
|
+
const visitQueueNumberAttributeUuid = config.concepts.visitQueueNumberAttributeUuid;
|
|
69
|
+
|
|
70
|
+
addQueueEntry(
|
|
71
|
+
visitUuid,
|
|
72
|
+
queueUuid,
|
|
73
|
+
patientUuid,
|
|
74
|
+
priority,
|
|
75
|
+
status,
|
|
76
|
+
sortWeight,
|
|
77
|
+
selectedQueueLocation,
|
|
78
|
+
visitQueueNumberAttributeUuid,
|
|
79
|
+
).then(
|
|
80
|
+
({ status }) => {
|
|
81
|
+
if (status === 201) {
|
|
82
|
+
showToast({
|
|
83
|
+
critical: true,
|
|
84
|
+
title: t('addEntry', 'Add entry'),
|
|
85
|
+
kind: 'success',
|
|
86
|
+
description: t('queueEntryAddedSuccessfully', 'Queue Entry Added Successfully'),
|
|
87
|
+
});
|
|
88
|
+
closeModal();
|
|
89
|
+
mutate();
|
|
90
|
+
mutateQueueEntries();
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
(error) => {
|
|
94
|
+
showNotification({
|
|
95
|
+
title: t('queueEntryAddFailed', 'Error adding queue entry status'),
|
|
96
|
+
kind: 'error',
|
|
97
|
+
critical: true,
|
|
98
|
+
description: error?.message,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}, [
|
|
103
|
+
queueUuid,
|
|
104
|
+
priority,
|
|
105
|
+
config.concepts.emergencyPriorityConceptUuid,
|
|
106
|
+
config.concepts.defaultStatusConceptUuid,
|
|
107
|
+
config.concepts.visitQueueNumberAttributeUuid,
|
|
108
|
+
visitUuid,
|
|
109
|
+
patientUuid,
|
|
110
|
+
selectedQueueLocation,
|
|
111
|
+
t,
|
|
112
|
+
closeModal,
|
|
113
|
+
mutate,
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div>
|
|
118
|
+
<ModalHeader closeModal={closeModal} title={t('addVisitToQueue', 'Add Visit To Queue?')} />
|
|
119
|
+
<ModalBody>
|
|
120
|
+
<Form onSubmit={addVisitToQueue}>
|
|
121
|
+
<div className={styles.modalBody}>
|
|
122
|
+
<h5>
|
|
123
|
+
{patientName} · {patientSex} · {patientAge} {t('years', 'Years')}
|
|
124
|
+
</h5>
|
|
125
|
+
</div>
|
|
126
|
+
<section>
|
|
127
|
+
<Select
|
|
128
|
+
labelText={t('selectQueueLocation', 'Select a queue location')}
|
|
129
|
+
id="location"
|
|
130
|
+
invalidText="Required"
|
|
131
|
+
value={selectedQueueLocation}
|
|
132
|
+
onChange={(event) => setSelectedQueueLocation(event.target.value)}>
|
|
133
|
+
{!selectedQueueLocation ? (
|
|
134
|
+
<SelectItem text={t('selectQueueLocation', 'Select a queue location')} value="" />
|
|
135
|
+
) : null}
|
|
136
|
+
{queueLocations?.length > 0 &&
|
|
137
|
+
queueLocations.map((location) => (
|
|
138
|
+
<SelectItem key={location.id} text={location.name} value={location.id}>
|
|
139
|
+
{location.name}
|
|
140
|
+
</SelectItem>
|
|
141
|
+
))}
|
|
142
|
+
</Select>
|
|
143
|
+
</section>
|
|
144
|
+
|
|
145
|
+
<section className={styles.section}>
|
|
146
|
+
<div className={styles.sectionTitle}>{t('queueService', 'Queue service')}</div>
|
|
147
|
+
<Select
|
|
148
|
+
labelText={t('selectService', 'Select a service')}
|
|
149
|
+
id="service"
|
|
150
|
+
invalidText="Required"
|
|
151
|
+
value={queueUuid}
|
|
152
|
+
onChange={(event) => setQueueUuid(event.target.value)}>
|
|
153
|
+
{!queueUuid ? <SelectItem text={t('chooseService', 'Select a service')} value="" /> : null}
|
|
154
|
+
{services?.length > 0 &&
|
|
155
|
+
services.map((service) => (
|
|
156
|
+
<SelectItem key={service.uuid} text={service.display} value={service.uuid}>
|
|
157
|
+
{service.display}
|
|
158
|
+
</SelectItem>
|
|
159
|
+
))}
|
|
160
|
+
</Select>
|
|
161
|
+
</section>
|
|
162
|
+
{isMissingService && (
|
|
163
|
+
<section>
|
|
164
|
+
<InlineNotification
|
|
165
|
+
style={{ margin: '0', minWidth: '100%' }}
|
|
166
|
+
kind="error"
|
|
167
|
+
lowContrast={true}
|
|
168
|
+
title={t('missingService', 'Please select a service')}
|
|
169
|
+
/>
|
|
170
|
+
</section>
|
|
171
|
+
)}
|
|
172
|
+
|
|
173
|
+
<section className={styles.section}>
|
|
174
|
+
<div className={styles.sectionTitle}>{t('queueStatus', 'Queue status')}</div>
|
|
175
|
+
{!priorities?.length ? (
|
|
176
|
+
<InlineNotification
|
|
177
|
+
className={styles.inlineNotification}
|
|
178
|
+
kind={'error'}
|
|
179
|
+
lowContrast
|
|
180
|
+
subtitle={t('configurePriorities', 'Please configure priorities to continue.')}
|
|
181
|
+
title={t('noPriorityFound', 'No priority found')}
|
|
182
|
+
/>
|
|
183
|
+
) : (
|
|
184
|
+
<RadioButtonGroup
|
|
185
|
+
className={styles.radioButtonWrapper}
|
|
186
|
+
name="priority"
|
|
187
|
+
defaultSelected={priority}
|
|
188
|
+
onChange={(uuid) => {
|
|
189
|
+
setPriority(uuid);
|
|
190
|
+
}}>
|
|
191
|
+
{priorities?.length > 0 &&
|
|
192
|
+
priorities.map(({ uuid, display }) => <RadioButton key={uuid} labelText={display} value={uuid} />)}
|
|
193
|
+
</RadioButtonGroup>
|
|
194
|
+
)}
|
|
195
|
+
</section>
|
|
196
|
+
{isMissingPriority && (
|
|
197
|
+
<section>
|
|
198
|
+
<InlineNotification
|
|
199
|
+
style={{ margin: '0', minWidth: '100%' }}
|
|
200
|
+
kind="error"
|
|
201
|
+
lowContrast={true}
|
|
202
|
+
title={t('missingPriority', 'Please select a priority')}
|
|
203
|
+
/>
|
|
204
|
+
</section>
|
|
205
|
+
)}
|
|
206
|
+
</Form>
|
|
207
|
+
</ModalBody>
|
|
208
|
+
<ModalFooter>
|
|
209
|
+
<Button kind="secondary" onClick={closeModal}>
|
|
210
|
+
{t('cancel', 'Cancel')}
|
|
211
|
+
</Button>
|
|
212
|
+
<Button onClick={addVisitToQueue}>{t('save', 'Save')}</Button>
|
|
213
|
+
</ModalFooter>
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export default AddVisitToQueue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
4
|
+
|
|
5
|
+
.radioButtonGroup {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
margin-top: spacing.$spacing-03;
|
|
10
|
+
min-height: spacing.$spacing-10;
|
|
11
|
+
width: 100%;
|
|
12
|
+
@include type.type-style('body-compact-01');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.radioButton {
|
|
16
|
+
padding: spacing.$spacing-02 spacing.$spacing-02;
|
|
17
|
+
margin: spacing.$spacing-03 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
section {
|
|
21
|
+
margin: spacing.$spacing-03;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sectionTitle {
|
|
25
|
+
@include type.type-style('heading-compact-02');
|
|
26
|
+
color: $text-02;
|
|
27
|
+
margin-bottom: spacing.$spacing-04;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.modalBody {
|
|
31
|
+
padding-bottom: spacing.$spacing-05;
|
|
32
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
ModalBody,
|
|
6
|
+
ModalFooter,
|
|
7
|
+
ModalHeader,
|
|
8
|
+
Form,
|
|
9
|
+
InlineNotification,
|
|
10
|
+
Select,
|
|
11
|
+
SelectItem,
|
|
12
|
+
Checkbox,
|
|
13
|
+
Dropdown,
|
|
14
|
+
} from '@carbon/react';
|
|
15
|
+
import { showNotification, showToast } from '@openmrs/esm-framework';
|
|
16
|
+
import { useServices, useVisitQueueEntries } from '../active-visits/active-visits-table.resource';
|
|
17
|
+
import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
|
|
18
|
+
import {
|
|
19
|
+
addProviderToQueueRoom,
|
|
20
|
+
updateProviderToQueueRoom,
|
|
21
|
+
useProvidersQueueRoom,
|
|
22
|
+
useQueueRooms,
|
|
23
|
+
} from './add-provider-queue-room.resource';
|
|
24
|
+
import {
|
|
25
|
+
updatedSelectedQueueRoomTimestamp,
|
|
26
|
+
updateIsPermanentProviderQueueRoom,
|
|
27
|
+
updateSelectedQueueLocationName,
|
|
28
|
+
updateSelectedQueueLocationUuid,
|
|
29
|
+
updateSelectedServiceName,
|
|
30
|
+
updateSelectedServiceUuid,
|
|
31
|
+
useIsPermanentProviderQueueRoom,
|
|
32
|
+
useSelectedQueueLocationUuid,
|
|
33
|
+
useSelectedServiceName,
|
|
34
|
+
useSelectedServiceUuid,
|
|
35
|
+
} from '../helpers/helpers';
|
|
36
|
+
import styles from './add-provider-queue-room.scss';
|
|
37
|
+
|
|
38
|
+
interface AddProviderQueueRoomProps {
|
|
39
|
+
providerUuid: string;
|
|
40
|
+
closeModal: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const AddProviderQueueRoom: React.FC<AddProviderQueueRoomProps> = ({ providerUuid, closeModal }) => {
|
|
44
|
+
const { t } = useTranslation();
|
|
45
|
+
|
|
46
|
+
const currentLocationName = useSelectedServiceName();
|
|
47
|
+
const currentLocationUuid = useSelectedQueueLocationUuid();
|
|
48
|
+
const currentServiceUuid = useSelectedServiceUuid();
|
|
49
|
+
const currentServiceName = useSelectedServiceName();
|
|
50
|
+
const currentIsPermanentProviderQueueRoom = useIsPermanentProviderQueueRoom();
|
|
51
|
+
const { providerRoom, isLoading: loading } = useProvidersQueueRoom(providerUuid);
|
|
52
|
+
const [queueRoomUuid, setQueueRoomUuid] = useState('');
|
|
53
|
+
const [queueProviderMapUuid, setQueueProviderMapUuid] = useState('');
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (providerRoom?.length > 0) {
|
|
57
|
+
setQueueRoomUuid(providerRoom?.[0].queueRoom?.uuid);
|
|
58
|
+
setQueueProviderMapUuid(providerRoom?.[0].uuid);
|
|
59
|
+
}
|
|
60
|
+
}, [providerRoom]);
|
|
61
|
+
|
|
62
|
+
const { mutate } = useProvidersQueueRoom(providerUuid);
|
|
63
|
+
const { services } = useServices(currentLocationUuid);
|
|
64
|
+
const { rooms } = useQueueRooms(currentLocationUuid, currentServiceUuid);
|
|
65
|
+
const { queueLocations } = useQueueLocations();
|
|
66
|
+
const [isMissingQueueRoom, setIsMissingQueueRoom] = useState(false);
|
|
67
|
+
|
|
68
|
+
const handleServiceChange = ({ selectedItem }) => {
|
|
69
|
+
localStorage.setItem('queueServiceName', selectedItem.name);
|
|
70
|
+
localStorage.setItem('queueServiceUuid', selectedItem.uuid);
|
|
71
|
+
updateSelectedServiceName(selectedItem.name);
|
|
72
|
+
updateSelectedServiceUuid(selectedItem.uuid);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const handleQueueLocationChange = ({ selectedItem }) => {
|
|
76
|
+
localStorage.setItem('queueLocationUuid', selectedItem.id);
|
|
77
|
+
localStorage.setItem('queueLocationName', selectedItem.name);
|
|
78
|
+
updateSelectedQueueLocationName(selectedItem.name);
|
|
79
|
+
updateSelectedQueueLocationUuid(selectedItem.id);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleRetainLocation = (e) => {
|
|
83
|
+
localStorage.setItem('isPermanentProviderQueueRoom', JSON.parse(e.target.checked));
|
|
84
|
+
updateIsPermanentProviderQueueRoom(JSON.parse(e.target.checked));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const onSubmit = useCallback(() => {
|
|
88
|
+
if (!queueRoomUuid) {
|
|
89
|
+
setIsMissingQueueRoom(true);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
setIsMissingQueueRoom(false);
|
|
93
|
+
|
|
94
|
+
if (providerRoom?.length > 0) {
|
|
95
|
+
updateProviderToQueueRoom(queueProviderMapUuid, queueRoomUuid, providerUuid).then(
|
|
96
|
+
({ status }) => {
|
|
97
|
+
if (status === 200) {
|
|
98
|
+
showToast({
|
|
99
|
+
critical: true,
|
|
100
|
+
title: t('updateRoom', 'Update room'),
|
|
101
|
+
kind: 'success',
|
|
102
|
+
description: t('queueRoomUpdatedSuccessfully', 'Queue room updated successfully'),
|
|
103
|
+
});
|
|
104
|
+
closeModal();
|
|
105
|
+
localStorage.setItem('lastUpdatedQueueRoomTimestamp', new Date().toString());
|
|
106
|
+
updatedSelectedQueueRoomTimestamp(new Date());
|
|
107
|
+
mutate();
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
(error) => {
|
|
111
|
+
showNotification({
|
|
112
|
+
title: t('queueRoomAddFailed', 'Error adding queue room'),
|
|
113
|
+
kind: 'error',
|
|
114
|
+
critical: true,
|
|
115
|
+
description: error?.message,
|
|
116
|
+
});
|
|
117
|
+
closeModal();
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
} else {
|
|
121
|
+
addProviderToQueueRoom(queueRoomUuid, providerUuid).then(
|
|
122
|
+
({ status }) => {
|
|
123
|
+
if (status === 201) {
|
|
124
|
+
showToast({
|
|
125
|
+
critical: true,
|
|
126
|
+
title: t('addRoom', 'Add room'),
|
|
127
|
+
kind: 'success',
|
|
128
|
+
description: t('queueRoomAddedSuccessfully', 'Queue room added successfully'),
|
|
129
|
+
});
|
|
130
|
+
closeModal();
|
|
131
|
+
localStorage.setItem('lastUpdatedQueueRoomTimestamp', new Date().toString());
|
|
132
|
+
updatedSelectedQueueRoomTimestamp(new Date());
|
|
133
|
+
mutate();
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
(error) => {
|
|
137
|
+
showNotification({
|
|
138
|
+
title: t('queueRoomAddFailed', 'Error adding queue room'),
|
|
139
|
+
kind: 'error',
|
|
140
|
+
critical: true,
|
|
141
|
+
description: error?.message,
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}, [queueRoomUuid, providerRoom?.length, queueProviderMapUuid, providerUuid, t, closeModal, mutate]);
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<div>
|
|
150
|
+
<ModalHeader closeModal={closeModal} title={t('addProviderQueueRoom', 'Add provider queue room?')} />
|
|
151
|
+
<ModalBody>
|
|
152
|
+
<Form onSubmit={onSubmit}>
|
|
153
|
+
<section className={styles.section}>
|
|
154
|
+
<div className={styles.sectionTitle}>{t('queueLocation', 'Queue location')}</div>
|
|
155
|
+
<Dropdown
|
|
156
|
+
id="queueLocation"
|
|
157
|
+
label={t('selectQueueLocation', 'Select a queue location')}
|
|
158
|
+
type="default"
|
|
159
|
+
items={queueLocations}
|
|
160
|
+
itemToString={(item) => (item ? item.name : '')}
|
|
161
|
+
onChange={handleQueueLocationChange}
|
|
162
|
+
size="md"
|
|
163
|
+
initialSelectedItem={{ uuid: currentLocationUuid, name: currentLocationName }}
|
|
164
|
+
/>
|
|
165
|
+
</section>
|
|
166
|
+
|
|
167
|
+
<section className={styles.section}>
|
|
168
|
+
<div className={styles.sectionTitle}>{t('queueService', 'Queue service')}</div>
|
|
169
|
+
<Dropdown
|
|
170
|
+
id="service"
|
|
171
|
+
label={t('selectService', 'Select a service')}
|
|
172
|
+
type="default"
|
|
173
|
+
items={services}
|
|
174
|
+
itemToString={(item) => (item ? item.display : '')}
|
|
175
|
+
onChange={handleServiceChange}
|
|
176
|
+
size="md"
|
|
177
|
+
initialSelectedItem={{ uuid: currentServiceUuid, display: currentServiceName }}
|
|
178
|
+
/>
|
|
179
|
+
</section>
|
|
180
|
+
|
|
181
|
+
<section className={styles.section}>
|
|
182
|
+
<div className={styles.sectionTitle}>{t('queueRoom', 'Queue room')}</div>
|
|
183
|
+
<div className={styles.filterContainer}>
|
|
184
|
+
<Select
|
|
185
|
+
labelText={t('selectRoom', 'Select a room')}
|
|
186
|
+
id="service"
|
|
187
|
+
invalidText="Required"
|
|
188
|
+
value={queueRoomUuid}
|
|
189
|
+
defaultValue={queueRoomUuid}
|
|
190
|
+
onChange={(event) => {
|
|
191
|
+
setQueueRoomUuid(event.target.value);
|
|
192
|
+
localStorage.setItem('lastUpdatedQueueRoomTimestamp', new Date().toString());
|
|
193
|
+
}}>
|
|
194
|
+
{!queueRoomUuid ? <SelectItem text={t('chooseRoom', 'Select a room')} value="" /> : null}
|
|
195
|
+
{rooms?.length > 0 &&
|
|
196
|
+
rooms.map((room) => (
|
|
197
|
+
<SelectItem key={room.uuid} text={room.display} value={room.uuid}>
|
|
198
|
+
{room.display}
|
|
199
|
+
</SelectItem>
|
|
200
|
+
))}
|
|
201
|
+
</Select>
|
|
202
|
+
</div>
|
|
203
|
+
</section>
|
|
204
|
+
{isMissingQueueRoom && (
|
|
205
|
+
<section>
|
|
206
|
+
<InlineNotification
|
|
207
|
+
style={{ margin: '0', minWidth: '100%' }}
|
|
208
|
+
kind="error"
|
|
209
|
+
lowContrast={true}
|
|
210
|
+
title={t('missingQueueRoom', 'Please select a queue room')}
|
|
211
|
+
/>
|
|
212
|
+
</section>
|
|
213
|
+
)}
|
|
214
|
+
|
|
215
|
+
<section className={styles.section}>
|
|
216
|
+
<Checkbox
|
|
217
|
+
onChange={handleRetainLocation}
|
|
218
|
+
checked={currentIsPermanentProviderQueueRoom}
|
|
219
|
+
labelText={t('retainLocation', 'Retain location')}
|
|
220
|
+
id="retianLocation"
|
|
221
|
+
className={styles.checkbox}
|
|
222
|
+
/>
|
|
223
|
+
</section>
|
|
224
|
+
</Form>
|
|
225
|
+
</ModalBody>
|
|
226
|
+
<ModalFooter>
|
|
227
|
+
<Button kind="secondary" onClick={closeModal}>
|
|
228
|
+
{t('cancel', 'Cancel')}
|
|
229
|
+
</Button>
|
|
230
|
+
<Button onClick={onSubmit}>{t('save', 'Save')}</Button>
|
|
231
|
+
</ModalFooter>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export default AddProviderQueueRoom;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
import { ProvidersQueueRoom, QueueRoom } from '../types';
|
|
4
|
+
|
|
5
|
+
export function useQueueRooms(location: string, queueUuid: string) {
|
|
6
|
+
const apiUrl = queueUuid
|
|
7
|
+
? `/ws/rest/v1/queueroom?location=${location}&queue=${queueUuid}`
|
|
8
|
+
: `/ws/rest/v1/queueroom?location=${location}`;
|
|
9
|
+
|
|
10
|
+
const { data, error, isLoading } = useSWR<{ data: { results: Array<QueueRoom> } }, Error>(
|
|
11
|
+
location ? apiUrl : null,
|
|
12
|
+
openmrsFetch,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
rooms: data ? data?.data?.results : [],
|
|
17
|
+
isError: error,
|
|
18
|
+
isLoading,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function addProviderToQueueRoom(queueRoomUuid: string, providerUuid) {
|
|
23
|
+
const abortController = new AbortController();
|
|
24
|
+
|
|
25
|
+
return openmrsFetch(`/ws/rest/v1/roomprovidermap`, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
},
|
|
30
|
+
signal: abortController.signal,
|
|
31
|
+
body: {
|
|
32
|
+
queueRoom: {
|
|
33
|
+
uuid: queueRoomUuid,
|
|
34
|
+
},
|
|
35
|
+
provider: {
|
|
36
|
+
uuid: providerUuid,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function updateProviderToQueueRoom(queueProviderMapUuid: string, queueRoomUuid: string, providerUuid) {
|
|
43
|
+
const abortController = new AbortController();
|
|
44
|
+
|
|
45
|
+
return openmrsFetch(`/ws/rest/v1/roomprovidermap/${queueProviderMapUuid}`, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: {
|
|
48
|
+
'Content-Type': 'application/json',
|
|
49
|
+
},
|
|
50
|
+
signal: abortController.signal,
|
|
51
|
+
body: {
|
|
52
|
+
queueRoom: {
|
|
53
|
+
uuid: queueRoomUuid,
|
|
54
|
+
},
|
|
55
|
+
provider: {
|
|
56
|
+
uuid: providerUuid,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function useProvidersQueueRoom(providerUuid: string) {
|
|
63
|
+
const apiUrl = `/ws/rest/v1/roomprovidermap?provider=${providerUuid}`;
|
|
64
|
+
|
|
65
|
+
const { data, error, isLoading, mutate } = useSWR<{ data: { results: Array<ProvidersQueueRoom> } }, Error>(
|
|
66
|
+
providerUuid ? apiUrl : null,
|
|
67
|
+
openmrsFetch,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
providerRoom: data ? data?.data?.results : [],
|
|
72
|
+
isError: error,
|
|
73
|
+
isLoading,
|
|
74
|
+
mutate,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
4
|
+
|
|
5
|
+
section {
|
|
6
|
+
margin: spacing.$spacing-03;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sectionTitle {
|
|
10
|
+
@include type.type-style('heading-compact-02');
|
|
11
|
+
color: $text-02;
|
|
12
|
+
margin-bottom: spacing.$spacing-04;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.checkbox {
|
|
16
|
+
padding-top: spacing.$spacing-04;
|
|
17
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import AddProviderQueueRoom from './add-provider-queue-room.component';
|
|
4
|
+
import { showToast } from '@openmrs/esm-framework';
|
|
5
|
+
|
|
6
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
|
7
|
+
...jest.requireActual('@openmrs/esm-framework'),
|
|
8
|
+
useCurrentProvider: jest.fn(() => ({
|
|
9
|
+
currentProvider: { uuid: 'provider-uuid-1' },
|
|
10
|
+
})),
|
|
11
|
+
showToast: jest.fn(),
|
|
12
|
+
showNotification: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
jest.mock('./add-provider-queue-room.resource', () => ({
|
|
15
|
+
useProvidersQueueRoom: jest.fn(() => ({
|
|
16
|
+
providerRoom: [
|
|
17
|
+
{
|
|
18
|
+
queueRoom: { uuid: 'c187d78b-5c54-49bf-a0f8-b7fb6034d36d' },
|
|
19
|
+
uuid: '6b3e233d-2b44-40ca-b0c8-c5a57a8c51b6',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
isLoading: false,
|
|
23
|
+
mutate: jest.fn(),
|
|
24
|
+
})),
|
|
25
|
+
updateProviderToQueueRoom: jest.fn().mockResolvedValue({ status: 200 }),
|
|
26
|
+
addProviderToQueueRoom: jest.fn(),
|
|
27
|
+
useQueueRooms: jest.fn(() => ({
|
|
28
|
+
rooms: [
|
|
29
|
+
{ uuid: '6b3e233d-2b44-40ca-b0c8-c5a57a8c51b6', display: 'Room 1' },
|
|
30
|
+
{ uuid: 'e7786ac0-ab62-11ec-b909-0242ac120002', display: 'Room 2' },
|
|
31
|
+
],
|
|
32
|
+
})),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
jest.mock('../active-visits/active-visits-table.resource', () => ({
|
|
36
|
+
useServices: jest.fn(() => ({
|
|
37
|
+
services: [
|
|
38
|
+
{ uuid: 'e7786ac0-ab62-11ec-b909-0242ac120002', display: 'Service 1' },
|
|
39
|
+
{ uuid: 'e7786ac0-ab62-11ec-b909-0242ac120032', display: 'Service 2' },
|
|
40
|
+
],
|
|
41
|
+
})),
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
jest.mock('../patient-search/hooks/useQueueLocations', () => ({
|
|
45
|
+
useQueueLocations: jest.fn(() => ({
|
|
46
|
+
queueLocations: [
|
|
47
|
+
{ id: '1GHI12', name: 'Location 1' },
|
|
48
|
+
{ id: '1GHI45', name: 'Location 2' },
|
|
49
|
+
],
|
|
50
|
+
})),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const providerUuid = 'cc75ad73-c24b-499c-8db9-a7ef4fc0b36d';
|
|
54
|
+
|
|
55
|
+
describe('AddProviderQueueRoom', () => {
|
|
56
|
+
it('renders the form fields', () => {
|
|
57
|
+
render(<AddProviderQueueRoom providerUuid={providerUuid} closeModal={jest.fn()} />);
|
|
58
|
+
|
|
59
|
+
expect(screen.getByText('Select a room')).toBeInTheDocument();
|
|
60
|
+
expect(screen.getByLabelText('Retain location')).toBeInTheDocument();
|
|
61
|
+
expect(screen.getByText('Cancel')).toBeInTheDocument();
|
|
62
|
+
expect(screen.getByText('Save')).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('updates queue room selection', () => {
|
|
66
|
+
render(<AddProviderQueueRoom providerUuid={providerUuid} closeModal={jest.fn()} />);
|
|
67
|
+
|
|
68
|
+
const selectQueueRoom: HTMLInputElement = screen.getByRole('combobox');
|
|
69
|
+
fireEvent.change(selectQueueRoom, { target: { value: 'room-uuid-1' } });
|
|
70
|
+
|
|
71
|
+
expect(selectQueueRoom.value).toBe('6b3e233d-2b44-40ca-b0c8-c5a57a8c51b6');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should update the retain location checkbox', () => {
|
|
75
|
+
render(<AddProviderQueueRoom providerUuid={providerUuid} closeModal={jest.fn()} />);
|
|
76
|
+
|
|
77
|
+
const retainLocationCheckbox: HTMLInputElement = screen.getByRole('checkbox');
|
|
78
|
+
fireEvent.click(retainLocationCheckbox);
|
|
79
|
+
|
|
80
|
+
expect(retainLocationCheckbox.checked).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should submit the form and add provider to queue room when all fields are filled', async () => {
|
|
84
|
+
const mockCloseModal = jest.fn();
|
|
85
|
+
render(<AddProviderQueueRoom providerUuid={providerUuid} closeModal={mockCloseModal} />);
|
|
86
|
+
|
|
87
|
+
const queueRoomSelect = screen.getByRole('combobox');
|
|
88
|
+
const submitButton = screen.getByText('Save');
|
|
89
|
+
|
|
90
|
+
fireEvent.change(queueRoomSelect, { target: { value: '6b3e233d-2b44-40ca-b0c8-c5a57a8c51b6' } });
|
|
91
|
+
fireEvent.click(submitButton);
|
|
92
|
+
|
|
93
|
+
await waitFor(() => {
|
|
94
|
+
expect(mockCloseModal).toHaveBeenCalled();
|
|
95
|
+
expect(showToast).toHaveBeenCalled();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|