feat(URL): add param for initial series and sop uids to display (#3265)
* feat: Allow navigating to a specified series and sop instance This was a feature in OHIF v2, so adding it to v3, albeit with new parameters. feat: Allow comma separated as well as repeated args params * docs * Test fixes * feat: Navigate to SOP selected - PR fixes * Updated docs * PR fixes
This commit is contained in:
1 parent
226244a26c
commit
50ed96ff73
16 files changed
+284
-47
No files matched your search
@@ -6,6 +6,10 @@ import IDisplaySet from '../DisplaySetService/IDisplaySet';
|
||||
import { CommandsManager } from '../../classes';
|
||||
import ServicesManager from '../ServicesManager';
|
||||
import * as HangingProtocol from '../../types/HangingProtocol';
|
||||
import {
|
||||
isDisplaySetFromUrl,
|
||||
sopInstanceLocation,
|
||||
} from './isDisplaySetFromUrl';
|
||||
|
||||
type Protocol = HangingProtocol.Protocol | HangingProtocol.ProtocolGenerator;
|
||||
|
||||
@@ -81,6 +85,14 @@ export default class HangingProtocolService extends PubSubService {
|
||||
// we can add more advanced checking here
|
||||
callback: displaySet => displaySet.isReconstructable ?? false,
|
||||
},
|
||||
isDisplaySetFromUrl: {
|
||||
name: 'Checks if the display set is as specified in the URL',
|
||||
callback: isDisplaySetFromUrl,
|
||||
},
|
||||
sopInstanceLocation: {
|
||||
name: 'Gets the position of the specified sop instance',
|
||||
callback: sopInstanceLocation,
|
||||
},
|
||||
};
|
||||
listeners = {};
|
||||
registeredImageLoadStrategies = {};
|
||||
@@ -648,6 +660,39 @@ export default class HangingProtocolService extends PubSubService {
|
||||
return viewportsToUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a computed options value, or a copy of the options
|
||||
* This allows computing values such as the initial image index to use
|
||||
* based on custom attribute functions, the same as the validators.
|
||||
* Computing individual values is something that can be declared statically
|
||||
* as long as the named functions are provided ahead of time, which is much
|
||||
* simpler than recomputing the entire protocol.
|
||||
*/
|
||||
public getComputedOptions(
|
||||
options: Record<string, unknown>,
|
||||
displaySetUIDs: string[]
|
||||
) {
|
||||
const computed = { ...options };
|
||||
let displaySets;
|
||||
for (const key in computed) {
|
||||
const value = computed[key];
|
||||
if (!value) continue;
|
||||
if (value.custom) {
|
||||
if (!displaySets) {
|
||||
displaySets = this.displaySets.filter(
|
||||
displaySet =>
|
||||
displaySetUIDs.indexOf(displaySet.displaySetInstanceUID) !== -1
|
||||
);
|
||||
}
|
||||
computed[key] = this.customAttributeRetrievalCallbacks[
|
||||
value.custom
|
||||
].callback.call(computed, displaySets);
|
||||
if (computed[key] === undefined) computed[key] = computed.defaultValue;
|
||||
}
|
||||
}
|
||||
return computed;
|
||||
}
|
||||
|
||||
/**
|
||||
* It applied the protocol to the current studies and display sets based on the
|
||||
* protocolId that is provided.
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { getSplitParam } from '../../utils';
|
||||
|
||||
/** Indicates if the given display set is the one specified in the
|
||||
* displaySet parameter in the URL
|
||||
* The parameters are:
|
||||
* initialSeriesInstanceUID
|
||||
* initialSOPInstanceUID
|
||||
*/
|
||||
const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const initialSeriesInstanceUID = getSplitParam(
|
||||
'initialseriesinstanceuid',
|
||||
params
|
||||
);
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid', params);
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) return false;
|
||||
const isSeriesMatch =
|
||||
!initialSeriesInstanceUID ||
|
||||
initialSeriesInstanceUID.some(
|
||||
seriesUID => displaySet.SeriesInstanceUID === seriesUID
|
||||
);
|
||||
const isSopMatch =
|
||||
!initialSOPInstanceUID ||
|
||||
displaySet.instances?.some?.(instance =>
|
||||
initialSOPInstanceUID.some(sopUID => sopUID === instance.SOPInstanceUID)
|
||||
);
|
||||
return isSeriesMatch && isSopMatch;
|
||||
};
|
||||
|
||||
/** Returns the index location of the requested image, or the defaultValue in this.
|
||||
* Returns undefined to fallback to the defaultValue
|
||||
*/
|
||||
function sopInstanceLocation(displaySets) {
|
||||
const displaySet = displaySets[0];
|
||||
if (!displaySet) return;
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid');
|
||||
if (!initialSOPInstanceUID) return;
|
||||
|
||||
const index = displaySet.instances.findIndex(instance =>
|
||||
initialSOPInstanceUID.includes(instance.SOPInstanceUID)
|
||||
);
|
||||
// Need to return in the initial position specified format.
|
||||
return index === -1 ? undefined : { index };
|
||||
}
|
||||
|
||||
export { isDisplaySetFromUrl, sopInstanceLocation };
|
||||
Reference in new issue
Block a user