From 1a1dd5b598823b369ec073a49594b6326ca619b3 Mon Sep 17 00:00:00 2001 From: Mahesh Ippili <74229437+Mahesh-I@users.noreply.github.com> Date: Thu, 11 Mar 2021 17:54:06 +0530 Subject: [PATCH] BAH-1166|[Mahesh] fixing timezone mismatch in appointments display control (#28) --- .../apps/customDisplayControl/js/customControl.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openmrs/apps/customDisplayControl/js/customControl.js b/openmrs/apps/customDisplayControl/js/customControl.js index bcbac4214..2b895ab9e 100644 --- a/openmrs/apps/customDisplayControl/js/customControl.js +++ b/openmrs/apps/customDisplayControl/js/customControl.js @@ -176,6 +176,11 @@ angular.module('bahmni.common.displaycontrol.custom') withCredentials: true }); }; + var convertUTCtoLocal = function (start_date_time, end_date_time) { + var date = Bahmni.Common.Util.DateUtil.formatDateWithoutTime(start_date_time); + var timeSlot = Bahmni.Common.Util.DateUtil.formatTime(start_date_time) + " - " + Bahmni.Common.Util.DateUtil.formatTime(end_date_time); + return [date, timeSlot]; + }; $q.all([getUpcomingAppointments(), getPastAppointments()]).then(function (response) { $scope.upcomingAppointments = response[0].data; $scope.upcomingAppointmentsUUIDs = []; @@ -184,6 +189,11 @@ angular.module('bahmni.common.displaycontrol.custom') $scope.upcomingAppointmentsUUIDs[i] = $scope.upcomingAppointments[i].uuid; $scope.teleconsultationAppointments[i] = $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_TELECONSULTATION; delete $scope.upcomingAppointments[i].uuid; + const [date, timeSlot] = convertUTCtoLocal($scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_START_DATE_KEY, $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_END_DATE_KEY); + delete $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_START_DATE_KEY; + delete $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_END_DATE_KEY; + $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_DATE_KEY = date; + $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_SLOT_KEY = timeSlot; delete $scope.upcomingAppointments[i].DASHBOARD_APPOINTMENTS_TELECONSULTATION; } $scope.upcomingAppointmentsHeadings = _.keys($scope.upcomingAppointments[0]); @@ -199,7 +209,7 @@ angular.module('bahmni.common.displaycontrol.custom') appService.setTeleConsultationVars(jitsiMeetingId, true); }; $scope.showJoinTeleconsultationOption = function (appointmentIndex) { - return $scope.upcomingAppointments[appointmentIndex].DASHBOARD_APPOINTMENTS_STATUS_KEY == 'Scheduled' && + return $scope.upcomingAppointments[appointmentIndex].DASHBOARD_APPOINTMENTS_STATUS_KEY == 'Scheduled' && $scope.teleconsultationAppointments[appointmentIndex]; } };