From 5ae742be2dd3e2d7a3dfad367bba6adcc01206b4 Mon Sep 17 00:00:00 2001 From: Arjun-Go Date: Tue, 7 May 2024 11:29:54 +0530 Subject: [PATCH 1/4] fix. awaiting appointments search post API update --- .../manage/list/appointmentsListViewController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/manage/list/appointmentsListViewController.js b/src/controllers/manage/list/appointmentsListViewController.js index 19dd030af..a83d9d584 100644 --- a/src/controllers/manage/list/appointmentsListViewController.js +++ b/src/controllers/manage/list/appointmentsListViewController.js @@ -31,7 +31,7 @@ angular.module('bahmni.appointments') var enableAutoRefresh = !isNaN(autoRefreshIntervalInSeconds); var autoRefreshStatus = true; const APPOINTMENT_STATUS_WAITLIST = { - "isDatelessAppointments": true + "withoutDates": true } const APPOINTMENTS_TAB_NAME = "appointments"; const AWAITING_APPOINTMENTS_TAB_NAME = "awaitingappointments"; @@ -108,7 +108,8 @@ angular.module('bahmni.appointments') } else return appointmentsService.search( prefilledPatient ? { patientUuid: prefilledPatient } : APPOINTMENT_STATUS_WAITLIST) - .then((response) => updateAppointments(response)); + .then((response) => updateAppointments(response)) + .catch((error) => messagingService.showMessage('error', 'UNEXPECTED_SERVICE_ERROR')); }; var updateAppointments = function (response){ From dd31be98a8e99d61b0aa29a0f8e79790c489a87d Mon Sep 17 00:00:00 2001 From: Arjun-Go Date: Tue, 7 May 2024 14:31:04 +0530 Subject: [PATCH 2/4] add. filter for awaiting appointments for bulk waitlists --- i18n/appointments/locale_en.json | 1 + .../manage/appointmentsFilterController.js | 12 ++++++++++-- .../manage/list/appointmentsListViewController.js | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/i18n/appointments/locale_en.json b/i18n/appointments/locale_en.json index 74a46122d..14e483b21 100644 --- a/i18n/appointments/locale_en.json +++ b/i18n/appointments/locale_en.json @@ -216,6 +216,7 @@ "RECURRENCE_WEEKDAYS_ERROR_MESSAGE": "Please select the day(s)", "NO_CONTENT_ERROR_MESSAGE": "Selected days do not fall under the end date selected", "UNEXPECTED_SERVICE_ERROR": "There was an unexpected issue on the server. Please try again", + "APPOINTMENT_SEARCH_TIME_ERROR": "Connection timed out. The request took too long to complete.", "PRIORITY_ERROR_MESSAGE": "Please select appointment category", "STATUS_ERROR_MESSAGE": "Please select appointment status", "PUBLIC_HOLIDAY_WARNING": "Date selected is a Public Holiday", diff --git a/src/controllers/manage/appointmentsFilterController.js b/src/controllers/manage/appointmentsFilterController.js index 8a1b22282..7f1332df7 100644 --- a/src/controllers/manage/appointmentsFilterController.js +++ b/src/controllers/manage/appointmentsFilterController.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('bahmni.appointments') - .controller('AppointmentsFilterController', ['$scope', '$state', '$rootScope', '$q', '$translate', 'appointmentsServiceService', 'spinner', 'ivhTreeviewMgr', 'providerService', 'appService', 'locationService', - function ($scope, $state, $rootScope, $q, $translate, appointmentsServiceService, spinner, ivhTreeviewMgr, providerService, appService, locationService) { + .controller('AppointmentsFilterController', ['$scope', '$state', '$rootScope', '$q', '$translate', 'appointmentsServiceService', 'spinner', 'ivhTreeviewMgr', 'providerService', 'appService', 'locationService', 'appointmentsService', + function ($scope, $state, $rootScope, $q, $translate, appointmentsServiceService, spinner, ivhTreeviewMgr, providerService, appService, locationService, appointmentsService) { var init = function () { $scope.isSpecialityEnabled = appService.getAppDescriptor().getConfigValue('enableSpecialities'); $scope.isServiceTypeEnabled = appService.getAppDescriptor().getConfigValue('enableServiceTypes'); @@ -254,6 +254,14 @@ angular.module('bahmni.appointments') $state.params.filterParams.statusList = _.map($scope.selectedStatusList, function (status) { return status.value; }); + const AWAITING_APPOINTMENTS_TAB_NAME = "awaitingappointments"; + if($state.current.tabName === AWAITING_APPOINTMENTS_TAB_NAME) { + let payload = $state.params.filterParams; + payload.withoutDates = true; + spinner.forPromise(appointmentsService.search(payload).then(function (response) { + $rootScope.appointmentsData = response.data; + })); + } }; $scope.isFilterApplied = function () { diff --git a/src/controllers/manage/list/appointmentsListViewController.js b/src/controllers/manage/list/appointmentsListViewController.js index a83d9d584..0494be9b3 100644 --- a/src/controllers/manage/list/appointmentsListViewController.js +++ b/src/controllers/manage/list/appointmentsListViewController.js @@ -109,7 +109,7 @@ angular.module('bahmni.appointments') else return appointmentsService.search( prefilledPatient ? { patientUuid: prefilledPatient } : APPOINTMENT_STATUS_WAITLIST) .then((response) => updateAppointments(response)) - .catch((error) => messagingService.showMessage('error', 'UNEXPECTED_SERVICE_ERROR')); + .catch((error) => messagingService.showMessage('error', 'APPOINTMENT_SEARCH_TIME_ERROR')); }; var updateAppointments = function (response){ From 22867033bd802c98da1b55bbd20f877336940043 Mon Sep 17 00:00:00 2001 From: Arjun-Go Date: Wed, 8 May 2024 11:28:56 +0530 Subject: [PATCH 3/4] fix. existing tests after appointments earch API update --- src/controllers/manage/appointmentsCreateController.js | 2 +- src/controllers/manage/list/appointmentsListViewController.js | 4 ++-- src/directives/patientSearch.js | 2 +- test/controllers/manage/appointmentsCreateController.spec.js | 2 +- test/directives/patientSearch.spec.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/controllers/manage/appointmentsCreateController.js b/src/controllers/manage/appointmentsCreateController.js index 30d85e252..431b274c5 100644 --- a/src/controllers/manage/appointmentsCreateController.js +++ b/src/controllers/manage/appointmentsCreateController.js @@ -157,7 +157,7 @@ angular.module('bahmni.appointments') $scope.onSelectPatient = function (data) { $scope.appointment.patient = data; - return spinner.forPromise(appointmentsService.search({patientUuid: data.uuid}).then(function (oldAppointments) { + return spinner.forPromise(appointmentsService.search({patientUuids: [data.uuid]}).then(function (oldAppointments) { $scope.patientAppointments = oldAppointments.data; })); }; diff --git a/src/controllers/manage/list/appointmentsListViewController.js b/src/controllers/manage/list/appointmentsListViewController.js index 0494be9b3..45540ec1c 100644 --- a/src/controllers/manage/list/appointmentsListViewController.js +++ b/src/controllers/manage/list/appointmentsListViewController.js @@ -107,7 +107,7 @@ angular.module('bahmni.appointments') .then((response) => updateAppointments(response)); } else - return appointmentsService.search( prefilledPatient ? { patientUuid: prefilledPatient } : APPOINTMENT_STATUS_WAITLIST) + return appointmentsService.search( prefilledPatient ? { patientUuids: [prefilledPatient] } : APPOINTMENT_STATUS_WAITLIST) .then((response) => updateAppointments(response)) .catch((error) => messagingService.showMessage('error', 'APPOINTMENT_SEARCH_TIME_ERROR')); }; @@ -151,7 +151,7 @@ angular.module('bahmni.appointments') } var setAppointmentsInPatientSearch = function (patientUuid) { - appointmentsService.search({patientUuid: patientUuid}).then(function (response) { + appointmentsService.search({patientUuids: [patientUuid]}).then(function (response) { var appointmentsInDESCOrderBasedOnStartDateTime = _.sortBy(response.data, "startDateTime").reverse(); setFilteredAppointmentsInPatientSearch(appointmentsInDESCOrderBasedOnStartDateTime); }); diff --git a/src/directives/patientSearch.js b/src/directives/patientSearch.js index 88e6a440b..066289e67 100644 --- a/src/directives/patientSearch.js +++ b/src/directives/patientSearch.js @@ -27,7 +27,7 @@ angular.module('bahmni.appointments') $scope.onSelectPatient = function (data) { $state.params.patient = data; - spinner.forPromise(appointmentsService.search({patientUuid: data.uuid}).then(function (oldAppointments) { + spinner.forPromise(appointmentsService.search({patientUuids: [data.uuid]}).then(function (oldAppointments) { var appointmentInDESCOrderBasedOnStartDateTime = _.sortBy(oldAppointments.data, "startDateTime").reverse(); $scope.onSearch(appointmentInDESCOrderBasedOnStartDateTime); })); diff --git a/test/controllers/manage/appointmentsCreateController.spec.js b/test/controllers/manage/appointmentsCreateController.spec.js index c74d31fcc..e103db5d6 100644 --- a/test/controllers/manage/appointmentsCreateController.spec.js +++ b/test/controllers/manage/appointmentsCreateController.spec.js @@ -284,7 +284,7 @@ describe("AppointmentsCreateController", function () { $scope.patientAppointments = undefined; var patientUuid = 'uuid'; appointmentContext = {appointment: {patient:{uuid: patientUuid}}}; - var appointmentSearchParams = {patientUuid: patientUuid}; + var appointmentSearchParams = {patientUuids: [patientUuid]}; createController(); expect(appointmentsService.search).toHaveBeenCalledWith(appointmentSearchParams); diff --git a/test/directives/patientSearch.spec.js b/test/directives/patientSearch.spec.js index 2d3f5811e..dd1aa780a 100644 --- a/test/directives/patientSearch.spec.js +++ b/test/directives/patientSearch.spec.js @@ -69,7 +69,7 @@ describe("Patient Search", function () { var patient = {uuid: 'patientUuid'}; compiledScope.onSelectPatient(patient); expect(state.params.patient).toEqual(patient); - expect(appointmentsService.search).toHaveBeenCalledWith({patientUuid: patient.uuid}); + expect(appointmentsService.search).toHaveBeenCalledWith({patientUuids: [patient.uuid]}); expect(scope.displaySearchedPatient).toHaveBeenCalled(); }); @@ -90,7 +90,7 @@ describe("Patient Search", function () { var element = createElement(); var compiledScope = element.isolateScope(); expect(compiledScope.patient).toBe(patient.givenName + " " + patient.familyName + " " + "(" + patient.identifier + ")"); - expect(appointmentsService.search).toHaveBeenCalledWith({patientUuid: patient.uuid}); + expect(appointmentsService.search).toHaveBeenCalledWith({patientUuids: [patient.uuid]}); expect(scope.displaySearchedPatient).toHaveBeenCalled(); }); From e6c113c1d66530c883b505d6fb294ceb7fac34e2 Mon Sep 17 00:00:00 2001 From: Arjun-Go Date: Wed, 8 May 2024 13:17:12 +0530 Subject: [PATCH 4/4] add. test for checking appointments earch getting called when a filter is selected --- .../appointmentsFilterController.spec.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/controllers/manage/appointmentsFilterController.spec.js b/test/controllers/manage/appointmentsFilterController.spec.js index 1265f5512..9a416dd6e 100644 --- a/test/controllers/manage/appointmentsFilterController.spec.js +++ b/test/controllers/manage/appointmentsFilterController.spec.js @@ -1,7 +1,7 @@ 'use strict'; describe('AppointmentsFilterController', function () { - var controller, scope, state, appService, appDescriptor, appointmentsServiceService, ivhTreeviewMgr, q, translate; + var controller, scope, state, appService, appDescriptor, appointmentsServiceService, ivhTreeviewMgr, q, translate, appointmentsService; var locationService = jasmine.createSpyObj('locationService', ['getAllByTag']); var providerService = jasmine.createSpyObj('providerService', ['list']); var appService = jasmine.createSpyObj('appService', ['getAppDescriptor']); @@ -93,6 +93,7 @@ describe('AppointmentsFilterController', function () { appService = jasmine.createSpyObj('appService', ['getAppDescriptor']); appDescriptor = jasmine.createSpyObj('appDescriptor', ['getConfigValue']); appointmentsServiceService = jasmine.createSpyObj('appointmentsServiceService', ['getAllServicesWithServiceTypes']); + appointmentsService = jasmine.createSpyObj('appointmentsService', ['search']); ivhTreeviewMgr = jasmine.createSpyObj('ivhTreeviewMgr', ['deselectAll', 'selectEach', 'collapseRecursive']); translate = jasmine.createSpyObj('$translate', ['instant']); appService.getAppDescriptor.and.returnValue(appDescriptor); @@ -115,6 +116,7 @@ describe('AppointmentsFilterController', function () { $scope: scope, appService: appService, appointmentsServiceService: appointmentsServiceService, + appointmentsService: appointmentsService, $state: state, ivhTreeviewMgr: ivhTreeviewMgr, $q: q, @@ -800,4 +802,20 @@ describe('AppointmentsFilterController', function () { createController(); expect(scope.providers.length).toBe(2) }); + + it("should make appointments search call when in awaiting appointments tab when filters are clicked", function() { + q.all.and.returnValue(specUtil.simplePromise([servicesWithTypes, providers, locations])); + createController(); + state.current.tabName = "awaitingappointments"; + appointmentsService.search.and.returnValue(specUtil.simplePromise({data: []})); + scope.applyFilter(); + expect(appointmentsService.search).toHaveBeenCalledWith({ + serviceUuids: [], + serviceTypeUuids : [], + providerUuids: [], + locationUuids: [], + statusList: [], + withoutDates: true + }); + }); });