Removing imageId from Measurement schema

This commit is contained in:
Bruno Alves de Faria committed 2017-08-15 07:50:20 -03:00
1 parent cf9136447e
commit 7bb25ae6aa
12 files changed
+66 -36

No files matched your search

+4
View File
@@ -31,6 +31,10 @@ Viewerbase.switchToImageByIndex = switchToImageByIndex;
import { getFrameOfReferenceUID } from './lib/getFrameOfReferenceUID';
Viewerbase.getFrameOfReferenceUID = getFrameOfReferenceUID;
// getImageIdForImagePath
import { getImageIdForImagePath } from './lib/getImageIdForImagePath';
Viewerbase.getImageIdForImagePath = getImageIdForImagePath;
// updateCrosshairsSynchronizer
import { updateCrosshairsSynchronizer } from './lib/updateCrosshairsSynchronizer';
Viewerbase.updateCrosshairsSynchronizer = updateCrosshairsSynchronizer;
@@ -2,13 +2,12 @@ import { getWADORSImageId } from './getWADORSImageId';
// https://stackoverflow.com/a/6021027/3895126
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
const regex = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
const separator = uri.indexOf('?') !== -1 ? '&' : '?';
if (uri.match(regex)) {
return uri.replace(regex, '$1' + key + '=' + value + '$2');
} else {
return uri + separator + key + '=' + value;
}
}
@@ -25,6 +24,10 @@ export function getImageId(instance, frame, thumbnail) {
return;
}
if (typeof instance.getImageId === 'function') {
return instance.getImageId();
}
if (instance.url) {
if (frame !== undefined) {
instance.url = updateQueryStringParameter(instance.url, 'frame', frame);
@@ -36,7 +39,7 @@ export function getImageId(instance, frame, thumbnail) {
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
if (!instance[renderingAttr] || instance[renderingAttr] === 'wadouri' || !instance.wadorsuri) {
var imageId = 'dicomweb:' + instance.wadouri;
let imageId = 'dicomweb:' + instance.wadouri;
if (frame !== undefined) {
imageId += '&frame=' + frame;
}
@@ -0,0 +1,17 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Obtain an imageId for the given imagePath
*
* @param {String} imagePath Path containing study, series and instance UIDs and frame index
* @returns {String} The resulting imageId for the given imagePath
*/
export const getImageIdForImagePath = (imagePath, thumbnail=false) => {
const [studyInstanceUid, seriesInstanceUid, sopInstanceUid, frameIndex] = imagePath.split('_');
const study = OHIF.viewer.Studies.findBy({ studyInstanceUid });
const series = study.getSeriesByUID(seriesInstanceUid);
const instance = series.getInstanceByUID(sopInstanceUid);
const imageId = OHIF.viewerbase.getImageId(instance, frameIndex, thumbnail);
return imageId;
};