@kenyaemr/esm-appointments-app 8.1.1-pre.123 → 8.1.1-pre.124
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 +1 -1
- package/dist/130.js +1 -1
- package/dist/130.js.map +1 -1
- package/dist/529.js +1 -1
- package/dist/529.js.map +1 -1
- package/dist/574.js +1 -1
- package/dist/711.js +1 -1
- package/dist/711.js.map +1 -1
- package/dist/kenyaemr-esm-appointments-app.js +1 -1
- package/dist/kenyaemr-esm-appointments-app.js.buildmanifest.json +16 -16
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/appointments/common-components/end-appointment.modal.tsx +24 -27
- package/src/appointments/common-components/end-appointment.test.tsx +10 -4
- package/src/form/appointments-form.component.tsx +1 -1
- package/translations/en.json +1 -1
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"home-appointments","slot":"homepage-widgets-slot","component":"homeAppointments","order":1},{"name":"clinical-appointments-dashboard-link","slot":"homepage-dashboard-slot","component":"appointmentsDashboardLink","meta":{"name":"appointments","slot":"clinical-appointments-dashboard-slot","title":"Appointments"}},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"expected-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"checked-in-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"completed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"missed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"cancelled-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"early-appointments-panel","component":"earlyAppointments"},{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-appointments-dashboard-slot","title":"Appointments","path":"Appointments"}},{"name":"patientAppointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"upcoming-appointment-slot"},{"name":"edit-appointments-form","component":"appointmentsForm","meta":{"title":{"key":"editAppointment","default":"Edit Appointment"}}},{"name":"search-patient","component":"searchPatient"},{"name":"create-appointment","component":"appointmentsForm","meta":{"title":{"key":"appointmentForm","default":"Appointment Form"}}},{"name":"add-appointment","component":"appointmentsForm","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"patient-appointment-cancel-confirmation-dialog","component":"patientAppointmentsCancelConfirmationDialog"}],"version":"8.1.1-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"home-appointments","slot":"homepage-widgets-slot","component":"homeAppointments","order":1},{"name":"clinical-appointments-dashboard-link","slot":"homepage-dashboard-slot","component":"appointmentsDashboardLink","meta":{"name":"appointments","slot":"clinical-appointments-dashboard-slot","title":"Appointments"}},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"expected-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"checked-in-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"completed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"missed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"cancelled-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsList"},{"name":"early-appointments-panel","component":"earlyAppointments"},{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-appointments-dashboard-slot","title":"Appointments","path":"Appointments"}},{"name":"patientAppointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"upcoming-appointment-slot"},{"name":"edit-appointments-form","component":"appointmentsForm","meta":{"title":{"key":"editAppointment","default":"Edit Appointment"}}},{"name":"search-patient","component":"searchPatient"},{"name":"create-appointment","component":"appointmentsForm","meta":{"title":{"key":"appointmentForm","default":"Appointment Form"}}},{"name":"add-appointment","component":"appointmentsForm","meta":{"title":{"key":"createNewAppointment","default":"Create new appointment"}}},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"patient-appointment-cancel-confirmation-dialog","component":"patientAppointmentsCancelConfirmationDialog"}],"version":"8.1.1-pre.124"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import {
|
|
3
|
+
import { showSnackbar, updateVisit, useVisit } from '@openmrs/esm-framework';
|
|
4
4
|
import { Button, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
|
|
5
5
|
import { changeAppointmentStatus } from '../../patient-appointments/patient-appointments.resource';
|
|
6
6
|
import { useMutateAppointments } from '../../form/appointments-form.resource';
|
|
@@ -12,48 +12,43 @@ interface EndAppointmentModalProps {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const EndAppointmentModal: React.FC<EndAppointmentModalProps> = ({ patientUuid, appointmentUuid, closeModal }) => {
|
|
15
|
-
const { activeVisit, mutate } = useVisit(patientUuid);
|
|
16
15
|
const { t } = useTranslation();
|
|
16
|
+
const { activeVisit, mutate } = useVisit(patientUuid);
|
|
17
17
|
const { mutateAppointments } = useMutateAppointments();
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const handleEndAppointment = useCallback(() => {
|
|
20
|
+
changeAppointmentStatus('Completed', appointmentUuid)
|
|
21
21
|
.then(() => {
|
|
22
22
|
mutateAppointments();
|
|
23
23
|
if (activeVisit) {
|
|
24
24
|
const abortController = new AbortController();
|
|
25
|
-
const endVisitPayload = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
visitType: activeVisit.visitType.uuid,
|
|
29
|
-
stopDatetime: new Date(),
|
|
30
|
-
};
|
|
31
|
-
updateVisit(activeVisit.uuid, endVisitPayload, abortController)
|
|
32
|
-
.toPromise()
|
|
25
|
+
const endVisitPayload = { stopDatetime: new Date() };
|
|
26
|
+
|
|
27
|
+
return updateVisit(activeVisit.uuid, endVisitPayload, abortController)
|
|
33
28
|
.then(() => {
|
|
34
|
-
mutate();
|
|
35
29
|
showSnackbar({
|
|
36
30
|
title: t('appointmentEnded', 'Appointment ended'),
|
|
37
31
|
subtitle: t(
|
|
38
32
|
'appointmentEndedAndVisitClosedSuccessfully',
|
|
39
|
-
'Appointment successfully ended and visit successfully closed
|
|
33
|
+
'Appointment successfully ended and visit successfully closed',
|
|
40
34
|
),
|
|
41
35
|
isLowContrast: true,
|
|
42
36
|
kind: 'success',
|
|
43
37
|
});
|
|
44
|
-
|
|
38
|
+
mutate();
|
|
45
39
|
})
|
|
46
|
-
.catch((
|
|
47
|
-
closeModal();
|
|
40
|
+
.catch((error) => {
|
|
48
41
|
showSnackbar({
|
|
49
|
-
title: t(
|
|
50
|
-
|
|
42
|
+
title: t(
|
|
43
|
+
'appointmentEndedButVisitNotClosedError',
|
|
44
|
+
'Appointment ended successfully, but there was an error closing the visit.',
|
|
45
|
+
),
|
|
46
|
+
subtitle: error?.message,
|
|
51
47
|
kind: 'error',
|
|
52
48
|
isLowContrast: true,
|
|
53
49
|
});
|
|
54
50
|
});
|
|
55
51
|
} else {
|
|
56
|
-
closeModal();
|
|
57
52
|
showSnackbar({
|
|
58
53
|
title: t('appointmentEnded', 'Appointment ended'),
|
|
59
54
|
subtitle: t('appointmentEndedSuccessfully', 'Appointment successfully ended.'),
|
|
@@ -62,16 +57,18 @@ const EndAppointmentModal: React.FC<EndAppointmentModalProps> = ({ patientUuid,
|
|
|
62
57
|
});
|
|
63
58
|
}
|
|
64
59
|
})
|
|
65
|
-
.catch((
|
|
66
|
-
closeModal();
|
|
60
|
+
.catch((error) => {
|
|
67
61
|
showSnackbar({
|
|
68
62
|
title: t('appointmentEndError', 'Error ending appointment'),
|
|
69
|
-
subtitle:
|
|
63
|
+
subtitle: error?.message,
|
|
70
64
|
kind: 'error',
|
|
71
65
|
isLowContrast: true,
|
|
72
66
|
});
|
|
67
|
+
})
|
|
68
|
+
.finally(() => {
|
|
69
|
+
closeModal();
|
|
73
70
|
});
|
|
74
|
-
};
|
|
71
|
+
}, [activeVisit, mutate, mutateAppointments, closeModal, patientUuid, appointmentUuid]);
|
|
75
72
|
|
|
76
73
|
return (
|
|
77
74
|
<div>
|
|
@@ -84,7 +81,7 @@ const EndAppointmentModal: React.FC<EndAppointmentModalProps> = ({ patientUuid,
|
|
|
84
81
|
{activeVisit
|
|
85
82
|
? t(
|
|
86
83
|
'endAppointmentAndVisitConfirmationMessage',
|
|
87
|
-
'Checking the patient out will mark the appointment as complete
|
|
84
|
+
'Checking the patient out will mark the appointment as complete and close out the active visit for this patient.',
|
|
88
85
|
)
|
|
89
86
|
: t('endAppointmentConfirmationMessage', 'Checking the patient out will mark the appointment as complete.')}
|
|
90
87
|
</p>
|
|
@@ -93,7 +90,7 @@ const EndAppointmentModal: React.FC<EndAppointmentModalProps> = ({ patientUuid,
|
|
|
93
90
|
<Button kind="secondary" onClick={closeModal}>
|
|
94
91
|
{t('cancel', 'Cancel')}
|
|
95
92
|
</Button>
|
|
96
|
-
<Button kind="danger" onClick={
|
|
93
|
+
<Button kind="danger" onClick={handleEndAppointment}>
|
|
97
94
|
{t('checkOut', 'Check out')}
|
|
98
95
|
</Button>
|
|
99
96
|
</ModalFooter>
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { of } from 'rxjs';
|
|
3
2
|
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
updateVisit,
|
|
6
|
+
showSnackbar,
|
|
7
|
+
useVisit,
|
|
8
|
+
type VisitReturnType,
|
|
9
|
+
type FetchResponse,
|
|
10
|
+
type Visit,
|
|
11
|
+
} from '@openmrs/esm-framework';
|
|
6
12
|
import { changeAppointmentStatus } from '../../patient-appointments/patient-appointments.resource';
|
|
7
13
|
import EndAppointmentModal from './end-appointment.modal';
|
|
8
14
|
|
|
@@ -20,7 +26,7 @@ jest.mock('../../form/appointments-form.resource', () => ({
|
|
|
20
26
|
|
|
21
27
|
describe('EndAppointmentModal', () => {
|
|
22
28
|
beforeEach(() => {
|
|
23
|
-
mockUpdateVisit.
|
|
29
|
+
mockUpdateVisit.mockResolvedValue({} as FetchResponse<Visit>);
|
|
24
30
|
});
|
|
25
31
|
|
|
26
32
|
it('has a cancel button that closes the modal', async () => {
|
|
@@ -73,7 +79,7 @@ describe('EndAppointmentModal', () => {
|
|
|
73
79
|
expect(closeModal).toHaveBeenCalled();
|
|
74
80
|
expect(showSnackbar).toHaveBeenCalledWith({
|
|
75
81
|
title: 'Appointment ended',
|
|
76
|
-
subtitle: 'Appointment successfully ended and visit successfully closed
|
|
82
|
+
subtitle: 'Appointment successfully ended and visit successfully closed',
|
|
77
83
|
isLowContrast: true,
|
|
78
84
|
kind: 'success',
|
|
79
85
|
});
|
|
@@ -832,7 +832,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
|
|
|
832
832
|
datePickerType="single"
|
|
833
833
|
dateFormat={datePickerFormat}
|
|
834
834
|
value={value}
|
|
835
|
-
maxDate={new Date()}
|
|
835
|
+
maxDate={new Date().toISOString()}
|
|
836
836
|
onChange={([date]) => onChange(date)}
|
|
837
837
|
invalid={!!fieldState?.error?.message}
|
|
838
838
|
invalidText={fieldState?.error?.message}>
|
package/translations/en.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"appointmentEdited": "Appointment edited",
|
|
13
13
|
"appointmentEditError": "Error editing appointment",
|
|
14
14
|
"appointmentEnded": "Appointment ended",
|
|
15
|
-
"appointmentEndedAndVisitClosedSuccessfully": "Appointment successfully ended and visit successfully closed
|
|
15
|
+
"appointmentEndedAndVisitClosedSuccessfully": "Appointment successfully ended and visit successfully closed",
|
|
16
16
|
"appointmentEndedButVisitNotClosedError": "Appointment ended, but error closing visit",
|
|
17
17
|
"appointmentEndedSuccessfully": "Appointment successfully ended.",
|
|
18
18
|
"appointmentEndError": "Error ending appointment",
|