@openmrs/esm-appointments-app 9.1.2-pre.6585 → 9.1.2-pre.6598

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.
@@ -511,9 +511,9 @@
511
511
  "entry": false,
512
512
  "recorded": false,
513
513
  "reason": "split chunk (cache group: default)",
514
- "size": 90914,
514
+ "size": 90995,
515
515
  "sizes": {
516
- "javascript": 90914
516
+ "javascript": 90995
517
517
  },
518
518
  "names": [],
519
519
  "idHints": [],
@@ -527,7 +527,7 @@
527
527
  "auxiliaryFiles": [
528
528
  "3092.js.map"
529
529
  ],
530
- "hash": "9f0629d3462dabb2",
530
+ "hash": "10429bb4dd86db7b",
531
531
  "childrenByOrder": {}
532
532
  },
533
533
  {
@@ -635,9 +635,9 @@
635
635
  "initial": false,
636
636
  "entry": false,
637
637
  "recorded": false,
638
- "size": 17595,
638
+ "size": 19637,
639
639
  "sizes": {
640
- "javascript": 17595
640
+ "javascript": 19637
641
641
  },
642
642
  "names": [],
643
643
  "idHints": [],
@@ -651,7 +651,7 @@
651
651
  "auxiliaryFiles": [
652
652
  "3431.js.map"
653
653
  ],
654
- "hash": "73f41321e5ed59c9",
654
+ "hash": "1a08fbb697e50c61",
655
655
  "childrenByOrder": {}
656
656
  },
657
657
  {
@@ -678,7 +678,7 @@
678
678
  "auxiliaryFiles": [
679
679
  "openmrs-esm-appointments-app.js.map"
680
680
  ],
681
- "hash": "c1baf539856e904b",
681
+ "hash": "b93144a69fda7f4a",
682
682
  "childrenByOrder": {}
683
683
  },
684
684
  {
@@ -857,9 +857,9 @@
857
857
  "initial": false,
858
858
  "entry": false,
859
859
  "recorded": false,
860
- "size": 6294,
860
+ "size": 6337,
861
861
  "sizes": {
862
- "javascript": 6294
862
+ "javascript": 6337
863
863
  },
864
864
  "names": [],
865
865
  "idHints": [],
@@ -871,7 +871,7 @@
871
871
  "4300.js"
872
872
  ],
873
873
  "auxiliaryFiles": [],
874
- "hash": "37ae6be4b361f414",
874
+ "hash": "3242cae15b503c1d",
875
875
  "childrenByOrder": {}
876
876
  },
877
877
  {
@@ -1014,9 +1014,9 @@
1014
1014
  "initial": false,
1015
1015
  "entry": false,
1016
1016
  "recorded": false,
1017
- "size": 75140,
1017
+ "size": 75113,
1018
1018
  "sizes": {
1019
- "javascript": 75140
1019
+ "javascript": 75113
1020
1020
  },
1021
1021
  "names": [],
1022
1022
  "idHints": [],
@@ -1030,7 +1030,7 @@
1030
1030
  "auxiliaryFiles": [
1031
1031
  "4745.js.map"
1032
1032
  ],
1033
- "hash": "7384f10883e655e2",
1033
+ "hash": "a4c2381e3cc385f1",
1034
1034
  "childrenByOrder": {}
1035
1035
  },
1036
1036
  {
@@ -1632,7 +1632,7 @@
1632
1632
  "auxiliaryFiles": [
1633
1633
  "7698.js.map"
1634
1634
  ],
1635
- "hash": "1e869d88e604f659",
1635
+ "hash": "6115a6533806f882",
1636
1636
  "childrenByOrder": {}
1637
1637
  },
1638
1638
  {
@@ -1792,7 +1792,7 @@
1792
1792
  "auxiliaryFiles": [
1793
1793
  "main.js.map"
1794
1794
  ],
1795
- "hash": "2355166986d725af",
1795
+ "hash": "833d9e5010661572",
1796
1796
  "childrenByOrder": {}
1797
1797
  },
1798
1798
  {
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"},"order":2},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-dashboard","slot":"appointments-dashboard-slot","component":"appointmentsDashboard"},{"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":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"hideDashboardTitle":true,"path":"Appointments","slot":"patient-chart-appointments-dashboard-slot","title":"Appointments"}},{"name":"appointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"visit-form-top-slot"},{"name":"search-patient","component":"searchPatient"},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"},{"name":"metrics-card-scheduled-appointments","component":"metricsCardScheduledAppointments","slot":"appointments-metrics-slot","order":1},{"name":"metrics-card-highest-volume-service","component":"metricsCardHighestVolumeService","slot":"appointments-metrics-slot","order":2},{"name":"metrics-card-providers-booked","component":"metricsCardProvidersBooked","slot":"appointments-metrics-slot","order":3}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"cancel-appointment-modal","component":"cancelAppointmentModal"}],"workspaces":[{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","title":"createNewAppointment","type":"form"}],"version":"9.1.2-pre.6585"}
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"},"order":2},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-dashboard","slot":"appointments-dashboard-slot","component":"appointmentsDashboard"},{"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":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"hideDashboardTitle":true,"path":"Appointments","slot":"patient-chart-appointments-dashboard-slot","title":"Appointments"}},{"name":"appointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"visit-form-top-slot"},{"name":"search-patient","component":"searchPatient"},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"},{"name":"metrics-card-scheduled-appointments","component":"metricsCardScheduledAppointments","slot":"appointments-metrics-slot","order":1},{"name":"metrics-card-highest-volume-service","component":"metricsCardHighestVolumeService","slot":"appointments-metrics-slot","order":2},{"name":"metrics-card-providers-booked","component":"metricsCardProvidersBooked","slot":"appointments-metrics-slot","order":3}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"cancel-appointment-modal","component":"cancelAppointmentModal"}],"workspaces":[{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","title":"createNewAppointment","type":"form"}],"version":"9.1.2-pre.6598"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-appointments-app",
3
- "version": "9.1.2-pre.6585",
3
+ "version": "9.1.2-pre.6598",
4
4
  "description": "Appointments front-end module for O3",
5
5
  "browser": "dist/openmrs-esm-appointments-app.js",
6
6
  "main": "src/index.ts",
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useMemo } from 'react';
2
2
  import dayjs from 'dayjs';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { Button, ContentSwitcher, DataTableSkeleton, InlineLoading, Layer, Switch, Tile } from '@carbon/react';
@@ -28,13 +28,17 @@ const PatientAppointmentsBase: React.FC<PatientAppointmentsBaseProps> = ({ patie
28
28
  const [switchedView, setSwitchedView] = useState(false);
29
29
 
30
30
  const [contentSwitcherValue, setContentSwitcherValue] = useState(0);
31
- const startDate = dayjs(new Date().toISOString()).subtract(6, 'month').toISOString();
31
+ const startDate = useMemo(() => dayjs().subtract(6, 'month').toISOString(), []);
32
32
  const {
33
33
  data: appointmentsData,
34
34
  error,
35
35
  isLoading,
36
36
  isValidating,
37
- } = usePatientAppointments(patientUuid, startDate, new AbortController());
37
+ } = usePatientAppointments(
38
+ patientUuid,
39
+ startDate,
40
+ useMemo(() => new AbortController(), []),
41
+ );
38
42
 
39
43
  const handleLaunchAppointmentsForm = () => {
40
44
  if (
@@ -114,6 +118,7 @@ const PatientAppointmentsBase: React.FC<PatientAppointmentsBaseProps> = ({ patie
114
118
  </Layer>
115
119
  );
116
120
  }
121
+
117
122
  if (contentSwitcherValue === AppointmentTypes.TODAY) {
118
123
  if (appointmentsData.todaysAppointments?.length) {
119
124
  return (
@@ -1,4 +1,5 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useMemo } from 'react';
2
+ import dayjs from 'dayjs';
2
3
  import { useTranslation } from 'react-i18next';
3
4
  import { Button, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
4
5
  import { showSnackbar } from '@openmrs/esm-framework';
@@ -16,31 +17,46 @@ const CancelAppointmentModal: React.FC<CancelAppointmentModalProps> = ({
16
17
  patientUuid,
17
18
  }) => {
18
19
  const { t } = useTranslation();
19
- const { mutate } = usePatientAppointments(patientUuid, new Date().toUTCString(), new AbortController());
20
+ const startDate = useMemo(() => dayjs().subtract(6, 'month').toISOString(), []);
21
+ const { mutate } = usePatientAppointments(
22
+ patientUuid,
23
+ startDate,
24
+ useMemo(() => new AbortController(), []),
25
+ );
20
26
  const [isSubmitting, setIsSubmitting] = useState(false);
21
27
 
22
28
  const handleCancelAppointment = async () => {
23
29
  setIsSubmitting(true);
24
30
 
25
- changeAppointmentStatus('Cancelled', appointmentUuid)
26
- .then(() => {
27
- mutate();
28
- closeCancelModal();
29
- showSnackbar({
30
- isLowContrast: true,
31
- kind: 'success',
32
- subtitle: t('appointmentCancelledSuccessfully', 'Appointment cancelled successfully'),
33
- title: t('appointmentCancelled', 'Appointment cancelled'),
34
- });
35
- })
36
- .catch((err) => {
37
- showSnackbar({
38
- title: t('appointmentCancelError', 'Error cancelling appointment'),
39
- kind: 'error',
40
- isLowContrast: true,
41
- subtitle: err?.message,
42
- });
31
+ try {
32
+ await changeAppointmentStatus('Cancelled', appointmentUuid);
33
+ mutate();
34
+ closeCancelModal();
35
+ showSnackbar({
36
+ isLowContrast: true,
37
+ kind: 'success',
38
+ subtitle: t('appointmentCancelledSuccessfully', 'Appointment cancelled successfully'),
39
+ title: t('appointmentCancelled', 'Appointment cancelled'),
40
+ });
41
+ } catch (err) {
42
+ const rawErrorMessage =
43
+ err?.responseBody?.error?.message ||
44
+ err?.responseBody?.message ||
45
+ err?.message ||
46
+ t('unknownError', 'An unknown error occurred');
47
+
48
+ // Remove square brackets from the error message
49
+ const errorMessage = rawErrorMessage.replace(/^\[|\]$/g, '');
50
+
51
+ showSnackbar({
52
+ title: t('appointmentCancelError', 'Error cancelling appointment'),
53
+ kind: 'error',
54
+ isLowContrast: false,
55
+ subtitle: errorMessage,
43
56
  });
57
+ } finally {
58
+ setIsSubmitting(false);
59
+ }
44
60
  };
45
61
 
46
62
  return (
@@ -1,4 +1,5 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import dayjs from 'dayjs';
2
3
  import { useTranslation } from 'react-i18next';
3
4
  import {
4
5
  InlineLoading,
@@ -11,12 +12,11 @@ import {
11
12
  StructuredListWrapper,
12
13
  } from '@carbon/react';
13
14
  import { formatDate, parseDate, showSnackbar, type Visit } from '@openmrs/esm-framework';
14
- import { changeAppointmentStatus, usePatientAppointments } from './patient-appointments.resource';
15
15
  import { ErrorState } from '@openmrs/esm-patient-common-lib';
16
- import styles from './patient-upcoming-appointments-card.scss';
17
- import dayjs from 'dayjs';
16
+ import { changeAppointmentStatus, usePatientAppointments } from './patient-appointments.resource';
18
17
  import { type Appointment } from '../types';
19
18
  import { useMutateAppointments } from '../form/appointments-form.resource';
19
+ import styles from './patient-upcoming-appointments-card.scss';
20
20
 
21
21
  interface VisitFormCallbacks {
22
22
  onVisitCreatedOrUpdated: (visit: Visit) => Promise<any>;
@@ -44,7 +44,7 @@ const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps
44
44
  patientChartConfig,
45
45
  }) => {
46
46
  const { t } = useTranslation();
47
- const startDate = dayjs(new Date().toISOString()).subtract(6, 'month').toISOString();
47
+ const startDate = useMemo(() => dayjs().subtract(6, 'month').toISOString(), []);
48
48
  const headerTitle = t('upcomingAppointments', 'Upcoming appointments');
49
49
  const [selectedAppointment, setSelectedAppointment] = useState<Appointment>(null);
50
50
  const { mutateAppointments } = useMutateAppointments();
@@ -102,12 +102,13 @@ const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps
102
102
  };
103
103
 
104
104
  if (!patientChartConfig.showUpcomingAppointments) {
105
- return <></>;
105
+ return null;
106
106
  }
107
107
 
108
108
  if (error) {
109
109
  return <ErrorState headerTitle={headerTitle} error={error} />;
110
110
  }
111
+
111
112
  if (isLoading) {
112
113
  return (
113
114
  <span>
@@ -159,11 +160,11 @@ const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps
159
160
 
160
161
  return (
161
162
  <InlineNotification
162
- kind={'info'}
163
- lowContrast
164
163
  className={styles.inlineNotification}
165
- title={t('upcomingAppointments', 'Upcoming appointments')}
164
+ kind="info"
165
+ lowContrast
166
166
  subtitle={t('noUpcomingAppointments', 'No upcoming appointments found')}
167
+ title={t('upcomingAppointments', 'Upcoming appointments')}
167
168
  />
168
169
  );
169
170
  };
@@ -149,6 +149,7 @@
149
149
  "todays": "Today's",
150
150
  "TUE": "TUE",
151
151
  "type": "Type",
152
+ "unknownError": "An unknown error occurred",
152
153
  "unscheduled": "Unscheduled",
153
154
  "unscheduledAppointments": "Unscheduled appointments",
154
155
  "unscheduledAppointments_lower": "unscheduled appointments",