@kenyaemr/esm-service-queues-app 8.1.1-pre.129 → 8.1.2-pre.152
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 +26 -26
- package/dist/1006.js +1 -0
- package/dist/1006.js.map +1 -0
- package/dist/1060.js +1 -0
- package/dist/1060.js.map +1 -0
- package/dist/130.js +1 -1
- package/dist/130.js.map +1 -1
- package/dist/1325.js +1 -0
- package/dist/1325.js.map +1 -0
- package/dist/1644.js +1 -0
- package/dist/1727.js +1 -0
- package/dist/1727.js.map +1 -0
- package/dist/1800.js +1 -0
- package/dist/1800.js.map +1 -0
- package/dist/236.js +1 -1
- package/dist/2757.js +1 -0
- package/dist/{282.js → 2760.js} +1 -1
- package/dist/2760.js.map +1 -0
- package/dist/2784.js +2 -0
- package/dist/2784.js.map +1 -0
- package/dist/3199.js +1 -0
- package/dist/3199.js.map +1 -0
- package/dist/3372.js +2 -0
- package/dist/3372.js.map +1 -0
- package/dist/3574.js +1 -0
- package/dist/3604.js +1 -0
- package/dist/3604.js.map +1 -0
- package/dist/3652.js +1 -0
- package/dist/3760.js +1 -0
- package/dist/3760.js.map +1 -0
- package/dist/3818.js +1 -0
- package/dist/3818.js.map +1 -0
- package/dist/3828.js +1 -0
- package/dist/3828.js.map +1 -0
- package/dist/4272.js +1 -0
- package/dist/4378.js +1 -0
- package/dist/443.js +1 -0
- package/dist/443.js.map +1 -0
- package/dist/4460.js +1 -0
- package/dist/4705.js +1 -0
- package/dist/4911.js +1 -0
- package/dist/4911.js.map +1 -0
- package/dist/5236.js +1 -0
- package/dist/5236.js.map +1 -0
- package/dist/5240.js +1 -0
- package/dist/5282.js +1 -0
- package/dist/5282.js.map +1 -0
- package/dist/5336.js +1 -0
- package/dist/539.js +1 -0
- package/dist/5673.js +1 -0
- package/dist/5711.js +1 -0
- package/dist/5737.js +1 -0
- package/dist/5833.js +1 -0
- package/dist/6566.js +1 -0
- package/dist/6578.js +2 -0
- package/dist/{660.js.LICENSE.txt → 6578.js.LICENSE.txt} +5 -0
- package/dist/6578.js.map +1 -0
- package/dist/6591.js +2 -0
- package/dist/6591.js.map +1 -0
- package/dist/6670.js +1 -0
- package/dist/6670.js.map +1 -0
- package/dist/6727.js +1 -0
- package/dist/744.js +1 -0
- package/dist/752.js +1 -1
- package/dist/752.js.map +1 -1
- package/dist/7807.js +1 -0
- package/dist/8271.js +1 -0
- package/dist/8319.js +1 -0
- package/dist/8788.js +1 -0
- package/dist/899.js +1 -0
- package/dist/9261.js +1 -0
- package/dist/9392.js +1 -0
- package/dist/9392.js.map +1 -0
- package/dist/9993.js +1 -0
- package/dist/9993.js.map +1 -0
- package/dist/kenyaemr-esm-service-queues-app.js +1 -1
- package/dist/kenyaemr-esm-service-queues-app.js.buildmanifest.json +541 -234
- package/dist/kenyaemr-esm-service-queues-app.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.LICENSE.txt +5 -0
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package-lock.json +2 -2
- package/package.json +8 -5
- package/src/active-visits/active-visits-table.resource.ts +0 -62
- package/src/active-visits/change-status-dialog.component.tsx +10 -3
- package/src/active-visits/change-status-dialog.scss +29 -1
- package/src/active-visits/change-status-dialog.test.tsx +11 -3
- package/src/add-provider-queue-room/add-provider-queue-room.component.tsx +53 -54
- package/src/add-provider-queue-room/add-provider-queue-room.scss +28 -0
- package/src/add-provider-queue-room/add-provider-queue-room.test.tsx +1 -1
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +1 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +29 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +4 -1
- package/src/config-schema.ts +28 -8
- package/src/create-queue-entry/create-queue-entry.workspace.tsx +99 -0
- package/src/create-queue-entry/existing-visit-form/existing-visit-form.component.tsx +73 -0
- package/src/{patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx → create-queue-entry/queue-fields/queue-fields.component.tsx} +76 -50
- package/src/create-queue-entry/queue-fields/queue-fields.resource.ts +63 -0
- package/src/{patient-search/visit-form-queue-fields/visit-form-queue-fields.scss → create-queue-entry/queue-fields/queue-fields.scss} +0 -4
- package/src/{patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx → create-queue-entry/queue-fields/queue-fields.test.tsx} +37 -17
- package/src/create-queue-entry/queue-fields/visit-form-queue-fields.extension.tsx +31 -0
- package/src/hooks/useQueueEntries.ts +13 -12
- package/src/index.ts +8 -14
- package/src/patient-info/patient-info.component.tsx +10 -8
- package/src/patient-queue-header/patient-queue-header.component.tsx +18 -13
- package/src/patient-queue-metrics/metrics-header.component.tsx +4 -4
- package/src/queue-entry-table-components/queue-priority.component.tsx +16 -11
- package/src/queue-entry-table-components/queue-priority.scss +5 -0
- package/src/queue-entry-table-components/transition-entry.component.tsx +1 -1
- package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +1 -1
- package/src/queue-patient-linelists/queue-linelist-filter.workspace.tsx +13 -12
- package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +1 -1
- package/src/queue-rooms/queue-room-form.test.tsx +2 -2
- package/src/queue-rooms/queue-room-form.workspace.tsx +1 -1
- package/src/queue-screen/queue-screen.test.tsx +11 -4
- package/src/queue-services/queue-service-form.test.tsx +76 -16
- package/src/queue-services/queue-service-form.workspace.tsx +131 -131
- package/src/queue-services/queue-service.resource.ts +7 -2
- package/src/queue-table/cells/columns.resource.ts +10 -7
- package/src/queue-table/cells/queue-table-visit-attribute-queue-number-cell.component.tsx +1 -0
- package/src/queue-table/default-queue-table.component.tsx +12 -13
- package/src/queue-table/default-queue-table.test.tsx +3 -3
- package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.scss +28 -0
- package/src/queue-table/queue-entry-actions/queue-entry-actions.modal.tsx +8 -2
- package/src/queue-table/queue-entry-actions/queue-entry-confirm-action.modal.tsx +2 -1
- package/src/queue-table/queue-entry-actions/queue-entry-confirm-action.scss +29 -0
- package/src/queue-table/queue-table.component.tsx +1 -1
- package/src/queue-table/queue-table.scss +12 -2
- package/src/queue-table/queue-table.test.tsx +10 -1
- package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +16 -4
- package/src/remove-queue-entry-dialog/remove-queue-entry.scss +29 -0
- package/src/routes.json +4 -8
- package/src/transition-latest-queue-entry/transition-latest-queue-entry.resource.ts +2 -10
- package/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +41 -32
- package/src/transition-queue-entry/transition-queue-entry-dialog.scss +28 -0
- package/src/types/index.ts +0 -8
- package/src/views/queue-tables-for-all-statuses.component.tsx +12 -15
- package/translations/am.json +5 -78
- package/translations/ar.json +5 -78
- package/translations/de.json +235 -0
- package/translations/en.json +9 -86
- package/translations/es.json +3 -76
- package/translations/fr.json +5 -78
- package/translations/he.json +5 -78
- package/translations/hi.json +235 -0
- package/translations/hi_IN.json +235 -0
- package/translations/id.json +235 -0
- package/translations/it.json +235 -0
- package/translations/km.json +5 -78
- package/translations/ne.json +235 -0
- package/translations/pt.json +235 -0
- package/translations/pt_BR.json +235 -0
- package/translations/qu.json +235 -0
- package/translations/si.json +235 -0
- package/translations/sw.json +235 -0
- package/translations/sw_KE.json +235 -0
- package/translations/tr.json +235 -0
- package/translations/tr_TR.json +235 -0
- package/translations/uk.json +235 -0
- package/translations/vi.json +235 -0
- package/translations/zh.json +6 -79
- package/translations/zh_CN.json +5 -78
- package/dist/169.js +0 -1
- package/dist/169.js.map +0 -1
- package/dist/199.js +0 -1
- package/dist/199.js.map +0 -1
- package/dist/236.js.map +0 -1
- package/dist/271.js +0 -1
- package/dist/282.js.map +0 -1
- package/dist/319.js +0 -1
- package/dist/325.js +0 -1
- package/dist/325.js.map +0 -1
- package/dist/366.js +0 -1
- package/dist/366.js.map +0 -1
- package/dist/372.js +0 -2
- package/dist/372.js.map +0 -1
- package/dist/392.js +0 -1
- package/dist/392.js.map +0 -1
- package/dist/460.js +0 -1
- package/dist/501.js +0 -1
- package/dist/501.js.map +0 -1
- package/dist/574.js +0 -1
- package/dist/591.js +0 -2
- package/dist/591.js.map +0 -1
- package/dist/6.js +0 -1
- package/dist/6.js.map +0 -1
- package/dist/60.js +0 -1
- package/dist/60.js.map +0 -1
- package/dist/604.js +0 -1
- package/dist/604.js.map +0 -1
- package/dist/644.js +0 -1
- package/dist/660.js +0 -2
- package/dist/660.js.map +0 -1
- package/dist/670.js +0 -1
- package/dist/670.js.map +0 -1
- package/dist/727.js +0 -1
- package/dist/727.js.map +0 -1
- package/dist/748.js +0 -1
- package/dist/748.js.map +0 -1
- package/dist/757.js +0 -1
- package/dist/760.js +0 -1
- package/dist/760.js.map +0 -1
- package/dist/784.js +0 -2
- package/dist/784.js.map +0 -1
- package/dist/788.js +0 -1
- package/dist/800.js +0 -1
- package/dist/800.js.map +0 -1
- package/dist/807.js +0 -1
- package/dist/818.js +0 -1
- package/dist/818.js.map +0 -1
- package/dist/828.js +0 -1
- package/dist/828.js.map +0 -1
- package/dist/833.js +0 -1
- package/dist/911.js +0 -1
- package/dist/911.js.map +0 -1
- package/dist/940.js +0 -1
- package/dist/940.js.map +0 -1
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +0 -228
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.scss +0 -32
- package/src/patient-search/advanced-search.component.tsx +0 -191
- package/src/patient-search/advanced-search.scss +0 -154
- package/src/patient-search/advanced-search.test.tsx +0 -26
- package/src/patient-search/basic-search.component.tsx +0 -112
- package/src/patient-search/basic-search.scss +0 -139
- package/src/patient-search/basic-search.test.tsx +0 -18
- package/src/patient-search/empty-data-illustration.component.tsx +0 -41
- package/src/patient-search/hooks/useActivePatientEnrollment.tsx +0 -29
- package/src/patient-search/hooks/useDefaultLocation.ts +0 -14
- package/src/patient-search/hooks/usePatients.tsx +0 -25
- package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +0 -35
- package/src/patient-search/hooks/useScheduledVisits.ts +0 -52
- package/src/patient-search/patient-scheduled-visits.component.tsx +0 -315
- package/src/patient-search/patient-scheduled-visits.scss +0 -131
- package/src/patient-search/patient-scheduled-visits.test.tsx +0 -39
- package/src/patient-search/patient-search.workspace.tsx +0 -135
- package/src/patient-search/search-illustration.component.tsx +0 -27
- package/src/patient-search/search-results.component.tsx +0 -75
- package/src/patient-search/search-results.scss +0 -80
- package/src/patient-search/search-results.test.tsx +0 -69
- package/src/patient-search/search.resource.ts +0 -10
- package/src/patient-search/visit-form/existing-visit-form.component.tsx +0 -112
- package/src/patient-search/visit-form/queue.resource.ts +0 -64
- package/src/patient-search/visit-form/visit-form.component.tsx +0 -337
- package/src/patient-search/visit-form/visit-type-selector.component.tsx +0 -153
- package/src/patient-search/visit-form/visit-type-selector.scss +0 -100
- package/src/patient-search/visit-form/visit-type-selector.test.tsx +0 -84
- package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +0 -277
- package/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +0 -93
- package/src/visits-missing-inqueue/visits-missing-inqueue.scss +0 -111
- /package/dist/{784.js.LICENSE.txt → 2784.js.LICENSE.txt} +0 -0
- /package/dist/{372.js.LICENSE.txt → 3372.js.LICENSE.txt} +0 -0
- /package/dist/{591.js.LICENSE.txt → 6591.js.LICENSE.txt} +0 -0
- /package/src/{patient-search/patient-search.scss → create-queue-entry/create-queue-entry.scss} +0 -0
- /package/src/{patient-search/visit-form/visit-form.scss → create-queue-entry/existing-visit-form/existing-visit-form.scss} +0 -0
- /package/src/{patient-search → create-queue-entry}/hooks/useQueueLocations.tsx +0 -0
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect } from 'react';
|
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { Dropdown } from '@carbon/react';
|
|
4
4
|
import { useConfig, useSession, PageHeader, PageHeaderContent, ServiceQueuesPictogram } from '@openmrs/esm-framework';
|
|
5
|
-
import { useQueueLocations } from '../
|
|
5
|
+
import { useQueueLocations } from '../create-queue-entry/hooks/useQueueLocations';
|
|
6
6
|
import {
|
|
7
7
|
updateSelectedQueueLocationUuid,
|
|
8
8
|
updateSelectedQueueLocationName,
|
|
@@ -27,16 +27,19 @@ const PatientQueueHeader: React.FC<PatientQueueHeaderProps> = ({ title, showLoca
|
|
|
27
27
|
const currentQueueLocationName = useSelectedQueueLocationName();
|
|
28
28
|
const currentQueueLocationUuid = useSelectedQueueLocationUuid();
|
|
29
29
|
|
|
30
|
-
const handleQueueLocationChange = useCallback(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
const handleQueueLocationChange = useCallback(
|
|
31
|
+
({ selectedItem }) => {
|
|
32
|
+
if (selectedItem.id === 'all') {
|
|
33
|
+
updateSelectedQueueLocationUuid(null);
|
|
34
|
+
updateSelectedQueueLocationName(null);
|
|
35
|
+
} else {
|
|
36
|
+
updateSelectedQueueLocationUuid(selectedItem.id);
|
|
37
|
+
updateSelectedQueueLocationName(selectedItem.name);
|
|
38
|
+
updateSelectedService(null, t('all', 'All'));
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[t],
|
|
42
|
+
);
|
|
40
43
|
|
|
41
44
|
useEffect(() => {
|
|
42
45
|
if (!isLoading && !error && !currentQueueLocationUuid) {
|
|
@@ -56,11 +59,13 @@ const PatientQueueHeader: React.FC<PatientQueueHeaderProps> = ({ title, showLoca
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}, [
|
|
59
|
-
queueLocations,
|
|
60
62
|
currentQueueLocationName,
|
|
61
63
|
currentQueueLocationUuid,
|
|
62
|
-
isLoading,
|
|
63
64
|
error,
|
|
65
|
+
handleQueueLocationChange,
|
|
66
|
+
isLoading,
|
|
67
|
+
queueLocations,
|
|
68
|
+
userSession?.sessionLocation?.display,
|
|
64
69
|
userSession?.sessionLocation?.uuid,
|
|
65
70
|
]);
|
|
66
71
|
|
|
@@ -37,12 +37,12 @@ const MetricsHeader = () => {
|
|
|
37
37
|
<div className={styles.metricsContainer}>
|
|
38
38
|
<span className={styles.metricsTitle}>{metricsTitle}</span>
|
|
39
39
|
<ComboButton
|
|
40
|
+
className={styles.comboBtn}
|
|
40
41
|
label={queueScreenText}
|
|
41
|
-
size={isDesktop(layout) ? 'sm' : 'lg'}
|
|
42
42
|
menuAlignment="bottom-end"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
onClick={navigateToQueueScreen}
|
|
44
|
+
size={isDesktop(layout) ? 'sm' : 'lg'}
|
|
45
|
+
tooltipAlignment="left">
|
|
46
46
|
<UserHasAccess privilege="Emr: View Legacy Interface">
|
|
47
47
|
<MenuItem
|
|
48
48
|
label={t('addNewService', 'Add new service')}
|
|
@@ -13,23 +13,28 @@ interface QueuePriorityProps {
|
|
|
13
13
|
|
|
14
14
|
const QueuePriority: React.FC<QueuePriorityProps> = ({ priority, priorityComment, priorityConfigs }) => {
|
|
15
15
|
const priorityConfig = priorityConfigs.find((c) => c.conceptUuid === priority.uuid);
|
|
16
|
+
|
|
17
|
+
const tag = (
|
|
18
|
+
<Tag
|
|
19
|
+
role={priorityComment ? 'tooltip' : null}
|
|
20
|
+
className={classNames(
|
|
21
|
+
styles.tag,
|
|
22
|
+
priorityConfig?.style === 'bold' && styles.bold,
|
|
23
|
+
priorityConfig?.color === 'orange' && styles.orange,
|
|
24
|
+
)}
|
|
25
|
+
type={priorityConfig?.color !== 'orange' ? priorityConfig?.color : null}>
|
|
26
|
+
{priority.display}
|
|
27
|
+
</Tag>
|
|
28
|
+
);
|
|
29
|
+
|
|
16
30
|
return (
|
|
17
31
|
<>
|
|
18
32
|
{priorityComment ? (
|
|
19
33
|
<DefinitionTooltip className={styles.tooltip} align="bottom-left" definition={priorityComment}>
|
|
20
|
-
|
|
21
|
-
role="tooltip"
|
|
22
|
-
className={classNames(styles.tag, priorityConfig?.style === 'bold' && styles.bold)}
|
|
23
|
-
type={priorityConfig?.color}>
|
|
24
|
-
{priority.display}
|
|
25
|
-
</Tag>
|
|
34
|
+
{tag}
|
|
26
35
|
</DefinitionTooltip>
|
|
27
36
|
) : (
|
|
28
|
-
|
|
29
|
-
className={classNames(styles.tag, priorityConfig?.style === 'bold' && styles.bold)}
|
|
30
|
-
type={priorityConfig?.color}>
|
|
31
|
-
{priority.display}
|
|
32
|
-
</Tag>
|
|
37
|
+
tag
|
|
33
38
|
)}
|
|
34
39
|
</>
|
|
35
40
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@use '@carbon/layout';
|
|
2
2
|
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
3
|
+
@use '@carbon/colors';
|
|
3
4
|
|
|
4
5
|
.tag {
|
|
5
6
|
margin: layout.$spacing-02 0;
|
|
@@ -9,3 +10,7 @@
|
|
|
9
10
|
.bold {
|
|
10
11
|
font-weight: bold;
|
|
11
12
|
}
|
|
13
|
+
|
|
14
|
+
.orange {
|
|
15
|
+
background-color: colors.$orange-20;
|
|
16
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import {
|
|
4
|
+
Button,
|
|
5
|
+
ButtonSet,
|
|
6
|
+
Column,
|
|
4
7
|
DatePicker,
|
|
5
8
|
DatePickerInput,
|
|
9
|
+
Dropdown,
|
|
6
10
|
Form,
|
|
7
11
|
Layer,
|
|
8
|
-
Stack,
|
|
9
|
-
RadioButtonGroup,
|
|
10
|
-
RadioButton,
|
|
11
|
-
Dropdown,
|
|
12
|
-
Column,
|
|
13
|
-
Button,
|
|
14
|
-
ButtonSet,
|
|
15
12
|
NumberInput,
|
|
13
|
+
RadioButton,
|
|
14
|
+
RadioButtonGroup,
|
|
15
|
+
Stack,
|
|
16
16
|
Toggle,
|
|
17
17
|
} from '@carbon/react';
|
|
18
18
|
import dayjs from 'dayjs';
|
|
@@ -23,18 +23,19 @@ import {
|
|
|
23
23
|
useLayoutType,
|
|
24
24
|
useVisitTypes,
|
|
25
25
|
} from '@openmrs/esm-framework';
|
|
26
|
-
import styles from './queue-linelist-filter.scss';
|
|
27
26
|
import { datePickerFormat, datePickerPlaceHolder } from '../constants';
|
|
27
|
+
import styles from './queue-linelist-filter.scss';
|
|
28
28
|
|
|
29
29
|
const QueueLinelistFilter: React.FC<DefaultWorkspaceProps> = ({ closeWorkspace }) => {
|
|
30
30
|
const { t } = useTranslation();
|
|
31
|
+
const allVisitTypes = useVisitTypes();
|
|
32
|
+
const isTablet = useLayoutType() === 'tablet';
|
|
33
|
+
|
|
34
|
+
const [endAge, setEndAge] = useState();
|
|
31
35
|
const [gender, setGender] = useState('');
|
|
32
|
-
const [startAge, setStartAge] = useState<number>();
|
|
33
|
-
const [endAge, setEndAge] = useState<number>();
|
|
34
36
|
const [returnDate, setReturnDate] = useState(new Date());
|
|
37
|
+
const [startAge, setStartAge] = useState();
|
|
35
38
|
const [visitType, setVisitType] = useState('');
|
|
36
|
-
const isTablet = useLayoutType() === 'tablet';
|
|
37
|
-
const allVisitTypes = useVisitTypes();
|
|
38
39
|
|
|
39
40
|
const handleFilter = useCallback(
|
|
40
41
|
(event) => {
|
|
@@ -6,8 +6,8 @@ import QueueRoomForm from './queue-room-form.workspace';
|
|
|
6
6
|
|
|
7
7
|
const mockUseLayoutType = jest.mocked(useLayoutType);
|
|
8
8
|
|
|
9
|
-
jest.mock('../
|
|
10
|
-
...jest.requireActual('../
|
|
9
|
+
jest.mock('../create-queue-entry/hooks/useQueueLocations', () => ({
|
|
10
|
+
...jest.requireActual('../create-queue-entry/hooks/useQueueLocations'),
|
|
11
11
|
useQueueLocations: jest.fn(() => ({
|
|
12
12
|
queueLocations: { uuid: 'e7786d9a-ab62-11ec-b909-0242ac120002', display: 'Location Test' },
|
|
13
13
|
})),
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from '@carbon/react';
|
|
15
15
|
import { type DefaultWorkspaceProps, restBaseUrl, showSnackbar, useLayoutType } from '@openmrs/esm-framework';
|
|
16
16
|
import { mutate } from 'swr';
|
|
17
|
-
import { useQueueLocations } from '../
|
|
17
|
+
import { useQueueLocations } from '../create-queue-entry/hooks/useQueueLocations';
|
|
18
18
|
import { saveQueueRoom } from './queue-room.resource';
|
|
19
19
|
import styles from './queue-room-form.scss';
|
|
20
20
|
import { useQueues } from '../hooks/useQueues';
|
|
@@ -3,7 +3,12 @@ import { render, screen } from '@testing-library/react';
|
|
|
3
3
|
import { useActiveTickets } from './useActiveTickets';
|
|
4
4
|
import QueueScreen from './queue-screen.component';
|
|
5
5
|
|
|
6
|
-
jest.
|
|
6
|
+
const mockUseActiveTickets = jest.mocked(useActiveTickets);
|
|
7
|
+
|
|
8
|
+
jest.mock('./useActiveTickets', () => ({
|
|
9
|
+
useActiveTickets: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
7
12
|
jest.mock('../helpers/helpers', () => ({
|
|
8
13
|
useSelectedQueueLocationName: jest.fn().mockReturnValue('Room A'),
|
|
9
14
|
useSelectedQueueLocationUuid: jest.fn().mockReturnValue(''),
|
|
@@ -11,26 +16,26 @@ jest.mock('../helpers/helpers', () => ({
|
|
|
11
16
|
|
|
12
17
|
describe('QueueScreen component', () => {
|
|
13
18
|
test('renders loading skeleton when data is loading', () => {
|
|
14
|
-
const mockUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
|
|
15
19
|
mockUseActiveTickets.mockReturnValue({ isLoading: true, activeTickets: [], error: undefined, mutate: jest.fn() });
|
|
20
|
+
|
|
16
21
|
render(<QueueScreen />);
|
|
22
|
+
|
|
17
23
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
18
24
|
});
|
|
19
25
|
|
|
20
26
|
test('renders error message when there is an error fetching data', () => {
|
|
21
|
-
const mockUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
|
|
22
27
|
mockUseActiveTickets.mockReturnValue({
|
|
23
28
|
error: new Error('Error'),
|
|
24
29
|
isLoading: false,
|
|
25
30
|
activeTickets: [],
|
|
26
31
|
mutate: jest.fn(),
|
|
27
32
|
});
|
|
33
|
+
|
|
28
34
|
render(<QueueScreen />);
|
|
29
35
|
expect(screen.getByText(/Error State/i)).toBeInTheDocument();
|
|
30
36
|
});
|
|
31
37
|
|
|
32
38
|
test('renders table with active tickets when data is loaded', () => {
|
|
33
|
-
const mockUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
|
|
34
39
|
mockUseActiveTickets.mockReturnValue({
|
|
35
40
|
activeTickets: [
|
|
36
41
|
{
|
|
@@ -43,7 +48,9 @@ describe('QueueScreen component', () => {
|
|
|
43
48
|
error: undefined,
|
|
44
49
|
mutate: jest.fn(),
|
|
45
50
|
});
|
|
51
|
+
|
|
46
52
|
render(<QueueScreen />);
|
|
53
|
+
|
|
47
54
|
expect(screen.getByText('Room : Room A')).toBeInTheDocument();
|
|
48
55
|
expect(screen.getByText('Ticket number')).toBeInTheDocument();
|
|
49
56
|
expect(screen.getByText('123')).toBeInTheDocument();
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import { useLayoutType } from '@openmrs/esm-framework';
|
|
4
|
+
import { showSnackbar, useLayoutType } from '@openmrs/esm-framework';
|
|
5
|
+
import { saveQueue } from './queue-service.resource';
|
|
5
6
|
import QueueServiceForm from './queue-service-form.workspace';
|
|
6
7
|
|
|
7
8
|
const defaultProps = {
|
|
8
9
|
closeWorkspace: jest.fn(),
|
|
9
|
-
promptBeforeClosing: jest.fn(),
|
|
10
10
|
closeWorkspaceWithSavedChanges: jest.fn(),
|
|
11
|
+
promptBeforeClosing: jest.fn(),
|
|
11
12
|
setTitle: jest.fn(),
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const mockSaveQueue = jest.mocked(saveQueue);
|
|
16
|
+
const mockShowSnackbar = jest.mocked(showSnackbar);
|
|
14
17
|
const mockUseLayoutType = jest.mocked(useLayoutType);
|
|
15
18
|
|
|
16
19
|
jest.mock('./queue-service.resource', () => ({
|
|
@@ -23,7 +26,7 @@ jest.mock('./queue-service.resource', () => ({
|
|
|
23
26
|
saveQueue: jest.fn(() => Promise.resolve({ status: 201 })),
|
|
24
27
|
}));
|
|
25
28
|
|
|
26
|
-
jest.mock('../
|
|
29
|
+
jest.mock('../create-queue-entry/hooks/useQueueLocations', () => ({
|
|
27
30
|
useQueueLocations: () => ({
|
|
28
31
|
queueLocations: [
|
|
29
32
|
{ id: '34567eb0-b035-4acd-b284-da45f5067502', name: 'Location 1' },
|
|
@@ -37,31 +40,88 @@ describe('QueueServiceForm', () => {
|
|
|
37
40
|
mockUseLayoutType.mockReturnValue('tablet');
|
|
38
41
|
});
|
|
39
42
|
|
|
40
|
-
it('
|
|
43
|
+
it('renders validation errors when form is submitted with missing fields', async () => {
|
|
41
44
|
const user = userEvent.setup();
|
|
42
|
-
|
|
43
45
|
render(<QueueServiceForm {...defaultProps} />);
|
|
44
46
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const queueNameInput = screen.getByRole('textbox', { name: /queue name/i });
|
|
48
|
+
const serviceTypeSelect = screen.getByRole('combobox', { name: /select a service type/i });
|
|
49
|
+
const locationSelect = screen.getByRole('combobox', { name: /select a location/i });
|
|
50
|
+
const cancelButton = screen.getByRole('button', { name: /cancel/i });
|
|
51
|
+
const saveButton = screen.getByRole('button', { name: /save/i });
|
|
52
|
+
expect(cancelButton).toBeInTheDocument();
|
|
53
|
+
expect(saveButton).toBeInTheDocument();
|
|
54
|
+
expect(queueNameInput).toBeInTheDocument();
|
|
55
|
+
expect(queueNameInput).not.toBeInvalid();
|
|
56
|
+
expect(serviceTypeSelect).toBeInTheDocument();
|
|
57
|
+
expect(serviceTypeSelect).not.toBeInvalid();
|
|
58
|
+
|
|
59
|
+
await user.click(saveButton);
|
|
60
|
+
expect(queueNameInput).toBeInvalid();
|
|
61
|
+
|
|
62
|
+
await user.type(queueNameInput, 'Test Queue');
|
|
63
|
+
expect(queueNameInput).not.toBeInvalid();
|
|
64
|
+
expect(serviceTypeSelect).toBeInvalid();
|
|
65
|
+
|
|
66
|
+
await user.selectOptions(serviceTypeSelect, '6f017eb0-b035-4acd-b284-da45f5067502');
|
|
67
|
+
await user.selectOptions(locationSelect, '34567eb0-b035-4acd-b284-da45f5067502');
|
|
68
|
+
await user.click(saveButton);
|
|
69
|
+
|
|
70
|
+
expect(serviceTypeSelect).not.toBeInvalid();
|
|
71
|
+
expect(queueNameInput).not.toBeInvalid();
|
|
72
|
+
expect(locationSelect).not.toBeInvalid();
|
|
48
73
|
});
|
|
49
74
|
|
|
50
|
-
it('
|
|
75
|
+
it('submits the form when all required fields are filled', async () => {
|
|
51
76
|
const user = userEvent.setup();
|
|
77
|
+
render(<QueueServiceForm {...defaultProps} />);
|
|
78
|
+
|
|
79
|
+
const queueNameInput = screen.getByRole('textbox', { name: /queue name/i });
|
|
80
|
+
const serviceTypeSelect = screen.getByRole('combobox', { name: /select a service type/i });
|
|
81
|
+
const locationSelect = screen.getByRole('combobox', { name: /select a location/i });
|
|
82
|
+
const saveButton = screen.getByRole('button', { name: /save/i });
|
|
83
|
+
|
|
84
|
+
await user.type(queueNameInput, 'Test Queue');
|
|
85
|
+
await user.selectOptions(serviceTypeSelect, '6f017eb0-b035-4acd-b284-da45f5067502');
|
|
86
|
+
await user.selectOptions(locationSelect, '34567eb0-b035-4acd-b284-da45f5067502');
|
|
87
|
+
await user.click(saveButton);
|
|
88
|
+
|
|
89
|
+
expect(mockSaveQueue).toHaveBeenCalledTimes(1);
|
|
90
|
+
expect(mockSaveQueue).toHaveBeenCalledWith(
|
|
91
|
+
'Test Queue',
|
|
92
|
+
'6f017eb0-b035-4acd-b284-da45f5067502',
|
|
93
|
+
'',
|
|
94
|
+
'34567eb0-b035-4acd-b284-da45f5067502',
|
|
95
|
+
);
|
|
96
|
+
expect(mockShowSnackbar).toHaveBeenCalledTimes(1);
|
|
97
|
+
expect(mockShowSnackbar).toHaveBeenCalledWith({
|
|
98
|
+
kind: 'success',
|
|
99
|
+
title: expect.stringMatching(/queue service created/i),
|
|
100
|
+
subtitle: expect.stringMatching(/queue service created successfully/i),
|
|
101
|
+
});
|
|
102
|
+
});
|
|
52
103
|
|
|
104
|
+
it('renders an error message when the queue service creation fails', async () => {
|
|
105
|
+
const user = userEvent.setup();
|
|
106
|
+
mockSaveQueue.mockRejectedValueOnce(new Error('Internal server error'));
|
|
53
107
|
render(<QueueServiceForm {...defaultProps} />);
|
|
54
108
|
|
|
55
|
-
const queueNameInput = screen.
|
|
56
|
-
const
|
|
57
|
-
const locationSelect = screen.
|
|
109
|
+
const queueNameInput = screen.getByRole('textbox', { name: /queue name/i });
|
|
110
|
+
const serviceTypeSelect = screen.getByRole('combobox', { name: /select a service type/i });
|
|
111
|
+
const locationSelect = screen.getByRole('combobox', { name: /select a location/i });
|
|
112
|
+
const saveButton = screen.getByRole('button', { name: /save/i });
|
|
58
113
|
|
|
59
114
|
await user.type(queueNameInput, 'Test Queue');
|
|
60
|
-
await user.selectOptions(
|
|
115
|
+
await user.selectOptions(serviceTypeSelect, '6f017eb0-b035-4acd-b284-da45f5067502');
|
|
61
116
|
await user.selectOptions(locationSelect, '34567eb0-b035-4acd-b284-da45f5067502');
|
|
117
|
+
await user.click(saveButton);
|
|
62
118
|
|
|
63
|
-
expect(
|
|
64
|
-
expect(
|
|
65
|
-
|
|
119
|
+
expect(mockShowSnackbar).toHaveBeenCalledTimes(1);
|
|
120
|
+
expect(mockShowSnackbar).toHaveBeenCalledWith({
|
|
121
|
+
isLowContrast: false,
|
|
122
|
+
kind: 'error',
|
|
123
|
+
title: expect.stringMatching(/error creating queue service/i),
|
|
124
|
+
subtitle: expect.stringMatching(/internal server error/i),
|
|
125
|
+
});
|
|
66
126
|
});
|
|
67
127
|
});
|