Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 205x | import OHIF from '@ohif/core';
import { setNonEnumerableInstanceProperty } from './dicomWriter';
const metadataProvider = OHIF.classes.MetadataProvider;
/**
* Gives a just stored instance the imageId that loading it back would use, and
* maps that imageId to the instance's UIDs.
*
* Instances that arrive through a data source's metadata request are given this
* as part of that request. An instance stored from the viewer is added to the
* metadata store directly, so it has to be done here - and until it is, the
* display set made from the stored instance does not know which instance it came
* from. That is what makes a just stored object the predecessor of the next save
* of the same data, so that the next save can offer to extend the series just
* written instead of creating another one.
*
* @param instance - naturalized instance that has just been stored
* @param dataSource - the data source it was stored to, when there is one
* @returns the imageId of the instance, or undefined when none can be determined
*/
export function registerStoredInstanceImageId(instance, dataSource?): string | undefined {
Iif (!instance) {
return undefined;
}
Iif (instance.imageId) {
return instance.imageId;
}
let imageId: string | undefined;
try {
imageId = dataSource?.getImageIdsForInstance?.({ instance });
} catch (error) {
OHIF.log.debug('Unable to derive the imageId of a stored instance', error);
}
// Instances with pixel data have already been registered with the local
// wadouri file manager, which puts that imageId on `url` and maps it.
imageId ||= instance.url;
Iif (!imageId || typeof imageId !== 'string') {
return undefined;
}
setNonEnumerableInstanceProperty(instance, 'imageId', imageId);
const { StudyInstanceUID, SeriesInstanceUID } = instance;
const SOPInstanceUID = instance.SOPInstanceUID || instance.SopInstanceUID;
Iif (StudyInstanceUID && SeriesInstanceUID && SOPInstanceUID) {
metadataProvider.addImageIdToUIDs(imageId, {
StudyInstanceUID,
SeriesInstanceUID,
SOPInstanceUID,
});
}
return imageId;
}
export function registerStoredInstanceImageIds(instances, dataSource?): void {
const list = Array.isArray(instances) ? instances : [instances];
list.forEach(instance => registerStoredInstanceImageId(instance, dataSource));
}
|