fix: Initial sort not consistent (#5224)

* fix: Initial sort not consistent

* Add better sort criteria

* Remove sorting changes

* Start replacing screen shots

* Update bun lock for version

* Leave default sort for test mode

* fix: Add consistent sorting for same series splits

* PR comments

* docs: add notes for series/display set sort

* Updated example docs

* Update sortVector to be compareSameStudy

* Add unit test

* PR comments
This commit is contained in:
Bill Wallace authored and GitHub committed 2025-12-04 12:26:21 -05:00
1 parent 14bc99124d
commit 77f9f8e1c4
8 files changed
+253 -66

No files matched your search

@@ -1,8 +1,8 @@
import getStudies from './studiesList';
import { DicomMetadataStore, log, utils, Enums } from '@ohif/core';
import getStudies from './studiesList';
import isSeriesFilterUsed from '../../utils/isSeriesFilterUsed';
const { getSplitParam } = utils;
const { seriesSortCriteria, getSplitParam } = utils;
/**
* Initialize the route.
@@ -14,7 +14,12 @@ const { getSplitParam } = utils;
* @returns array of subscriptions to cancel
*/
export async function defaultRouteInit(
{ servicesManager, studyInstanceUIDs, dataSource, filters, appConfig }: withAppTypes,
{
servicesManager,
studyInstanceUIDs,
dataSource,
filters,
}: withAppTypes & { studyInstanceUIDs?: string[] },
hangingProtocolId,
stageIndex
) {
@@ -27,13 +32,17 @@ export async function defaultRouteInit(
*/
function applyHangingProtocol() {
const displaySets = displaySetService.getActiveDisplaySets();
// The display sets are not necessarily in load order, even though the
// series got started in load order, so re-sort them before hanging
const sortCriteria = seriesSortCriteria.default;
if (!displaySets || !displaySets.length) {
return;
}
const sortedDisplaySets = [...displaySets].sort(sortCriteria);
// Gets the studies list to use
const studies = getStudies(studyInstanceUIDs, displaySets);
const studies = getStudies(studyInstanceUIDs, sortedDisplaySets);
// study being displayed, and is thus the "active" study.
const activeStudy = studies[0];