diff --git a/ui/app/i18n/ot/locale_en.json b/ui/app/i18n/ot/locale_en.json index e28eb4726d..97029a8246 100644 --- a/ui/app/i18n/ot/locale_en.json +++ b/ui/app/i18n/ot/locale_en.json @@ -95,5 +95,7 @@ "OT_SURGICAL_BLOCK_DIALOG_DURATION": "Duration", "OT_FILTER_KEY": "Filter", "OT_SURGICAL_APPOINTMENT_DIALOG_DETAILS": "Surgical Appointment Details", - "OT_SURGICAL_APPOINTMENT_ACTUAL_TIME": "Actual Time" + "OT_SURGICAL_APPOINTMENT_ACTUAL_TIME": "Actual Time", + "OT_SAVE_ANYWAY_KEY": "Save Anyway", + "OT_SURGICAL_BLOCK_MULTIPLE_DAYS_DIALOG_TITLE": "Warning - Creating Surgical Block" } diff --git a/ui/app/ot/controller/calendarViewController.js b/ui/app/ot/controller/calendarViewController.js index d3378e418d..1862efc9ff 100644 --- a/ui/app/ot/controller/calendarViewController.js +++ b/ui/app/ot/controller/calendarViewController.js @@ -214,6 +214,7 @@ angular.module('bahmni.ot') $scope.cancelDisabled = true; $scope.surgicalBlockSelected = surgicalBlock; $scope.surgicalAppointmentSelected = {}; + $scope.showEndDate = (Bahmni.Common.Util.DateUtil.diffInDaysRegardlessOfTime(surgicalBlock.startDatetime, surgicalBlock.endDatetime) != 0); var surgicalBlockWithCompletedAppointments = function () { return _.find(surgicalBlock.surgicalAppointments, function (appointment) { @@ -241,6 +242,7 @@ angular.module('bahmni.ot') $scope.addActualTimeDisabled = true; $scope.surgicalBlockSelected = {}; $scope.surgicalAppointmentSelected = {}; + $scope.showEndDate = false; }; $scope.$on("event:surgicalBlockDeselect", function (event) { diff --git a/ui/app/ot/controller/listViewController.js b/ui/app/ot/controller/listViewController.js index bec32eb520..b2b66e8581 100644 --- a/ui/app/ot/controller/listViewController.js +++ b/ui/app/ot/controller/listViewController.js @@ -77,6 +77,15 @@ angular.module('bahmni.ot') } return mappedAppointment; }); + surgicalBlock.surgicalAppointments = _.filter(surgicalBlock.surgicalAppointments, function (surgicalAppointment) { + if (surgicalAppointment.derivedAttributes.expectedStartTime) { + var surgicalAppointmentStartDateTime = surgicalAppointment.derivedAttributes.expectedStartTime; + var surgicalAppointmentEndDateTime = Bahmni.Common.Util.DateUtil.addMinutes(surgicalAppointmentStartDateTime, surgicalAppointment.derivedAttributes.duration); + return surgicalAppointmentStartDateTime < endDatetime && surgicalAppointmentEndDateTime > startDatetime; + } + return surgicalAppointment.derivedAttributes.expectedStartDate <= endDatetime + && surgicalAppointment.derivedAttributes.expectedStartDate >= startDatetime; + }); return surgicalBlock; }); @@ -100,7 +109,7 @@ angular.module('bahmni.ot') $scope.cancelDisabled = true; $scope.reverseSort = false; $scope.sortColumn = ""; - return $q.all([surgicalAppointmentService.getSurgicalBlocksInDateRange(startDatetime, endDatetime, true)]).then(function (response) { + return $q.all([surgicalAppointmentService.getSurgicalBlocksInDateRange(startDatetime, endDatetime, true, true)]).then(function (response) { $scope.surgicalBlocks = response[0].data.results; filterSurgicalBlocksAndMapAppointmentsForDisplay($scope.surgicalBlocks); }); diff --git a/ui/app/ot/controller/otCalendarController.js b/ui/app/ot/controller/otCalendarController.js index 146a55f483..84076d4658 100644 --- a/ui/app/ot/controller/otCalendarController.js +++ b/ui/app/ot/controller/otCalendarController.js @@ -27,7 +27,7 @@ angular.module('bahmni.ot') updateBlocksStartDatetimeAndBlocksEndDatetime(); $scope.rows = $scope.getRowsForCalendar(); return $q.all([locationService.getAllByTag('Operation Theater'), - surgicalAppointmentService.getSurgicalBlocksInDateRange($scope.blocksStartDatetime, $scope.blocksEndDatetime)]).then(function (response) { + surgicalAppointmentService.getSurgicalBlocksInDateRange($scope.blocksStartDatetime, $scope.blocksEndDatetime, false, true)]).then(function (response) { $scope.locations = response[0].data.results; $scope.weekDates = $scope.getAllWeekDates(); $scope.surgicalBlocksByLocation = _.map($scope.locations, function (location) { @@ -37,13 +37,18 @@ angular.module('bahmni.ot') }); $scope.surgicalBlocksByDate = _.map($scope.weekDates, function (weekDate) { return _.filter(response[1].data.results, function (surgicalBlock) { - return Bahmni.Common.Util.DateUtil.isSameDate(moment(surgicalBlock.startDatetime).startOf('day').toDate(), weekDate); + return $scope.isSurgicalBlockActiveOnGivenDate(surgicalBlock, weekDate); }); }); $scope.blockedOtsOfTheWeek = getBlockedOtsOfTheWeek(); }); }; + $scope.isSurgicalBlockActiveOnGivenDate = function (surgicalBlock, weekDate) { + return Bahmni.Common.Util.DateUtil.isSameDate(moment(surgicalBlock.startDatetime).startOf('day').toDate(), weekDate) + || moment(surgicalBlock.endDatetime).toDate() > weekDate; + }; + $scope.intervals = function () { var dayStart = ($scope.dayViewStart || '00:00').split(':'); var dayEnd = ($scope.dayViewEnd || '23:59').split(':'); diff --git a/ui/app/ot/controller/surgicalBlockController.js b/ui/app/ot/controller/surgicalBlockController.js index ade02c3952..d73aeebaae 100644 --- a/ui/app/ot/controller/surgicalBlockController.js +++ b/ui/app/ot/controller/surgicalBlockController.js @@ -65,6 +65,18 @@ angular.module('bahmni.ot') return true; }; + $scope.closeDialog = function () { + ngDialog.close(); + }; + + $scope.saveAnywaysFlag = false; + + $scope.saveAnyways = function (surgicalForm) { + $scope.saveAnywaysFlag = true; + $scope.save(surgicalForm); + ngDialog.close(); + }; + $scope.save = function (surgicalForm) { if (!$scope.isFormValid()) { messagingService.showMessage('error', "{{'OT_ENTER_MANDATORY_FIELDS' | translate}}"); @@ -74,16 +86,27 @@ angular.module('bahmni.ot') messagingService.showMessage('error', "{{'OT_SURGICAL_APPOINTMENT_EXCEEDS_BLOCK_DURATION' | translate}}"); return; } - $scope.updateSortWeight(surgicalForm); - var surgicalBlock = new Bahmni.OT.SurgicalBlockMapper().mapSurgicalBlockUIToDomain(surgicalForm); - var saveOrupdateSurgicalBlock = _.isEmpty(surgicalBlock.uuid) ? surgicalAppointmentService.saveSurgicalBlock : surgicalAppointmentService.updateSurgicalBlock; - spinner.forPromise(saveOrupdateSurgicalBlock(surgicalBlock)).then(function (response) { - $scope.surgicalForm = new Bahmni.OT.SurgicalBlockMapper().map(response.data, $scope.attributeTypes, $scope.surgeons); - $scope.surgicalForm.surgicalAppointments = surgicalAppointmentHelper.filterSurgicalAppointmentsByStatus( - $scope.surgicalForm.surgicalAppointments, [Bahmni.OT.Constants.scheduled, Bahmni.OT.Constants.completed]); - messagingService.showMessage('info', "{{'OT_SAVE_SUCCESS_MESSAGE_KEY' | translate}}"); - $state.go('editSurgicalAppointment', {surgicalBlockUuid: response.data.uuid}); - }); + if ($scope.saveAnywaysFlag || Bahmni.Common.Util.DateUtil.isSameDate(surgicalForm.startDatetime, surgicalForm.endDatetime)) { + $scope.updateSortWeight(surgicalForm); + var surgicalBlock = new Bahmni.OT.SurgicalBlockMapper().mapSurgicalBlockUIToDomain(surgicalForm); + var saveOrupdateSurgicalBlock = _.isEmpty(surgicalBlock.uuid) ? surgicalAppointmentService.saveSurgicalBlock : surgicalAppointmentService.updateSurgicalBlock; + spinner.forPromise(saveOrupdateSurgicalBlock(surgicalBlock)).then(function (response) { + $scope.surgicalForm = new Bahmni.OT.SurgicalBlockMapper().map(response.data, $scope.attributeTypes, $scope.surgeons); + $scope.surgicalForm.surgicalAppointments = surgicalAppointmentHelper.filterSurgicalAppointmentsByStatus( + $scope.surgicalForm.surgicalAppointments, [Bahmni.OT.Constants.scheduled, Bahmni.OT.Constants.completed]); + messagingService.showMessage('info', "{{'OT_SAVE_SUCCESS_MESSAGE_KEY' | translate}}"); + $state.go('editSurgicalAppointment', {surgicalBlockUuid: response.data.uuid}); + }); + $scope.saveAnywaysFlag = false; + } else { + ngDialog.open({ + template: 'views/surgicalBlockMultipleDaysDialog.html', + className: 'ngdialog-theme-default', + closeByNavigation: true, + data: { surgicalForm: surgicalForm }, + scope: $scope + }); + } }; var addOrUpdateTheSurgicalAppointment = function (surgicalAppointment) { diff --git a/ui/app/ot/directives/otCalendarSurgicalAppointment.js b/ui/app/ot/directives/otCalendarSurgicalAppointment.js index 4c1e69e5a1..7d2676f805 100644 --- a/ui/app/ot/directives/otCalendarSurgicalAppointment.js +++ b/ui/app/ot/directives/otCalendarSurgicalAppointment.js @@ -31,7 +31,7 @@ angular.module('bahmni.ot') }; var getHeightForSurgicalAppointment = function () { - return $scope.surgicalAppointment.derivedAttributes.duration * $scope.heightPerMin; + return $scope.surgicalAppointment.derivedAttributes.height * $scope.heightPerMin; }; $scope.selectSurgicalAppointment = function ($event) { diff --git a/ui/app/ot/directives/otCalendarSurgicalBlock.js b/ui/app/ot/directives/otCalendarSurgicalBlock.js index cfd5fb6224..7d72a27382 100644 --- a/ui/app/ot/directives/otCalendarSurgicalBlock.js +++ b/ui/app/ot/directives/otCalendarSurgicalBlock.js @@ -18,7 +18,7 @@ angular.module('bahmni.ot') left: $scope.weekOrDay === 'week' ? getLeftPositionForSurgicalBlock() : 0, color: getColorForProvider(), appointmentHeightPerMin: (surgicalBlockHeight - heightForSurgeonName) / Bahmni.Common.Util.DateUtil.diffInMinutes( - $scope.surgicalBlock.startDatetime, $scope.surgicalBlock.endDatetime) + getSurgicalBlockStartDateTimeBasedOnCalendarStartDateTime(), getSurgicalBlockEndDateTimeBasedOnCalendarEndDateTime()) }; }; @@ -50,12 +50,13 @@ angular.module('bahmni.ot') }; var getHeightForSurgicalBlock = function () { return Bahmni.Common.Util.DateUtil.diffInMinutes( - $scope.surgicalBlock.startDatetime, $scope.surgicalBlock.endDatetime) * surgicalBlockHeightPerMin; + getSurgicalBlockStartDateTimeBasedOnCalendarStartDateTime(), getSurgicalBlockEndDateTimeBasedOnCalendarEndDateTime()) * surgicalBlockHeightPerMin; }; var getTopForSurgicalBlock = function () { - return Bahmni.Common.Util.DateUtil.diffInMinutes( - getCalendarStartDateTime($scope.surgicalBlock.startDatetime), $scope.surgicalBlock.startDatetime) * surgicalBlockHeightPerMin; + var top = Bahmni.Common.Util.DateUtil.diffInMinutes( + getCalendarStartDateTime($scope.viewDate), $scope.surgicalBlock.startDatetime) * surgicalBlockHeightPerMin; + return top > 0 ? top : 0; }; var getCalendarStartDateTime = function (date) { var dayStart = ($scope.dayViewStart || Bahmni.OT.Constants.defaultCalendarStartTime).split(':'); @@ -66,6 +67,17 @@ angular.module('bahmni.ot') var dayEnd = ($scope.dayViewEnd || Bahmni.OT.Constants.defaultCalendarEndTime).split(':'); return Bahmni.Common.Util.DateUtil.addMinutes(moment(date).startOf('day'), (dayEnd[0] * 60 + parseInt(dayEnd[1]))); }; + + var getSurgicalBlockStartDateTimeBasedOnCalendarStartDateTime = function () { + return moment($scope.surgicalBlock.startDatetime).toDate() < getCalendarStartDateTime($scope.viewDate) + ? getCalendarStartDateTime($scope.viewDate) : $scope.surgicalBlock.startDatetime; + }; + + var getSurgicalBlockEndDateTimeBasedOnCalendarEndDateTime = function () { + return getCalendarEndDateTime($scope.viewDate) < moment($scope.surgicalBlock.endDatetime).toDate() + ? getCalendarEndDateTime($scope.viewDate) : $scope.surgicalBlock.endDatetime; + }; + var calculateEstimatedAppointmentDuration = function () { var surgicalAppointments = _.filter($scope.surgicalBlock.surgicalAppointments, function (surgicalAppointment) { return $scope.isValidSurgicalAppointment(surgicalAppointment); @@ -78,6 +90,12 @@ angular.module('bahmni.ot') surgicalAppointment.derivedAttributes.expectedStartDatetime = nextAppointmentStartDatetime; surgicalAppointment.derivedAttributes.expectedEndDatetime = Bahmni.Common.Util.DateUtil.addMinutes(nextAppointmentStartDatetime, surgicalAppointment.derivedAttributes.duration); + surgicalAppointment.derivedAttributes.height = Bahmni.Common.Util.DateUtil.diffInMinutes( + surgicalAppointment.derivedAttributes.expectedStartDatetime < getCalendarStartDateTime($scope.viewDate) + ? getCalendarStartDateTime($scope.viewDate) : surgicalAppointment.derivedAttributes.expectedStartDatetime, + getCalendarEndDateTime($scope.viewDate) < surgicalAppointment.derivedAttributes.expectedEndDatetime + ? getCalendarEndDateTime($scope.viewDate) : surgicalAppointment.derivedAttributes.expectedEndDatetime + ); nextAppointmentStartDatetime = surgicalAppointment.derivedAttributes.expectedEndDatetime; return surgicalAppointment; }); @@ -87,6 +105,12 @@ angular.module('bahmni.ot') return surgicalAppointment.status !== Bahmni.OT.Constants.cancelled && surgicalAppointment.status !== Bahmni.OT.Constants.postponed; }; + $scope.canShowInCalendarView = function (surgicalAppointment) { + return $scope.isValidSurgicalAppointment(surgicalAppointment) + && surgicalAppointment.derivedAttributes.expectedStartDatetime < getCalendarEndDateTime($scope.viewDate) + && surgicalAppointment.derivedAttributes.expectedEndDatetime > getCalendarStartDateTime($scope.viewDate); + }; + $scope.selectSurgicalBlock = function ($event) { $scope.$emit("event:surgicalBlockSelect", $scope.surgicalBlock); $event.stopPropagation(); @@ -119,7 +143,8 @@ angular.module('bahmni.ot') dayViewEnd: "=", dayViewSplit: "=", filterParams: "=", - weekOrDay: "=" + weekOrDay: "=", + viewDate: "=" }, templateUrl: "../ot/views/calendarSurgicalBlock.html" }; diff --git a/ui/app/ot/services/surgicalAppointmentService.js b/ui/app/ot/services/surgicalAppointmentService.js index 60ed62c73d..fdd9e91918 100644 --- a/ui/app/ot/services/surgicalAppointmentService.js +++ b/ui/app/ot/services/surgicalAppointmentService.js @@ -50,13 +50,14 @@ angular.module('bahmni.ot') }); }; - this.getSurgicalBlocksInDateRange = function (startDatetime, endDatetime, includeVoided) { + this.getSurgicalBlocksInDateRange = function (startDatetime, endDatetime, includeVoided, activeBlocks) { return $http.get(Bahmni.OT.Constants.addSurgicalBlockUrl, { method: "GET", params: { startDatetime: Bahmni.Common.Util.DateUtil.parseLongDateToServerFormat(startDatetime), endDatetime: Bahmni.Common.Util.DateUtil.parseLongDateToServerFormat(endDatetime), includeVoided: includeVoided || false, + activeBlocks: activeBlocks || false, v: "custom:(id,uuid," + "provider:(uuid,person:(uuid,display),attributes:(attributeType:(display),value,voided))," + "location:(uuid,name),startDatetime,endDatetime,surgicalAppointments:(id,uuid,patient:(uuid,display,person:(age))," + diff --git a/ui/app/ot/views/addActualTimeDialog.html b/ui/app/ot/views/addActualTimeDialog.html index f7aa887620..07e8334d69 100644 --- a/ui/app/ot/views/addActualTimeDialog.html +++ b/ui/app/ot/views/addActualTimeDialog.html @@ -2,12 +2,18 @@

{{'OT_SURGICAL_APPOINTMENT_ADD_ACTUAL_TIME_FOR' | translate}} {{patientDisplayLabel}}

- + + + +

- + + + +

@@ -18,4 +24,4 @@

{{'OT_SURGICAL_APPOINTMENT_ADD_ACTUAL

- \ No newline at end of file + diff --git a/ui/app/ot/views/calendarSurgicalBlock.html b/ui/app/ot/views/calendarSurgicalBlock.html index 6f10317f15..cb4769f63a 100644 --- a/ui/app/ot/views/calendarSurgicalBlock.html +++ b/ui/app/ot/views/calendarSurgicalBlock.html @@ -10,7 +10,7 @@ week-or-day="weekOrDay" operation-theatre="operationTheatre" background-color="blockDimensions.color" - ng-if="isValidSurgicalAppointment(surgicalAppointment)" + ng-if="canShowInCalendarView(surgicalAppointment)" height-per-min="blockDimensions.appointmentHeightPerMin" filter-params="filterParams"> diff --git a/ui/app/ot/views/otCalendar.html b/ui/app/ot/views/otCalendar.html index 0041cb81eb..fc68b694bc 100644 --- a/ui/app/ot/views/otCalendar.html +++ b/ui/app/ot/views/otCalendar.html @@ -25,6 +25,7 @@ day-view-split="::dayViewSplit" filter-params="filterParams" week-or-day="::weekOrDay" + view-date="::viewDate" >

{{'OT_SURGICAL_APPOINTMENT_DIALOG_DETAILS' | translate}}

{{'OT_PATIENT' | translate}}: {{getPatientDisplayLabel(ngDialogData)}}

{{'OT_SURGICAL_BLOCK_DIALOG_LOCATION' | translate}}: {{surgicalBlockSelected.location.name}}

-

{{'OT_SURGICAL_APPOINTMENT_ESTIMATED_TIME' | - translate}}: {{ngDialogData.derivedAttributes.expectedStartDatetime | bahmniTime}} - - {{ngDialogData.derivedAttributes.expectedEndDatetime | bahmniTime}}

+

{{'OT_SURGICAL_APPOINTMENT_ESTIMATED_TIME' | translate}}: + {{ngDialogData.derivedAttributes.expectedStartDatetime | date : 'dd MMM, '}}{{ngDialogData.derivedAttributes.expectedStartDatetime | bahmniTime}} - + {{ngDialogData.derivedAttributes.expectedEndDatetime | date : 'dd MMM, '}}{{ngDialogData.derivedAttributes.expectedEndDatetime | bahmniTime}}

{{'OT_SURGICAL_APPOINTMENT_PROCEDURE' | translate}}: {{attributes.procedure}}

{{'OT_SURGICAL_APPOINTMENT_ANAESTHETIST' | translate}}: {{attributes.anaesthetist}}

{{'OT_SURGICAL_APPOINTMENT_NOTES' | translate}}: {{attributes.notes}}


{{'OT_SURGICAL_APPOINTMENT_ACTUAL_TIME' | translate}}: - {{ngDialogData.actualStartDatetime | bahmniTime}} - {{ngDialogData.actualEndDatetime | bahmniTime}}

+ {{ngDialogData.actualStartDatetime | date : 'dd MMM, '}}{{ngDialogData.actualStartDatetime | bahmniTime}} - + {{ngDialogData.actualEndDatetime | date : 'dd MMM, '}}{{ngDialogData.actualEndDatetime | bahmniTime}}

- \ No newline at end of file + diff --git a/ui/app/ot/views/surgicalBlockMultipleDaysDialog.html b/ui/app/ot/views/surgicalBlockMultipleDaysDialog.html new file mode 100644 index 0000000000..221283a56c --- /dev/null +++ b/ui/app/ot/views/surgicalBlockMultipleDaysDialog.html @@ -0,0 +1,13 @@ +
+
+

{{ 'OT_SURGICAL_BLOCK_MULTIPLE_DAYS_DIALOG_TITLE' | translate }}

+

Are you sure you want to create a surgical block across days?

+
+ + +
+
diff --git a/ui/app/styles/ot/_ot.scss b/ui/app/styles/ot/_ot.scss index 7714c42423..ef97eed751 100644 --- a/ui/app/styles/ot/_ot.scss +++ b/ui/app/styles/ot/_ot.scss @@ -277,6 +277,10 @@ div[ng-app="ot"] { text-align: center; padding: 15px 0px 3px 0px; } + .ot-actual-datetime-input { + text-align: center; + display: block; + } .ot-actual-time-input { word-spacing: 1px; font-size: 18px; @@ -284,7 +288,6 @@ div[ng-app="ot"] { border-radius: 6px; padding: 0px 10px 0px 30px; margin: 0px auto 0px !important; - display: block; } .ot-actual-time-notes { min-height: 100px; diff --git a/ui/test/unit/ot/controller/listViewController.spec.js b/ui/test/unit/ot/controller/listViewController.spec.js index 55e14dfedc..f904a8edd4 100644 --- a/ui/test/unit/ot/controller/listViewController.spec.js +++ b/ui/test/unit/ot/controller/listViewController.spec.js @@ -368,7 +368,7 @@ describe('listViewController', function () { it("should sort the appointments by start date and by the location and by start time", function () { - scope.viewDate = moment('2017-02-22').toDate(); + scope.viewDate = moment('2017-06-22').toDate(); scope.filterParams = { providers: [], locations: {"OT 1": true, "OT 2": true, "OT 3": true}, @@ -376,7 +376,7 @@ describe('listViewController', function () { statusList: [] }; createController(); - expect(surgicalAppointmentService.getSurgicalBlocksInDateRange).toHaveBeenCalledWith(jasmine.any(Date), jasmine.any(Date), true); + expect(surgicalAppointmentService.getSurgicalBlocksInDateRange).toHaveBeenCalledWith(jasmine.any(Date), jasmine.any(Date), true, true); expect(scope.surgicalAppointmentList.length).toEqual(6); expect(scope.surgicalAppointmentList[0].id).toEqual(104); expect(scope.surgicalAppointmentList[1].id).toEqual(105); @@ -387,6 +387,7 @@ describe('listViewController', function () { }); it("should set the derived attributes for appointments", function () { + scope.viewDate = moment('2017-06-22').toDate(); scope.filterParams = { providers: [], locations: {"OT 1": true, "OT 2": false, "OT 3": false}, @@ -455,6 +456,7 @@ describe('listViewController', function () { }); it("should sort appointments by the sort column", function () { + scope.viewDate = moment('2017-06-22').toDate(); scope.filterParams = { providers: [], locations: {"OT 1": true, "OT 2": true, "OT 3": true}, @@ -523,6 +525,7 @@ describe('listViewController', function () { }); it("should reverse sort appointments if sorted on the same column consecutively", function () { + scope.viewDate = moment('2017-06-22').toDate(); scope.filterParams = { providers: [], locations: {"OT 1": true, "OT 2": true, "OT 3": true}, diff --git a/ui/test/unit/ot/controller/otCalendarController.spec.js b/ui/test/unit/ot/controller/otCalendarController.spec.js index 916215d466..5b59f6e98b 100644 --- a/ui/test/unit/ot/controller/otCalendarController.spec.js +++ b/ui/test/unit/ot/controller/otCalendarController.spec.js @@ -123,7 +123,7 @@ describe("otCalendarController", function () { }); scope.weekOrDay = 'day'; createController(); - expect(surgicalAppointmentService.getSurgicalBlocksInDateRange).toHaveBeenCalledWith(scope.viewDate, moment(scope.viewDate).endOf('day')); + expect(surgicalAppointmentService.getSurgicalBlocksInDateRange).toHaveBeenCalledWith(scope.viewDate, moment(scope.viewDate).endOf('day'), false, true); expect(scope.surgicalBlocksByLocation.length).toEqual(2); expect(scope.surgicalBlocksByLocation[0][0]).toEqual(surgicalBlocks[0]); expect(scope.surgicalBlocksByLocation[1][0]).toEqual(surgicalBlocks[1]); @@ -171,13 +171,12 @@ describe("otCalendarController", function () { scope.weekOrDay = 'week'; scope.weekStartDate = moment('2020-04-06').toDate(); createController(); - scope.updateBlockedOtsOfTheDay(4); expect(scope.blockedOtsOfTheWeek.length).toEqual(7); - expect(scope.blockedOtsOfTheWeek[0]).toEqual([]); - expect(scope.blockedOtsOfTheWeek[1]).toEqual([]); - expect(scope.blockedOtsOfTheWeek[2]).toEqual([]); - expect(scope.blockedOtsOfTheWeek[3]).toEqual([]); - expect(scope.blockedOtsOfTheWeek[4]).toEqual(["uuid1"]); + expect(scope.blockedOtsOfTheWeek[0]).toEqual(['uuid1', 'uuid2']); + expect(scope.blockedOtsOfTheWeek[1]).toEqual(['uuid1', 'uuid2']); + expect(scope.blockedOtsOfTheWeek[2]).toEqual(['uuid1', 'uuid2']); + expect(scope.blockedOtsOfTheWeek[3]).toEqual(['uuid1', 'uuid2']); + expect(scope.blockedOtsOfTheWeek[4]).toEqual(['uuid1', 'uuid2']); expect(scope.blockedOtsOfTheWeek[5]).toEqual(["uuid2"]); expect(scope.blockedOtsOfTheWeek[6]).toEqual([]); @@ -190,7 +189,7 @@ describe("otCalendarController", function () { scope.weekOrDay = 'week'; scope.weekStartDate = moment('2020-04-06').toDate(); createController(); - expect(surgicalAppointmentService.getSurgicalBlocksInDateRange).toHaveBeenCalledWith(moment(scope.weekStartDate).startOf('day'), moment(Bahmni.Common.Util.DateUtil.getWeekEndDate(scope.weekStartDate)).endOf('day')); + expect(surgicalAppointmentService.getSurgicalBlocksInDateRange).toHaveBeenCalledWith(moment(scope.weekStartDate).startOf('day'), moment(Bahmni.Common.Util.DateUtil.getWeekEndDate(scope.weekStartDate)).endOf('day'), false, true); expect(scope.surgicalBlocksByDate.length).toEqual(7); expect(scope.surgicalBlocksByDate[4][0]).toEqual(weekSurgicalBlocks[0]); expect(scope.surgicalBlocksByDate[5][0]).toEqual(weekSurgicalBlocks[1]); @@ -204,8 +203,8 @@ describe("otCalendarController", function () { scope.weekStartDate = moment('2020-04-06').toDate(); createController(); scope.updateBlockedOtsOfTheDay(4); - expect(scope.blockedOtsOfTheDay.length).toEqual(1); - expect(scope.blockedOtsOfTheDay).toEqual(["uuid1"]); + expect(scope.blockedOtsOfTheDay.length).toEqual(2); + expect(scope.blockedOtsOfTheDay).toEqual(["uuid1", "uuid2"]); }); }); diff --git a/ui/test/unit/ot/controller/surgicalBlockController.spec.js b/ui/test/unit/ot/controller/surgicalBlockController.spec.js index 9e5aab6167..f53987a706 100644 --- a/ui/test/unit/ot/controller/surgicalBlockController.spec.js +++ b/ui/test/unit/ot/controller/surgicalBlockController.spec.js @@ -390,6 +390,7 @@ describe("surgicalBlockController", function () { scope.surgicalForm.location = {uuid: "locationUuid"}; scope.surgicalForm.surgicalAppointments = [{id: "11", patient: {uuid: "patientUuid"}, notes: "need more assistants", sortWeight: 0, surgicalAppointmentAttributes: uiSurgicalAppointmentAttributes}]; + scope.saveAnywaysFlag = true; scope.save(scope.surgicalForm); expect(surgicalAppointmentService.saveSurgicalBlock).toHaveBeenCalled(); @@ -427,6 +428,7 @@ describe("surgicalBlockController", function () { scope.surgicalForm.location = {uuid: "locationUuid"}; scope.surgicalForm.surgicalAppointments = [{id: "11", patient: {uuid: "patientUuid"}, notes: "need more assistants", sortWeight: 0, surgicalAppointmentAttributes: uiSurgicalAppointmentAttributes}]; + scope.saveAnywaysFlag = true; scope.save(scope.surgicalForm); expect(surgicalAppointmentService.updateSurgicalBlock).toHaveBeenCalled(); diff --git a/ui/test/unit/ot/directives/otCalendarSurgicalAppointment.spec.js b/ui/test/unit/ot/directives/otCalendarSurgicalAppointment.spec.js index c4548f9301..654c69cf8c 100644 --- a/ui/test/unit/ot/directives/otCalendarSurgicalAppointment.spec.js +++ b/ui/test/unit/ot/directives/otCalendarSurgicalAppointment.spec.js @@ -57,7 +57,8 @@ describe("otCalendarSurgicalAppointment", function () { }], "derivedAttributes": { - duration: 136 + duration: 136, + height: 136 } }; scope.filterParams = { diff --git a/ui/test/unit/ot/directives/otCalendarSurgicalBlock.spec.js b/ui/test/unit/ot/directives/otCalendarSurgicalBlock.spec.js index e2decdf890..8a91a8c380 100644 --- a/ui/test/unit/ot/directives/otCalendarSurgicalBlock.spec.js +++ b/ui/test/unit/ot/directives/otCalendarSurgicalBlock.spec.js @@ -3,7 +3,7 @@ describe("otCalendarSurgicalBlock", function () { var simpleHtml = ''; + ' day-view-split="dayViewSplit" filter-params="filterParams" week-or-day="::weekOrDay" view-date="::viewDate" >'; var $compile, element, mockBackend, scope; beforeEach(module('ngHtml2JsPreprocessor')); @@ -44,6 +44,7 @@ describe("otCalendarSurgicalBlock", function () { scope.dayViewEnd = "16:00"; scope.dayViewSplit = 30; scope.weekOrDay = 'day'; + scope.viewDate = "2017-05-24 09:00:00"; mockBackend.expectGET('../ot/views/calendarSurgicalBlock.html').respond("
dummy
"); element = $compile(simpleHtml)(scope); @@ -81,6 +82,7 @@ describe("otCalendarSurgicalBlock", function () { scope.dayViewEnd = "16:00"; scope.dayViewSplit = 30; scope.weekOrDay = 'day'; + scope.viewDate = "2017-05-24 09:00:00"; mockBackend.expectGET('../ot/views/calendarSurgicalBlock.html').respond("
dummy
"); element = $compile(simpleHtml)(scope); @@ -231,6 +233,7 @@ describe("otCalendarSurgicalBlock", function () { scope.dayViewSplit = 30; scope.weekOrDay = 'week'; scope.blockedOtsOfTheDay = ["3353ccb2-3086-11e7-b60e-0800274a5156"]; + scope.viewDate = "2017-05-24 09:00:00"; mockBackend.expectGET('../ot/views/calendarSurgicalBlock.html').respond("
dummy
"); element = $compile(simpleHtml)(scope); @@ -255,6 +258,7 @@ describe("otCalendarSurgicalBlock", function () { scope.dayViewSplit = 30; scope.weekOrDay = 'week'; scope.blockedOtsOfTheDay = ["3e175fd1-4ce5-11e7-9b35-000c29e530d2", "3353ccb2-3086-11e7-b60e-0800274a5156", "3e1740e5-4ce5-11e7-9b35-000c29e530d2"]; + scope.viewDate = "2017-05-24 09:00:00"; mockBackend.expectGET('../ot/views/calendarSurgicalBlock.html').respond("
dummy
"); element = $compile(simpleHtml)(scope); diff --git a/ui/test/unit/ot/services/surgicalAppointmentService.spec.js b/ui/test/unit/ot/services/surgicalAppointmentService.spec.js index 1b78fe5877..4c7ccdc75f 100644 --- a/ui/test/unit/ot/services/surgicalAppointmentService.spec.js +++ b/ui/test/unit/ot/services/surgicalAppointmentService.spec.js @@ -90,14 +90,14 @@ describe('surgicalAppointmentService', function () { mockHttp.get.and.returnValue(specUtil.respondWith(data)); - surgicalAppointmentService.getSurgicalBlocksInDateRange(startDatetime, endDatetime).then(function (response) { + surgicalAppointmentService.getSurgicalBlocksInDateRange(startDatetime, endDatetime, false, true).then(function (response) { expect(response).toEqual(data); done(); }); expect(mockHttp.get).toHaveBeenCalled(); expect(mockHttp.get.calls.mostRecent().args[0]).toBe("/openmrs/ws/rest/v1/surgicalBlock"); - expect(mockHttp.get.calls.mostRecent().args[1].params).toEqual({ startDatetime : '2039-08-26T12:00:00.000', endDatetime : '2039-08-26T15:00:00.000',includeVoided: false, v: "custom:(id,uuid," + + expect(mockHttp.get.calls.mostRecent().args[1].params).toEqual({ startDatetime : '2039-08-26T12:00:00.000', endDatetime : '2039-08-26T15:00:00.000',includeVoided: false, activeBlocks: true, v: "custom:(id,uuid," + "provider:(uuid,person:(uuid,display),attributes:(attributeType:(display),value,voided))," + "location:(uuid,name),startDatetime,endDatetime,surgicalAppointments:(id,uuid,patient:(uuid,display,person:(age))," + "actualStartDatetime,actualEndDatetime,status,notes,sortWeight,bedNumber,bedLocation,surgicalAppointmentAttributes))"});