Skip to content

Commit

Permalink
Merge branch 'main' into HIE-9
Browse files Browse the repository at this point in the history
  • Loading branch information
reagan-meant authored Dec 13, 2024
2 parents 093abf8 + 0b3e877 commit 8554220
Show file tree
Hide file tree
Showing 82 changed files with 409 additions and 817 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const testProps = {

const mockOpenmrsFetch = jest.mocked(openmrsFetch);

describe('AppointmensOverview', () => {
describe('AppointmentsOverview', () => {
it('renders an empty state if appointments data is unavailable', async () => {
mockOpenmrsFetch.mockResolvedValueOnce({
data: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
InlineLoading,
Expand All @@ -18,9 +18,13 @@ import dayjs from 'dayjs';
import { type Appointment } from '../types';
import { useMutateAppointments } from '../form/appointments-form.resource';

interface VisitFormCallbacks {
onVisitCreatedOrUpdated: (visit: Visit) => Promise<any>;
}

// See VisitFormExtensionState in esm-patient-chart-app
export interface PatientUpcomingAppointmentsProps {
setOnVisitCreatedOrUpdated(onSubmit: (visit: Visit) => Promise<any>);
setVisitFormCallbacks(callbacks: VisitFormCallbacks);
visitFormOpenedFrom: string;
patientChartConfig?: {
showUpcomingAppointments: boolean;
Expand All @@ -36,45 +40,53 @@ export interface PatientUpcomingAppointmentsProps {
*/
const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps> = ({
patientUuid,
setOnVisitCreatedOrUpdated,
setVisitFormCallbacks,
patientChartConfig,
}) => {
const { t } = useTranslation();
const startDate = dayjs(new Date().toISOString()).subtract(6, 'month').toISOString();
const headerTitle = t('upcomingAppointments', 'Upcoming appointments');
const [selectedAppointment, setSelectedAppointment] = useState<Appointment>(null);
const { mutateAppointments } = useMutateAppointments();
const memoMutateAppointments = useMemo(() => mutateAppointments, [mutateAppointments]);

const ac = useMemo<AbortController>(() => new AbortController(), []);
useEffect(() => () => ac.abort(), [ac]);
const { data: appointmentsData, error, isLoading } = usePatientAppointments(patientUuid, startDate, ac);

useEffect(() => {
setOnVisitCreatedOrUpdated(() => {
if (selectedAppointment) {
return changeAppointmentStatus('CheckedIn', selectedAppointment.uuid)
.then(() => {
mutateAppointments();
showSnackbar({
isLowContrast: true,
kind: 'success',
subtitle: t('appointmentMarkedChecked', 'Appointment marked as Checked In'),
title: t('appointmentCheckedIn', 'Appointment Checked In'),
});
})
.catch((error) => {
showSnackbar({
title: t('updateError', 'Error updating upcoming appointment'),
kind: 'error',
isLowContrast: false,
subtitle: error?.message,
const onVisitCreatedOrUpdated = useMemo(
() => ({
onVisitCreatedOrUpdated: () => {
if (selectedAppointment) {
return changeAppointmentStatus('CheckedIn', selectedAppointment.uuid)
.then(() => {
memoMutateAppointments();
showSnackbar({
isLowContrast: true,
kind: 'success',
subtitle: t('appointmentMarkedChecked', 'Appointment marked as Checked In'),
title: t('appointmentCheckedIn', 'Appointment Checked In'),
});
})
.catch((error) => {
showSnackbar({
title: t('updateError', 'Error updating upcoming appointment'),
kind: 'error',
isLowContrast: false,
subtitle: error?.message,
});
});
});
} else {
return Promise.resolve();
}
});
}, [selectedAppointment, mutateAppointments, setOnVisitCreatedOrUpdated, t]);
} else {
return Promise.resolve();
}
},
}),
[selectedAppointment, memoMutateAppointments, t],
);

useEffect(() => {
setVisitFormCallbacks(onVisitCreatedOrUpdated);
}, [onVisitCreatedOrUpdated, setVisitFormCallbacks]);

const todaysAppointments = appointmentsData?.todaysAppointments?.length ? appointmentsData?.todaysAppointments : [];
const futureAppointments = appointmentsData?.upcomingAppointments?.length
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "خطأ في إلغاء الموعد",
"appointmentCancelled": "تم إلغاء الموعد",
"appointmentCancelledSuccessfully": "تم إلغاء الموعد بنجاح",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "لون الموعد",
"appointmentConflict": "تعارض بالمواعيد",
"appointmentEdited": "تم تعديل الموعد",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "خطأ في انهاء الموعد",
"appointmentFormError": "خطأ في جدولة الموعد",
"appointmentHistory": "تاريخ الموعد",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "مقاييس الموعد",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "كتابة ملاحظة اضافية",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "مواعيد غير مجدولة",
"upcoming": "القادمة",
"upcomingAppointments": "المواعيد القادمة",
"updateError": "Error updating upcoming appointment",
"view": "عرض",
"vitals": "العلامات الحيوية",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error al cancelar la cita",
"appointmentCancelled": "Cita Cancelada",
"appointmentCancelledSuccessfully": "Cita cancelada con éxito",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Color de la cita",
"appointmentConflict": "Conflicto en las citas",
"appointmentEdited": "Cita editada",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error al finalizar la cita",
"appointmentFormError": "Error al programar la cita",
"appointmentHistory": "Historial de Citas",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Métricas de citas",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Escriba una nota adicional",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "citas no programadas",
"upcoming": "Próximas",
"upcomingAppointments": "Próximas citas",
"updateError": "Error updating upcoming appointment",
"view": "Ver",
"vitals": "Signos Vitales",
"week": "Semana",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Erreur d’annulation du rendez-vous",
"appointmentCancelled": "Rendez-vous annulé",
"appointmentCancelledSuccessfully": "Rendez-vous annulé avec succès",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Couleur du rendez-vous",
"appointmentConflict": "Conflit du rendez-vous",
"appointmentEdited": "Rendez-vous modifié",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Erreur lors de la clôture du rendez-vous",
"appointmentFormError": "Erreur lors de la planification du rendez-vous",
"appointmentHistory": "Historique de Rendez-vous",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Métriques de rendez-vous",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Écrire une note additionnelle",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "rendez-vous non-planifiés",
"upcoming": "À venir",
"upcomingAppointments": "À venir rendez-vous",
"updateError": "Error updating upcoming appointment",
"view": "Vue",
"vitals": "Signes Vitaux",
"week": "Semaine",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "שגיאה בביטול התור",
"appointmentCancelled": "התור בוטל",
"appointmentCancelledSuccessfully": "התור בוטל בהצלחה",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "צבע התור",
"appointmentConflict": "סתירת תורים",
"appointmentEdited": "התור נערך",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "שגיאה בסיום תור",
"appointmentFormError": "שגיאה בתזמון התור",
"appointmentHistory": "היסטוריית התורים",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "מדדי התורים",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "הצגת הערה נוספ",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "תורים שאינם מתוזמנים",
"upcoming": "בקרוב",
"upcomingAppointments": "תורים עתידיים",
"updateError": "Error updating upcoming appointment",
"view": "הצגה",
"vitals": "מדדים",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/hi_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "កំហុសក្នុងការបោះបង់ការណាត់ជួប",
"appointmentCancelled": "ការណាត់ជួបត្រូវបានលុបចោល",
"appointmentCancelledSuccessfully": "ការណាត់ជួបបានលុបចោលដោយជោគជ័យ",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "ពណ៌ណាត់ជួប",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "កំហុសក្នុងការកំណត់ពេលណាត់ជួប",
"appointmentHistory": "ប្រវត្តិនៃការណាត់ជួប",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "មាត្រដ្ឋានណាត់ជួប",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "ការណាត់ជួបនាពេលខាងមុខ",
"updateError": "Error updating upcoming appointment",
"view": "ពិនិត្យមើល",
"vitals": "សញ្ញាជីវិត",
"week": "Week",
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-appointments-app/translations/ne.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"appointmentCancelError": "Error cancelling appointment",
"appointmentCancelled": "Appointment Cancelled",
"appointmentCancelledSuccessfully": "Appointment cancelled successfully",
"appointmentCheckedIn": "Appointment Checked In",
"appointmentColor": "Appointment color",
"appointmentConflict": "Appointment conflict",
"appointmentEdited": "Appointment edited",
Expand All @@ -18,6 +19,7 @@
"appointmentEndError": "Error ending appointment",
"appointmentFormError": "Error scheduling appointment",
"appointmentHistory": "Appointment History",
"appointmentMarkedChecked": "Appointment marked as Checked In",
"appointmentMetrics": "Appointment metrics",
"appointmentMetricsLoadError": "",
"appointmentNoteLabel": "Write an additional note",
Expand Down Expand Up @@ -158,6 +160,7 @@
"unscheduledAppointments_lower": "unscheduled appointments",
"upcoming": "Upcoming",
"upcomingAppointments": "Upcoming appointments",
"updateError": "Error updating upcoming appointment",
"view": "View",
"vitals": "Vitals",
"week": "Week",
Expand Down
Loading

0 comments on commit 8554220

Please sign in to comment.