Fix infinite loop caused by Measurements and Timepoints Collections during Validation
This commit is contained in:
parent
02010aea81
commit
4737afb47c
@ -55,6 +55,8 @@ function addValidationErrorsToCollection(validationErrors, prefix, type) {
|
|||||||
* @returns {Array} Array of error messages related to the input conformance checks
|
* @returns {Array} Array of error messages related to the input conformance checks
|
||||||
*/
|
*/
|
||||||
function assessGroupOfMeasurements(constraints) {
|
function assessGroupOfMeasurements(constraints) {
|
||||||
|
log.info('assessGroupOfMeasurements');
|
||||||
|
|
||||||
// Retrieve the group-level constraints
|
// Retrieve the group-level constraints
|
||||||
var groupConstraints = constraints.group;
|
var groupConstraints = constraints.group;
|
||||||
|
|
||||||
@ -97,6 +99,8 @@ function assessGroupOfMeasurements(constraints) {
|
|||||||
* @returns {Array} Array of error messages related to the input conformance checks
|
* @returns {Array} Array of error messages related to the input conformance checks
|
||||||
*/
|
*/
|
||||||
function assessMeasurementPerOrgan(constraints) {
|
function assessMeasurementPerOrgan(constraints) {
|
||||||
|
log.info('assessMeasurementPerOrgan');
|
||||||
|
|
||||||
// Retrieve the per-organ constraints
|
// Retrieve the per-organ constraints
|
||||||
var perOrganConstraints = constraints.perOrgan;
|
var perOrganConstraints = constraints.perOrgan;
|
||||||
|
|
||||||
@ -154,6 +158,8 @@ function assessMeasurementPerOrgan(constraints) {
|
|||||||
* @returns {Array} Array of error messages related to the input conformance checks
|
* @returns {Array} Array of error messages related to the input conformance checks
|
||||||
*/
|
*/
|
||||||
function assessSingleMeasurement(constraints, measurementData) {
|
function assessSingleMeasurement(constraints, measurementData) {
|
||||||
|
log.info('assessSingleMeasurement');
|
||||||
|
|
||||||
// Check whether this is a Target or Non-Target Measurement
|
// Check whether this is a Target or Non-Target Measurement
|
||||||
var targetType = measurementData.isTarget ? 'target' : 'nonTarget';
|
var targetType = measurementData.isTarget ? 'target' : 'nonTarget';
|
||||||
|
|
||||||
@ -257,17 +263,25 @@ function validateSingleMeasurement(measurementData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateGroups() {
|
function validateGroups() {
|
||||||
|
log.info('validateGroups');
|
||||||
|
|
||||||
// Obtain the name of the current TrialResponseAssessmentCriteria that
|
// Obtain the name of the current TrialResponseAssessmentCriteria that
|
||||||
// we are using.
|
// we are using.
|
||||||
var criteriaType = Session.get('TrialResponseAssessmentCriteria');
|
var criteriaType = Session.get('TrialResponseAssessmentCriteria');
|
||||||
|
|
||||||
Timepoints.find().forEach(function(timepoint) {
|
// Criteria for the specific image are retrieved from the general set of criteria.
|
||||||
// Criteria for the specific image are retrieved from the general set of criteria.
|
var currentConstraints = getTrialCriteriaConstraints(criteriaType);
|
||||||
var currentConstraints = getTrialCriteriaConstraints(criteriaType);
|
if (!currentConstraints) {
|
||||||
if (!currentConstraints) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// TODO: Revisit this! We can't use the Timepoints collection inside ANY
|
||||||
|
// of these functions, since it causes an infinite loop, since Measurement
|
||||||
|
// validation is performed inside the observe:added hook for the Measurements
|
||||||
|
// Collection.
|
||||||
|
|
||||||
|
var timepointTypes = ['baseline', 'followup'];
|
||||||
|
timepointTypes.forEach(function(timepoint) {
|
||||||
// Retrieve the current constraints which apply to the specific Timepoint type
|
// Retrieve the current constraints which apply to the specific Timepoint type
|
||||||
// (e.g. baseline, followup) that this Measurement is being edited on.
|
// (e.g. baseline, followup) that this Measurement is being edited on.
|
||||||
var timepointConstraints = currentConstraints[timepoint.timepointType];
|
var timepointConstraints = currentConstraints[timepoint.timepointType];
|
||||||
@ -284,6 +298,7 @@ function validateGroups() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateAll() {
|
function validateAll() {
|
||||||
|
log.info('validateAll');
|
||||||
// Obtain the name of the current TrialResponseAssessmentCriteria that
|
// Obtain the name of the current TrialResponseAssessmentCriteria that
|
||||||
// we are using.
|
// we are using.
|
||||||
var criteriaType = Session.get('TrialResponseAssessmentCriteria');
|
var criteriaType = Session.get('TrialResponseAssessmentCriteria');
|
||||||
@ -307,6 +322,7 @@ function validateAll() {
|
|||||||
assessSingleMeasurement(currentConstraints, currentMeasurement);
|
assessSingleMeasurement(currentConstraints, currentMeasurement);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
validateGroups();
|
validateGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,12 +334,14 @@ var validationTimeout = 400;
|
|||||||
* @param measurementData Input measurement data from CornerstoneTools
|
* @param measurementData Input measurement data from CornerstoneTools
|
||||||
*/
|
*/
|
||||||
function validateDelayed(measurementData) {
|
function validateDelayed(measurementData) {
|
||||||
|
log.info('validateAllDelayed');
|
||||||
|
|
||||||
// Erase any currently-waiting validation call
|
// Erase any currently-waiting validation call
|
||||||
clearTimeout(validationTimeout);
|
Meteor.clearTimeout(validationTimeout);
|
||||||
|
|
||||||
// Set a timeout to run validation after a delay
|
// Set a timeout to run validation after a delay
|
||||||
// Currently this is 400 milliseconds
|
// Currently this is 400 milliseconds
|
||||||
setTimeout(function() {
|
Meteor.setTimeout(function() {
|
||||||
validateSingleMeasurement(measurementData);
|
validateSingleMeasurement(measurementData);
|
||||||
}, validationTimeout);
|
}, validationTimeout);
|
||||||
}
|
}
|
||||||
@ -333,11 +351,11 @@ function validateDelayed(measurementData) {
|
|||||||
*/
|
*/
|
||||||
function validateAllDelayed() {
|
function validateAllDelayed() {
|
||||||
// Erase any currently-waiting validation call
|
// Erase any currently-waiting validation call
|
||||||
clearTimeout(validationTimeout);
|
Meteor.clearTimeout(validationTimeout);
|
||||||
|
|
||||||
// Set a timeout to run validation after a delay
|
// Set a timeout to run validation after a delay
|
||||||
// Currently this is 400 milliseconds
|
// Currently this is 400 milliseconds
|
||||||
setTimeout(function() {
|
Meteor.setTimeout(function() {
|
||||||
validateAll();
|
validateAll();
|
||||||
}, validationTimeout);
|
}, validationTimeout);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user