From 1511642000bd7cc438f8e50bb40a3bd178e0773f Mon Sep 17 00:00:00 2001 From: Erik Ziegler Date: Tue, 17 Nov 2015 18:17:51 +0100 Subject: [PATCH] Switched studies in Session to ViewerStudies and WorklistStudies Collections. Fixes studyDate selector issues --- LesionTracker/client/components/viewer.js | 7 ++- OHIFViewer/client/components/viewer/viewer.js | 7 ++- .../cornerstone/client/hangingProtocol.js | 3 +- .../studyDateList/studyDateList.css | 0 .../studyDateList/studyDateList.html | 4 +- .../components/studyDateList/studyDateList.js | 58 ++++++++++--------- Packages/lesiontracker/package.js | 1 - .../imageThumbnail/imageThumbnail.js | 4 ++ .../studyBrowser/studyBrowser/studyBrowser.js | 16 +---- .../thumbnailEntry/thumbnailEntry.js | 1 + .../studyBrowser/thumbnails/thumbnails.js | 6 +- .../imageViewerViewport.js | 33 ++++++----- .../imageViewerViewports.js | 4 +- Packages/worklist/components/worklist.js | 6 +- .../worklistResult/worklistResult.js | 2 +- .../worklistSearch/worklistSearch.js | 4 +- Packages/worklist/package.js | 4 +- 17 files changed, 82 insertions(+), 78 deletions(-) delete mode 100644 Packages/lesiontracker/components/studyDateList/studyDateList.css diff --git a/LesionTracker/client/components/viewer.js b/LesionTracker/client/components/viewer.js index 41b2c44ba..152d48fd5 100644 --- a/LesionTracker/client/components/viewer.js +++ b/LesionTracker/client/components/viewer.js @@ -83,7 +83,12 @@ Template.viewer.onCreated(function() { Session.set('activeViewport', ViewerData[contentId].activeViewport || 0); - Session.set("studies", this.data.studies); + // Update the ViewerStudies collection with the loaded studies + ViewerStudies = new Meteor.Collection(null); + this.data.studies.forEach(function(study) { + study.selected = true; + ViewerStudies.insert(study); + }); OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.updateImageSynchronizer); }); diff --git a/OHIFViewer/client/components/viewer/viewer.js b/OHIFViewer/client/components/viewer/viewer.js index 16a90bcd0..e92042de0 100644 --- a/OHIFViewer/client/components/viewer/viewer.js +++ b/OHIFViewer/client/components/viewer/viewer.js @@ -88,7 +88,12 @@ Template.viewer.onCreated(function() { Session.set('activeViewport', ViewerData[contentId].activeViewport || 0); - Session.set("studies", this.data.studies); + // Update the ViewerStudies collection with the loaded studies + ViewerStudies = new Meteor.Collection(null); + this.data.studies.forEach(function(study) { + study.selected = true; + ViewerStudies.insert(study); + }); OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.updateImageSynchronizer); }); diff --git a/Packages/cornerstone/client/hangingProtocol.js b/Packages/cornerstone/client/hangingProtocol.js index 6f5195c87..a1f1ab0e4 100644 --- a/Packages/cornerstone/client/hangingProtocol.js +++ b/Packages/cornerstone/client/hangingProtocol.js @@ -12,7 +12,8 @@ var hangingProtocol; * @returns {Array} */ function defaultHangingProtocol(inputData) { - var studies = inputData.studies; + // TODO = Update this to use Collection logic + var studies = inputData.studies.find().fetch(); var viewportRows = inputData.viewportRows; var viewportColumns = inputData.viewportColumns; diff --git a/Packages/lesiontracker/components/studyDateList/studyDateList.css b/Packages/lesiontracker/components/studyDateList/studyDateList.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/Packages/lesiontracker/components/studyDateList/studyDateList.html b/Packages/lesiontracker/components/studyDateList/studyDateList.html index e8cd2612b..5328d8285 100644 --- a/Packages/lesiontracker/components/studyDateList/studyDateList.html +++ b/Packages/lesiontracker/components/studyDateList/studyDateList.html @@ -1,9 +1,7 @@ \ No newline at end of file diff --git a/Packages/lesiontracker/components/studyDateList/studyDateList.js b/Packages/lesiontracker/components/studyDateList/studyDateList.js index 4335db020..19883148c 100644 --- a/Packages/lesiontracker/components/studyDateList/studyDateList.js +++ b/Packages/lesiontracker/components/studyDateList/studyDateList.js @@ -6,16 +6,8 @@ Template.studyDateList.onCreated(function(){ this.selectedDate = ""; }); -function cleanTimepoints() { - var timepoints = Timepoints.find(); - timepoints.forEach(function (timepoint) { - Timepoints.remove({_id: timepoint._id}); - }); -} Template.studyDateList.onRendered(function(){ - //cleanTimepoints(); - // Add Study dates to Timepoints this.patientStudies.forEach(function(study) { Timepoints.insert({ @@ -35,7 +27,12 @@ Template.studyDateList.helpers({ var studyData = this.studies[0]; // study which is loaded in tab self.selectedDate = studyData.studyDate; - var studies = Studies.find().fetch(); // All studies list + + // TODO= Fix this! This won't work to retrieve all studies + // related to this patient. We will need to do a real search + // since the WorklistStudies Collection only contains the studies on-screen + + var studies = WorklistStudies.find({}).fetch(); // All studies list var patientStudies = []; // Holds studies of patient // Get all studies of patient with patientID @@ -53,26 +50,31 @@ Template.studyDateList.helpers({ Template.studyDateList.events({ 'change select#selectStudyDate': function(e, template) { - var selector = e.currentTarget; - var selectedStudyDate = $(selector).val(); - var patientStudies = template.patientStudies; - var studies = []; // all studies that has the same date and get with studyInstanceUId - patientStudies.forEach(function(study) { - if(study.studyDate === selectedStudyDate) { - studies.push(study); + var studyInstanceUid = $(e.currentTarget).val(); + + Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) { + sortStudy(study); + + // Set "Selected" to false for the entire collection + ViewerStudies.update({}, + {$set: {selected: false}}, + { multi: true }); + + // Check if this study already exists in the ViewerStudies collection + // of loaded studies. If it does, set it's 'selected' value to true. + var existingStudy = ViewerStudies.findOne({studyInstanceUid: studyInstanceUid}); + if (existingStudy) { + // Set the current finding in the collection to true + ViewerStudies.update(existingStudy._id, { + $set: {selected: true} + }); + return; } + + // If the study does not exist, add the 'selected' key to the object + // with the value True, and insert it into the ViewerStudies Collection + study.selected = true; + ViewerStudies.insert(study); }); - - studies.forEach(function(studyData) { - var studyInstanceUid = studyData.studyInstanceUid; - Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) { - sortStudy(study); - // TODO: - Session.set('studies', [study]); - // TODO: Change thumbnails only - }); - }); - - } }); diff --git a/Packages/lesiontracker/package.js b/Packages/lesiontracker/package.js index 3b91af175..50d504e10 100644 --- a/Packages/lesiontracker/package.js +++ b/Packages/lesiontracker/package.js @@ -40,7 +40,6 @@ Package.onUse(function (api) { api.addFiles('components/nonTargetLesionDialog/nonTargetLesionDialog.js', 'client'); api.addFiles('components/studyDateList/studyDateList.html', 'client'); - api.addFiles('components/studyDateList/studyDateList.css', 'client'); api.addFiles('components/studyDateList/studyDateList.js', 'client'); diff --git a/Packages/viewerbase/components/studyBrowser/imageThumbnail/imageThumbnail.js b/Packages/viewerbase/components/studyBrowser/imageThumbnail/imageThumbnail.js index 2a8e175e9..063821ed1 100644 --- a/Packages/viewerbase/components/studyBrowser/imageThumbnail/imageThumbnail.js +++ b/Packages/viewerbase/components/studyBrowser/imageThumbnail/imageThumbnail.js @@ -1,6 +1,10 @@ Template.imageThumbnail.onRendered(function() { var instance = this.data.stack.instances[0]; var element = this.find('.imageThumbnail'); + + cornerstone.disable(element); + $(element).find('canvas').remove(); + cornerstone.enable(element); var imageId = getImageId(instance); diff --git a/Packages/viewerbase/components/studyBrowser/studyBrowser/studyBrowser.js b/Packages/viewerbase/components/studyBrowser/studyBrowser/studyBrowser.js index 7b756aff6..38a1c2e51 100644 --- a/Packages/viewerbase/components/studyBrowser/studyBrowser/studyBrowser.js +++ b/Packages/viewerbase/components/studyBrowser/studyBrowser/studyBrowser.js @@ -1,15 +1,5 @@ Template.studyBrowser.helpers({ - studies : function() { - var studies = Session.get('studies'); - console.log(studies); - - var array = []; - studies.forEach(function(study, index) { - array.push({ - studyIndex: index, - study: study - }); - }); - return array; - } + studies : function() { + return ViewerStudies.find({selected: true}); + } }); \ No newline at end of file diff --git a/Packages/viewerbase/components/studyBrowser/thumbnailEntry/thumbnailEntry.js b/Packages/viewerbase/components/studyBrowser/thumbnailEntry/thumbnailEntry.js index 52927b6ad..7e7d96ae0 100644 --- a/Packages/viewerbase/components/studyBrowser/thumbnailEntry/thumbnailEntry.js +++ b/Packages/viewerbase/components/studyBrowser/thumbnailEntry/thumbnailEntry.js @@ -190,6 +190,7 @@ function thumbnailDragEndHandler(e, target) { } Template.thumbnailEntry.onRendered(function() { + console.log(this.data); var entry = this.find('.thumbnailEntry'); $(entry).data('seriesInstanceUid', Template.parentData(0).seriesInstanceUid); $(entry).data('studyInstanceUid', Template.parentData(1).studyInstanceUid); diff --git a/Packages/viewerbase/components/studyBrowser/thumbnails/thumbnails.js b/Packages/viewerbase/components/studyBrowser/thumbnails/thumbnails.js index dc9150b6f..2893c346c 100644 --- a/Packages/viewerbase/components/studyBrowser/thumbnails/thumbnails.js +++ b/Packages/viewerbase/components/studyBrowser/thumbnails/thumbnails.js @@ -1,12 +1,12 @@ Template.thumbnails.helpers({ thumbnails: function() { - var stacks = createStacks(this.study); - var studyIndex = this.studyIndex; + var study = this; + var stacks = createStacks(study); var array = []; stacks.forEach(function(stack, index) { array.push({ - thumbnailIndex: index * (studyIndex + 1), + thumbnailIndex: index, stack: stack }); }); diff --git a/Packages/viewerbase/components/viewer/imageViewerViewport/imageViewerViewport.js b/Packages/viewerbase/components/viewer/imageViewerViewport/imageViewerViewport.js index 23826a2e8..36444fd56 100644 --- a/Packages/viewerbase/components/viewer/imageViewerViewport/imageViewerViewport.js +++ b/Packages/viewerbase/components/viewer/imageViewerViewport/imageViewerViewport.js @@ -399,30 +399,31 @@ Template.imageViewerViewport.onRendered(function() { return; } - // Retrieve the current set of studies from the Meteor Session - var studies = Session.get('studies'); + // Look through the ViewerStudies collection for a + // study with this studyInstanceUid + var study = ViewerStudies.findOne({ + studyInstanceUid: this.data.studyInstanceUid + }); - // Look through every study and their series' until we find the - // series that matches the seriesInstanceUid and studyInstanceUid - var studyInstanceUid = this.data.studyInstanceUid; + // If we didn't find anything, stop here + if (!study) { + return; + } + + data.study = study; + + // Look through this study for a series with this seriesInstanceUid var seriesInstanceUid = this.data.seriesInstanceUid; - studies.every(function(study) { - if (study.studyInstanceUid === studyInstanceUid) { - data.study = study; - study.seriesList.every(function(series) { - if (series.seriesInstanceUid === seriesInstanceUid) { - data.series = series; - return false; - } - return true; - }); + study.seriesList.every(function(series) { + if (series.seriesInstanceUid === seriesInstanceUid) { + data.series = series; return false; } return true; }); // If we didn't find anything, stop here - if (!data.study || !data.series) { + if (!data.series) { return; } diff --git a/Packages/viewerbase/components/viewer/imageViewerViewports/imageViewerViewports.js b/Packages/viewerbase/components/viewer/imageViewerViewports/imageViewerViewports.js index 48e2bf207..921b419dc 100644 --- a/Packages/viewerbase/components/viewer/imageViewerViewports/imageViewerViewports.js +++ b/Packages/viewerbase/components/viewer/imageViewerViewports/imageViewerViewports.js @@ -21,8 +21,6 @@ Template.imageViewerViewports.helpers({ viewportArray: function() { log.info("imageViewerViewports viewportArray"); - var studies = Session.get('studies'); - var viewportRows = this.viewportRows || 1; var viewportColumns = this.viewportColumns || 1; @@ -49,7 +47,7 @@ Template.imageViewerViewports.helpers({ var inputData = { viewportColumns: viewportColumns, viewportRows: viewportRows, - studies: studies + studies: ViewerStudies }; var hangingProtocolViewportData = hangingProtocol(inputData); diff --git a/Packages/worklist/components/worklist.js b/Packages/worklist/components/worklist.js index 267921307..a4e450e19 100644 --- a/Packages/worklist/components/worklist.js +++ b/Packages/worklist/components/worklist.js @@ -17,6 +17,9 @@ var StudyMetaData = {}; // Create the WorklistTabs collection WorklistTabs = new Meteor.Collection(null); +// Create the WorklistStudies collection +WorklistStudies = new Meteor.Collection(null); + /** * Retrieves study metadata using a server call, and fires a callback * when completed. @@ -105,9 +108,6 @@ switchToTab = function(contentId) { studies: [study] }; - // Update the Session variable with the loaded studies - Session.set('studies', data.studies); - // Remove the loading text template that is inside the tab container by default container.innerHTML = ""; diff --git a/Packages/worklist/components/worklistResult/worklistResult.js b/Packages/worklist/components/worklistResult/worklistResult.js index 26cb5aa14..5b47f9c41 100644 --- a/Packages/worklist/components/worklistResult/worklistResult.js +++ b/Packages/worklist/components/worklistResult/worklistResult.js @@ -10,6 +10,6 @@ Template.worklistResult.helpers({ * by Patient name and Study Date in Ascending order. */ studies : function() { - return Studies.find({}, {sort: {patientName : 1, studyDate : 1}}); + return WorklistStudies.find({}, {sort: {patientName : 1, studyDate : 1}}); } }); diff --git a/Packages/worklist/components/worklistSearch/worklistSearch.js b/Packages/worklist/components/worklistSearch/worklistSearch.js index 6f7c09514..35531efae 100644 --- a/Packages/worklist/components/worklistSearch/worklistSearch.js +++ b/Packages/worklist/components/worklistSearch/worklistSearch.js @@ -69,7 +69,7 @@ function search() { var modality = replaceUndefinedColumnValue($('#modality').val()); // Clear all current studies - Studies.remove({}); + WorklistStudies.remove({}); Meteor.call('WorklistSearch', filter, function(error, studies) { if (!studies) { @@ -85,7 +85,7 @@ function search() { (convertStringToStudyDate(study.studyDate) <= new Date(studyDateTo).setHours(0,0,0,0) || !checkTo)) { // Insert any matching studies into the Studies Collection - Studies.insert(study); + WorklistStudies.insert(study); } }); }); diff --git a/Packages/worklist/package.js b/Packages/worklist/package.js index 918cd7558..6b6448573 100644 --- a/Packages/worklist/package.js +++ b/Packages/worklist/package.js @@ -57,8 +57,8 @@ Package.onUse(function (api) { // Export the global ViewerData object api.export('ViewerData', 'client'); - // Export the WorklistTabs Collection + // Export the Collections api.export('WorklistTabs', 'client'); - api.export('Studies', 'client'); + api.export('WorklistStudies', 'client'); });