Skip to content

Commit

Permalink
BAH-3052 | Refactor. search using extraIdentiervalues and display con…
Browse files Browse the repository at this point in the history
…figured identifier in patientList
  • Loading branch information
SanoferSameera committed Jun 13, 2023
1 parent 462802c commit bb61ba8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('bahmni.common.patientSearch')
.controller('PatientsListController', ['$scope', '$window', 'patientService', '$rootScope', 'appService', 'spinner',
'$stateParams', '$bahmniCookieStore', 'printer', 'configurationService',
function ($scope, $window, patientService, $rootScope, appService, spinner, $stateParams, $bahmniCookieStore, printer, configurationService) {
$scope.preferExtraIdInSearchResults = appService.getAppDescriptor().getConfigValue("preferExtraIdInSearchResults");
var preferredExtraIdInPatientList = appService.getAppDescriptor().getConfigValue("preferredExtraIdInPatientList");
const DEFAULT_FETCH_DELAY = 2000;
var patientSearchConfig = appService.getAppDescriptor().getConfigValue("patientSearch");
var patientListSpinner;
Expand Down Expand Up @@ -207,6 +207,17 @@ angular.module('bahmni.common.patientSearch')
});
}
};
$scope.getIdentifierValue = function (patient) {
if (preferredExtraIdInPatientList !== null) {
var identifierIndex = patient.extraIdentifiers !== undefined ? patient.extraIdentifiers.split(",").indexOf(preferredExtraIdInPatientList) : -1;
if (identifierIndex >= 0) {
if (patient.extraIdentifierVal !== undefined && patient.extraIdentifierVal) {
return patient.extraIdentifierVal.split(",")[identifierIndex];
}
}
}
return patient.identifier;
};
initialize();
}
]);
11 changes: 0 additions & 11 deletions ui/app/common/patient-search/models/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ Bahmni.Common.PatientSearch.Search = function (searchTypes) {
return patient[column];
}).join(" - ");

var extraIdentifier = null;
if (patient.extraIdentifiers) {
var objIdentifiers = JSON.parse(patient.extraIdentifiers);
for (var key in objIdentifiers) {
extraIdentifier = objIdentifiers[key];
break;
}
} else if (patient.extraIdentifierVal) {
extraIdentifier = patient.extraIdentifierVal;
}
patient.extraIdentifier = patient.extraIdentifier ? patient.extraIdentifier : (extraIdentifier ? extraIdentifier : patient.identifier);
patient.image = Bahmni.Common.Constants.patientImageUrlByPatientUuid + patient.uuid;
return patient;
}
Expand Down
3 changes: 1 addition & 2 deletions ui/app/common/patient-search/views/patientsList.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@
<li ng-repeat="patient in search.visiblePatients" class="active-patient" ng-click="forwardPatient(patient)">
<img class="smallImages" ng-src="{{::patient.image}}" fallback-src='../images/blank-user.png'>
<div class="patient-name">{{::patient.name}}</div>
<div ng-if="!preferExtraIdInSearchResults" class="patient-id">{{::patient.identifier}}</div>
<div ng-if="preferExtraIdInSearchResults" class="patient-id">{{::patient.extraIdentifier}}</div>
<div class="patient-id">{{::getIdentifierValue(patient)}}</div>
<i class="ipd-indication fa fa-bed" ng-if="::(patient.hasBeenAdmitted===true||patient.hasBeenAdmitted==='true')"></i>
</li>
</ul>
Expand Down

0 comments on commit bb61ba8

Please sign in to comment.