Skip to content

Commit

Permalink
[Ashish | Abinaya]Fix. Search results for prefilled patients | 120536…
Browse files Browse the repository at this point in the history
…5242337347 (#300)

* [Ashish | Abinaya]Fix. Search results for prefilled patients

* [Abinaya | Ashish ] Fix.Failing tests
  • Loading branch information
AshishkurianTw authored Sep 19, 2023
1 parent 6f7cfe4 commit 50a0d92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 10 additions & 6 deletions src/controllers/manage/list/appointmentsListViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

angular.module('bahmni.appointments')
.controller('AppointmentsListViewController', ['$scope', '$state', '$rootScope', '$translate', '$stateParams', 'spinner',
'appointmentsService', 'appService', 'appointmentsFilter', 'printer', 'checkinPopUp', 'confirmBox', 'ngDialog', 'messagingService', 'appointmentCommonService', '$interval',
'appointmentsService', 'appService', 'appointmentsFilter', 'printer', 'checkinPopUp', 'confirmBox', 'ngDialog', 'messagingService', 'appointmentCommonService', '$interval','$window','$location',
function ($scope, $state, $rootScope, $translate, $stateParams, spinner, appointmentsService, appService,
appointmentsFilter, printer, checkinPopUp, confirmBox, ngDialog, messagingService, appointmentCommonService, $interval) {
appointmentsFilter, printer, checkinPopUp, confirmBox, ngDialog, messagingService, appointmentCommonService, $interval, $window, $location,) {
$scope.enableSpecialities = appService.getAppDescriptor().getConfigValue('enableSpecialities');
$scope.enableServiceTypes = appService.getAppDescriptor().getConfigValue('enableServiceTypes');
$scope.priorityOptionsList = appService.getAppDescriptor().getConfigValue('priorityOptionsList') || [];
Expand Down Expand Up @@ -101,12 +101,12 @@ angular.module('bahmni.appointments')

var setAppointments = function (params) {
autoRefreshStatus = false;
if($scope.getCurrentTabName() === APPOINTMENTS_TAB_NAME)
if($scope.getCurrentTabName() === APPOINTMENTS_TAB_NAME && $state.params.patient != null)
return appointmentsService.getAllAppointments(params)
.then((response) => updateAppointments(response));
else
return appointmentsService.search(APPOINTMENT_STATUS_WAITLIST)
.then((response) => updateAppointments(response));
return appointmentsService.search( $location.search()['patient'] ? { patientUuid: $location.search()['patient'] } : APPOINTMENT_STATUS_WAITLIST)
.then((response) => updateAppointments(response));
};

var updateAppointments = function (response){
Expand Down Expand Up @@ -234,8 +234,12 @@ angular.module('bahmni.appointments')
$scope.selectedAppointment = undefined;
};

$scope.hasNoAppointments = function () {
$scope.hasNoAppointments = function () {if ($state.params.patient && $state.params.patient.label === 'undefined (undefined)') {
$window.location.reload();
return false;
} else {
return _.isEmpty($scope.filteredAppointments);
}
};

$scope.goBackToPreviousView = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ describe('AppointmentsListViewController', function () {
controller = $controller;
stateparams = $stateParams;
_appointmentsFilter = jasmine.createSpy('appointmentsFilter');
appointmentsService = jasmine.createSpyObj('appointmentsService', ['getAllAppointments', 'changeStatus', 'undoCheckIn', 'changeProviderResponse']);
appointmentsService = jasmine.createSpyObj('appointmentsService', ['getAllAppointments', 'changeStatus', 'undoCheckIn', 'changeProviderResponse' , 'search']);
appointmentsService.getAllAppointments.and.returnValue(specUtil.simplePromise({}));
appointmentsService.search.and.returnValue(specUtil.simplePromise({}));
appService = jasmine.createSpyObj('appService', ['getAppDescriptor']);
appDescriptor = jasmine.createSpyObj('appDescriptor', ['getConfigValue']);
printer = jasmine.createSpyObj('printer', ['print']);
Expand Down Expand Up @@ -114,6 +115,7 @@ describe('AppointmentsListViewController', function () {
createController();
var viewDate = new Date('1970-01-01T11:30:00.000Z');
$state.params = {doFetchAppointmentsData: true};
$state.params.patient = '123';
scope.getAppointmentsForDate(viewDate);
expect(stateparams.viewDate).toEqual(viewDate);
expect(appointmentsService.getAllAppointments).toHaveBeenCalledWith({forDate: viewDate});
Expand Down Expand Up @@ -242,7 +244,7 @@ describe('AppointmentsListViewController', function () {
stateparams.filterParams = {serviceUuids: ["02666cc6-5f3e-4920-856d-ab7e28d3dbdb"]};
createController();
var viewDate = new Date('2017-08-28T11:30:00.000Z');
$state.params = {doFetchAppointmentsData: true};
$state.params = {doFetchAppointmentsData: true , patient: "123"};
scope.getAppointmentsForDate(viewDate);
expect(scope.appointments).toBe(appointments);
expect(scope.filteredAppointments.length).toEqual(1);
Expand Down Expand Up @@ -346,7 +348,7 @@ describe('AppointmentsListViewController', function () {
};
createController();
var viewDate = new Date('2017-08-28T11:30:00.000Z');
$state.params = {doFetchAppointmentsData: true};
$state.params = {doFetchAppointmentsData: true , patient:"123"};
scope.getAppointmentsForDate(viewDate);
expect(scope.appointments).toBe(appointments);
expect(scope.searchedPatient).toBeFalsy();
Expand Down

0 comments on commit 50a0d92

Please sign in to comment.