@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,29 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
4
|
+
import { type PatientProgram } from '../../types';
|
|
5
|
+
import uniqBy from 'lodash-es/uniqBy';
|
|
6
|
+
|
|
7
|
+
export const useActivePatientEnrollment = (patientUuid: string) => {
|
|
8
|
+
const customRepresentation = `custom:(uuid,display,program,dateEnrolled,dateCompleted,location:(uuid,display))`;
|
|
9
|
+
const apiUrl = `${restBaseUrl}/programenrollment?patient=${patientUuid}&v=${customRepresentation}`;
|
|
10
|
+
|
|
11
|
+
const { data, error, isLoading } = useSWR<{ data: { results: Array<PatientProgram> } }>(
|
|
12
|
+
patientUuid ? apiUrl : null,
|
|
13
|
+
openmrsFetch,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const activePatientEnrollment = useMemo(
|
|
17
|
+
() =>
|
|
18
|
+
data?.data.results
|
|
19
|
+
.sort((a, b) => (b.dateEnrolled > a.dateEnrolled ? 1 : -1))
|
|
20
|
+
.filter((enrollment) => enrollment.dateCompleted === null) ?? [],
|
|
21
|
+
[data?.data.results],
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
activePatientEnrollment: uniqBy(activePatientEnrollment, (program) => program?.program?.uuid),
|
|
26
|
+
error,
|
|
27
|
+
isLoading,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FetchResponse, openmrsFetch, useConfig } from '@openmrs/esm-framework';
|
|
2
|
+
import useSWRImmutable from 'swr/immutable';
|
|
3
|
+
|
|
4
|
+
export const useDefaultLoginLocation = () => {
|
|
5
|
+
const config = useConfig();
|
|
6
|
+
const apiUrl = config.defaultFacilityUrl;
|
|
7
|
+
const { data, error, isLoading } = useSWRImmutable<FetchResponse>(apiUrl, openmrsFetch);
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
defaultFacility: data ? data?.data : null,
|
|
11
|
+
isLoading: isLoading,
|
|
12
|
+
isError: error,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
import { fhirBaseUrl, openmrsFetch } from '@openmrs/esm-framework';
|
|
4
|
+
|
|
5
|
+
interface FHIRResponse {
|
|
6
|
+
entry: Array<{ resource: fhir.Patient }>;
|
|
7
|
+
total: number;
|
|
8
|
+
type: string;
|
|
9
|
+
resourceType: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const usePatients = (searchTerm: string) => {
|
|
13
|
+
const apiUrl = `${fhirBaseUrl}/Patient?name=${searchTerm}&_summary=data`;
|
|
14
|
+
|
|
15
|
+
const { data, error, isLoading } = useSWR<{ data: FHIRResponse }>(searchTerm !== null ? apiUrl : null, openmrsFetch);
|
|
16
|
+
|
|
17
|
+
const searchedPatients = useMemo(
|
|
18
|
+
() => data?.data?.entry?.map((response) => response.resource) ?? [],
|
|
19
|
+
[data?.data?.entry],
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return { patients: searchedPatients, isLoading: isLoading && searchTerm !== null, error };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default usePatients;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { fhirBaseUrl, getLocale, openmrsFetch } from '@openmrs/esm-framework';
|
|
3
|
+
import useSWRImmutable from 'swr/immutable';
|
|
4
|
+
|
|
5
|
+
interface FHIRResponse {
|
|
6
|
+
entry: Array<{ resource: fhir.Location }>;
|
|
7
|
+
total: number;
|
|
8
|
+
type: string;
|
|
9
|
+
resourceType: string;
|
|
10
|
+
}
|
|
11
|
+
export function useQueueLocations() {
|
|
12
|
+
const apiUrl = `${fhirBaseUrl}/Location?_summary=data&_tag=queue location`;
|
|
13
|
+
const { data, error, isLoading } = useSWRImmutable<{ data: FHIRResponse }>(apiUrl, openmrsFetch);
|
|
14
|
+
|
|
15
|
+
const queueLocations = useMemo(
|
|
16
|
+
() =>
|
|
17
|
+
data?.data?.entry
|
|
18
|
+
?.map((response) => response.resource)
|
|
19
|
+
.sort((a, b) => a.name.localeCompare(b.name, getLocale())) ?? [],
|
|
20
|
+
[data?.data?.entry],
|
|
21
|
+
);
|
|
22
|
+
return { queueLocations, isLoading, error };
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
2
|
+
import { openmrsFetch, useConfig } from '@openmrs/esm-framework';
|
|
3
|
+
import { type ConfigObject } from '../../config-schema';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
|
|
6
|
+
interface EnrollmentVisitType {
|
|
7
|
+
dataDependencies: Array<string>;
|
|
8
|
+
enrollmentOptions: object;
|
|
9
|
+
incompatibleWith: Array<string>;
|
|
10
|
+
name: string;
|
|
11
|
+
visitTypes: { allowed: Array<EnrollmentVisitType>; disallowed: Array<EnrollmentVisitType> };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useRecommendedVisitTypes = (
|
|
15
|
+
patientUuid: string,
|
|
16
|
+
enrollmentUuid: string,
|
|
17
|
+
programUuid: string,
|
|
18
|
+
locationUuid: string,
|
|
19
|
+
) => {
|
|
20
|
+
const { visitTypeResourceUrl, showRecommendedVisitTypeTab } = useConfig<ConfigObject>();
|
|
21
|
+
|
|
22
|
+
const apiUrl = `${visitTypeResourceUrl}${patientUuid}/program/${programUuid}/enrollment/${enrollmentUuid}?intendedLocationUuid=${locationUuid}`;
|
|
23
|
+
|
|
24
|
+
const { data, error, isLoading } = useSWR<{ data: EnrollmentVisitType }>(
|
|
25
|
+
showRecommendedVisitTypeTab && patientUuid && enrollmentUuid && programUuid ? apiUrl : null,
|
|
26
|
+
openmrsFetch,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const recommendedVisitTypes = useMemo(() => data?.data?.visitTypes?.allowed.map(mapToVisitType) ?? [], [data]);
|
|
30
|
+
return { recommendedVisitTypes, error, isLoading };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const mapToVisitType = (visitType) => {
|
|
34
|
+
return { ...visitType, display: visitType.name };
|
|
35
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import { type AppointmentsFetchResponse } from '../../types';
|
|
5
|
+
|
|
6
|
+
const fetcher = (appointmentsSearchUrl: string, patientUuid: string) => {
|
|
7
|
+
const abortController = new AbortController();
|
|
8
|
+
let startDate = dayjs(new Date().toISOString()).subtract(6, 'month').toISOString();
|
|
9
|
+
|
|
10
|
+
return openmrsFetch(appointmentsSearchUrl, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
signal: abortController.signal,
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
body: {
|
|
17
|
+
patientUuid: patientUuid,
|
|
18
|
+
startDate: startDate,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function useScheduledVisits(patientUuid: string) {
|
|
24
|
+
const appointmentsSearchUrl = `${restBaseUrl}/appointments/search`;
|
|
25
|
+
|
|
26
|
+
const { data, error, isLoading } = useSWR<AppointmentsFetchResponse, Error>(
|
|
27
|
+
patientUuid ? [appointmentsSearchUrl, patientUuid] : null,
|
|
28
|
+
([appointmentsSearchUrl, patientUuid]) => fetcher(appointmentsSearchUrl, patientUuid as string),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const appointments = data?.data?.length
|
|
32
|
+
? data.data.sort((a, b) => (b.startDateTime > a.startDateTime ? 1 : -1))
|
|
33
|
+
: null;
|
|
34
|
+
|
|
35
|
+
// visits + or - 7 days before visit date
|
|
36
|
+
const recentVisits = appointments?.filter(
|
|
37
|
+
(appointment) =>
|
|
38
|
+
dayjs((appointment.startDateTime / 1000) * 1000).isBefore(dayjs().add(7, 'day')) ||
|
|
39
|
+
dayjs((appointment.startDateTime / 1000) * 1000).isBefore(dayjs().subtract(7, 'day')),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// visits past 7 days
|
|
43
|
+
const futureVisits = appointments?.filter((appointment) =>
|
|
44
|
+
dayjs((appointment.startDateTime / 1000) * 1000).isAfter(dayjs().add(7, 'day')),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
appointments: data ? { recentVisits, futureVisits } : null,
|
|
49
|
+
isError: error,
|
|
50
|
+
isLoading,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
ButtonSet,
|
|
6
|
+
ContentSwitcher,
|
|
7
|
+
DataTableSkeleton,
|
|
8
|
+
InlineLoading,
|
|
9
|
+
InlineNotification,
|
|
10
|
+
RadioTile,
|
|
11
|
+
Switch,
|
|
12
|
+
TileGroup,
|
|
13
|
+
} from '@carbon/react';
|
|
14
|
+
import {
|
|
15
|
+
formatDatetime,
|
|
16
|
+
type NewVisitPayload,
|
|
17
|
+
parseDate,
|
|
18
|
+
saveVisit,
|
|
19
|
+
showSnackbar,
|
|
20
|
+
toDateObjectStrict,
|
|
21
|
+
toOmrsIsoString,
|
|
22
|
+
useConfig,
|
|
23
|
+
useLayoutType,
|
|
24
|
+
useLocations,
|
|
25
|
+
useSession,
|
|
26
|
+
useVisit,
|
|
27
|
+
useVisitTypes,
|
|
28
|
+
} from '@openmrs/esm-framework';
|
|
29
|
+
import { type Appointment, SearchTypes } from '../types';
|
|
30
|
+
import styles from './patient-scheduled-visits.scss';
|
|
31
|
+
import { postQueueEntry } from './visit-form/queue.resource';
|
|
32
|
+
import { first } from 'rxjs/operators';
|
|
33
|
+
import { convertTime12to24 } from '../helpers/time-helpers';
|
|
34
|
+
import dayjs from 'dayjs';
|
|
35
|
+
import head from 'lodash-es/head';
|
|
36
|
+
import { useQueueLocations } from './hooks/useQueueLocations';
|
|
37
|
+
import { useQueues } from '../hooks/useQueues';
|
|
38
|
+
import { useMutateQueueEntries } from '../hooks/useQueueEntries';
|
|
39
|
+
import { type ConfigObject } from '../config-schema';
|
|
40
|
+
|
|
41
|
+
enum visitType {
|
|
42
|
+
RECENT = 'Recent',
|
|
43
|
+
FUTURE = 'Future',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ScheduledVisitsForVisitType: React.FC<{
|
|
47
|
+
visits;
|
|
48
|
+
visitType;
|
|
49
|
+
scheduledVisitHeader;
|
|
50
|
+
patientUuid;
|
|
51
|
+
closeWorkspace: () => void;
|
|
52
|
+
}> = ({ visits, scheduledVisitHeader, patientUuid, closeWorkspace }) => {
|
|
53
|
+
const { t } = useTranslation();
|
|
54
|
+
const [visitsIndex, setVisitsIndex] = useState(0);
|
|
55
|
+
const [hasPriority, setHasPriority] = useState(false);
|
|
56
|
+
const [userLocation, setUserLocation] = useState('');
|
|
57
|
+
const locations = useLocations();
|
|
58
|
+
const session = useSession();
|
|
59
|
+
const { queues, isLoading: isLoadingQueues } = useQueues(userLocation);
|
|
60
|
+
const { mutateQueueEntries } = useMutateQueueEntries();
|
|
61
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
62
|
+
const timeFormat = new Date().getHours() >= 12 ? 'PM' : 'AM';
|
|
63
|
+
const visitDate = new Date();
|
|
64
|
+
const visitTime = dayjs(new Date()).format('hh:mm');
|
|
65
|
+
const [appointment, setAppointment] = useState<Appointment>();
|
|
66
|
+
const [patientId, setPatientId] = useState('');
|
|
67
|
+
const allVisitTypes = useVisitTypes();
|
|
68
|
+
const { currentVisit } = useVisit(patientUuid);
|
|
69
|
+
const config = useConfig<ConfigObject>();
|
|
70
|
+
const visitQueueNumberAttributeUuid = config.visitQueueNumberAttributeUuid;
|
|
71
|
+
const { queueLocations } = useQueueLocations();
|
|
72
|
+
const selectedQueueLocation = queueLocations[0]?.id;
|
|
73
|
+
|
|
74
|
+
// TODO: This needs fixing, we cannot just take the first queue and assume that is what is wanted
|
|
75
|
+
const service = head(queues)?.uuid;
|
|
76
|
+
const defaultStatus = config.concepts.defaultStatusConceptUuid;
|
|
77
|
+
const priorities = queues.find((q) => q.uuid === service)?.allowedPriorities ?? [];
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!userLocation && session?.sessionLocation !== null) {
|
|
81
|
+
setUserLocation(session?.sessionLocation?.uuid);
|
|
82
|
+
} else if (!userLocation && locations) {
|
|
83
|
+
setUserLocation(head(locations)?.uuid);
|
|
84
|
+
}
|
|
85
|
+
}, [session, locations, userLocation]);
|
|
86
|
+
|
|
87
|
+
const handleSubmit = useCallback(
|
|
88
|
+
(priority) => {
|
|
89
|
+
setIsSubmitting(true);
|
|
90
|
+
const [hours, minutes] = convertTime12to24(visitTime, timeFormat);
|
|
91
|
+
const visitType = [...allVisitTypes].shift().uuid;
|
|
92
|
+
|
|
93
|
+
const payload: NewVisitPayload = {
|
|
94
|
+
patient: patientId,
|
|
95
|
+
startDatetime: toDateObjectStrict(
|
|
96
|
+
toOmrsIsoString(
|
|
97
|
+
new Date(dayjs(visitDate).year(), dayjs(visitDate).month(), dayjs(visitDate).date(), hours, minutes),
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
visitType: visitType,
|
|
101
|
+
location: userLocation,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
if (currentVisit) {
|
|
105
|
+
showSnackbar({
|
|
106
|
+
title: t('startVisitError', 'Error starting visit'),
|
|
107
|
+
kind: 'error',
|
|
108
|
+
isLowContrast: false,
|
|
109
|
+
subtitle: t('patientHasActiveVisit', 'The patient already has an active visit'),
|
|
110
|
+
});
|
|
111
|
+
setIsSubmitting(false);
|
|
112
|
+
} else {
|
|
113
|
+
const abortController = new AbortController();
|
|
114
|
+
|
|
115
|
+
saveVisit(payload, abortController)
|
|
116
|
+
.pipe(first())
|
|
117
|
+
.subscribe(
|
|
118
|
+
(response) => {
|
|
119
|
+
if (response.status === 201) {
|
|
120
|
+
postQueueEntry(
|
|
121
|
+
response.data.uuid,
|
|
122
|
+
patientId,
|
|
123
|
+
priority,
|
|
124
|
+
defaultStatus,
|
|
125
|
+
service,
|
|
126
|
+
appointment,
|
|
127
|
+
selectedQueueLocation,
|
|
128
|
+
visitQueueNumberAttributeUuid,
|
|
129
|
+
).then(
|
|
130
|
+
({ status }) => {
|
|
131
|
+
if (status === 201) {
|
|
132
|
+
showSnackbar({
|
|
133
|
+
kind: 'success',
|
|
134
|
+
title: t('startAVisit', 'Start a visit'),
|
|
135
|
+
subtitle: t(
|
|
136
|
+
'startVisitQueueSuccessfully',
|
|
137
|
+
'Patient has been added to active visits list and queue.',
|
|
138
|
+
`${hours} : ${minutes}`,
|
|
139
|
+
),
|
|
140
|
+
});
|
|
141
|
+
closeWorkspace();
|
|
142
|
+
setIsSubmitting(false);
|
|
143
|
+
mutateQueueEntries();
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
(error) => {
|
|
147
|
+
showSnackbar({
|
|
148
|
+
title: t('queueEntryError', 'Error adding patient to the queue'),
|
|
149
|
+
kind: 'error',
|
|
150
|
+
isLowContrast: false,
|
|
151
|
+
subtitle: error?.message,
|
|
152
|
+
});
|
|
153
|
+
setIsSubmitting(false);
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
(error) => {
|
|
159
|
+
showSnackbar({
|
|
160
|
+
title: t('startVisitError', 'Error starting visit'),
|
|
161
|
+
kind: 'error',
|
|
162
|
+
isLowContrast: false,
|
|
163
|
+
subtitle: error?.message,
|
|
164
|
+
});
|
|
165
|
+
setIsSubmitting(false);
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
[
|
|
171
|
+
visitTime,
|
|
172
|
+
timeFormat,
|
|
173
|
+
allVisitTypes,
|
|
174
|
+
patientId,
|
|
175
|
+
visitDate,
|
|
176
|
+
userLocation,
|
|
177
|
+
queues,
|
|
178
|
+
config.concepts.defaultStatusConceptUuid,
|
|
179
|
+
config.concepts.defaultPriorityConceptUuid,
|
|
180
|
+
currentVisit,
|
|
181
|
+
t,
|
|
182
|
+
priorities,
|
|
183
|
+
appointment,
|
|
184
|
+
selectedQueueLocation,
|
|
185
|
+
visitQueueNumberAttributeUuid,
|
|
186
|
+
closeWorkspace,
|
|
187
|
+
mutateQueueEntries,
|
|
188
|
+
],
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
if (visits) {
|
|
192
|
+
return (
|
|
193
|
+
<div className={styles.row}>
|
|
194
|
+
<p className={styles.heading}>{scheduledVisitHeader} </p>
|
|
195
|
+
{visits?.length > 0 ? (
|
|
196
|
+
<TileGroup name="tile-group" defaultSelected="default-selected">
|
|
197
|
+
{visits?.map((visit, ind) => {
|
|
198
|
+
return (
|
|
199
|
+
<RadioTile
|
|
200
|
+
value={visit.uuid}
|
|
201
|
+
key={visit.uuid}
|
|
202
|
+
className={styles.visitTile}
|
|
203
|
+
onClick={(e) => {
|
|
204
|
+
setHasPriority(true);
|
|
205
|
+
setVisitsIndex(ind);
|
|
206
|
+
setPatientId(visit?.patient?.uuid);
|
|
207
|
+
setAppointment(visit);
|
|
208
|
+
}}>
|
|
209
|
+
<div className={styles.helperText}>
|
|
210
|
+
<p className={styles.primaryText}>{visit.service?.name}</p>
|
|
211
|
+
<p className={styles.secondaryText}>
|
|
212
|
+
{' '}
|
|
213
|
+
{formatDatetime(parseDate(visit?.startDateTime))} · {visit.location?.name}{' '}
|
|
214
|
+
</p>
|
|
215
|
+
|
|
216
|
+
{!visit.service ? (
|
|
217
|
+
<DataTableSkeleton />
|
|
218
|
+
) : isLoadingQueues ? null : !priorities?.length ? (
|
|
219
|
+
<InlineNotification
|
|
220
|
+
className={styles.inlineNotification}
|
|
221
|
+
kind={'error'}
|
|
222
|
+
lowContrast
|
|
223
|
+
subtitle={t('configurePriorities', 'Please configure priorities to continue.')}
|
|
224
|
+
title={t('noPrioritiesConfigured', 'No priorities configured')}
|
|
225
|
+
/>
|
|
226
|
+
) : hasPriority && ind == visitsIndex ? (
|
|
227
|
+
<ContentSwitcher
|
|
228
|
+
size="sm"
|
|
229
|
+
selectedIndex={null}
|
|
230
|
+
className={styles.prioritySwitcher}
|
|
231
|
+
onChange={(e) => {
|
|
232
|
+
handleSubmit(e.name);
|
|
233
|
+
}}>
|
|
234
|
+
{priorities?.length > 0
|
|
235
|
+
? priorities.map(({ uuid, display }) => {
|
|
236
|
+
return <Switch name={uuid} text={display} />;
|
|
237
|
+
})
|
|
238
|
+
: null}
|
|
239
|
+
</ContentSwitcher>
|
|
240
|
+
) : null}
|
|
241
|
+
{hasPriority && ind == visitsIndex && isSubmitting ? (
|
|
242
|
+
<InlineLoading description={t('loading', 'Loading...')} />
|
|
243
|
+
) : null}
|
|
244
|
+
</div>
|
|
245
|
+
</RadioTile>
|
|
246
|
+
);
|
|
247
|
+
})}
|
|
248
|
+
</TileGroup>
|
|
249
|
+
) : (
|
|
250
|
+
<div className={styles.emptyAppointment}>
|
|
251
|
+
<p>{t('noAppointmentsFound', 'No appointments found')} </p>
|
|
252
|
+
</div>
|
|
253
|
+
)}
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
return (
|
|
258
|
+
<div className={styles.emptyAppointment}>
|
|
259
|
+
<p className={styles.heading}> {scheduledVisitHeader} </p>
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
interface PatientScheduledVisitsProps {
|
|
265
|
+
appointments: { recentVisits: Appointment[]; futureVisits: Appointment[] };
|
|
266
|
+
toggleSearchType: (searchMode: SearchTypes) => void;
|
|
267
|
+
patientUuid: string;
|
|
268
|
+
closeWorkspace: () => void;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const PatientScheduledVisits: React.FC<PatientScheduledVisitsProps> = ({
|
|
272
|
+
appointments,
|
|
273
|
+
toggleSearchType,
|
|
274
|
+
patientUuid,
|
|
275
|
+
closeWorkspace,
|
|
276
|
+
}) => {
|
|
277
|
+
const { t } = useTranslation();
|
|
278
|
+
const isTablet = useLayoutType() === 'tablet';
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<div className={styles.container}>
|
|
282
|
+
<ScheduledVisitsForVisitType
|
|
283
|
+
visitType={visitType.RECENT}
|
|
284
|
+
visits={appointments?.recentVisits}
|
|
285
|
+
scheduledVisitHeader={t('recentScheduledVisits', '{{count}} visit(s) scheduled for +/- 7 days', {
|
|
286
|
+
count: appointments?.recentVisits?.length,
|
|
287
|
+
})}
|
|
288
|
+
patientUuid={patientUuid}
|
|
289
|
+
closeWorkspace={closeWorkspace}
|
|
290
|
+
/>
|
|
291
|
+
<ScheduledVisitsForVisitType
|
|
292
|
+
visitType={visitType.FUTURE}
|
|
293
|
+
visits={appointments?.futureVisits}
|
|
294
|
+
scheduledVisitHeader={t('futureScheduledVisits', '{{count}} visit(s) scheduled for dates in the future', {
|
|
295
|
+
count: appointments?.futureVisits?.length,
|
|
296
|
+
})}
|
|
297
|
+
patientUuid={patientUuid}
|
|
298
|
+
closeWorkspace={closeWorkspace}
|
|
299
|
+
/>
|
|
300
|
+
|
|
301
|
+
<div className={styles['text-divider']}>{t('orInProperFormat', 'Or')}</div>
|
|
302
|
+
|
|
303
|
+
<div className={styles.buttonContainer}>
|
|
304
|
+
<Button
|
|
305
|
+
kind="ghost"
|
|
306
|
+
iconDescription="Start another visit type"
|
|
307
|
+
onClick={() => toggleSearchType(SearchTypes.VISIT_FORM)}>
|
|
308
|
+
{t('anotherVisitType', 'Start another visit type')}
|
|
309
|
+
</Button>
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
|
|
313
|
+
<Button className={styles.button} kind="secondary" onClick={() => toggleSearchType(SearchTypes.SEARCH_RESULTS)}>
|
|
314
|
+
{t('cancel', 'Cancel')}
|
|
315
|
+
</Button>
|
|
316
|
+
<Button className={styles.button} kind="primary" type="submit">
|
|
317
|
+
{t('search', 'Search')}
|
|
318
|
+
</Button>
|
|
319
|
+
</ButtonSet>
|
|
320
|
+
</div>
|
|
321
|
+
);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export default PatientScheduledVisits;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
background-color: $ui-background;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
height: calc(var(--desktop-workspace-window-height) - 7rem - 2px); // 7rem patient banner, plus border
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.grid {
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.visitTile {
|
|
18
|
+
margin: spacing.$spacing-05 0;
|
|
19
|
+
|
|
20
|
+
&:global(.cds--tile--is-selected:focus) {
|
|
21
|
+
background-color: $color-blue-10;
|
|
22
|
+
color: $color-blue-10;
|
|
23
|
+
border: 1px solid $color-blue-60-2;
|
|
24
|
+
outline: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:global(.cds--tile--is-selected:hover) {
|
|
28
|
+
background-color: $color-blue-10;
|
|
29
|
+
color: $color-blue-10;
|
|
30
|
+
border: 1px solid $color-blue-60-2;
|
|
31
|
+
outline: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:global(.cds--tile--is-selected:hover .cds--tile__checkmark svg) {
|
|
35
|
+
fill: $color-blue-60-2;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.recentlyScheduledVisitsContainer {
|
|
40
|
+
margin-top: spacing.$spacing-06;
|
|
41
|
+
margin-bottom: spacing.$spacing-10;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.row {
|
|
45
|
+
margin: 0 spacing.$spacing-05 spacing.$spacing-05 spacing.$spacing-05;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.backButton {
|
|
49
|
+
align-items: center;
|
|
50
|
+
display: flex;
|
|
51
|
+
justify-content: flex-start;
|
|
52
|
+
margin: spacing.$spacing-03 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
@include type.type-style('body-compact-01');
|
|
55
|
+
|
|
56
|
+
button {
|
|
57
|
+
display: flex;
|
|
58
|
+
|
|
59
|
+
svg {
|
|
60
|
+
order: 1;
|
|
61
|
+
margin-right: 0.5rem;
|
|
62
|
+
margin-left: 0rem !important;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
span {
|
|
66
|
+
order: 2;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.heading {
|
|
72
|
+
@include type.type-style('body-02');
|
|
73
|
+
color: $text-02;
|
|
74
|
+
margin-left: 1.2rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.primaryText {
|
|
78
|
+
@include type.type-style('heading-compact-02');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.secondaryText {
|
|
82
|
+
@include type.type-style('body-01');
|
|
83
|
+
color: $text-02;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.button {
|
|
87
|
+
height: 4rem;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-content: flex-start;
|
|
90
|
+
align-items: baseline;
|
|
91
|
+
min-width: 50%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.text-divider {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
margin: spacing.$spacing-08 25%;
|
|
98
|
+
@include type.type-style('heading-03');
|
|
99
|
+
color: $text-02;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.text-divider::before,
|
|
103
|
+
.text-divider::after {
|
|
104
|
+
content: '';
|
|
105
|
+
height: 1px;
|
|
106
|
+
background-color: $text-03;
|
|
107
|
+
flex-grow: 1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.text-divider::before {
|
|
111
|
+
margin-right: spacing.$spacing-05;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.text-divider::after {
|
|
115
|
+
margin-left: spacing.$spacing-05;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.buttonContainer {
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
margin-bottom: spacing.$spacing-03;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.prioritySwitcher {
|
|
126
|
+
margin: spacing.$spacing-03 0 spacing.$spacing-03;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.emptyAppointment {
|
|
130
|
+
margin: spacing.$spacing-05;
|
|
131
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { screen } from '@testing-library/react';
|
|
3
|
+
import { renderWithSwr } from 'tools';
|
|
4
|
+
import { mockLocations, mockPatient, mockPatientsVisits, mockSession } from '__mocks__';
|
|
5
|
+
import { type ConfigObject, useConfig } from '@openmrs/esm-framework';
|
|
6
|
+
import PatientScheduledVisits from './patient-scheduled-visits.component';
|
|
7
|
+
|
|
8
|
+
const mockedUseConfig = useConfig as jest.Mock;
|
|
9
|
+
const mockToggleSearchType = jest.fn();
|
|
10
|
+
|
|
11
|
+
const testProps = {
|
|
12
|
+
appointments: { recentVisits: mockPatientsVisits.recentVisits, futureVisits: [] },
|
|
13
|
+
toggleSearchType: mockToggleSearchType,
|
|
14
|
+
patientUuid: mockPatient.uuid,
|
|
15
|
+
closePanel: () => false,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
jest.mock('@openmrs/esm-framework', () => {
|
|
19
|
+
const originalModule = jest.requireActual('@openmrs/esm-framework');
|
|
20
|
+
return {
|
|
21
|
+
...originalModule,
|
|
22
|
+
openmrsFetch: jest.fn(),
|
|
23
|
+
useLocations: jest.fn().mockImplementation(() => mockLocations.data),
|
|
24
|
+
useSession: jest.fn().mockImplementation(() => mockSession.data),
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
describe('ScheduledVisits', () => {
|
|
28
|
+
beforeEach(() =>
|
|
29
|
+
mockedUseConfig.mockReturnValue({
|
|
30
|
+
concepts: {},
|
|
31
|
+
} as ConfigObject),
|
|
32
|
+
);
|
|
33
|
+
it('should display recent and future scheduled visits', async () => {
|
|
34
|
+
renderPatientScheduledVisits();
|
|
35
|
+
|
|
36
|
+
expect(screen.getByText(/Cardiology Consultation 1/i)).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByText(/08-Aug-2022, 02:56 PM · 10 Engineer VCT/i)).toBeInTheDocument();
|
|
38
|
+
expect(screen.getByText(/No appointments found/i)).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function renderPatientScheduledVisits() {
|
|
43
|
+
renderWithSwr(<PatientScheduledVisits {...testProps} />);
|
|
44
|
+
}
|