@kenyaemr/esm-service-queues-app 7.0.2-pre.65
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/README.md +20 -0
- package/dist/130.js +2 -0
- package/dist/130.js.LICENSE.txt +3 -0
- package/dist/130.js.map +1 -0
- package/dist/152.js +1 -0
- package/dist/152.js.map +1 -0
- package/dist/169.js +1 -0
- package/dist/169.js.map +1 -0
- package/dist/185.js +1 -0
- package/dist/185.js.map +1 -0
- package/dist/233.js +1 -0
- package/dist/233.js.map +1 -0
- package/dist/237.js +1 -0
- package/dist/237.js.map +1 -0
- package/dist/255.js +2 -0
- package/dist/255.js.LICENSE.txt +9 -0
- package/dist/255.js.map +1 -0
- package/dist/271.js +1 -0
- package/dist/276.js +1 -0
- package/dist/276.js.map +1 -0
- package/dist/303.js +1 -0
- package/dist/303.js.map +1 -0
- package/dist/319.js +1 -0
- package/dist/401.js +1 -0
- package/dist/401.js.map +1 -0
- package/dist/430.js +2 -0
- package/dist/430.js.LICENSE.txt +50 -0
- package/dist/430.js.map +1 -0
- package/dist/460.js +1 -0
- package/dist/501.js +1 -0
- package/dist/501.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/644.js +1 -0
- package/dist/647.js +1 -0
- package/dist/647.js.map +1 -0
- package/dist/650.js +1 -0
- package/dist/650.js.map +1 -0
- package/dist/669.js +1 -0
- package/dist/669.js.map +1 -0
- package/dist/696.js +1 -0
- package/dist/696.js.map +1 -0
- package/dist/703.js +1 -0
- package/dist/703.js.map +1 -0
- package/dist/729.js +1 -0
- package/dist/729.js.map +1 -0
- package/dist/738.js +1 -0
- package/dist/738.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/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/806.js +1 -0
- package/dist/806.js.map +1 -0
- package/dist/807.js +1 -0
- package/dist/833.js +1 -0
- package/dist/877.js +1 -0
- package/dist/877.js.map +1 -0
- package/dist/917.js +1 -0
- package/dist/917.js.map +1 -0
- package/dist/940.js +1 -0
- package/dist/940.js.map +1 -0
- package/dist/981.js +1 -0
- package/dist/981.js.map +1 -0
- package/dist/kenyaemr-esm-service-queues-app.js +1 -0
- package/dist/kenyaemr-esm-service-queues-app.js.buildmanifest.json +965 -0
- package/dist/kenyaemr-esm-service-queues-app.js.map +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +60 -0
- package/dist/main.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.js +3 -0
- package/package.json +54 -0
- package/src/active-visits/active-visits-row-actions.component.tsx +25 -0
- package/src/active-visits/active-visits-row-actions.scss +4 -0
- package/src/active-visits/active-visits-table.resource.ts +273 -0
- package/src/active-visits/change-status-dialog.component.tsx +272 -0
- package/src/active-visits/change-status-dialog.scss +47 -0
- package/src/active-visits/change-status-dialog.test.tsx +154 -0
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +228 -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 +238 -0
- package/src/add-provider-queue-room/add-provider-queue-room.resource.ts +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 +105 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +76 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.ts +7 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +8 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +43 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries.component.tsx +43 -0
- package/src/config-schema.ts +465 -0
- package/src/constants.ts +10 -0
- package/src/createDashboardLink.component.tsx +39 -0
- package/src/current-visit/current-visit-summary.component.tsx +38 -0
- package/src/current-visit/current-visit-summary.test.tsx +43 -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 +165 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +4 -0
- package/src/helpers/functions.ts +28 -0
- package/src/helpers/helpers.ts +177 -0
- package/src/helpers/time-helpers.ts +15 -0
- package/src/home.component.tsx +16 -0
- package/src/home.test.tsx +48 -0
- package/src/hooks/useConcept.ts +13 -0
- package/src/hooks/useQueue.ts +10 -0
- package/src/hooks/useQueueEntries.ts +187 -0
- package/src/hooks/useQueues.ts +22 -0
- package/src/hooks/useSystemSetting.ts +18 -0
- package/src/index.ts +172 -0
- package/src/past-visit/past-visit-details/encounter-list.component.tsx +54 -0
- package/src/past-visit/past-visit-details/medications-list.component.tsx +98 -0
- package/src/past-visit/past-visit-details/notes-list.component.tsx +41 -0
- package/src/past-visit/past-visit-details/past-visit-summary.component.tsx +181 -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.ts +43 -0
- package/src/patient-info/hooks/usePatientAttributes.tsx +42 -0
- package/src/patient-info/patient-info.component.tsx +82 -0
- package/src/patient-info/patient-info.scss +60 -0
- package/src/patient-info/patient-info.test.tsx +43 -0
- package/src/patient-queue-header/patient-queue-header.component.tsx +99 -0
- package/src/patient-queue-header/patient-queue-header.scss +90 -0
- package/src/patient-queue-header/patient-queue-illustration.component.tsx +22 -0
- package/src/patient-queue-metrics/clinic-metrics.component.tsx +98 -0
- package/src/patient-queue-metrics/clinic-metrics.resource.ts +58 -0
- package/src/patient-queue-metrics/clinic-metrics.scss +11 -0
- package/src/patient-queue-metrics/clinic-metrics.test.tsx +76 -0
- package/src/patient-queue-metrics/metrics-card.component.tsx +68 -0
- package/src/patient-queue-metrics/metrics-card.scss +80 -0
- package/src/patient-queue-metrics/metrics-header.component.tsx +61 -0
- package/src/patient-queue-metrics/metrics-header.scss +26 -0
- package/src/patient-queue-metrics/queue-metrics.resource.ts +42 -0
- package/src/patient-search/advanced-search.component.tsx +191 -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.ts +14 -0
- package/src/patient-search/hooks/usePatients.tsx +25 -0
- package/src/patient-search/hooks/useQueueLocations.tsx +23 -0
- package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +35 -0
- package/src/patient-search/hooks/useScheduledVisits.ts +52 -0
- package/src/patient-search/patient-scheduled-visits.component.tsx +324 -0
- package/src/patient-search/patient-scheduled-visits.scss +131 -0
- package/src/patient-search/patient-scheduled-visits.test.tsx +44 -0
- package/src/patient-search/patient-search.scss +43 -0
- package/src/patient-search/patient-search.workspace.tsx +135 -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/existing-visit-form.component.tsx +112 -0
- package/src/patient-search/visit-form/queue.resource.ts +64 -0
- package/src/patient-search/visit-form/visit-form.component.tsx +344 -0
- package/src/patient-search/visit-form/visit-form.scss +73 -0
- package/src/patient-search/visit-form/visit-type-selector.component.tsx +155 -0
- package/src/patient-search/visit-form/visit-type-selector.scss +100 -0
- package/src/patient-search/visit-form/visit-type-selector.test.tsx +83 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx +178 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.scss +19 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx +63 -0
- package/src/queue-entry-table-components/edit-entry.scss +14 -0
- package/src/queue-entry-table-components/queue-duration.component.tsx +41 -0
- package/src/queue-entry-table-components/queue-priority.component.tsx +38 -0
- package/src/queue-entry-table-components/queue-priority.scss +12 -0
- package/src/queue-entry-table-components/queue-status.component.tsx +39 -0
- package/src/queue-entry-table-components/transition-entry.component.tsx +55 -0
- package/src/queue-entry-table-components/transition-entry.scss +22 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +241 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.scss +110 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.test.tsx +93 -0
- package/src/queue-patient-linelists/queue-linelist-filter.scss +63 -0
- package/src/queue-patient-linelists/queue-linelist-filter.test.tsx +94 -0
- package/src/queue-patient-linelists/queue-linelist-filter.workspace.tsx +185 -0
- package/src/queue-patient-linelists/queue-linelist.resource.ts +84 -0
- package/src/queue-patient-linelists/queue-services-table.component.tsx +63 -0
- package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +305 -0
- package/src/queue-patient-linelists/scheduled-appointments-table.test.tsx +41 -0
- package/src/queue-rooms/queue-room-form.scss +56 -0
- package/src/queue-rooms/queue-room-form.test.tsx +80 -0
- package/src/queue-rooms/queue-room-form.workspace.tsx +169 -0
- package/src/queue-rooms/queue-room.resource.ts +20 -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 +51 -0
- package/src/queue-screen/useActiveTickets.tsx +13 -0
- package/src/queue-services/queue-service-form.scss +61 -0
- package/src/queue-services/queue-service-form.test.tsx +60 -0
- package/src/queue-services/queue-service-form.workspace.tsx +179 -0
- package/src/queue-services/queue-service.resource.ts +33 -0
- package/src/queue-table/cells/columns.resource.ts +135 -0
- package/src/queue-table/cells/queue-table-action-cell.component.tsx +88 -0
- package/src/queue-table/cells/queue-table-action-cell.scss +7 -0
- package/src/queue-table/cells/queue-table-coming-from-cell.component.tsx +13 -0
- package/src/queue-table/cells/queue-table-extension-cell.component.tsx +16 -0
- package/src/queue-table/cells/queue-table-name-cell.component.tsx +20 -0
- package/src/queue-table/cells/queue-table-patient-age-cell.component.tsx +18 -0
- package/src/queue-table/cells/queue-table-patient-identifier-cell.component.tsx +25 -0
- package/src/queue-table/cells/queue-table-priority-cell.component.tsx +23 -0
- package/src/queue-table/cells/queue-table-queue-name-cell.component.tsx +14 -0
- package/src/queue-table/cells/queue-table-status-cell.component.tsx +18 -0
- package/src/queue-table/cells/queue-table-visit-attribute-queue-number-cell.component.tsx +37 -0
- package/src/queue-table/cells/queue-table-visit-start-time-cell.component.tsx +20 -0
- package/src/queue-table/cells/queue-table-wait-time-cell.component.tsx +17 -0
- package/src/queue-table/default-queue-table.component.tsx +174 -0
- package/src/queue-table/default-queue-table.test.tsx +131 -0
- package/src/queue-table/queue-entry-actions/edit-queue-entry-modal.component.tsx +52 -0
- package/src/queue-table/queue-entry-actions/end-queue-entry-modal.component.tsx +39 -0
- package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.component.tsx +362 -0
- package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.test.tsx +152 -0
- package/src/queue-table/queue-entry-actions/queue-entry-actions.resource.ts +83 -0
- package/src/queue-table/queue-entry-actions/queue-entry-actons-modal.scss +36 -0
- package/src/queue-table/queue-entry-actions/queue-entry-confirm-action-modal.component.tsx +97 -0
- package/src/queue-table/queue-entry-actions/queue-entry-confirm-action-modal.test.tsx +106 -0
- package/src/queue-table/queue-entry-actions/queue-entry-undo-actions-modal.test.tsx +76 -0
- package/src/queue-table/queue-entry-actions/transition-queue-entry-modal.component.tsx +51 -0
- package/src/queue-table/queue-entry-actions/undo-transition-queue-entry-modal.component.tsx +58 -0
- package/src/queue-table/queue-entry-actions/void-queue-entry-modal.component.tsx +34 -0
- package/src/queue-table/queue-table-by-status-menu.component.tsx +42 -0
- package/src/queue-table/queue-table-by-status-menu.scss +11 -0
- package/src/queue-table/queue-table-by-status-skeleton.component.tsx +32 -0
- package/src/queue-table/queue-table-by-status.component.tsx +96 -0
- package/src/queue-table/queue-table-expanded-row.component.tsx +29 -0
- package/src/queue-table/queue-table-metrics-card.component.tsx +50 -0
- package/src/queue-table/queue-table-metrics-card.scss +48 -0
- package/src/queue-table/queue-table-metrics.component.tsx +30 -0
- package/src/queue-table/queue-table-metrics.scss +11 -0
- package/src/queue-table/queue-table.component.tsx +179 -0
- package/src/queue-table/queue-table.scss +192 -0
- package/src/queue-table/queue-table.test.tsx +210 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +87 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.resource.ts +93 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.scss +7 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.test.tsx +45 -0
- package/src/root.component.tsx +28 -0
- package/src/root.scss +15 -0
- package/src/root.test.tsx +24 -0
- package/src/routes.json +133 -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 +134 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.scss +12 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.test.tsx +102 -0
- package/src/transition-queue-entry/transition-queue-entry.resource.ts +16 -0
- package/src/types/index.ts +494 -0
- package/src/views/queue-table-by-status-view.component.tsx +25 -0
- package/src/views/queue-tables-for-all-statuses.component.tsx +150 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +277 -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 +295 -0
- package/translations/ar.json +295 -0
- package/translations/en.json +305 -0
- package/translations/es.json +295 -0
- package/translations/fr.json +295 -0
- package/translations/he.json +295 -0
- package/translations/km.json +295 -0
- package/translations/zh.json +295 -0
- package/translations/zh_CN.json +295 -0
- package/tsconfig.json +5 -0
- package/webpack.config.js +1 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
DatePicker,
|
|
5
|
+
DatePickerInput,
|
|
6
|
+
Form,
|
|
7
|
+
Layer,
|
|
8
|
+
Stack,
|
|
9
|
+
RadioButtonGroup,
|
|
10
|
+
RadioButton,
|
|
11
|
+
Dropdown,
|
|
12
|
+
Column,
|
|
13
|
+
Button,
|
|
14
|
+
ButtonSet,
|
|
15
|
+
NumberInput,
|
|
16
|
+
Toggle,
|
|
17
|
+
} from '@carbon/react';
|
|
18
|
+
import dayjs from 'dayjs';
|
|
19
|
+
import {
|
|
20
|
+
type DefaultWorkspaceProps,
|
|
21
|
+
toDateObjectStrict,
|
|
22
|
+
toOmrsIsoString,
|
|
23
|
+
useLayoutType,
|
|
24
|
+
useVisitTypes,
|
|
25
|
+
} from '@openmrs/esm-framework';
|
|
26
|
+
import styles from './queue-linelist-filter.scss';
|
|
27
|
+
import { datePickerFormat, datePickerPlaceHolder } from '../constants';
|
|
28
|
+
|
|
29
|
+
const QueueLinelistFilter: React.FC<DefaultWorkspaceProps> = ({ closeWorkspace }) => {
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const [gender, setGender] = useState('');
|
|
32
|
+
const [startAge, setStartAge] = useState<number>();
|
|
33
|
+
const [endAge, setEndAge] = useState<number>();
|
|
34
|
+
const [returnDate, setReturnDate] = useState(new Date());
|
|
35
|
+
const [visitType, setVisitType] = useState('');
|
|
36
|
+
const isTablet = useLayoutType() === 'tablet';
|
|
37
|
+
const allVisitTypes = useVisitTypes();
|
|
38
|
+
|
|
39
|
+
const handleFilter = useCallback(
|
|
40
|
+
(event) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
|
|
43
|
+
const payload = {
|
|
44
|
+
gender: gender,
|
|
45
|
+
startAge: startAge,
|
|
46
|
+
endAge: endAge,
|
|
47
|
+
returnDate: toDateObjectStrict(
|
|
48
|
+
toOmrsIsoString(new Date(dayjs(returnDate).year(), dayjs(returnDate).month(), dayjs(returnDate).date())),
|
|
49
|
+
),
|
|
50
|
+
visitType: visitType,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
[gender, startAge, endAge, returnDate, visitType],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const handleTodaysDate = () => {
|
|
57
|
+
setReturnDate(new Date());
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<Form onSubmit={handleFilter}>
|
|
63
|
+
<div className={styles.wrapper}>
|
|
64
|
+
<Stack gap={4} className={styles.grid}>
|
|
65
|
+
<Column>
|
|
66
|
+
<p className={styles.heading}> {t('gender', 'Gender')}</p>
|
|
67
|
+
<RadioButtonGroup name="gender" orientation="vertical" onChange={(event) => setGender(event.toString())}>
|
|
68
|
+
<RadioButton
|
|
69
|
+
className={styles.radioButton}
|
|
70
|
+
id="male"
|
|
71
|
+
labelText={t('maleLabelText', 'Male')}
|
|
72
|
+
value="Male"
|
|
73
|
+
/>
|
|
74
|
+
<RadioButton
|
|
75
|
+
className={styles.radioButton}
|
|
76
|
+
id="female"
|
|
77
|
+
labelText={t('femaleLabelText', 'Female')}
|
|
78
|
+
value="Female"
|
|
79
|
+
/>
|
|
80
|
+
</RadioButtonGroup>
|
|
81
|
+
</Column>
|
|
82
|
+
</Stack>
|
|
83
|
+
|
|
84
|
+
<Stack gap={4} className={styles.grid}>
|
|
85
|
+
<Column md={2}>
|
|
86
|
+
<p className={styles.heading}> {t('age', 'Age')}</p>
|
|
87
|
+
<Layer>
|
|
88
|
+
<Toggle
|
|
89
|
+
size="sm"
|
|
90
|
+
aria-label={t('age', 'Age')}
|
|
91
|
+
defaultToggled
|
|
92
|
+
id="age"
|
|
93
|
+
labelA="Off"
|
|
94
|
+
labelB="On"
|
|
95
|
+
labelText=""
|
|
96
|
+
/>
|
|
97
|
+
</Layer>
|
|
98
|
+
<Layer className={styles.numberInputs}>
|
|
99
|
+
<Layer>
|
|
100
|
+
<NumberInput
|
|
101
|
+
id="startAge"
|
|
102
|
+
invalidText={t('startAgeRangeInvalid', 'Start age range is not valid')}
|
|
103
|
+
label={t('between', 'Between')}
|
|
104
|
+
max={100}
|
|
105
|
+
min={0}
|
|
106
|
+
onChange={(event) => setStartAge(event.target.value)}
|
|
107
|
+
size="md"
|
|
108
|
+
value={startAge}
|
|
109
|
+
/>
|
|
110
|
+
</Layer>
|
|
111
|
+
<Layer>
|
|
112
|
+
<NumberInput
|
|
113
|
+
id="endAge"
|
|
114
|
+
invalidText={t('endAgeRangeInvalid', 'End age range is not valid')}
|
|
115
|
+
label={t('and', 'And')}
|
|
116
|
+
max={100}
|
|
117
|
+
min={0}
|
|
118
|
+
onChange={(event) => setEndAge(event.target.value)}
|
|
119
|
+
size="md"
|
|
120
|
+
value={endAge}
|
|
121
|
+
/>
|
|
122
|
+
</Layer>
|
|
123
|
+
</Layer>
|
|
124
|
+
</Column>
|
|
125
|
+
</Stack>
|
|
126
|
+
|
|
127
|
+
<Stack gap={4} className={styles.grid}>
|
|
128
|
+
<Column md={2}>
|
|
129
|
+
<p className={styles.heading}> {t('returnDate', 'Return Date')}</p>
|
|
130
|
+
<Layer>
|
|
131
|
+
<DatePicker
|
|
132
|
+
datePickerType="single"
|
|
133
|
+
dateFormat={datePickerFormat}
|
|
134
|
+
value={returnDate}
|
|
135
|
+
onChange={([date]) => setReturnDate(date)}>
|
|
136
|
+
<DatePickerInput
|
|
137
|
+
id="returnDate"
|
|
138
|
+
placeholder={datePickerPlaceHolder}
|
|
139
|
+
labelText={t('date', 'Date')}
|
|
140
|
+
type="date"
|
|
141
|
+
/>
|
|
142
|
+
</DatePicker>
|
|
143
|
+
</Layer>
|
|
144
|
+
<Button
|
|
145
|
+
kind="ghost"
|
|
146
|
+
onClick={() => {
|
|
147
|
+
handleTodaysDate();
|
|
148
|
+
}}>
|
|
149
|
+
{t('useTodaysDate', "Use today's date")}
|
|
150
|
+
</Button>
|
|
151
|
+
</Column>
|
|
152
|
+
</Stack>
|
|
153
|
+
|
|
154
|
+
<Stack gap={4} className={styles.grid}>
|
|
155
|
+
<Column>
|
|
156
|
+
<p className={styles.heading}>{t('visitType', 'Visit Type')}</p>
|
|
157
|
+
<Layer>
|
|
158
|
+
<Dropdown
|
|
159
|
+
id="visitType"
|
|
160
|
+
label={t('selectAVisitType', 'Select visit type')}
|
|
161
|
+
titleText={t('selectAVisitType', 'Select visit type')}
|
|
162
|
+
items={allVisitTypes}
|
|
163
|
+
onChange={(event) => setVisitType(event.selectedItem.toString)}
|
|
164
|
+
size="sm"
|
|
165
|
+
itemToElement={(item) => (item ? <span>{item.display}</span> : null)}
|
|
166
|
+
/>
|
|
167
|
+
</Layer>
|
|
168
|
+
</Column>
|
|
169
|
+
</Stack>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
|
|
173
|
+
<Button className={styles.button} kind="secondary" onClick={closeWorkspace}>
|
|
174
|
+
{t('cancel', 'Cancel')}
|
|
175
|
+
</Button>
|
|
176
|
+
<Button className={styles.button} kind="primary" type="submit">
|
|
177
|
+
{t('applyFilters', 'Apply filters')}
|
|
178
|
+
</Button>
|
|
179
|
+
</ButtonSet>
|
|
180
|
+
</Form>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export default QueueLinelistFilter;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
|
+
import { type Appointment, type AppointmentsFetchResponse } from '../types/index';
|
|
4
|
+
import { type Provider } from '../types';
|
|
5
|
+
import { startOfDay } from '../constants';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
|
|
8
|
+
export function useAppointments() {
|
|
9
|
+
const apiUrl = `${restBaseUrl}/appointment/all?forDate=${startOfDay}`;
|
|
10
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: Array<Appointment> }, Error>(apiUrl, openmrsFetch);
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
appointmentQueueEntries: data ? data?.data : [],
|
|
14
|
+
isLoading,
|
|
15
|
+
isError: error,
|
|
16
|
+
isValidating,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function useCheckedInAppointments() {
|
|
21
|
+
const apiUrl = `${restBaseUrl}/appointment/appointmentStatus?forDate=${startOfDay}&status=CheckedIn`;
|
|
22
|
+
|
|
23
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: Array<Appointment> }, Error>(apiUrl, openmrsFetch);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
checkedInAppointments: data ? data?.data : [],
|
|
27
|
+
isLoading,
|
|
28
|
+
isError: error,
|
|
29
|
+
isValidating,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function useProviders() {
|
|
34
|
+
const customRepresentation = 'custom:(uuid,display,person:(age,display,gender,uuid))';
|
|
35
|
+
const apiUrl = `${restBaseUrl}/provider?q=&v=${customRepresentation}`;
|
|
36
|
+
const { data, error, isLoading, isValidating } = useSWR<{ data: { results: Array<Provider> } }, Error>(
|
|
37
|
+
apiUrl,
|
|
38
|
+
openmrsFetch,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
providers: data ? data.data?.results : [],
|
|
43
|
+
isLoading,
|
|
44
|
+
isError: error,
|
|
45
|
+
isValidating,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function usePatientAppointments(patientUuid: string, startDate) {
|
|
50
|
+
const abortController = new AbortController();
|
|
51
|
+
|
|
52
|
+
const appointmentsSearchUrl = `${restBaseUrl}/appointments/search`;
|
|
53
|
+
const fetcher = () =>
|
|
54
|
+
openmrsFetch(appointmentsSearchUrl, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
signal: abortController.signal,
|
|
57
|
+
headers: {
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
},
|
|
60
|
+
body: {
|
|
61
|
+
patientUuid: patientUuid,
|
|
62
|
+
startDate: startDate,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const { data, error, isLoading, isValidating } = useSWR<AppointmentsFetchResponse, Error>(
|
|
67
|
+
appointmentsSearchUrl,
|
|
68
|
+
fetcher,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const appointments = data?.data?.length ? data.data : [];
|
|
72
|
+
|
|
73
|
+
const upcomingAppointments = appointments
|
|
74
|
+
?.sort((a, b) => (a.startDateTime > b.startDateTime ? 1 : -1))
|
|
75
|
+
?.filter(({ status }) => status !== 'Cancelled')
|
|
76
|
+
?.filter(({ startDateTime }) => dayjs(new Date(startDateTime).toISOString()).isAfter(new Date()));
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
upcomingAppointment: upcomingAppointments ? upcomingAppointments?.[0] : null,
|
|
80
|
+
isError: error,
|
|
81
|
+
isLoading,
|
|
82
|
+
isValidating,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import QueuePatientBaseTable from './queue-linelist-base-table.component';
|
|
4
|
+
import { useServiceQueueEntries } from '../active-visits/active-visits-table.resource';
|
|
5
|
+
|
|
6
|
+
const ServicesTable: React.FC = () => {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
|
|
9
|
+
const currentPathName: string = window.location.pathname.replace('%20', ' ');
|
|
10
|
+
let service = currentPathName.split('/')[6];
|
|
11
|
+
let locationUuid = currentPathName.split('/')[8];
|
|
12
|
+
const { serviceQueueEntries, isLoading } = useServiceQueueEntries(service, locationUuid);
|
|
13
|
+
|
|
14
|
+
const tableHeaders = useMemo(
|
|
15
|
+
() => [
|
|
16
|
+
{
|
|
17
|
+
id: 0,
|
|
18
|
+
header: t('name', 'Name'),
|
|
19
|
+
key: 'name',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 1,
|
|
23
|
+
header: t('returnDate', 'Return Date'),
|
|
24
|
+
key: 'returnDate',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 2,
|
|
28
|
+
header: t('gender', 'Gender'),
|
|
29
|
+
key: 'gender',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 3,
|
|
33
|
+
header: t('age', 'Age'),
|
|
34
|
+
key: 'age',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 4,
|
|
38
|
+
header: t('visitType', 'Visit Type'),
|
|
39
|
+
key: 'visitType',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 5,
|
|
43
|
+
header: t('phoneNumber', 'Phone number'),
|
|
44
|
+
key: 'phoneNumber',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
[t],
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
<QueuePatientBaseTable
|
|
53
|
+
title={t('alistOfClients', 'A list of clients waiting for ')}
|
|
54
|
+
headers={tableHeaders}
|
|
55
|
+
patientData={serviceQueueEntries}
|
|
56
|
+
serviceType={service}
|
|
57
|
+
isLoading={isLoading}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ServicesTable;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
DataTable,
|
|
6
|
+
type DataTableHeader,
|
|
7
|
+
Layer,
|
|
8
|
+
Table,
|
|
9
|
+
TableBody,
|
|
10
|
+
TableCell,
|
|
11
|
+
TableContainer,
|
|
12
|
+
TableHead,
|
|
13
|
+
TableHeader,
|
|
14
|
+
TableRow,
|
|
15
|
+
TableToolbar,
|
|
16
|
+
TableToolbarContent,
|
|
17
|
+
TableToolbarSearch,
|
|
18
|
+
Tag,
|
|
19
|
+
Tile,
|
|
20
|
+
DataTableSkeleton,
|
|
21
|
+
Dropdown,
|
|
22
|
+
Pagination,
|
|
23
|
+
} from '@carbon/react';
|
|
24
|
+
import { Filter, OverflowMenuVertical } from '@carbon/react/icons';
|
|
25
|
+
import {
|
|
26
|
+
ExtensionSlot,
|
|
27
|
+
formatDatetime,
|
|
28
|
+
useConfig,
|
|
29
|
+
usePagination,
|
|
30
|
+
ConfigurableLink,
|
|
31
|
+
formatDate,
|
|
32
|
+
launchWorkspace,
|
|
33
|
+
} from '@openmrs/esm-framework';
|
|
34
|
+
import styles from './queue-linelist-base-table.scss';
|
|
35
|
+
import { updateSelectedAppointmentStatus, useSelectedAppointmentStatus } from '../helpers/helpers';
|
|
36
|
+
import { useAppointments } from './queue-linelist.resource';
|
|
37
|
+
import { getGender } from '../helpers/functions';
|
|
38
|
+
import { type ConfigObject } from '../config-schema';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* FIXME Temporarily moved here
|
|
42
|
+
*/
|
|
43
|
+
interface DataTableHeader {
|
|
44
|
+
key: string;
|
|
45
|
+
header: React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type FilterProps = {
|
|
49
|
+
rowIds: Array<string>;
|
|
50
|
+
headers: Array<DataTableHeader>;
|
|
51
|
+
cellsById: any;
|
|
52
|
+
inputValue: string;
|
|
53
|
+
getCellId: (row, key) => string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const AppointmentsTable: React.FC = () => {
|
|
57
|
+
const { t } = useTranslation();
|
|
58
|
+
const { appointmentStatuses } = useConfig<ConfigObject>();
|
|
59
|
+
const currentAppointmentStatus = useSelectedAppointmentStatus();
|
|
60
|
+
const { appointmentQueueEntries, isLoading } = useAppointments();
|
|
61
|
+
const [filteredRows, setFilteredRows] = useState(appointmentQueueEntries);
|
|
62
|
+
const { results, currentPage, goTo } = usePagination(filteredRows ?? [], 20);
|
|
63
|
+
|
|
64
|
+
const handleFilter = ({ rowIds, headers, cellsById, inputValue, getCellId }: FilterProps): Array<string> => {
|
|
65
|
+
return rowIds.filter((rowId) =>
|
|
66
|
+
headers.some(({ key }) => {
|
|
67
|
+
const cellId = getCellId(rowId, key);
|
|
68
|
+
const filterableValue = cellsById[cellId].value;
|
|
69
|
+
const filterTerm = inputValue.toLowerCase();
|
|
70
|
+
|
|
71
|
+
if (typeof filterableValue === 'boolean') {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (filterableValue.hasOwnProperty('content')) {
|
|
75
|
+
if (Array.isArray(filterableValue.content.props.children)) {
|
|
76
|
+
return ('' + filterableValue.content.props.children[1].props.children).toLowerCase().includes(filterTerm);
|
|
77
|
+
}
|
|
78
|
+
if (typeof filterableValue.content.props.children === 'object') {
|
|
79
|
+
return ('' + filterableValue.content.props.children.props.children.props.children)
|
|
80
|
+
.toLowerCase()
|
|
81
|
+
.includes(filterTerm);
|
|
82
|
+
}
|
|
83
|
+
return ('' + filterableValue.content.props.children).toLowerCase().includes(filterTerm);
|
|
84
|
+
}
|
|
85
|
+
return ('' + filterableValue).toLowerCase().includes(filterTerm);
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (currentAppointmentStatus != t('all', 'All') && currentAppointmentStatus !== '') {
|
|
92
|
+
setFilteredRows(
|
|
93
|
+
appointmentQueueEntries?.filter((appointment) => appointment.status === currentAppointmentStatus),
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
setFilteredRows(appointmentQueueEntries);
|
|
97
|
+
}
|
|
98
|
+
}, [t, currentAppointmentStatus, results, appointmentQueueEntries]);
|
|
99
|
+
|
|
100
|
+
const tableHeaders = useMemo(
|
|
101
|
+
() => [
|
|
102
|
+
{
|
|
103
|
+
id: 0,
|
|
104
|
+
header: t('name', 'Name'),
|
|
105
|
+
key: 'name',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 1,
|
|
109
|
+
header: t('returnDate', 'Return Date'),
|
|
110
|
+
key: 'returnDate',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 2,
|
|
114
|
+
header: t('gender', 'Gender'),
|
|
115
|
+
key: 'gender',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 3,
|
|
119
|
+
header: t('age', 'Age'),
|
|
120
|
+
key: 'age',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 4,
|
|
124
|
+
header: t('visitType', 'Visit Type'),
|
|
125
|
+
key: 'visitType',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: 5,
|
|
129
|
+
header: t('status', 'Status'),
|
|
130
|
+
key: 'status',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 6,
|
|
134
|
+
header: t('phoneNumber', 'Phone number'),
|
|
135
|
+
key: 'phoneNumber',
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
[t],
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const tableRows = useMemo(() => {
|
|
142
|
+
return results?.map((appointment) => ({
|
|
143
|
+
id: appointment.uuid,
|
|
144
|
+
name: {
|
|
145
|
+
content: (
|
|
146
|
+
<ConfigurableLink to={`\${openmrsSpaBase}/patient/${appointment.patient.uuid}/chart`}>
|
|
147
|
+
{appointment.patient.name}
|
|
148
|
+
</ConfigurableLink>
|
|
149
|
+
),
|
|
150
|
+
},
|
|
151
|
+
returnDate: formatDate(new Date(appointment.startDateTime), {
|
|
152
|
+
mode: 'wide',
|
|
153
|
+
}),
|
|
154
|
+
gender: getGender(appointment.patient?.gender, t),
|
|
155
|
+
age: appointment.patient.age,
|
|
156
|
+
visitType: appointment.appointmentKind,
|
|
157
|
+
status: appointment.status,
|
|
158
|
+
phoneNumber: appointment.patient?.phoneNumber,
|
|
159
|
+
}));
|
|
160
|
+
}, [results, t]);
|
|
161
|
+
|
|
162
|
+
const handleStatusChange = ({ selectedItem }) => {
|
|
163
|
+
updateSelectedAppointmentStatus(selectedItem);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const pageSizes = useMemo(() => {
|
|
167
|
+
const numberOfPages = Math.ceil(appointmentQueueEntries?.length / 100);
|
|
168
|
+
return [...Array(numberOfPages).keys()].map((x) => {
|
|
169
|
+
return (x + 1) * 100;
|
|
170
|
+
});
|
|
171
|
+
}, [appointmentQueueEntries]);
|
|
172
|
+
|
|
173
|
+
if (isLoading) {
|
|
174
|
+
return <DataTableSkeleton role="progressbar" />;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<div className={styles.container}>
|
|
179
|
+
<ExtensionSlot name="breadcrumbs-slot" />
|
|
180
|
+
|
|
181
|
+
<div className={styles.headerContainer}>
|
|
182
|
+
<div>
|
|
183
|
+
<p className={styles.title}>{t('scheduledAppointmentsList', 'Scheduled appointments patient list')}</p>
|
|
184
|
+
<p className={styles.subTitle}>
|
|
185
|
+
{appointmentQueueEntries?.length} · Last Updated: {formatDatetime(new Date(), { mode: 'standard' })}
|
|
186
|
+
</p>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<Button kind="ghost" size="sm" renderIcon={(props) => <OverflowMenuVertical size={16} {...props} />}>
|
|
190
|
+
{t('actions', 'Actions')}
|
|
191
|
+
</Button>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<Layer>
|
|
195
|
+
<Tile className={styles.filterTile}>
|
|
196
|
+
<Tag size="md" title="Clear Filter" type="blue">
|
|
197
|
+
{t('today', 'Today')}
|
|
198
|
+
</Tag>
|
|
199
|
+
|
|
200
|
+
<div className={styles.actionsBtn}>
|
|
201
|
+
<Button
|
|
202
|
+
kind="ghost"
|
|
203
|
+
renderIcon={(props) => <Filter size={16} {...props} />}
|
|
204
|
+
iconDescription={t('filter', 'Filter')}
|
|
205
|
+
onClick={() => launchWorkspace('service-queues-linelist-filter')}
|
|
206
|
+
size="sm">
|
|
207
|
+
{t('filter', 'Filter')}
|
|
208
|
+
</Button>
|
|
209
|
+
</div>
|
|
210
|
+
</Tile>
|
|
211
|
+
</Layer>
|
|
212
|
+
|
|
213
|
+
<DataTable
|
|
214
|
+
data-floating-menu-container
|
|
215
|
+
filterRows={handleFilter}
|
|
216
|
+
headers={tableHeaders}
|
|
217
|
+
overflowMenuOnHover={false}
|
|
218
|
+
rows={tableRows}
|
|
219
|
+
size="md"
|
|
220
|
+
useZebraStyles>
|
|
221
|
+
{({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
|
|
222
|
+
<TableContainer className={styles.tableContainer}>
|
|
223
|
+
<TableToolbar
|
|
224
|
+
style={{
|
|
225
|
+
position: 'static',
|
|
226
|
+
height: '3rem',
|
|
227
|
+
overflow: 'visible',
|
|
228
|
+
backgroundColor: 'color',
|
|
229
|
+
}}>
|
|
230
|
+
<TableToolbarContent className={styles.toolbarContent}>
|
|
231
|
+
<div className={styles.filterContainer}>
|
|
232
|
+
<Dropdown
|
|
233
|
+
id="serviceFilter"
|
|
234
|
+
initialSelectedItem={'All'}
|
|
235
|
+
label={currentAppointmentStatus}
|
|
236
|
+
titleText={t('status', 'Status') + ':'}
|
|
237
|
+
type="inline"
|
|
238
|
+
items={['All', ...appointmentStatuses]}
|
|
239
|
+
onChange={handleStatusChange}
|
|
240
|
+
size="sm"
|
|
241
|
+
/>
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
<TableToolbarSearch
|
|
245
|
+
className={styles.search}
|
|
246
|
+
expanded
|
|
247
|
+
onChange={onInputChange}
|
|
248
|
+
placeholder={t('searchThisList', 'Search this list')}
|
|
249
|
+
size="sm"
|
|
250
|
+
/>
|
|
251
|
+
</TableToolbarContent>
|
|
252
|
+
</TableToolbar>
|
|
253
|
+
<Table {...getTableProps()} className={styles.queueTable}>
|
|
254
|
+
<TableHead>
|
|
255
|
+
<TableRow>
|
|
256
|
+
{headers.map((header) => (
|
|
257
|
+
<TableHeader {...getHeaderProps({ header })}>{header.header}</TableHeader>
|
|
258
|
+
))}
|
|
259
|
+
</TableRow>
|
|
260
|
+
</TableHead>
|
|
261
|
+
<TableBody>
|
|
262
|
+
{rows.map((row, index) => {
|
|
263
|
+
return (
|
|
264
|
+
<React.Fragment key={row.id}>
|
|
265
|
+
<TableRow {...getRowProps({ row })}>
|
|
266
|
+
{row.cells.map((cell) => (
|
|
267
|
+
<TableCell key={cell.id}>{cell.value?.content ?? cell.value}</TableCell>
|
|
268
|
+
))}
|
|
269
|
+
</TableRow>
|
|
270
|
+
</React.Fragment>
|
|
271
|
+
);
|
|
272
|
+
})}
|
|
273
|
+
</TableBody>
|
|
274
|
+
</Table>
|
|
275
|
+
{rows.length === 0 ? (
|
|
276
|
+
<div className={styles.tileContainer}>
|
|
277
|
+
<Layer>
|
|
278
|
+
<Tile className={styles.tile}>
|
|
279
|
+
<div className={styles.tileContent}>
|
|
280
|
+
<p className={styles.content}>{t('noPatientsToDisplay', 'No patients to display')}</p>
|
|
281
|
+
<p className={styles.helper}>{t('checkFilters', 'Check the filters above')}</p>
|
|
282
|
+
</div>
|
|
283
|
+
</Tile>
|
|
284
|
+
</Layer>
|
|
285
|
+
</div>
|
|
286
|
+
) : null}
|
|
287
|
+
</TableContainer>
|
|
288
|
+
)}
|
|
289
|
+
</DataTable>
|
|
290
|
+
|
|
291
|
+
<Pagination
|
|
292
|
+
backwardText="Previous page"
|
|
293
|
+
forwardText="Next page"
|
|
294
|
+
page={currentPage}
|
|
295
|
+
pageNumberText="Page Number"
|
|
296
|
+
pageSize={100}
|
|
297
|
+
onChange={({ page }) => goTo(page)}
|
|
298
|
+
pageSizes={pageSizes?.length > 0 ? pageSizes : [100]}
|
|
299
|
+
totalItems={appointmentQueueEntries?.length ?? 0}
|
|
300
|
+
/>
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export default AppointmentsTable;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { mockAppointmentsData } from '__mocks__';
|
|
5
|
+
import AppointmentsTable from './scheduled-appointments-table.component';
|
|
6
|
+
|
|
7
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
|
8
|
+
...jest.requireActual('@openmrs/esm-framework'),
|
|
9
|
+
useConfig: () => ({
|
|
10
|
+
appointmentStatuses: ['All', 'Scheduled', 'Completed'],
|
|
11
|
+
}),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('./queue-linelist.resource', () => ({
|
|
15
|
+
useAppointments: () => ({
|
|
16
|
+
appointmentQueueEntries: mockAppointmentsData.data,
|
|
17
|
+
isLoading: false,
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
describe('AppointmentsTable', () => {
|
|
22
|
+
it('renders appointments when loading is complete', () => {
|
|
23
|
+
render(<AppointmentsTable />);
|
|
24
|
+
|
|
25
|
+
const appointmentName = screen.getByText(/charles babbage/i);
|
|
26
|
+
expect(appointmentName).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('filters appointments based on status selection', async () => {
|
|
30
|
+
const user = userEvent.setup();
|
|
31
|
+
|
|
32
|
+
render(<AppointmentsTable />);
|
|
33
|
+
|
|
34
|
+
const statusDropdown = screen.getAllByLabelText('Status:');
|
|
35
|
+
|
|
36
|
+
await user.type(statusDropdown[0], 'Completed');
|
|
37
|
+
|
|
38
|
+
const filteredAppointmentName = screen.getByText(/charles babbage/i);
|
|
39
|
+
expect(filteredAppointmentName).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
});
|