2015-10-23 14:08:51 +02:00
|
|
|
|
ViewerData = Session.get('ViewerData') || {};
|
2015-10-30 12:21:59 +01:00
|
|
|
|
StudyMetaData = {};
|
2015-10-23 14:08:51 +02:00
|
|
|
|
|
2015-10-30 12:21:59 +01:00
|
|
|
|
getStudyMetadata = function(studyInstanceUid, doneCallback) {
|
|
|
|
|
|
log.info('worklistStudy getStudyMetadata');
|
2015-10-13 14:14:50 +02:00
|
|
|
|
|
2015-10-30 12:21:59 +01:00
|
|
|
|
if (StudyMetaData.hasOwnProperty(studyInstanceUid) && StudyMetaData[studyInstanceUid]) {
|
|
|
|
|
|
var study = StudyMetaData[studyInstanceUid];
|
|
|
|
|
|
doneCallback(study);
|
|
|
|
|
|
return;
|
2015-10-20 15:45:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-30 12:21:59 +01:00
|
|
|
|
Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) {
|
|
|
|
|
|
sortStudy(study);
|
|
|
|
|
|
|
|
|
|
|
|
StudyMetaData[studyInstanceUid] = study;
|
2015-10-20 15:45:27 +02:00
|
|
|
|
|
2015-10-30 12:21:59 +01:00
|
|
|
|
doneCallback(study);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2015-10-29 13:50:28 +01:00
|
|
|
|
|
2015-10-30 12:21:59 +01:00
|
|
|
|
switchToTab = function(contentId) {
|
|
|
|
|
|
log.info("Switching to tab: " + contentId);
|
2015-10-29 13:50:28 +01:00
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
$('.tabTitle a[data-target="#' + contentId + '"]').tab('show');
|
2015-10-20 15:45:27 +02:00
|
|
|
|
|
|
|
|
|
|
$("#viewer").remove();
|
|
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
if (contentId === 'worklistTab') {
|
2015-10-20 15:45:27 +02:00
|
|
|
|
document.body.style.overflow = null;
|
|
|
|
|
|
document.body.style.height = null;
|
|
|
|
|
|
document.body.style.minWidth = null;
|
|
|
|
|
|
document.body.style.position = null;
|
2015-10-30 12:21:59 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set active tab
|
|
|
|
|
|
Session.set("activeContentId", contentId);
|
|
|
|
|
|
|
|
|
|
|
|
// Get tab content container
|
|
|
|
|
|
var container = $('.tab-content').find("#" + contentId).get(0);
|
|
|
|
|
|
if (!container) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var studyInstanceUid = ViewerData[contentId].studyInstanceUid;
|
|
|
|
|
|
getStudyMetadata(studyInstanceUid, function(study) {
|
|
|
|
|
|
var data = {
|
|
|
|
|
|
viewportRows: ViewerData[contentId].viewportRows,
|
|
|
|
|
|
viewportColumns: ViewerData[contentId].viewportColumns,
|
|
|
|
|
|
contentId: contentId,
|
|
|
|
|
|
studies: [study],
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Session.set('studies', data.studies);
|
|
|
|
|
|
|
2015-11-06 12:36:38 +01:00
|
|
|
|
// Remove the loading text template that is inside by default
|
|
|
|
|
|
container.innerHTML = "";
|
2015-10-20 15:45:27 +02:00
|
|
|
|
UI.renderWithData(Template.viewer, data, container);
|
|
|
|
|
|
var imageViewer = $("#viewer");
|
|
|
|
|
|
if (imageViewer) {
|
|
|
|
|
|
document.body.style.overflow = "hidden";
|
|
|
|
|
|
document.body.style.height = '100%';
|
|
|
|
|
|
document.body.style.width = '100%';
|
|
|
|
|
|
document.body.style.minWidth = 0;
|
|
|
|
|
|
document.body.style.position = 'fixed'; // Prevent overscroll on mobile devices
|
2015-10-13 14:14:50 +02:00
|
|
|
|
}
|
2015-10-30 12:21:59 +01:00
|
|
|
|
});
|
2015-10-20 15:45:27 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
|
2015-11-06 12:36:38 +01:00
|
|
|
|
openNewTab = function(studyInstanceUid, title) {
|
|
|
|
|
|
var contentid = generateUUID();
|
|
|
|
|
|
var data = {
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
contentid: contentid,
|
|
|
|
|
|
};
|
|
|
|
|
|
tabs.insert(data);
|
|
|
|
|
|
|
|
|
|
|
|
ViewerData[contentid] = {
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
contentid: contentid,
|
|
|
|
|
|
studyInstanceUid: studyInstanceUid
|
|
|
|
|
|
};
|
|
|
|
|
|
switchToTab(contentid);
|
2015-10-30 12:21:59 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Template.worklist.onRendered(function() {
|
|
|
|
|
|
// If there is a tab set as active in the Session,
|
|
|
|
|
|
// switch to that now.
|
|
|
|
|
|
var contentId = Session.get("activeContentId");
|
|
|
|
|
|
if (contentId) {
|
|
|
|
|
|
switchToTab(contentId);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2015-10-23 14:08:51 +02:00
|
|
|
|
|
2015-10-29 13:50:28 +01:00
|
|
|
|
|
2015-10-30 12:21:59 +01:00
|
|
|
|
Template.worklist.helpers({
|
|
|
|
|
|
'tabs': function() {
|
|
|
|
|
|
log.info('Updating tabs');
|
|
|
|
|
|
return tabs.find();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Template.worklist.events({
|
2015-11-03 22:56:12 +01:00
|
|
|
|
'click #tablist a[data-toggle="tab"]': function(e) {
|
2015-11-06 15:29:09 +01:00
|
|
|
|
// If this tab is already active, do nothing
|
|
|
|
|
|
var tabButton = $(e.currentTarget);
|
|
|
|
|
|
var tabTitle = tabButton.parents('.tabTitle');
|
|
|
|
|
|
if (tabTitle.hasClass("active")) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, switch to the tab
|
|
|
|
|
|
var contentId = tabButton.data('target').replace("#", "");
|
2015-10-23 14:08:51 +02:00
|
|
|
|
switchToTab(contentId);
|
2015-10-30 12:21:59 +01:00
|
|
|
|
}
|
2015-10-13 14:14:50 +02:00
|
|
|
|
});
|