Move decrementing to server and out of observe hook
This commit is contained in:
parent
fdde2f9ff9
commit
906f7c6234
@ -181,34 +181,26 @@ Template.viewer.onCreated(function() {
|
|||||||
removeToolDataWithMeasurementId(imageId, toolType, measurementId);
|
removeToolDataWithMeasurementId(imageId, toolType, measurementId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update all Measurements to decrement the lesion numbers for those
|
// Sync database data with toolData for all the measurements
|
||||||
// that were created after the current lesion by 1
|
// that have just been updated
|
||||||
Meteor.call('decrementLesionNumbers', data, function(error, response) {
|
|
||||||
if (error) {
|
// Note that here we need to use greater than and equals to
|
||||||
log.warn(error);
|
// find the Measurements, whereas on the server it's
|
||||||
|
// only "greater than", since inside this callback the
|
||||||
|
// Measurements have already been decremented.
|
||||||
|
Measurements.find({
|
||||||
|
patientId: data.patientId,
|
||||||
|
lesionNumberAbsolute: {
|
||||||
|
$gte: data.lesionNumberAbsolute
|
||||||
}
|
}
|
||||||
|
}).forEach(function(measurementData) {
|
||||||
|
syncMeasurementAndToolData(measurementData);
|
||||||
|
});
|
||||||
|
|
||||||
// Sync database data with toolData for all the measurements
|
// Update each displayed viewport
|
||||||
// that have just been updated
|
var viewports = $('.imageViewerViewport').not('.empty');
|
||||||
|
viewports.each(function(index, element) {
|
||||||
// Note that here we need to use greater than and equals to
|
cornerstone.updateImage(element);
|
||||||
// find the Measurements, whereas on the server it's
|
|
||||||
// only "greater than", since inside this callback the
|
|
||||||
// Measurements have already been decremented.
|
|
||||||
Measurements.find({
|
|
||||||
patientId: data.patientId,
|
|
||||||
lesionNumberAbsolute: {
|
|
||||||
$gte: data.lesionNumberAbsolute
|
|
||||||
}
|
|
||||||
}).forEach(function(measurementData) {
|
|
||||||
syncMeasurementAndToolData(measurementData);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update each displayed viewport
|
|
||||||
var viewports = $('.imageViewerViewport').not('.empty');
|
|
||||||
viewports.each(function(index, element) {
|
|
||||||
cornerstone.updateImage(element);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,13 +1,7 @@
|
|||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
removeMeasurement: function(id) {
|
removeMeasurement: function(id) {
|
||||||
Measurements.remove(id);
|
var lesionData = Measurements.findOne(id);
|
||||||
},
|
|
||||||
removeMeasurementsByPatientId: function(patientId) {
|
|
||||||
Measurements.remove({
|
|
||||||
patientId: patientId
|
|
||||||
});
|
|
||||||
},
|
|
||||||
decrementLesionNumbers: function(lesionData) {
|
|
||||||
// Update all Measurements to decrement the lesion numbers for those
|
// Update all Measurements to decrement the lesion numbers for those
|
||||||
// that were created after the current lesion by 1
|
// that were created after the current lesion by 1
|
||||||
|
|
||||||
@ -42,5 +36,12 @@ Meteor.methods({
|
|||||||
}, {
|
}, {
|
||||||
multi: true
|
multi: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Measurements.remove(id);
|
||||||
|
},
|
||||||
|
removeMeasurementsByPatientId: function(patientId) {
|
||||||
|
Measurements.remove({
|
||||||
|
patientId: patientId
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user