All files / extensions/default/src/DicomWebDataSource/utils getImageId.js

29.16% Statements 7/24
61.53% Branches 8/13
50% Functions 1/2
29.16% Lines 7/24

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                                                      39203x       39203x 15024x     24179x       24179x   24179x                   24179x      
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 }) {
  Iif (!instance) {
    return;
  }
 
  if (instance.imageId && frame === undefined) {
    return instance.imageId;
  }
 
  Iif (instance.url) {
    return instance.url;
  }
 
  const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
 
  Iif (!config[renderingAttr] || config[renderingAttr] === 'wadouri') {
    const wadouri = buildInstanceWadoUrl(config, instance);
 
    let imageId = 'dicomweb:' + wadouri;
    Iif (frame !== undefined) {
      imageId += '&frame=' + frame;
    }
 
    return imageId;
  } else {
    return getWADORSImageId(instance, config, frame); // WADO-RS Retrieve Frame
  }
}