diff --git a/ui/app/ot/controller/calendarViewController.js b/ui/app/ot/controller/calendarViewController.js index 92d7ff0e32..0dea6577da 100644 --- a/ui/app/ot/controller/calendarViewController.js +++ b/ui/app/ot/controller/calendarViewController.js @@ -70,6 +70,7 @@ angular.module('bahmni.ot') return newVar; }); $scope.filters.statusList = []; + $rootScope.providerToggle = appService.getAppDescriptor().getConfigValue("defaultViewAsSurgeonBased"); setAppointmentStatusList($scope.view); return locationService.getAllByTag('Operation Theater').then(function (response) { $scope.locations = response.data.results; @@ -101,6 +102,11 @@ angular.module('bahmni.ot') $state.view = $scope.view; }; + $scope.providerView = function (providerToggle) { + $rootScope.providerToggle = providerToggle; + $rootScope.$broadcast("event:providerView", providerToggle); + }; + var getBackGroundHSLColorFor = function (otCalendarColorAttribute) { var hue = otCalendarColorAttribute ? otCalendarColorAttribute.value.toString() : "0"; return "hsl(" + hue + ", 100%, 90%)"; @@ -185,6 +191,12 @@ angular.module('bahmni.ot') $scope.viewDate = Bahmni.Common.Util.DateUtil.addDays(date, 1); $state.viewDate = $scope.viewDate; }; + + $scope.goToSelectedDate = function (date) { + $scope.viewDate = date; + $state.viewDate = $scope.viewDate; + }; + $scope.goToCurrentWeek = function () { $scope.weekStartDate = Bahmni.Common.Util.DateUtil.getWeekStartDate(currentDate, $scope.startOfWeekCode); $state.weekStartDate = $scope.weekStartDate; @@ -211,6 +223,13 @@ angular.module('bahmni.ot') $state.weekEndDate = $scope.weekEndDate; }; + $scope.goToSelectedWeek = function (date) { + $scope.weekStartDate = date; + $scope.weekEndDate = Bahmni.Common.Util.DateUtil.addDays($scope.weekStartDate, 7); + $state.weekStartDate = $scope.weekStartDate; + $state.weekEndDate = $scope.weekEndDate; + }; + $scope.$on("event:surgicalAppointmentSelect", function (event, surgicalAppointment, surgicalBlock) { $scope.cancelDisabled = !(surgicalAppointment.status === Bahmni.OT.Constants.scheduled); $scope.moveButtonDisabled = !(surgicalAppointment.status === Bahmni.OT.Constants.scheduled); diff --git a/ui/app/ot/controller/otCalendarController.js b/ui/app/ot/controller/otCalendarController.js index 84076d4658..d4771d4b49 100644 --- a/ui/app/ot/controller/otCalendarController.js +++ b/ui/app/ot/controller/otCalendarController.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('bahmni.ot') - .controller('otCalendarController', ['$scope', '$q', '$interval', 'spinner', 'locationService', 'surgicalAppointmentService', '$timeout', - function ($scope, $q, $interval, spinner, locationService, surgicalAppointmentService, $timeout) { + .controller('otCalendarController', ['$scope', '$rootScope', '$q', '$interval', 'spinner', 'locationService', 'surgicalAppointmentService', '$timeout', 'appService', 'surgicalAppointmentHelper', + function ($scope, $rootScope, $q, $interval, spinner, locationService, surgicalAppointmentService, $timeout, appService, surgicalAppointmentHelper) { var updateCurrentDayTimeline = function () { $scope.currentTimeLineHeight = heightPerMin * Bahmni.Common.Util.DateUtil.diffInMinutes($scope.calendarStartDatetime, new Date()); }; @@ -27,20 +27,41 @@ angular.module('bahmni.ot') updateBlocksStartDatetimeAndBlocksEndDatetime(); $scope.rows = $scope.getRowsForCalendar(); return $q.all([locationService.getAllByTag('Operation Theater'), - surgicalAppointmentService.getSurgicalBlocksInDateRange($scope.blocksStartDatetime, $scope.blocksEndDatetime, false, true)]).then(function (response) { + surgicalAppointmentService.getSurgicalBlocksInDateRange($scope.blocksStartDatetime, $scope.blocksEndDatetime, false, true), + surgicalAppointmentService.getSurgeons()]).then(function (response) { $scope.locations = response[0].data.results; $scope.weekDates = $scope.getAllWeekDates(); - $scope.surgicalBlocksByLocation = _.map($scope.locations, function (location) { + var surgicalBlocksByLocation = _.map($scope.locations, function (location) { return _.filter(response[1].data.results, function (surgicalBlock) { return surgicalBlock.location.uuid === location.uuid; }); }); + var providerNames = appService.getAppDescriptor().getConfigValue("primarySurgeonsForOT"); + $scope.surgeons = surgicalAppointmentHelper.filterProvidersByName(providerNames, response[2].data.results); + var surgicalBlocksBySurgeons = _.map($scope.surgeons, function (surgeon) { + return _.filter(response[1].data.results, function (surgicalBlock) { + return surgicalBlock.provider.uuid === surgeon.uuid; + }); + }); $scope.surgicalBlocksByDate = _.map($scope.weekDates, function (weekDate) { return _.filter(response[1].data.results, function (surgicalBlock) { return $scope.isSurgicalBlockActiveOnGivenDate(surgicalBlock, weekDate); }); }); $scope.blockedOtsOfTheWeek = getBlockedOtsOfTheWeek(); + + var setOTView = function (providerToggle) { + $scope.providerToggle = providerToggle; + if (providerToggle) { + $scope.surgicalBlocks = surgicalBlocksBySurgeons; + } else { + $scope.surgicalBlocks = surgicalBlocksByLocation; + } + }; + setOTView($rootScope.providerToggle); + $scope.$on("event:providerView", function (event, providerToggle) { + setOTView(providerToggle); + }); }); }; diff --git a/ui/app/ot/views/home.html b/ui/app/ot/views/home.html index 04cb3477d4..50f1b0cac0 100644 --- a/ui/app/ot/views/home.html +++ b/ui/app/ot/views/home.html @@ -60,41 +60,41 @@
- {{viewDate | date : 'dd MMM yyyy, EEE'}} + + +
- {{weekStartDate | date : 'dd MMM yyyy, EEE'}} to {{weekEndDate | date : 'dd MMM yyyy, EEE'}} + + + + + +
-+ + - + - +
+ + - - + - +
diff --git a/ui/app/ot/views/otCalendar.html b/ui/app/ot/views/otCalendar.html index fc68b694bc..4651a0f369 100644 --- a/ui/app/ot/views/otCalendar.html +++ b/ui/app/ot/views/otCalendar.html @@ -1,9 +1,12 @@ -+
{{location.name}}
++ {{surgeon.person.display}} +