in pathology/viewer/src/components/search-results/search-results.component.ts [112:151]
ngOnChanges(changes: SimpleChanges) {
const cases = changes['cases']?.currentValue;
const casesByCaseId = changes['casesByCaseId']?.currentValue;
const diagnosticReports = changes['diagnosticReports']?.currentValue;
const searchText = changes['searchText']?.currentValue;
if (diagnosticReports || cases || casesByCaseId) {
this.caseWidgets = [
...this.casesToCaseWidgets(this.cases),
...this.diagnosticReportsToCaseWidgets(
this.diagnosticReports,
this.casesByCaseId ?? new Map(),
),
];
// Search page results should not be sorted as we can load more results.
if (!this.searchText) {
this.caseWidgets.sort((a, b) => {
const aDate =
this.isDate(a.caseDate) ? new Date(a.caseDate).getTime() : 0;
const bDate =
this.isDate(b.caseDate) ? new Date(b.caseDate).getTime() : 0;
// Sort by date and then id
return (this.diagnosticReportsSortBy ===
SearchDiagnosticReportSort.LAST_MODIFIED_DESC ?
bDate - aDate :
aDate - bDate) ||
a.id.localeCompare(b.id);
});
}
this.selectedCases.clear();
this.validateAllSelected();
}
if (searchText) {
this.searchedKeywords =
new Set(this.searchText.split(' ').map(word => word.trim()));
}
}