ohif-viewer/Packages/ohif-viewerbase/client/lib/getWADORSImageId.js

34 lines
789 B
JavaScript

import { OHIF } from 'meteor/ohif:core';
function getWADORSImageUrl(instance, frame) {
let wadorsuri = instance.wadorsuri;
if (!wadorsuri) {
return;
}
// We need to sum 1 because WADO-RS frame number is 1-based
frame = (frame || 0) + 1;
// Replaces /frame/1 by /frame/{frame}
wadorsuri = wadorsuri.replace(/(%2Fframes%2F)(\d+)/, `$1${frame}`);
return wadorsuri;
}
/**
* Obtain an imageId for Cornerstone based on the WADO-RS scheme
*
* @param {object} instanceMetada metadata object (InstanceMetadata)
* @returns {string} The imageId to be used by Cornerstone
*/
export function getWADORSImageId(instance, frame) {
const uri = getWADORSImageUrl(instance, frame);
if (!uri) {
return;
}
return `wadors:${uri}`;
};