Skip to content

Commit

Permalink
BAH-3225 | Custom filtering/ordering of headings in tabular view (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavitha-sundararajan authored Sep 19, 2023
1 parent 7b3aa4a commit 8f6209f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,21 @@ angular.module('bahmni.common.patientSearch')

$scope.getHeadings = function () {
if ($scope.search.activePatients && $scope.search.activePatients.length > 0) {
var ingoreHeadingList = Bahmni.Common.PatientSearch.Constants.tabularViewIgnoreHeadingsList;
if ($scope.search.searchType) {
ingoreHeadingList = ingoreHeadingList.concat($scope.search.searchType.tabularViewIgnoreHeadingsList);
}
var headings = _.chain($scope.search.activePatients[0])
.keys()
.filter(function (heading) {
return _.indexOf(Bahmni.Common.PatientSearch.Constants.tabularViewIgnoreHeadingsList, heading) === -1;
return _.indexOf(ingoreHeadingList, heading) === -1;
})
.value();
if ($scope.search.searchType && $scope.search.searchType.tabularViewHeadingOrder) {
headings.sort(function (a, b) {
return $scope.search.searchType.tabularViewHeadingOrder.indexOf(a) - $scope.search.searchType.tabularViewHeadingOrder.indexOf(b);
});
}
setActiveHeadings(headings);
}
};
Expand All @@ -110,6 +119,13 @@ angular.module('bahmni.common.patientSearch')
});
};

$scope.isHeadingOfDateColumn = function (heading) {
if ($scope.search.searchType && $scope.search.searchType.dateColumns) {
return $scope.search.searchType.dateColumns.includes(heading);
}
return false;
};

$scope.sortVisiblePatientsBy = function (sortColumn) {
var emptyObjects = _.filter($scope.search.searchResults, function (visiblePatient) {
return !_.property(sortColumn)(visiblePatient);
Expand Down Expand Up @@ -178,6 +194,9 @@ angular.module('bahmni.common.patientSearch')
params: appExtn.extensionParams.searchParams,
refreshTime: appExtn.extensionParams.refreshTime || 0,
view: appExtn.extensionParams.view || Bahmni.Common.PatientSearch.Constants.searchExtensionTileViewType,
tabularViewHeadingOrder: appExtn.extensionParams.tabularViewHeadingOrder || [],
dateColumns: appExtn.extensionParams.dateColumns || [],
tabularViewIgnoreHeadingsList: appExtn.extensionParams.tabularViewIgnoreHeadingsList || [],
showPrint: appExtn.extensionParams.showPrint || false,
printHtmlLocation: appExtn.extensionParams.printHtmlLocation || null,
additionalParams: appExtn.extensionParams.additionalParams,
Expand Down
4 changes: 2 additions & 2 deletions ui/app/common/patient-search/views/patientsList.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
ng-click="forwardPatient(row, heading)">{{::row[heading.name]}}</a>
<div ng-if="::isHeadingOfName(heading.name)" style="min-width: 150px" ng-click="forwardPatient(row)">
<div style="width: 80%;">
{{::row[heading.name]}}
{{::(isHeadingOfDateColumn(heading.name) ? (row[heading.name] | bahmniDate) : row[heading.name])}}
</div>
<span class="icons-container">
<i class="ipd-indication fa fa-bed" ng-if="::(row.hasBeenAdmitted===true||row.hasBeenAdmitted==='true')"></i>
<i class="ipd-indication fa fa-solid fa-child" style="background-color: #F58C35; padding: 2px 12.289px;" ng-if="::row.kid === 'true'"></i>
</span>
</div>
<span ng-if="::(!isHeadingOfLinkColumn(heading.name) && !isHeadingOfName(heading.name))">
{{::row[heading.name]}}
{{::(isHeadingOfDateColumn(heading.name) ? (row[heading.name] | bahmniDate) : row[heading.name])}}
</span>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe("PatientsListController", function () {
scope.$apply(setUp);

expect(scope.search.searchType).toEqual({ name : 'All active patients', display : 'All active patients', handler : 'emrapi.sqlSearch.activePatients', forwardUrl : undefined, targetedTab : null, id : 'bahmni.clinical.patients.allPatients', params : undefined, refreshTime : '10', view : 'tile',
showPrint : false, printHtmlLocation : null, searchColumns : undefined, additionalParams : undefined, translationKey : undefined, patientCount : '...', linkColumn : undefined, links : undefined});
tabularViewHeadingOrder : [], dateColumns : [], tabularViewIgnoreHeadingsList : [], showPrint : false, printHtmlLocation : null, searchColumns : undefined, additionalParams : undefined, translationKey : undefined, patientCount : '...', linkColumn : undefined, links : undefined});
expect(_patientService.findPatients).toHaveBeenCalled();

findPatientsPromise.callThenCallBack({data: patients});
Expand Down

0 comments on commit 8f6209f

Please sign in to comment.