[WIP] Moving ViewerStudies collection to TypeSafeCollection implementation + Fixing sorting bug in findAllBy method in TypeSafeCollection
This commit is contained in:
1 parent
a4e7aa86ab
commit
d25141f336
18 files changed
+143
-77
No files matched your search
+6
-1
@@ -1,6 +1,11 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.studyBrowser.helpers({
|
||||
studies() {
|
||||
return ViewerStudies.find({
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
return OHIF.viewer.Studies.findAllBy({
|
||||
selected: true
|
||||
});
|
||||
}
|
||||
|
||||
+6
-9
@@ -585,14 +585,9 @@ Template.imageViewerViewport.onRendered(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
// @TODO: Reconcile ViewerStudies and Studies Collection.
|
||||
// const study = Studies.findBy({ studyInstanceUid });
|
||||
|
||||
// Look through the ViewerStudies collection for a
|
||||
// study with this studyInstanceUid
|
||||
const study = ViewerStudies.findOne({
|
||||
studyInstanceUid: this.data.studyInstanceUid
|
||||
});
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
const study = OHIF.viewer.Studies.findBy({ studyInstanceUid });
|
||||
|
||||
data.study = study;
|
||||
setDisplaySet(data, displaySetInstanceUid, templateData);
|
||||
@@ -669,7 +664,9 @@ Template.imageViewerViewport.events({
|
||||
// Set the active viewport as the previous zoomed viewport
|
||||
viewportIndexToZoom = layoutManager.zoomedViewportIndex || 0;
|
||||
}
|
||||
setActiveViewport($('.imageViewerViewport').get(viewportIndexToZoom));
|
||||
// Set zoomed viewport as active...
|
||||
const element = $('.imageViewerViewport').get(viewportIndexToZoom);
|
||||
setActiveViewport(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
+5
-3
@@ -4,7 +4,6 @@ import { Session } from 'meteor/session';
|
||||
import { $ } from 'meteor/jquery';
|
||||
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
|
||||
Template.studySeriesQuickSwitch.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
@@ -29,13 +28,16 @@ Template.studySeriesQuickSwitch.onCreated(() => {
|
||||
|
||||
const viewportData = instance.getViewportData(viewportIndex);
|
||||
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
|
||||
if (viewportData) {
|
||||
// Finds the current study and return it
|
||||
instance.study = ViewerStudies.findOne({
|
||||
instance.study = OHIF.viewer.Studies.findBy({
|
||||
studyInstanceUid: viewportData.studyInstanceUid
|
||||
});
|
||||
} else {
|
||||
instance.study = ViewerStudies.findOne();
|
||||
instance.study = OHIF.viewer.Studies.getElementByIndex(0);
|
||||
}
|
||||
|
||||
if (!instance.study) {
|
||||
|
||||
+5
-1
@@ -1,4 +1,5 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.studyTimepoint.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
@@ -39,9 +40,12 @@ Template.studyTimepoint.events({
|
||||
// Defines where will be the studies searched
|
||||
let $studiesTarget = instance.$('.studyTimepoint');
|
||||
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
|
||||
if (changed.isQuickSwitch) {
|
||||
// Changes the current quick switch study
|
||||
const study = ViewerStudies.findOne({
|
||||
const study = OHIF.viewer.Studies.findBy({
|
||||
studyInstanceUid: changed.studyInstanceUid
|
||||
});
|
||||
instance.data.currentStudy.set(study);
|
||||
|
||||
+6
-3
@@ -2,7 +2,7 @@ import { Template } from 'meteor/templating';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { _ } from 'meteor/underscore';
|
||||
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { OHIFError } from '../../../lib/classes/OHIFError';
|
||||
|
||||
Template.studyTimepointBrowser.onCreated(() => {
|
||||
@@ -21,8 +21,11 @@ Template.studyTimepointBrowser.onCreated(() => {
|
||||
|
||||
// Get the studies for a specific timepoint
|
||||
instance.getStudies = timepoint => {
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
|
||||
if (!timepoint) {
|
||||
return ViewerStudies.find().fetch();
|
||||
return OHIF.viewer.Studies.all();
|
||||
}
|
||||
|
||||
return timepoint.studyInstanceUids.map(studyInstanceUid => {
|
||||
@@ -31,7 +34,7 @@ Template.studyTimepointBrowser.onCreated(() => {
|
||||
studyInstanceUid: studyInstanceUid
|
||||
};
|
||||
|
||||
const loadedStudy = ViewerStudies.findOne(query);
|
||||
const loadedStudy = OHIF.viewer.Studies.findBy(query);
|
||||
if (loadedStudy) {
|
||||
return loadedStudy;
|
||||
}
|
||||
|
||||
+11
-8
@@ -3,6 +3,7 @@ import { Template } from 'meteor/templating';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { $ } from 'meteor/jquery';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { sortingManager } from '../../../lib/sortingManager';
|
||||
|
||||
Template.studyTimepointStudy.onCreated(() => {
|
||||
@@ -97,10 +98,12 @@ Template.studyTimepointStudy.events({
|
||||
|
||||
const isQuickSwitch = !_.isUndefined(instance.data.viewportIndex);
|
||||
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
// Check if the study already has series data,
|
||||
// and if not, retrieve it.
|
||||
if (!studyData.seriesList) {
|
||||
const alreadyLoaded = ViewerStudies.findOne({ _id });
|
||||
const alreadyLoaded = OHIF.viewer.Studies.findBy({ studyInstanceUid });
|
||||
|
||||
if (!alreadyLoaded) {
|
||||
const $studies = instance.getStudyElement(true);
|
||||
@@ -108,12 +111,10 @@ Template.studyTimepointStudy.events({
|
||||
getStudyMetadata(studyInstanceUid, study => {
|
||||
study.displaySets = sortingManager.getDisplaySets(study);
|
||||
instance.data.study = study;
|
||||
ViewerStudies.insert(study, () => {
|
||||
// To make sure studies are rendered in the DOM
|
||||
// use minimongo insert callback
|
||||
$studies.trigger('loadEnded');
|
||||
instance.select(isQuickSwitch);
|
||||
});
|
||||
OHIF.viewer.Studies.insert(study);
|
||||
// make sure studies are rendered in the DOM
|
||||
$studies.trigger('loadEnded');
|
||||
instance.select(isQuickSwitch);
|
||||
});
|
||||
} else {
|
||||
studyData.seriesList = alreadyLoaded.seriesList;
|
||||
@@ -126,9 +127,11 @@ Template.studyTimepointStudy.events({
|
||||
|
||||
Template.studyTimepointStudy.helpers({
|
||||
isLoading() {
|
||||
// @TypeSafeStudies
|
||||
debugger;
|
||||
const instance = Template.instance();
|
||||
const studyData = instance.data.study;
|
||||
const alreadyLoaded = ViewerStudies.findOne({ _id: studyData._id });
|
||||
const alreadyLoaded = OHIF.viewer.Studies.findBy({ studyInstanceUid: studyData.studyInstanceUid });
|
||||
return instance.loading.get() && !alreadyLoaded;
|
||||
},
|
||||
modalities() {
|
||||
|
||||
+7
-4
@@ -1,5 +1,6 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Session } from 'meteor/session';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { viewportOverlayUtils } from '../../../lib/viewportOverlayUtils';
|
||||
import { getElementIfNotEmpty } from '../../../lib/getElementIfNotEmpty';
|
||||
import { getStackDataIfNotEmpty } from '../../../lib/getStackDataIfNotEmpty';
|
||||
@@ -217,17 +218,19 @@ Template.viewportOverlay.helpers({
|
||||
return;
|
||||
}
|
||||
|
||||
// @TypeSafeStudies
|
||||
debugger
|
||||
// Make sure there are more than two studies loaded in the viewer
|
||||
const viewportStudies = ViewerStudies.find();
|
||||
if (viewportStudies.count() < 2) {
|
||||
const viewportStudies = OHIF.viewer.Studies.all();
|
||||
if (viewportStudies.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Here we sort the collection in ascending order by study date, so
|
||||
// that we can obtain the oldest study as the first element of the array
|
||||
//
|
||||
// TODO= Find out if we should encode studyDate as a Date in the ViewerStudies Collection
|
||||
const viewportStudiesArray = _.sortBy(viewportStudies.fetch(), function(study) {
|
||||
// TODO= Find out if we should encode studyDate as a Date in the OHIF.viewer.Studies Collection
|
||||
const viewportStudiesArray = _.sortBy(viewportStudies, function(study) {
|
||||
return viewportOverlayUtils.formatDateTime(study.studyDate, study.studyTime);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user