@openmrs/esm-service-queues-app 5.0.1-pre.2087
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +40 -0
- package/LICENSE.md +401 -0
- package/README.md +23 -0
- package/__mocks__/active-visits.mock.ts +97 -0
- package/__mocks__/appointments-data.mock.ts +283 -0
- package/__mocks__/search.mock.ts +35 -0
- package/__mocks__/visits.mock.ts +42 -0
- package/dist/121.js +1 -0
- package/dist/121.js.map +1 -0
- package/dist/130.js +2 -0
- package/dist/130.js.LICENSE.txt +5 -0
- package/dist/130.js.map +1 -0
- package/dist/176.js +1 -0
- package/dist/176.js.map +1 -0
- package/dist/227.js +1 -0
- package/dist/227.js.map +1 -0
- package/dist/242.js +1 -0
- package/dist/242.js.map +1 -0
- package/dist/252.js +1 -0
- package/dist/252.js.map +1 -0
- package/dist/286.js +1 -0
- package/dist/286.js.map +1 -0
- package/dist/308.js +1 -0
- package/dist/308.js.map +1 -0
- package/dist/319.js +1 -0
- package/dist/328.js +1 -0
- package/dist/328.js.map +1 -0
- package/dist/330.js +1 -0
- package/dist/330.js.map +1 -0
- package/dist/364.js +1 -0
- package/dist/364.js.map +1 -0
- package/dist/425.js +1 -0
- package/dist/425.js.map +1 -0
- package/dist/457.js +1 -0
- package/dist/457.js.map +1 -0
- package/dist/469.js +1 -0
- package/dist/469.js.map +1 -0
- package/dist/521.js +1 -0
- package/dist/521.js.map +1 -0
- package/dist/53.js +1 -0
- package/dist/53.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/591.js +2 -0
- package/dist/591.js.LICENSE.txt +32 -0
- package/dist/591.js.map +1 -0
- package/dist/610.js +1 -0
- package/dist/610.js.map +1 -0
- package/dist/611.js +1 -0
- package/dist/611.js.map +1 -0
- package/dist/616.js +1 -0
- package/dist/616.js.map +1 -0
- package/dist/644.js +1 -0
- package/dist/644.js.map +1 -0
- package/dist/670.js +2 -0
- package/dist/670.js.LICENSE.txt +57 -0
- package/dist/670.js.map +1 -0
- package/dist/733.js +1 -0
- package/dist/733.js.map +1 -0
- package/dist/757.js +1 -0
- package/dist/764.js +1 -0
- package/dist/764.js.map +1 -0
- package/dist/766.js +1 -0
- package/dist/766.js.map +1 -0
- package/dist/784.js +2 -0
- package/dist/784.js.LICENSE.txt +9 -0
- package/dist/784.js.map +1 -0
- package/dist/788.js +1 -0
- package/dist/807.js +1 -0
- package/dist/833.js +1 -0
- package/dist/86.js +1 -0
- package/dist/86.js.map +1 -0
- package/dist/981.js +1 -0
- package/dist/981.js.map +1 -0
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-service-queues-app.js +1 -0
- package/dist/openmrs-esm-service-queues-app.js.buildmanifest.json +930 -0
- package/dist/openmrs-esm-service-queues-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.js +3 -0
- package/package.json +53 -0
- package/src/active-visits/active-visits-tab.component.tsx +71 -0
- package/src/active-visits/active-visits-tab.test.tsx +19 -0
- package/src/active-visits/active-visits-table.component.tsx +543 -0
- package/src/active-visits/active-visits-table.resource.ts +443 -0
- package/src/active-visits/active-visits-table.scss +271 -0
- package/src/active-visits/active-visits-table.test.tsx +131 -0
- package/src/active-visits/change-status-dialog.component.tsx +233 -0
- package/src/active-visits/change-status-dialog.scss +32 -0
- package/src/active-visits/change-status-dialog.test.tsx +107 -0
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +218 -0
- package/src/add-patient-toqueue/add-patient-toqueue-dialog.scss +32 -0
- package/src/add-provider-queue-room/add-provider-queue-room.component.tsx +236 -0
- package/src/add-provider-queue-room/add-provider-queue-room.resource.tsx +76 -0
- package/src/add-provider-queue-room/add-provider-queue-room.scss +17 -0
- package/src/add-provider-queue-room/add-provider-queue-room.test.tsx +98 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +74 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx +46 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +15 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +42 -0
- package/src/clear-queue-entries-dialog/clear-queue-entries.component.tsx +36 -0
- package/src/config-schema.ts +177 -0
- package/src/constants.ts +7 -0
- package/src/createDashboardLink.tsx +35 -0
- package/src/current-visit/current-visit-summary.component.tsx +38 -0
- package/src/current-visit/current-visit-summary.test.tsx +47 -0
- package/src/current-visit/current-visit.resource.ts +84 -0
- package/src/current-visit/current-visit.scss +34 -0
- package/src/current-visit/hooks/useVitalsConceptMetadata.tsx +101 -0
- package/src/current-visit/visit-details/biometrics-config-schema.ts +14 -0
- package/src/current-visit/visit-details/current-visit-details.component.tsx +96 -0
- package/src/current-visit/visit-details/triage-note.component.tsx +53 -0
- package/src/current-visit/visit-details/triage-note.scss +89 -0
- package/src/current-visit/visit-details/vitals-config-schema.ts +17 -0
- package/src/current-visit/visit-details/vitals.component.tsx +164 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +2 -0
- package/src/helpers/functions.ts +67 -0
- package/src/helpers/helpers.ts +170 -0
- package/src/helpers/time-helpers.ts +15 -0
- package/src/home.component.tsx +29 -0
- package/src/home.test.tsx +58 -0
- package/src/index.ts +100 -0
- package/src/overlay.component.tsx +46 -0
- package/src/overlay.scss +96 -0
- package/src/overlay.test.tsx +49 -0
- package/src/past-visit/past-visit-details/encounter-list.component.tsx +51 -0
- package/src/past-visit/past-visit-details/medications-list.component.tsx +95 -0
- package/src/past-visit/past-visit-details/notes-list.component.tsx +40 -0
- package/src/past-visit/past-visit-details/past-visit-summary.component.tsx +172 -0
- package/src/past-visit/past-visit-details/past-visit-summary.scss +58 -0
- package/src/past-visit/past-visit.component.tsx +37 -0
- package/src/past-visit/past-visit.resource.ts +83 -0
- package/src/past-visit/past-visit.scss +126 -0
- package/src/past-visit/past-visit.test.tsx +41 -0
- package/src/patient-info/appointment-details.component.tsx +98 -0
- package/src/patient-info/appointment-details.scss +34 -0
- package/src/patient-info/appointment-details.test.tsx +36 -0
- package/src/patient-info/appointments.resource.tsx +43 -0
- package/src/patient-info/contact-details.component.tsx +71 -0
- package/src/patient-info/contact-details.scss +31 -0
- package/src/patient-info/contact-details.test.tsx +94 -0
- package/src/patient-info/hooks/usePatientAttributes.tsx +42 -0
- package/src/patient-info/patient-info.component.tsx +78 -0
- package/src/patient-info/patient-info.scss +60 -0
- package/src/patient-info/patient-info.test.tsx +45 -0
- package/src/patient-queue-header/patient-queue-header.component.tsx +64 -0
- package/src/patient-queue-header/patient-queue-header.scss +88 -0
- package/src/patient-queue-header/patient-queue-illustration.component.tsx +22 -0
- package/src/patient-queue-metrics/clinic-metrics.component.tsx +93 -0
- package/src/patient-queue-metrics/clinic-metrics.resource.tsx +51 -0
- package/src/patient-queue-metrics/clinic-metrics.scss +11 -0
- package/src/patient-queue-metrics/clinic-metrics.test.tsx +87 -0
- package/src/patient-queue-metrics/metrics-card.component.tsx +64 -0
- package/src/patient-queue-metrics/metrics-card.scss +80 -0
- package/src/patient-queue-metrics/metrics-header.component.tsx +74 -0
- package/src/patient-queue-metrics/metrics-header.scss +22 -0
- package/src/patient-queue-metrics/queue-metrics.resource.ts +54 -0
- package/src/patient-search/advanced-search.component.tsx +190 -0
- package/src/patient-search/advanced-search.scss +154 -0
- package/src/patient-search/advanced-search.test.tsx +29 -0
- package/src/patient-search/basic-search.component.tsx +112 -0
- package/src/patient-search/basic-search.scss +139 -0
- package/src/patient-search/basic-search.test.tsx +23 -0
- package/src/patient-search/empty-data-illustration.component.tsx +41 -0
- package/src/patient-search/hooks/useActivePatientEnrollment.tsx +29 -0
- package/src/patient-search/hooks/useDefaultLocation.tsx +14 -0
- package/src/patient-search/hooks/usePatients.tsx +25 -0
- package/src/patient-search/hooks/useQueueLocations.tsx +20 -0
- package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +36 -0
- package/src/patient-search/hooks/useScheduledVisits.tsx +50 -0
- package/src/patient-search/patient-scheduled-visits.component.tsx +350 -0
- package/src/patient-search/patient-scheduled-visits.scss +131 -0
- package/src/patient-search/patient-scheduled-visits.test.tsx +55 -0
- package/src/patient-search/patient-search.component.tsx +64 -0
- package/src/patient-search/search-illustration.component.tsx +27 -0
- package/src/patient-search/search-results.component.tsx +75 -0
- package/src/patient-search/search-results.scss +80 -0
- package/src/patient-search/search-results.test.tsx +77 -0
- package/src/patient-search/search.resource.ts +10 -0
- package/src/patient-search/visit-form/base-visit-type.component.tsx +82 -0
- package/src/patient-search/visit-form/base-visit-type.scss +100 -0
- package/src/patient-search/visit-form/base-visit-type.test.tsx +41 -0
- package/src/patient-search/visit-form/queue.resource.ts +73 -0
- package/src/patient-search/visit-form/recommended-visit-type.component.tsx +38 -0
- package/src/patient-search/visit-form/visit-form.component.tsx +366 -0
- package/src/patient-search/visit-form/visit-form.scss +96 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx +160 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.scss +21 -0
- package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx +67 -0
- package/src/queue-entry-table-components/actions-menu.component.tsx +51 -0
- package/src/queue-entry-table-components/actions-menu.scss +3 -0
- package/src/queue-entry-table-components/edit-entry.component.tsx +28 -0
- package/src/queue-entry-table-components/edit-entry.scss +14 -0
- package/src/queue-entry-table-components/open-chart.component.tsx +33 -0
- package/src/queue-entry-table-components/open-chart.resource.tsx +14 -0
- package/src/queue-entry-table-components/open-chart.scss +14 -0
- package/src/queue-entry-table-components/status-icon.component.tsx +17 -0
- package/src/queue-entry-table-components/transition-entry.component.tsx +53 -0
- package/src/queue-entry-table-components/transition-entry.scss +22 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +230 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.scss +110 -0
- package/src/queue-patient-linelists/queue-linelist-base-table.test.tsx +118 -0
- package/src/queue-patient-linelists/queue-linelist-filter.component.tsx +172 -0
- package/src/queue-patient-linelists/queue-linelist-filter.scss +63 -0
- package/src/queue-patient-linelists/queue-linelist-filter.test.tsx +76 -0
- package/src/queue-patient-linelists/queue-linelist.component.tsx +29 -0
- package/src/queue-patient-linelists/queue-linelist.resource.tsx +84 -0
- package/src/queue-patient-linelists/queue-linelist.test.tsx +22 -0
- package/src/queue-patient-linelists/queue-services-table.component.tsx +63 -0
- package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +300 -0
- package/src/queue-patient-linelists/scheduled-appointments-table.test.tsx +42 -0
- package/src/queue-rooms/queue-room-form.component.tsx +168 -0
- package/src/queue-rooms/queue-room-form.test.tsx +65 -0
- package/src/queue-rooms/queue-room.resource.tsx +20 -0
- package/src/queue-rooms/queue-room.scss +58 -0
- package/src/queue-screen/queue-screen.component.tsx +47 -0
- package/src/queue-screen/queue-screen.scss +39 -0
- package/src/queue-screen/queue-screen.test.tsx +47 -0
- package/src/queue-screen/useActiveTickets.tsx +13 -0
- package/src/queue-services/queue-service-form.component.tsx +183 -0
- package/src/queue-services/queue-service-form.test.tsx +56 -0
- package/src/queue-services/queue-service.resource.tsx +38 -0
- package/src/queue-services/queue-service.scss +54 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +95 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.resource.tsx +93 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.scss +8 -0
- package/src/remove-queue-entry-dialog/remove-queue-entry.test.tsx +44 -0
- package/src/root.component.tsx +28 -0
- package/src/root.scss +15 -0
- package/src/root.test.tsx +28 -0
- package/src/routes.json +91 -0
- package/src/side-menu/nav-group/createNavGroup.tsx +17 -0
- package/src/side-menu/nav-group/nav-group.component.tsx +24 -0
- package/src/side-menu/nav-group/nav-group.test.tsx +32 -0
- package/src/side-menu/nav-group/nav-group.ts +10 -0
- package/src/side-menu/side-menu.component.tsx +6 -0
- package/src/side-menu/side-menu.test.tsx +17 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +174 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.scss +12 -0
- package/src/transition-queue-entry/transition-queue-entry-dialog.test.tsx +95 -0
- package/src/transition-queue-entry/transition-queue-entry.resource.ts +16 -0
- package/src/types/index.ts +434 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +298 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +93 -0
- package/src/visits-missing-inqueue/visits-missing-inqueue.scss +108 -0
- package/translations/am.json +258 -0
- package/translations/en.json +258 -0
- package/translations/es.json +258 -0
- package/translations/fr.json +258 -0
- package/translations/he.json +262 -0
- package/translations/km.json +258 -0
- package/tsconfig.json +5 -0
- package/webpack.config.js +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
4
|
+
|
|
5
|
+
.visitTypeOverviewWrapper {
|
|
6
|
+
margin: spacing.$spacing-05 0rem;
|
|
7
|
+
border: 0.0625rem solid $grey-2;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.tablet {
|
|
11
|
+
background-color: $ui-02;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.desktop {
|
|
15
|
+
background-color: $ui-01;
|
|
16
|
+
|
|
17
|
+
.paginationContainer div {
|
|
18
|
+
background-color: $ui-01;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.visitTypeOverviewWrapper div:nth-child(3) > div:nth-child(2) {
|
|
23
|
+
position: relative;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.visitTypeOverviewWrapper div:nth-child(3) span * {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.radioButtonGroup {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
margin-top: spacing.$spacing-03;
|
|
35
|
+
min-height: spacing.$spacing-10;
|
|
36
|
+
width: 100%;
|
|
37
|
+
@include type.type-style('body-compact-01');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.radioButton {
|
|
41
|
+
padding: spacing.$spacing-02 spacing.$spacing-05;
|
|
42
|
+
margin: spacing.$spacing-03 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.content {
|
|
46
|
+
@include type.type-style('heading-compact-01');
|
|
47
|
+
color: $text-02;
|
|
48
|
+
margin-top: spacing.$spacing-05;
|
|
49
|
+
margin-bottom: spacing.$spacing-03;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.desktopHeading {
|
|
53
|
+
h4 {
|
|
54
|
+
@include type.type-style('heading-compact-02');
|
|
55
|
+
color: $text-02;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.tabletHeading {
|
|
60
|
+
h4 {
|
|
61
|
+
@include type.type-style('heading-03');
|
|
62
|
+
color: $text-02;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.desktopHeading,
|
|
67
|
+
.tabletHeading {
|
|
68
|
+
text-align: left;
|
|
69
|
+
text-transform: capitalize;
|
|
70
|
+
margin-bottom: spacing.$spacing-05;
|
|
71
|
+
|
|
72
|
+
h4:after {
|
|
73
|
+
content: '';
|
|
74
|
+
display: block;
|
|
75
|
+
width: 2rem;
|
|
76
|
+
padding-top: 0.188rem;
|
|
77
|
+
border-bottom: 0.375rem solid var(--brand-03);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.heading:after {
|
|
82
|
+
content: '';
|
|
83
|
+
display: block;
|
|
84
|
+
width: 2rem;
|
|
85
|
+
padding-top: 0.188rem;
|
|
86
|
+
border-bottom: 0.375rem solid var(--brand-03);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.tile {
|
|
90
|
+
text-align: center;
|
|
91
|
+
border: 1px solid $ui-03;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Overriding styles for RTL support
|
|
95
|
+
html[dir='rtl'] {
|
|
96
|
+
.desktopHeading,
|
|
97
|
+
.tabletHeading {
|
|
98
|
+
text-align: right;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import BaseVisitType from './base-visit-type.component';
|
|
4
|
+
import { mockVisitTypes } from '../../../__mocks__/visits.mock';
|
|
5
|
+
|
|
6
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
|
7
|
+
useLayoutType: () => 'desktop',
|
|
8
|
+
usePagination: jest.fn(() => ({ results: mockVisitTypes, currentPage: 1, goTo: jest.fn() })),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
describe('BaseVisitType', () => {
|
|
12
|
+
it('renders visit types correctly', () => {
|
|
13
|
+
render(<BaseVisitType onChange={() => {}} visitTypes={mockVisitTypes} />);
|
|
14
|
+
|
|
15
|
+
const searchInput = screen.getByRole('searchbox');
|
|
16
|
+
expect(searchInput).toBeInTheDocument();
|
|
17
|
+
|
|
18
|
+
mockVisitTypes.forEach((visitType) => {
|
|
19
|
+
const radioButton = screen.getByLabelText(visitType.display);
|
|
20
|
+
expect(radioButton).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('handles search input correctly', () => {
|
|
25
|
+
render(<BaseVisitType onChange={() => {}} visitTypes={mockVisitTypes} />);
|
|
26
|
+
|
|
27
|
+
const searchInput: HTMLInputElement = screen.getByRole('searchbox');
|
|
28
|
+
fireEvent.change(searchInput, { target: { value: 'Visit Type 1' } });
|
|
29
|
+
|
|
30
|
+
expect(searchInput.value).toBe('Visit Type 1');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('calls onChange when a visit type is selected', () => {
|
|
34
|
+
const mockOnChange = jest.fn();
|
|
35
|
+
render(<BaseVisitType onChange={mockOnChange} visitTypes={mockVisitTypes} />);
|
|
36
|
+
|
|
37
|
+
const radioButton: HTMLInputElement = screen.getByLabelText(mockVisitTypes[0].display);
|
|
38
|
+
fireEvent.click(radioButton);
|
|
39
|
+
expect(radioButton.checked).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { openmrsFetch, toDateObjectStrict, toOmrsIsoString } from '@openmrs/esm-framework';
|
|
2
|
+
import { generateVisitQueueNumber } from '../../active-visits/active-visits-table.resource';
|
|
3
|
+
import { Appointment } from '../../types';
|
|
4
|
+
|
|
5
|
+
export async function addQueueEntry(
|
|
6
|
+
visitUuid: string,
|
|
7
|
+
patientUuid: string,
|
|
8
|
+
priority: string,
|
|
9
|
+
status: string,
|
|
10
|
+
queueServiceUuid: string,
|
|
11
|
+
appointment: Appointment,
|
|
12
|
+
|
|
13
|
+
locationUuid: string,
|
|
14
|
+
visitQueueNumberAttributeUuid: string,
|
|
15
|
+
) {
|
|
16
|
+
const abortController = new AbortController();
|
|
17
|
+
|
|
18
|
+
await Promise.all([
|
|
19
|
+
saveAppointment(appointment),
|
|
20
|
+
generateVisitQueueNumber(locationUuid, visitUuid, queueServiceUuid, visitQueueNumberAttributeUuid),
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
return openmrsFetch(`/ws/rest/v1/visit-queue-entry`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
signal: abortController.signal,
|
|
29
|
+
body: {
|
|
30
|
+
visit: { uuid: visitUuid },
|
|
31
|
+
queueEntry: {
|
|
32
|
+
status: {
|
|
33
|
+
uuid: status,
|
|
34
|
+
},
|
|
35
|
+
priority: {
|
|
36
|
+
uuid: priority,
|
|
37
|
+
},
|
|
38
|
+
queue: {
|
|
39
|
+
uuid: queueServiceUuid,
|
|
40
|
+
},
|
|
41
|
+
patient: {
|
|
42
|
+
uuid: patientUuid,
|
|
43
|
+
},
|
|
44
|
+
startedAt: toDateObjectStrict(toOmrsIsoString(new Date())),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function saveAppointment(appointment: Appointment) {
|
|
51
|
+
const abortController = new AbortController();
|
|
52
|
+
|
|
53
|
+
await openmrsFetch(`/ws/rest/v1/appointment`, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
signal: abortController.signal,
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
},
|
|
59
|
+
body: {
|
|
60
|
+
patientUuid: appointment?.patient.uuid,
|
|
61
|
+
serviceUuid: appointment?.service?.uuid,
|
|
62
|
+
startDateTime: appointment?.startDateTime,
|
|
63
|
+
endDateTime: appointment?.endDateTime,
|
|
64
|
+
appointmentKind: appointment?.appointmentKind,
|
|
65
|
+
locationUuid: appointment?.location?.uuid,
|
|
66
|
+
comments: appointment?.comments,
|
|
67
|
+
status: 'CheckedIn',
|
|
68
|
+
appointmentNumber: appointment?.appointmentNumber,
|
|
69
|
+
uuid: appointment?.uuid,
|
|
70
|
+
providerUuid: appointment?.provider?.uuid,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StructuredListSkeleton } from '@carbon/react';
|
|
3
|
+
import { useRecommendedVisitTypes } from '../hooks/useRecommendedVisitTypes';
|
|
4
|
+
import BaseVisitType from './base-visit-type.component';
|
|
5
|
+
import { PatientProgram } from '../../types';
|
|
6
|
+
|
|
7
|
+
interface RecommendedVisitTypeProp {
|
|
8
|
+
patientUuid: string;
|
|
9
|
+
patientProgramEnrollment: PatientProgram;
|
|
10
|
+
onChange: (visitTypeUuid) => void;
|
|
11
|
+
locationUuid: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const RecommendedVisitType: React.FC<RecommendedVisitTypeProp> = ({
|
|
15
|
+
patientUuid,
|
|
16
|
+
patientProgramEnrollment,
|
|
17
|
+
onChange,
|
|
18
|
+
locationUuid,
|
|
19
|
+
}) => {
|
|
20
|
+
const { recommendedVisitTypes, error, isLoading } = useRecommendedVisitTypes(
|
|
21
|
+
patientUuid,
|
|
22
|
+
patientProgramEnrollment?.uuid,
|
|
23
|
+
patientProgramEnrollment?.program?.uuid,
|
|
24
|
+
locationUuid,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div style={{ marginTop: '0.625rem' }}>
|
|
29
|
+
{isLoading ? (
|
|
30
|
+
<StructuredListSkeleton />
|
|
31
|
+
) : (
|
|
32
|
+
<BaseVisitType onChange={onChange} visitTypes={recommendedVisitTypes} patientUuid={patientUuid} />
|
|
33
|
+
)}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const MemoizedRecommendedVisitType = React.memo(RecommendedVisitType);
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import React, { useEffect, useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { first } from 'rxjs/operators';
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
ButtonSet,
|
|
7
|
+
ContentSwitcher,
|
|
8
|
+
DatePicker,
|
|
9
|
+
DatePickerInput,
|
|
10
|
+
Form,
|
|
11
|
+
InlineNotification,
|
|
12
|
+
Layer,
|
|
13
|
+
Row,
|
|
14
|
+
Select,
|
|
15
|
+
SelectItem,
|
|
16
|
+
Stack,
|
|
17
|
+
Switch,
|
|
18
|
+
TimePicker,
|
|
19
|
+
TimePickerSelect,
|
|
20
|
+
FormGroup,
|
|
21
|
+
RadioButton,
|
|
22
|
+
RadioButtonGroup,
|
|
23
|
+
} from '@carbon/react';
|
|
24
|
+
import { ArrowLeft } from '@carbon/react/icons';
|
|
25
|
+
import { useTranslation } from 'react-i18next';
|
|
26
|
+
import {
|
|
27
|
+
useLocations,
|
|
28
|
+
useSession,
|
|
29
|
+
ExtensionSlot,
|
|
30
|
+
useLayoutType,
|
|
31
|
+
useVisitTypes,
|
|
32
|
+
saveVisit,
|
|
33
|
+
toOmrsIsoString,
|
|
34
|
+
toDateObjectStrict,
|
|
35
|
+
showNotification,
|
|
36
|
+
showToast,
|
|
37
|
+
useConfig,
|
|
38
|
+
ConfigObject,
|
|
39
|
+
} from '@openmrs/esm-framework';
|
|
40
|
+
import BaseVisitType from './base-visit-type.component';
|
|
41
|
+
import { addQueueEntry, useVisitQueueEntries } from '../../active-visits/active-visits-table.resource';
|
|
42
|
+
import { convertTime12to24, amPm } from '../../helpers/time-helpers';
|
|
43
|
+
import { MemoizedRecommendedVisitType } from './recommended-visit-type.component';
|
|
44
|
+
import { useActivePatientEnrollment } from '../hooks/useActivePatientEnrollment';
|
|
45
|
+
import { SearchTypes, PatientProgram, NewVisitPayload } from '../../types';
|
|
46
|
+
import styles from './visit-form.scss';
|
|
47
|
+
import { useDefaultLoginLocation } from '../hooks/useDefaultLocation';
|
|
48
|
+
import isEmpty from 'lodash-es/isEmpty';
|
|
49
|
+
|
|
50
|
+
interface VisitFormProps {
|
|
51
|
+
toggleSearchType: (searchMode: SearchTypes, patientUuid) => void;
|
|
52
|
+
patientUuid: string;
|
|
53
|
+
closePanel: () => void;
|
|
54
|
+
mode: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const StartVisitForm: React.FC<VisitFormProps> = ({ patientUuid, toggleSearchType, closePanel, mode }) => {
|
|
58
|
+
const { t } = useTranslation();
|
|
59
|
+
const isTablet = useLayoutType() === 'tablet';
|
|
60
|
+
const locations = useLocations();
|
|
61
|
+
const sessionUser = useSession();
|
|
62
|
+
const { defaultFacility, isLoading: loadingDefaultFacility } = useDefaultLoginLocation();
|
|
63
|
+
|
|
64
|
+
const config = useConfig() as ConfigObject;
|
|
65
|
+
const [contentSwitcherIndex, setContentSwitcherIndex] = useState(config.showRecommendedVisitTypeTab ? 0 : 1);
|
|
66
|
+
const [isMissingVisitType, setIsMissingVisitType] = useState(false);
|
|
67
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
68
|
+
const [timeFormat, setTimeFormat] = useState<amPm>(new Date().getHours() >= 12 ? 'PM' : 'AM');
|
|
69
|
+
const [visitDate, setVisitDate] = useState(new Date());
|
|
70
|
+
const [visitTime, setVisitTime] = useState(dayjs(new Date()).format('hh:mm'));
|
|
71
|
+
const state = useMemo(() => ({ patientUuid }), [patientUuid]);
|
|
72
|
+
const allVisitTypes = useVisitTypes();
|
|
73
|
+
const [ignoreChanges, setIgnoreChanges] = useState(true);
|
|
74
|
+
const { activePatientEnrollment, isLoading } = useActivePatientEnrollment(patientUuid);
|
|
75
|
+
const [enrollment, setEnrollment] = useState<PatientProgram>(activePatientEnrollment[0]);
|
|
76
|
+
const { mutate } = useVisitQueueEntries('', '');
|
|
77
|
+
const visitQueueNumberAttributeUuid = config.concepts.visitQueueNumberAttributeUuid;
|
|
78
|
+
const [selectedLocation, setSelectedLocation] = useState('');
|
|
79
|
+
const [visitType, setVisitType] = useState('');
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (locations?.length && sessionUser) {
|
|
83
|
+
setSelectedLocation(sessionUser?.sessionLocation?.uuid);
|
|
84
|
+
setVisitType(allVisitTypes?.length > 0 ? allVisitTypes[0].uuid : null);
|
|
85
|
+
} else if (!loadingDefaultFacility && defaultFacility) {
|
|
86
|
+
setSelectedLocation(defaultFacility?.uuid);
|
|
87
|
+
setVisitType(allVisitTypes?.length > 0 ? allVisitTypes[0].uuid : null);
|
|
88
|
+
}
|
|
89
|
+
}, [locations, sessionUser, loadingDefaultFacility]);
|
|
90
|
+
|
|
91
|
+
const handleSubmit = useCallback(
|
|
92
|
+
(event) => {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
|
|
95
|
+
// retrieve values from queue extension
|
|
96
|
+
const queueLocation = event?.target['queueLocation']?.value;
|
|
97
|
+
const serviceUuid = event?.target['service']?.value;
|
|
98
|
+
const priority = event?.target['priority']?.value;
|
|
99
|
+
const status = event?.target['status']?.value;
|
|
100
|
+
const sortWeight = event?.target['sortWeight']?.value;
|
|
101
|
+
|
|
102
|
+
if (!visitType) {
|
|
103
|
+
setIsMissingVisitType(true);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setIsSubmitting(true);
|
|
108
|
+
|
|
109
|
+
const [hours, minutes] = convertTime12to24(visitTime, timeFormat);
|
|
110
|
+
|
|
111
|
+
const payload: NewVisitPayload = {
|
|
112
|
+
patient: patientUuid,
|
|
113
|
+
startDatetime: toDateObjectStrict(
|
|
114
|
+
toOmrsIsoString(
|
|
115
|
+
new Date(dayjs(visitDate).year(), dayjs(visitDate).month(), dayjs(visitDate).date(), hours, minutes),
|
|
116
|
+
),
|
|
117
|
+
),
|
|
118
|
+
visitType: visitType,
|
|
119
|
+
location: selectedLocation,
|
|
120
|
+
attributes: [],
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const abortController = new AbortController();
|
|
124
|
+
|
|
125
|
+
saveVisit(payload, abortController)
|
|
126
|
+
.pipe(first())
|
|
127
|
+
.subscribe(
|
|
128
|
+
(response) => {
|
|
129
|
+
if (response.status === 201) {
|
|
130
|
+
// add new queue entry if visit created successfully
|
|
131
|
+
addQueueEntry(
|
|
132
|
+
response.data.uuid,
|
|
133
|
+
serviceUuid,
|
|
134
|
+
patientUuid,
|
|
135
|
+
priority,
|
|
136
|
+
status,
|
|
137
|
+
sortWeight,
|
|
138
|
+
queueLocation,
|
|
139
|
+
visitQueueNumberAttributeUuid,
|
|
140
|
+
).then(
|
|
141
|
+
({ status }) => {
|
|
142
|
+
if (status === 201) {
|
|
143
|
+
showToast({
|
|
144
|
+
kind: 'success',
|
|
145
|
+
title: t('startVisit', 'Start a visit'),
|
|
146
|
+
description: t(
|
|
147
|
+
'startVisitQueueSuccessfully',
|
|
148
|
+
'Patient has been added to active visits list and queue.',
|
|
149
|
+
`${hours} : ${minutes}`,
|
|
150
|
+
),
|
|
151
|
+
});
|
|
152
|
+
closePanel();
|
|
153
|
+
mutate();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
(error) => {
|
|
157
|
+
showNotification({
|
|
158
|
+
title: t('queueEntryError', 'Error adding patient to the queue'),
|
|
159
|
+
kind: 'error',
|
|
160
|
+
critical: true,
|
|
161
|
+
description: error?.message,
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
(error) => {
|
|
168
|
+
showNotification({
|
|
169
|
+
title: t('startVisitError', 'Error starting visit'),
|
|
170
|
+
kind: 'error',
|
|
171
|
+
critical: true,
|
|
172
|
+
description: error?.message,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
[
|
|
178
|
+
closePanel,
|
|
179
|
+
mutate,
|
|
180
|
+
patientUuid,
|
|
181
|
+
selectedLocation,
|
|
182
|
+
t,
|
|
183
|
+
timeFormat,
|
|
184
|
+
visitDate,
|
|
185
|
+
visitQueueNumberAttributeUuid,
|
|
186
|
+
visitTime,
|
|
187
|
+
visitType,
|
|
188
|
+
],
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
const handleOnChange = () => {
|
|
192
|
+
setIgnoreChanges((prevState) => !prevState);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<Form className={styles.form} onChange={handleOnChange} onSubmit={handleSubmit}>
|
|
197
|
+
<div>
|
|
198
|
+
{isTablet && (
|
|
199
|
+
<Row className={styles.headerGridRow}>
|
|
200
|
+
<ExtensionSlot name="visit-form-header-slot" className={styles.dataGridRow} state={state} />
|
|
201
|
+
</Row>
|
|
202
|
+
)}
|
|
203
|
+
<div className={styles.backButton}>
|
|
204
|
+
{mode === true ? null : (
|
|
205
|
+
<Button
|
|
206
|
+
kind="ghost"
|
|
207
|
+
renderIcon={(props) => <ArrowLeft size={24} {...props} />}
|
|
208
|
+
iconDescription={t('backToScheduledVisits', 'Back to scheduled visits')}
|
|
209
|
+
size="sm"
|
|
210
|
+
onClick={() => toggleSearchType(SearchTypes.SCHEDULED_VISITS, patientUuid)}>
|
|
211
|
+
<span>{t('backToScheduledVisits', 'Back to scheduled visits')}</span>
|
|
212
|
+
</Button>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
<Stack gap={8} className={styles.container}>
|
|
216
|
+
<section className={styles.section}>
|
|
217
|
+
<div className={styles.sectionTitle}>{t('dateAndTimeOfVisit', 'Date and time of visit')}</div>
|
|
218
|
+
<div className={styles.dateTimeSection}>
|
|
219
|
+
<DatePicker
|
|
220
|
+
dateFormat="d/m/Y"
|
|
221
|
+
datePickerType="single"
|
|
222
|
+
id="visitDate"
|
|
223
|
+
style={{ paddingBottom: '1rem' }}
|
|
224
|
+
maxDate={new Date().toISOString()}
|
|
225
|
+
onChange={([date]) => setVisitDate(date)}
|
|
226
|
+
value={visitDate}>
|
|
227
|
+
<DatePickerInput
|
|
228
|
+
id="visitStartDateInput"
|
|
229
|
+
labelText={t('date', 'Date')}
|
|
230
|
+
placeholder="dd/mm/yyyy"
|
|
231
|
+
style={{ width: '100%' }}
|
|
232
|
+
/>
|
|
233
|
+
</DatePicker>
|
|
234
|
+
<ResponsiveWrapper isTablet={isTablet}>
|
|
235
|
+
<TimePicker
|
|
236
|
+
id="visitStartTime"
|
|
237
|
+
labelText={t('time', 'Time')}
|
|
238
|
+
onChange={(event) => setVisitTime(event.target.value as amPm)}
|
|
239
|
+
pattern="^(1[0-2]|0?[1-9]):([0-5]?[0-9])$"
|
|
240
|
+
style={{ marginLeft: '0.125rem', flex: 'none' }}
|
|
241
|
+
value={visitTime}>
|
|
242
|
+
<TimePickerSelect
|
|
243
|
+
id="visitStartTimeSelect"
|
|
244
|
+
onChange={(event) => setTimeFormat(event.target.value as amPm)}
|
|
245
|
+
value={timeFormat}
|
|
246
|
+
labelText={t('time', 'Time')}
|
|
247
|
+
aria-label={t('time', 'Time')}>
|
|
248
|
+
<SelectItem value="AM" text="AM" />
|
|
249
|
+
<SelectItem value="PM" text="PM" />
|
|
250
|
+
</TimePickerSelect>
|
|
251
|
+
</TimePicker>
|
|
252
|
+
</ResponsiveWrapper>
|
|
253
|
+
</div>
|
|
254
|
+
</section>
|
|
255
|
+
|
|
256
|
+
<section className={styles.section}>
|
|
257
|
+
<div className={styles.sectionTitle}>{t('facility', 'Facility')}</div>
|
|
258
|
+
<Select
|
|
259
|
+
labelText={t('selectFacility', 'Select a facility')}
|
|
260
|
+
id="location"
|
|
261
|
+
invalidText="Required"
|
|
262
|
+
value={selectedLocation}
|
|
263
|
+
defaultSelected={selectedLocation}
|
|
264
|
+
onChange={(event) => setSelectedLocation(event.target.value)}>
|
|
265
|
+
{!selectedLocation ? <SelectItem text={t('selectOption', 'Select an option')} value="" /> : null}
|
|
266
|
+
{!isEmpty(defaultFacility) ? (
|
|
267
|
+
<SelectItem key={defaultFacility?.uuid} text={defaultFacility?.display} value={defaultFacility?.uuid}>
|
|
268
|
+
{defaultFacility?.display}
|
|
269
|
+
</SelectItem>
|
|
270
|
+
) : locations?.length > 0 ? (
|
|
271
|
+
locations.map((location) => (
|
|
272
|
+
<SelectItem key={location.uuid} text={location.display} value={location.uuid}>
|
|
273
|
+
{location.display}
|
|
274
|
+
</SelectItem>
|
|
275
|
+
))
|
|
276
|
+
) : null}
|
|
277
|
+
</Select>
|
|
278
|
+
</section>
|
|
279
|
+
|
|
280
|
+
{config.showRecommendedVisitTypeTab && (
|
|
281
|
+
<section>
|
|
282
|
+
<div className={styles.sectionTitle}>{t('program', 'Program')}</div>
|
|
283
|
+
<FormGroup legendText={t('selectProgramType', 'Select program type')}>
|
|
284
|
+
<RadioButtonGroup
|
|
285
|
+
defaultSelected={enrollment?.program?.uuid}
|
|
286
|
+
orientation="vertical"
|
|
287
|
+
onChange={(uuid) =>
|
|
288
|
+
setEnrollment(activePatientEnrollment.find(({ program }) => program.uuid === uuid))
|
|
289
|
+
}
|
|
290
|
+
name="program-type-radio-group"
|
|
291
|
+
valueSelected="default-selected">
|
|
292
|
+
{activePatientEnrollment.map(({ uuid, display, program }) => (
|
|
293
|
+
<RadioButton
|
|
294
|
+
key={uuid}
|
|
295
|
+
className={styles.radioButton}
|
|
296
|
+
id={uuid}
|
|
297
|
+
labelText={display}
|
|
298
|
+
value={program.uuid}
|
|
299
|
+
/>
|
|
300
|
+
))}
|
|
301
|
+
</RadioButtonGroup>
|
|
302
|
+
</FormGroup>
|
|
303
|
+
</section>
|
|
304
|
+
)}
|
|
305
|
+
<section>
|
|
306
|
+
<div className={styles.sectionTitle}>{t('visitType', 'Visit Type')}</div>
|
|
307
|
+
<ContentSwitcher
|
|
308
|
+
selectedIndex={contentSwitcherIndex}
|
|
309
|
+
className={styles.contentSwitcher}
|
|
310
|
+
onChange={({ index }) => setContentSwitcherIndex(index)}>
|
|
311
|
+
<Switch name="recommended" text={t('recommended', 'Recommended')} />
|
|
312
|
+
<Switch name="all" text={t('all', 'All')} />
|
|
313
|
+
</ContentSwitcher>
|
|
314
|
+
{contentSwitcherIndex === 0 && !isLoading && (
|
|
315
|
+
<MemoizedRecommendedVisitType
|
|
316
|
+
onChange={(visitType) => {
|
|
317
|
+
setVisitType(visitType);
|
|
318
|
+
setIsMissingVisitType(false);
|
|
319
|
+
}}
|
|
320
|
+
patientUuid={patientUuid}
|
|
321
|
+
patientProgramEnrollment={enrollment}
|
|
322
|
+
locationUuid={selectedLocation}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
325
|
+
{contentSwitcherIndex === 1 && (
|
|
326
|
+
<BaseVisitType
|
|
327
|
+
onChange={(visitType) => {
|
|
328
|
+
setVisitType(visitType);
|
|
329
|
+
setIsMissingVisitType(false);
|
|
330
|
+
}}
|
|
331
|
+
visitTypes={allVisitTypes}
|
|
332
|
+
patientUuid={patientUuid}
|
|
333
|
+
/>
|
|
334
|
+
)}
|
|
335
|
+
</section>
|
|
336
|
+
{isMissingVisitType && (
|
|
337
|
+
<section>
|
|
338
|
+
<InlineNotification
|
|
339
|
+
style={{ margin: '0', minWidth: '100%' }}
|
|
340
|
+
kind="error"
|
|
341
|
+
lowContrast={true}
|
|
342
|
+
title={t('missingVisitType', 'Missing visit type')}
|
|
343
|
+
subtitle={t('selectVisitType', 'Please select a Visit Type')}
|
|
344
|
+
/>
|
|
345
|
+
</section>
|
|
346
|
+
)}
|
|
347
|
+
</Stack>
|
|
348
|
+
<ExtensionSlot name="add-queue-entry-slot" />
|
|
349
|
+
</div>
|
|
350
|
+
<ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
|
|
351
|
+
<Button className={styles.button} kind="secondary" onClick={closePanel}>
|
|
352
|
+
{t('discard', 'Discard')}
|
|
353
|
+
</Button>
|
|
354
|
+
<Button className={styles.button} disabled={isSubmitting} kind="primary" type="submit">
|
|
355
|
+
{t('startVisit', 'Start visit')}
|
|
356
|
+
</Button>
|
|
357
|
+
</ButtonSet>
|
|
358
|
+
</Form>
|
|
359
|
+
);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
function ResponsiveWrapper({ children, isTablet }) {
|
|
363
|
+
return isTablet ? <Layer>{children}</Layer> : <div>{children}</div>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export default StartVisitForm;
|