Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
'use strict';

angular.module('bahmni.appointments')
.controller('AppointmentsFilterController', ['$scope', '$state', '$rootScope', '$q', '$translate', 'appointmentsServiceService', 'spinner', 'ivhTreeviewMgr', 'providerService', 'appService',
function ($scope, $state, $rootScope, $q, $translate, appointmentsServiceService, spinner, ivhTreeviewMgr, providerService, appService) {
.controller('AppointmentsFilterController', ['$scope', '$state', '$rootScope', '$q', '$translate', 'locationService', 'appointmentsServiceService', 'spinner', 'ivhTreeviewMgr', 'providerService', 'appService',
function ($scope, $state, $rootScope, $q, $translate, locationService, appointmentsServiceService, spinner, ivhTreeviewMgr, providerService, appService) {
var init = function () {
$scope.isSpecialityEnabled = appService.getAppDescriptor().getConfigValue('enableSpecialities');
$scope.isServiceTypeEnabled = appService.getAppDescriptor().getConfigValue('enableServiceTypes');
$scope.isFilterOpen = $state.params.isFilterOpen;
$scope.isSearchEnabled = $state.params.isSearchEnabled;

locationService.getAllByTag("Visit Location").then(
function (response) {
$scope.locationList = response.data.results;
$scope.selectedLocationList = $scope.locationList;
}
);

$scope.statusList = _.map(Bahmni.Appointments.Constants.appointmentStatusList, function (status) {
return {name: status, value: status};
});
Expand Down Expand Up @@ -102,6 +110,7 @@ angular.module('bahmni.appointments')
serviceUuids: [],
serviceTypeUuids: [],
providerUuids: [],
locationList: [],
statusList: []
};
};
Expand All @@ -118,6 +127,7 @@ angular.module('bahmni.appointments')
ivhTreeviewMgr.deselectAll($scope.selectedSpecialities, false);
}
$scope.selectedProviders = [];
$scope.selectedLocationList = [];
$scope.selectedStatusList = [];
$scope.showSelected = false;
$scope.filterSelectedValues = undefined;
Expand Down Expand Up @@ -186,6 +196,10 @@ angular.module('bahmni.appointments')
return provider.uuid;
});

$state.params.filterParams.locationList = _.map($scope.selectedLocationList, function (location) {
return location.uuid;
});

$state.params.filterParams.statusList = _.map($scope.selectedStatusList, function (status) {
return status.value;
});
Expand Down Expand Up @@ -221,6 +235,10 @@ angular.module('bahmni.appointments')
return status.name !== "Cancelled";
});
} else {
$scope.locationList = _.map(Bahmni.Appointments.Constants.locationList, function (location) {
return location;
});

$scope.statusList = _.map(Bahmni.Appointments.Constants.appointmentStatusList, function (status) {
return {name: status, value: status};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ angular.module('bahmni.appointments')
{heading: 'APPOINTMENT_PATIENT_NAME', sortInfo: 'patient.name', class: true, enable: true},
{heading: 'APPOINTMENT_PATIENT_AGE', sortInfo: 'age', enable: true},
{heading: 'APPOINTMENT_PATIENT_SEX', sortInfo: 'gender', enable: true},
{heading: 'APPOINTMENT_STATUS', sortInfo: 'status', enable: true},
{heading: 'APPOINTMENT_SERVICE_LOCATION_KEY', sortInfo: 'location.name', class: true, enable: true},
{heading: 'APPOINTMENT_PATIENT_CONTACTS', sortInfo: 'contacts', enable: true},
{heading: 'APPOINTMENT_PATIENT_VILLAGE', sortInfo: 'contacts', enable: true},
{heading: 'APPOINTMENT_PROVIDER', sortInfo: 'provider.name', class: true, enable: true},
{heading: 'APPOINTMENT_SERVICE_SPECIALITY_KEY', sortInfo: 'service.speciality.name', enable: $scope.enableSpecialities},
{heading: 'APPOINTMENT_SERVICE', sortInfo: 'service.name', class: true, enable: true},
{heading: 'APPOINTMENT_SERVICE_TYPE_FULL', sortInfo: 'serviceType.name', class: true, enable: $scope.enableServiceTypes},
{heading: 'APPOINTMENT_STATUS', sortInfo: 'status', enable: true},
{heading: 'APPOINTMENT_WALK_IN', sortInfo: 'appointmentKind', enable: true},
{heading: 'APPOINTMENT_SERVICE_LOCATION_KEY', sortInfo: 'location.name', class: true, enable: true},
{heading: 'APPOINTMENT_ADDITIONAL_INFO', sortInfo: 'additionalInfo', class: true, enable: true},
{heading: 'APPOINTMENT_CREATE_NOTES', sortInfo: 'comments', enable: true}];
var init = function () {
Expand Down
37 changes: 24 additions & 13 deletions ui/app/appointments/filters/appointmentsFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ angular.module('bahmni.appointments')
});
};

var filterAppointmentsByProviders = function (appointments, providerUuids) {
if (_.isEmpty(providerUuids)) {
return appointments;
}
return _.filter(appointments, function (appointment) {
if (!appointment.provider) return _.includes(providerUuids, 'no-provider-uuid');
return appointment.provider && _.includes(providerUuids, appointment.provider.uuid);
});
};
// var filterAppointmentsByProviders = function (appointments, providerUuids) {
// if (_.isEmpty(providerUuids)) {
// return appointments;
// }
// return _.filter(appointments, function (appointment) {
// if (!appointment.provider) return _.includes(providerUuids, 'no-provider-uuid');
// return appointment.provider && _.includes(providerUuids, appointment.provider.uuid);
// });
// };

var filterAppointmentsByLocation = function (appointments, locationList) {
if (_.isEmpty(locationList)) {
return appointments;
}

return _.filter(appointments, function (appointment) {
return _.includes(locationList, appointment.location.uuid);
});
};

var filterAppointmentsByStatus = function (appointments, statusList) {
if (_.isEmpty(statusList)) {
Expand All @@ -38,13 +48,14 @@ angular.module('bahmni.appointments')
return appointments;
}
if ((_.isEmpty(filters.serviceUuids) && _.isEmpty(filters.serviceTypeUuids))) {
var appointmentsFilteredByProviders = filterAppointmentsByProviders(appointments, filters.providerUuids);
return filterAppointmentsByStatus(appointmentsFilteredByProviders, filters.statusList);
var appointmentsFilteredByLocation = filterAppointmentsByLocation(appointments, filters.locationList);
return filterAppointmentsByStatus(appointmentsFilteredByLocation, filters.statusList);
}

var appointmentsFilteredByService = filterAppointmentsByService(appointments, filters.serviceUuids);
var appointmentsFilteredByServiceType = filterAppointmentsByServiceType(appointments, filters.serviceTypeUuids);
var appointmentsFilteredBySpeciality = appointmentsFilteredByService.concat(appointmentsFilteredByServiceType);
var appointmentsFilteredByProviders = filterAppointmentsByProviders(appointmentsFilteredBySpeciality, filters.providerUuids);
return filterAppointmentsByStatus(appointmentsFilteredByProviders, filters.statusList);
var appointmentsFilteredByLocation = filterAppointmentsByLocation(appointmentsFilteredBySpeciality, filters.locationList);
return filterAppointmentsByStatus(appointmentsFilteredByLocation, filters.statusList);
};
}]);
11 changes: 6 additions & 5 deletions ui/app/appointments/views/manage/appointmentFilter.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
</div>

</div>
<div class="appointment-filter-items provider-block">
<label>{{::'APPOINTMENT_PROVIDER' |translate}}</label>

<div class="appointment-filter-items status-block">
<label>Location</label>
<multi-select-autocomplete
input-items="providers"
selected-values="selectedProviders"
input-items="locationList"
selected-values="selectedLocationList"
display-property="'name'"
key-property="'uuid'"
placeholder="::'APPOINTMENT_ENTER_PROVIDER_NAME_KEY'"
placeholder="'Enter location name'"
load-on-down-arrow="true"
auto-complete-min-length="1"></multi-select-autocomplete>

Expand Down
4 changes: 2 additions & 2 deletions ui/app/appointments/views/manage/list/listView.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<!-- Adding Age, Sex and Contacts -->
<td>{{::appointment.age}}</td>
<td>{{::appointment.gender}}</td>
<td>{{appointment.status}}</td>
<td class="table-mid-width">{{::appointment.location.name}}</td>
<td>{{::appointment.contacts}}</td>
<td>{{::appointment.village}}</td>
<td class="table-mid-width">{{::appointment.provider.name}}</td>
Expand All @@ -69,9 +71,7 @@
{{::appointment.serviceType && (appointment.serviceType.name + ' ['
+ appointment.serviceType.duration + ' min]')}}
</td>
<td>{{appointment.status}}</td>
<td>{{:: isWalkIn(appointment.appointmentKind)}}</td>
<td class="table-mid-width">{{::appointment.location.name}}</td>
<td class="table-mid-width">
{{display(appointment.additionalInfo)}}
</td>
Expand Down
Loading