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 and Phanindra-tw committed Mar 5, 2024
1 parent a39dbb0 commit 524daa5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
32 changes: 18 additions & 14 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 @@ -73,12 +73,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));
.then((response) => updateAppointments(response));
else
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 @@ -206,8 +206,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 All @@ -234,22 +238,22 @@ angular.module('bahmni.appointments')
return appointmentType === 'WalkIn' ? 'Yes' : 'No';
};

$scope.editAppointment = function () {
$scope.editAppointment = function () {
var params = $stateParams;
params.uuid = $scope.selectedAppointment.uuid;
params.isRecurring = $scope.selectedAppointment.recurring;
$state.go('home.manage.appointments.list.edit', params);
};

$scope.openTeleConsultation = function () {
window.open("https://" +
window.location.hostname +
Bahmni.Common.Constants.patientsURL +
window.open("https://" +
window.location.hostname +
Bahmni.Common.Constants.patientsURL +
$scope.selectedAppointment.patient.uuid +
Bahmni.Common.Constants.patientsURLGeneralInformationTab
, '_self')
};
};

$scope.copyTeleConsultationMeetingURL = function () {
var jitsiMeetingUrl = $scope.selectedAppointment.teleconsultationLink;
const el = document.createElement('textarea');
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 524daa5

Please sign in to comment.