From 863ca3c7159803a4263e353dff89544b87baf7bd Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Tue, 10 Oct 2023 09:02:23 -0400 Subject: [PATCH] O3-2476 - Remove unnecessary conversion from date to string back to date --- .../src/visits-summary/visit-detail.test.tsx | 6 ++++-- .../details/appointment-details.component.tsx | 2 +- .../src/patient-queue/visit-form/queue.resource.ts | 2 +- .../patient-queue/visit-form/visit-form.component.tsx | 10 ++++++---- packages/esm-appointments-app/translations/am.json | 2 +- packages/esm-appointments-app/translations/en.json | 2 +- packages/esm-appointments-app/translations/fr.json | 2 +- packages/esm-appointments-app/translations/he.json | 2 +- packages/esm-appointments-app/translations/km.json | 2 +- .../src/active-visits/active-visits-table.resource.ts | 4 ++-- .../active-visits/change-status-dialog.component.tsx | 2 +- .../clear-queue-entries-dialog.resource.tsx | 2 +- .../src/patient-search/visit-form/queue.resource.ts | 2 +- .../remove-queue-entry.component.tsx | 2 +- .../transition-queue-entry-dialog.component.tsx | 2 +- 15 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/esm-active-visits-app/src/visits-summary/visit-detail.test.tsx b/packages/esm-active-visits-app/src/visits-summary/visit-detail.test.tsx index 314c020e0..19a373103 100644 --- a/packages/esm-active-visits-app/src/visits-summary/visit-detail.test.tsx +++ b/packages/esm-active-visits-app/src/visits-summary/visit-detail.test.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { render, screen, act } from '@testing-library/react'; import VisitDetailComponent from './visit-detail.component'; import { useVisit } from './visit.resource'; +import { formatDate } from '@openmrs/esm-framework'; jest.mock('./visit.resource'); @@ -23,11 +24,12 @@ describe('VisitDetailComponent', () => { }); it('should render visit details and switches when data is available', () => { + let visitDate = new Date(); mockedUseVisit.mockReturnValueOnce({ visit: { uuid: visitUuid, visitType: { display: 'Some Visit Type' }, - startDatetime: '2023-07-29T12:34:56Z', + startDatetime: visitDate, encounters: [], }, isLoading: false, @@ -36,7 +38,7 @@ describe('VisitDetailComponent', () => { render(); expect(screen.getByText(/Some Visit Type/)).toBeInTheDocument(); - expect(screen.getByText(/29-Jul-2023, 12:34 PM/)).toBeInTheDocument(); + expect(screen.getByText(formatDate(visitDate))).toBeInTheDocument(); expect(screen.getByText('All Encounters')).toBeInTheDocument(); expect(screen.getByText('Visit Summary')).toBeInTheDocument(); diff --git a/packages/esm-appointments-app/src/appointments/details/appointment-details.component.tsx b/packages/esm-appointments-app/src/appointments/details/appointment-details.component.tsx index 9d52c4b50..9abcbb014 100644 --- a/packages/esm-appointments-app/src/appointments/details/appointment-details.component.tsx +++ b/packages/esm-appointments-app/src/appointments/details/appointment-details.component.tsx @@ -63,7 +63,7 @@ const AppointmentDetails: React.FC = ({ appointment }) {appointmentsCount.cancelledAppointments}
-

{t('upcomming', 'Upcoming')}

+

{t('upcoming', 'Upcoming')}

{appointmentsCount.upcomingAppointments}
diff --git a/packages/esm-appointments-app/src/patient-queue/visit-form/queue.resource.ts b/packages/esm-appointments-app/src/patient-queue/visit-form/queue.resource.ts index 1d26d5388..56aabaef9 100644 --- a/packages/esm-appointments-app/src/patient-queue/visit-form/queue.resource.ts +++ b/packages/esm-appointments-app/src/patient-queue/visit-form/queue.resource.ts @@ -36,7 +36,7 @@ export async function saveQueueEntry( patient: { uuid: patientUuid, }, - startedAt: toDateObjectStrict(toOmrsIsoString(new Date())), + startedAt: new Date(), sortWeight: sortWeight, }, }, diff --git a/packages/esm-appointments-app/src/patient-queue/visit-form/visit-form.component.tsx b/packages/esm-appointments-app/src/patient-queue/visit-form/visit-form.component.tsx index 627e00620..91fb57adb 100644 --- a/packages/esm-appointments-app/src/patient-queue/visit-form/visit-form.component.tsx +++ b/packages/esm-appointments-app/src/patient-queue/visit-form/visit-form.component.tsx @@ -98,10 +98,12 @@ const VisitForm: React.FC = ({ patientUuid, appointment }) => { const payload: NewVisitPayload = { patient: patientUuid, - startDatetime: toDateObjectStrict( - toOmrsIsoString( - new Date(dayjs(visitDate).year(), dayjs(visitDate).month(), dayjs(visitDate).date(), hours, minutes), - ), + startDatetime: new Date( + dayjs(visitDate).year(), + dayjs(visitDate).month(), + dayjs(visitDate).date(), + hours, + minutes, ), visitType: visitType, location: selectedLocation, diff --git a/packages/esm-appointments-app/translations/am.json b/packages/esm-appointments-app/translations/am.json index 9faa08211..3e629c429 100644 --- a/packages/esm-appointments-app/translations/am.json +++ b/packages/esm-appointments-app/translations/am.json @@ -137,7 +137,7 @@ "unscheduled": "Unscheduled", "unscheduledAppointments": "Unscheduled appointments", "unscheduledAppointments_lower": "unscheduled appointments", - "upcomming": "Upcoming", + "upcoming": "Upcoming", "view": "View", "viewCalendar": "View Calendar", "visitLocation": "Visit Location", diff --git a/packages/esm-appointments-app/translations/en.json b/packages/esm-appointments-app/translations/en.json index d6092734d..ff3c2a1b7 100644 --- a/packages/esm-appointments-app/translations/en.json +++ b/packages/esm-appointments-app/translations/en.json @@ -137,7 +137,7 @@ "unscheduled": "Unscheduled", "unscheduledAppointments": "Unscheduled appointments", "unscheduledAppointments_lower": "unscheduled appointments", - "upcomming": "Upcoming", + "upcoming": "Upcoming", "view": "View", "viewCalendar": "View Calendar", "visitLocation": "Visit Location", diff --git a/packages/esm-appointments-app/translations/fr.json b/packages/esm-appointments-app/translations/fr.json index 9faa08211..3e629c429 100644 --- a/packages/esm-appointments-app/translations/fr.json +++ b/packages/esm-appointments-app/translations/fr.json @@ -137,7 +137,7 @@ "unscheduled": "Unscheduled", "unscheduledAppointments": "Unscheduled appointments", "unscheduledAppointments_lower": "unscheduled appointments", - "upcomming": "Upcoming", + "upcoming": "Upcoming", "view": "View", "viewCalendar": "View Calendar", "visitLocation": "Visit Location", diff --git a/packages/esm-appointments-app/translations/he.json b/packages/esm-appointments-app/translations/he.json index 6018d28ab..428d4247b 100644 --- a/packages/esm-appointments-app/translations/he.json +++ b/packages/esm-appointments-app/translations/he.json @@ -137,7 +137,7 @@ "unscheduled": "Unscheduled", "unscheduledAppointments": "Unscheduled appointments", "unscheduledAppointments_lower": "unscheduled appointments", - "upcomming": "Upcoming", + "upcoming": "Upcoming", "view": "הצג", "viewCalendar": "הצג לוח שנה", "visitLocation": "מיקום הביקור", diff --git a/packages/esm-appointments-app/translations/km.json b/packages/esm-appointments-app/translations/km.json index 247434e0f..4b21b5cd7 100644 --- a/packages/esm-appointments-app/translations/km.json +++ b/packages/esm-appointments-app/translations/km.json @@ -137,7 +137,7 @@ "unscheduled": "មិនបានគ្រោងទុក", "unscheduledAppointments": "ការណាត់ជួបដែលមិនបានគ្រោងទុក", "unscheduledAppointments_lower": "unscheduled appointments", - "upcomming": "Upcoming", + "upcoming": "Upcoming", "view": "ពិនិត្យមើល", "viewCalendar": "ពិនិត្យមើលប្រតិទិន", "visitLocation": "ទីតាំងមកពិនិត្យ", diff --git a/packages/esm-service-queues-app/src/active-visits/active-visits-table.resource.ts b/packages/esm-service-queues-app/src/active-visits/active-visits-table.resource.ts index 973f1558c..68a79faa1 100644 --- a/packages/esm-service-queues-app/src/active-visits/active-visits-table.resource.ts +++ b/packages/esm-service-queues-app/src/active-visits/active-visits-table.resource.ts @@ -311,7 +311,7 @@ export async function updateQueueEntry( patient: { uuid: patientUuid, }, - startedAt: toDateObjectStrict(toOmrsIsoString(new Date())), + startedAt: new Date(), sortWeight: sortWeight, queueComingFrom: previousQueueUuid, }, @@ -396,7 +396,7 @@ export async function addQueueEntry( patient: { uuid: patientUuid, }, - startedAt: toDateObjectStrict(toOmrsIsoString(new Date())), + startedAt: new Date(), sortWeight: sortWeight, }, }, diff --git a/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx b/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx index 257e7ad43..289767c5a 100644 --- a/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx +++ b/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx @@ -62,7 +62,7 @@ const ChangeStatus: React.FC = ({ queueEntry, closeModa const queuePriority = priority === '' ? defaultPriority : priority; const emergencyPriorityConceptUuid = config.concepts.emergencyPriorityConceptUuid; const sortWeight = priority === emergencyPriorityConceptUuid ? 1.0 : 0.0; - const endDate = toDateObjectStrict(toOmrsIsoString(new Date())); + const endDate = new Date(); updateQueueEntry( queueEntry?.visitUuid, queueEntry?.queueUuid, diff --git a/packages/esm-service-queues-app/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx b/packages/esm-service-queues-app/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx index 90d74a968..fb9bab760 100644 --- a/packages/esm-service-queues-app/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx +++ b/packages/esm-service-queues-app/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx @@ -11,7 +11,7 @@ export async function batchClearQueueEntries(queueEntries: Array = ({ queueEn stopDatetime: new Date(), }; - const endedAt = toDateObjectStrict(toOmrsIsoString(new Date())); + const endedAt = new Date(); voidQueueEntry( queueEntry.queueUuid, diff --git a/packages/esm-service-queues-app/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx b/packages/esm-service-queues-app/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx index c42731abb..17b0054bd 100644 --- a/packages/esm-service-queues-app/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +++ b/packages/esm-service-queues-app/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx @@ -53,7 +53,7 @@ const TransitionQueueEntryModal: React.FC = ({ q const { mutate } = useVisitQueueEntries('', ''); const launchEditPriorityModal = useCallback(() => { - const endedAt = toDateObjectStrict(toOmrsIsoString(new Date())); + const endedAt = new Date(); updateQueueEntry( queueEntry?.visitUuid, queueEntry?.queueUuid,