2020-05-12 16:00:27 +02:00
|
|
|
import getWADORSImageId from './getWADORSImageId';
|
|
|
|
|
|
|
|
|
|
function buildInstanceWadoUrl(config, instance) {
|
|
|
|
|
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
|
|
|
|
|
const params = [];
|
|
|
|
|
|
|
|
|
|
params.push('requestType=WADO');
|
|
|
|
|
params.push(`studyUID=${StudyInstanceUID}`);
|
|
|
|
|
params.push(`seriesUID=${SeriesInstanceUID}`);
|
|
|
|
|
params.push(`objectUID=${SOPInstanceUID}`);
|
|
|
|
|
params.push('contentType=application/dicom');
|
|
|
|
|
params.push('transferSyntax=*');
|
|
|
|
|
|
|
|
|
|
const paramString = params.join('&');
|
|
|
|
|
|
|
|
|
|
return `${config.wadoUriRoot}?${paramString}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Obtain an imageId for Cornerstone from an image instance
|
|
|
|
|
*
|
|
|
|
|
* @param instance
|
|
|
|
|
* @param frame
|
|
|
|
|
* @param thumbnail
|
|
|
|
|
* @returns {string} The imageId to be used by Cornerstone
|
|
|
|
|
*/
|
|
|
|
|
export default function getImageId({
|
|
|
|
|
instance,
|
|
|
|
|
frame,
|
|
|
|
|
config,
|
|
|
|
|
thumbnail = false,
|
|
|
|
|
}) {
|
|
|
|
|
if (!instance) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-28 14:32:48 -04:00
|
|
|
if (instance.url) {
|
|
|
|
|
return instance.url;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-12 16:00:27 +02:00
|
|
|
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
|
|
|
|
|
|
|
|
|
|
if (!config[renderingAttr] || config[renderingAttr] === 'wadouri') {
|
|
|
|
|
const wadouri = buildInstanceWadoUrl(config, instance);
|
|
|
|
|
|
|
|
|
|
let imageId = 'dicomweb:' + wadouri;
|
|
|
|
|
if (frame !== undefined) {
|
|
|
|
|
imageId += '&frame=' + frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return imageId;
|
|
|
|
|
} else {
|
|
|
|
|
return getWADORSImageId(instance, config, frame); // WADO-RS Retrieve Frame
|
|
|
|
|
}
|
|
|
|
|
}
|