2019-08-13 15:36:46 -04:00
|
|
|
function getWADORSImageUrl(instance, frame) {
|
|
|
|
|
let wadorsuri = instance.wadorsuri;
|
|
|
|
|
|
|
|
|
|
if (!wadorsuri) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-27 08:47:08 -03:00
|
|
|
// Use null to obtain an imageId which represents the instance
|
|
|
|
|
if (frame === null) {
|
|
|
|
|
wadorsuri = wadorsuri.replace(/frames\/(\d+)/, '');
|
|
|
|
|
} else {
|
|
|
|
|
// We need to sum 1 because WADO-RS frame number is 1-based
|
|
|
|
|
frame = frame ? parseInt(frame) + 1 : 1;
|
2019-08-13 15:36:46 -04:00
|
|
|
|
2019-09-27 08:47:08 -03:00
|
|
|
// Replaces /frame/1 by /frame/{frame}
|
|
|
|
|
wadorsuri = wadorsuri.replace(/frames\/(\d+)/, `frames/${frame}`);
|
|
|
|
|
}
|
2019-08-13 15:36:46 -04:00
|
|
|
|
|
|
|
|
return wadorsuri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Obtain an imageId for Cornerstone based on the WADO-RS scheme
|
|
|
|
|
*
|
|
|
|
|
* @param {object} instanceMetada metadata object (InstanceMetadata)
|
|
|
|
|
* @param {(string\|number)} [frame] the frame number
|
|
|
|
|
* @returns {string} The imageId to be used by Cornerstone
|
|
|
|
|
*/
|
|
|
|
|
export default function getWADORSImageId(instance, frame) {
|
|
|
|
|
const uri = getWADORSImageUrl(instance, frame);
|
|
|
|
|
|
|
|
|
|
if (!uri) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `wadors:${uri}`;
|
|
|
|
|
}
|