Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH-4053 | FIx. Add condition to show all providers in OT when a filter config is not passed. #993

Merged
merged 2 commits into from
Aug 1, 2024
Merged
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
5 changes: 5 additions & 0 deletions ui/app/ot/helpers/surgicalAppointmentHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
angular.module('bahmni.ot')
.service('surgicalAppointmentHelper', [function () {
this.filterProvidersByName = function (providerNames, providers) {
if (!providerNames || providerNames.length === 0) {
return _.filter(providers, function (provider) {
return provider.person.display != "";
});
}
var validProviderNames = _.filter(providerNames, function (providerName) {
return _.find(providers, function (provider) {
return providerName === provider.person.display;
Expand Down
29 changes: 29 additions & 0 deletions ui/test/unit/ot/helpers/surgicalAppointmentHelper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,35 @@ describe('surgicalAppointmentHelper', function () {
expect(filteredProviders[2]).toEqual({uuid: "uuid2", person: {display: "Provider2"}});
});

it('should return all providers with a display name when an empty list of names is passed', function () {
var providerNames = [];
var providers = [{uuid: "uuid1", person: { display: "Provider1"}}, {uuid: "uuid2", person: { display: "Provider2"}}];
var filteredProviders = surgicalAppointmentHelper.filterProvidersByName(providerNames, providers);

expect(filteredProviders.length).toEqual(2);
expect(filteredProviders[0]).toEqual({uuid: "uuid1", person: {display: "Provider1"}});
expect(filteredProviders[1]).toEqual({uuid: "uuid2", person: {display: "Provider2"}});
});

it('should return all providers with a display name when the list of names is undefined', function () {
var providerNames = undefined;
var providers = [{ uuid: "uuid1", person: { display: "Provider1" } }, { uuid: "uuid2", person: { display: "Provider2" } }];
var filteredProviders = surgicalAppointmentHelper.filterProvidersByName(providerNames, providers);

expect(filteredProviders.length).toEqual(2);
expect(filteredProviders[0]).toEqual({ uuid: "uuid1", person: { display: "Provider1" } });
expect(filteredProviders[1]).toEqual({ uuid: "uuid2", person: { display: "Provider2" } });
});

it('should not return providers with an empty display name and when the an empty list of names is passed', function () {
var providerNames = [];
var providers = [{ uuid: "uuid1", person: { display: "Provider1" } }, { uuid: "uuid2", person: { display: "" } }];
var filteredProviders = surgicalAppointmentHelper.filterProvidersByName(providerNames, providers);

expect(filteredProviders.length).toEqual(1);
expect(filteredProviders[0]).toEqual({ uuid: "uuid1", person: { display: "Provider1" } });
});

it('should get the duration in minutes', function () {
var estTimInHours = "1";
var estTimInMinutes = "15";
Expand Down
Loading