Remove some subscription / reactivity / caching bugs and the unnecessary PatientLocations collection
This commit is contained in:
1 parent
7d42456f57
commit
9cde04bcfe
43 files changed
+321
-234
No files matched your search
@@ -1,20 +1,3 @@
|
||||
/**
|
||||
* Retrieve a location name (e.g. Liver Right) from the
|
||||
* PatientLocations Collection by id, if it exists. Otherwise,
|
||||
* return an empty string.
|
||||
*
|
||||
* @param id
|
||||
* @returns {*|string}
|
||||
*/
|
||||
function getLocationName(id) {
|
||||
var locationObject = PatientLocations.findOne(id);
|
||||
if (!locationObject || !locationObject.location) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return locationObject.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Timepoint object for a specific Measurement.
|
||||
* If no measurement exists yet, one will be created.
|
||||
@@ -33,7 +16,6 @@ function updateLesionData(lesionData) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var timepoint = Timepoints.findOne({
|
||||
timepointId: study.timepointId
|
||||
});
|
||||
@@ -84,7 +66,7 @@ function updateLesionData(lesionData) {
|
||||
|
||||
// Retrieve the location name given the locationUID
|
||||
if (lesionData.locationUID !== undefined) {
|
||||
var locationObj = PatientLocations.findOne({
|
||||
var locationObj = LesionLocations.findOne({
|
||||
locationUID: lesionData.locationUID
|
||||
});
|
||||
|
||||
@@ -191,12 +173,11 @@ function lesionNumberExists(lesionData) {
|
||||
return;
|
||||
}
|
||||
|
||||
return measurement.locationUID;
|
||||
return measurement.locationId;
|
||||
}
|
||||
|
||||
LesionManager = {
|
||||
updateLesionData: updateLesionData,
|
||||
getNewLesionNumber: getNewLesionNumber,
|
||||
lesionNumberExists: lesionNumberExists,
|
||||
getLocationName: getLocationName
|
||||
lesionNumberExists: lesionNumberExists
|
||||
};
|
||||
@@ -50,7 +50,7 @@ function RECIST(image) {
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 15,
|
||||
message: '^Nodal target lesions must be >= %{count} mm short axis'
|
||||
//message: '^Nodal target lesions must be >= %{count} mm short axis'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -72,7 +72,7 @@ function RECIST(image) {
|
||||
totalLesionBurden: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 2, // TODO: Check this, the value wasn't specified!
|
||||
message: '^Total lesion burden (SPD target lesions + SPD new lesions) should be greater than %{count}.'
|
||||
//message: '^Total lesion burden (SPD target lesions + SPD new lesions) should be greater than %{count}.'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -126,7 +126,7 @@ function RECIST(image) {
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 20,
|
||||
message: '^Extranodal lesions must be >= %{count} mm on chest X-ray'
|
||||
//message: '^Extranodal lesions must be >= %{count} mm on chest X-ray'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -135,7 +135,7 @@ function RECIST(image) {
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 10,
|
||||
message: '^Extranodal target lesions must be >= %{count} mm long axis'
|
||||
//message: '^Extranodal target lesions must be >= %{count} mm long axis'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -340,6 +340,9 @@ getTrialCriteriaConstraints = function(criteriaType, imageId) {
|
||||
|
||||
// Otherwise, retrieve the series metaData to identify the modality of the image
|
||||
var seriesMetaData = cornerstoneTools.metaData.get('series', imageId);
|
||||
if (!seriesMetaData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Get the rest of the metaData that has already been loaded by Cornerstone
|
||||
var image = {};
|
||||
@@ -363,7 +366,6 @@ getTrialCriteriaConstraints = function(criteriaType, imageId) {
|
||||
});
|
||||
|
||||
if (!study) {
|
||||
log.warn('No study/timepoint association.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Create a client-only Collection to store our Validation Errors
|
||||
ValidationErrors = new Meteor.Collection(null);
|
||||
ValidationErrors._debugName = 'ValidationErrors';
|
||||
|
||||
// Set Validate.js Library's default options
|
||||
validate.options = {
|
||||
@@ -216,8 +217,8 @@ function validateSingleMeasurement(measurementData) {
|
||||
var criteriaType = Session.get('TrialResponseAssessmentCriteria');
|
||||
var currentConstraints = getTrialCriteriaConstraints(criteriaType, measurementData.imageId);
|
||||
|
||||
// If we have no relevant constraints, stop here
|
||||
if (!currentConstraints) {
|
||||
log.warn('No relevant contraints could be applied');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,6 +237,11 @@ function validateSingleMeasurement(measurementData) {
|
||||
// Find the specific measurement data for this Measurement at this Timepoint
|
||||
var currentMeasurement = measurement.timepoints[timepointId];
|
||||
|
||||
// Return here if the measurement was removed during validation
|
||||
if (!currentMeasurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Include target and nodal flags on the timepoint-specific data so it is easier to validate
|
||||
// TODO: Rethink what to pass to assessSingleMeasurement?
|
||||
currentMeasurement.isTarget = measurement.isTarget;
|
||||
@@ -256,10 +262,11 @@ function validateGroups() {
|
||||
var criteriaType = Session.get('TrialResponseAssessmentCriteria');
|
||||
|
||||
Timepoints.find().forEach(function(timepoint) {
|
||||
// TODO: Criteria for the specific image are retrieved from the general set of criteria.
|
||||
// - The acquisitionSliceThickness, for example, may be pulled from the image metadata
|
||||
// - The organ in question, e.g. Chest X-ray, may determine the exact specifications for the current trial criteria
|
||||
// Criteria for the specific image are retrieved from the general set of criteria.
|
||||
var currentConstraints = getTrialCriteriaConstraints(criteriaType);
|
||||
if (!currentConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the current constraints which apply to the specific Timepoint type
|
||||
// (e.g. baseline, followup) that this Measurement is being edited on.
|
||||
@@ -289,12 +296,9 @@ function validateAll() {
|
||||
currentMeasurement.lesionNumber = measurement.lesionNumber;
|
||||
currentMeasurement._id = measurement._id;
|
||||
|
||||
// TODO: Criteria for the specific image are retrieved from the general set of criteria.
|
||||
// - The acquisitionSliceThickness, for example, may be pulled from the image metadata
|
||||
// - The organ in question, e.g. Chest X-ray, may determine the exact specifications for the current trial criteria
|
||||
// Criteria for the specific image are retrieved from the general set of criteria.
|
||||
var currentConstraints = getTrialCriteriaConstraints(criteriaType, currentMeasurement.imageId);
|
||||
if (!currentConstraints) {
|
||||
log.warn('No relevant contraints could be applied');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ activateMeasurements = function(element, measurementId, templateData, viewportIn
|
||||
var timepointData = getTimepointObject(imageId);
|
||||
var measurementData = Measurements.findOne(measurementId);
|
||||
|
||||
if (!timepointData) {
|
||||
return;
|
||||
}
|
||||
|
||||
var measurementAtTimepoint = measurementData.timepoints[timepointData.timepointId];
|
||||
if (!measurementAtTimepoint) {
|
||||
return;
|
||||
|
||||
@@ -5,11 +5,15 @@ clearTools = function() {
|
||||
var toolStateKeys = Object.keys(toolState).slice(0);
|
||||
|
||||
var viewportElements = $('.imageViewerViewport').not('.empty');
|
||||
var seriesInstanceUIds = []; // Holds seriesInstanceUId of imageViewerViewport elements
|
||||
var seriesInstanceUids = []; // Holds seriesInstanceUid of imageViewerViewport elements
|
||||
viewportElements.each(function(index, element) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var series = cornerstoneTools.metaData.get('series', enabledElement.image.imageId);
|
||||
seriesInstanceUIds.push(series.seriesInstanceUid);
|
||||
if (!series) {
|
||||
return;
|
||||
}
|
||||
|
||||
seriesInstanceUids.push(series.seriesInstanceUid);
|
||||
});
|
||||
|
||||
// Set null array for toolState data found by imageId and toolType
|
||||
@@ -18,8 +22,12 @@ clearTools = function() {
|
||||
var toolTypeData = toolState[imageId][toolType];
|
||||
if (toolTypeData && toolTypeData.data.length > 0) {
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
// If seriesInstanceUid is found in seriesInstanceUIds, set toolState data as null
|
||||
if (seriesInstanceUIds.indexOf(series.seriesInstanceUid) > -1) {
|
||||
if (!series) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If seriesInstanceUid is found in seriesInstanceUids, set toolState data as null
|
||||
if (seriesInstanceUids.indexOf(series.seriesInstanceUid) > -1) {
|
||||
toolState[imageId][toolType] = {
|
||||
data: []
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
handleMeasurementAdded = function(e, eventData) {
|
||||
log.info('CornerstoneToolsMeasurementAdded');
|
||||
var measurementData = eventData.measurementData;
|
||||
|
||||
switch (eventData.toolType) {
|
||||
case 'nonTarget':
|
||||
case 'lesion':
|
||||
log.info('CornerstoneToolsMeasurementAdded');
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
TrialResponseCriteria.validateDelayed(measurementData);
|
||||
break;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
handleMeasurementModified = function(e, eventData) {
|
||||
log.info('CornerstoneToolsMeasurementModified');
|
||||
var measurementData = eventData.measurementData;
|
||||
|
||||
switch (eventData.toolType) {
|
||||
case 'nonTarget':
|
||||
case 'lesion':
|
||||
log.info('CornerstoneToolsMeasurementModified');
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
TrialResponseCriteria.validateDelayed(measurementData);
|
||||
break;
|
||||
|
||||
@@ -62,7 +62,7 @@ syncMeasurementAndToolData = function(data) {
|
||||
measurementData.isDeleted = data.isDeleted;
|
||||
measurementData.location = data.location;
|
||||
measurementData.locationUID = data.locationUID;
|
||||
measurementData.patientId = patientId;
|
||||
measurementData.patientId = data.patientId;
|
||||
measurementData.visible = data.visible;
|
||||
measurementData.active = data.active;
|
||||
measurementData.uid = data.uid;
|
||||
|
||||
@@ -33,5 +33,8 @@ function dblClickOnStudy(data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the Timepoint name to the Patient name to create the tab title
|
||||
title += ' ' + getTimepointName(timepoint);
|
||||
|
||||
openNewTabWithTimepoint(timepoint.timepointId, title);
|
||||
}
|
||||
Reference in new issue
Block a user