Fix duplicate lesion bug LT-110

This commit is contained in:
Erik Ziegler 2016-01-09 15:56:59 +01:00
parent d912c7a269
commit e4547f121d
9 changed files with 29 additions and 31 deletions

View File

@ -56,7 +56,6 @@ var LesionManager = (function() {
};
if (lesionData.isTarget === true) {
// TODO = Add short axis
timepointData.shortestDiameter = lesionData.widthMeasurement;
timepointData.longestDiameter = lesionData.measurementText;
} else {
@ -86,8 +85,8 @@ var LesionManager = (function() {
// Set a flag to prevent duplication of toolData
measurement.toolDataInsertedManually = true;
// Increment and store the Lesion Number for this Measurement
measurement.lesionNumber = Measurements.find().count() + 1;
// Increment and store the absolute Lesion Number for this Measurement
measurement.lesionNumberAbsolute = Measurements.find().count() + 1;
// Insert this into the Measurements Collection
// Save the ID into the toolData (not sure if this works?)
@ -114,36 +113,38 @@ var LesionManager = (function() {
*/
function getNewLesionNumber(timepointID, isTarget) {
// Get all current lesion measurements
var numMeasurements = Measurements.find({
isTarget: isTarget
}).count();
// If no measurements exist yet, start at 1
if (!numMeasurements) {
return 1;
}
// Find related measurements (i.e. target or non-target)
var measurements = Measurements.find({
isTarget: isTarget
}, {
sort: {lesionNumber: 1}
}).fetch();
// If no measurements exist yet, start at 1
if (!measurements.length) {
return 1;
}
});
// If measurements exist, find the last lesion number
// from the given timepoint
var lesionNumberCounter = 1;
var numMeasurements = measurements.length;
// Search through Measurements to see which ones
// already have data for this Timepoint
for (var i = 0; i < numMeasurements; i++) {
var measurement = measurements[i];
measurements.forEach(function(measurement) {
// If this measurement has no data for this Timepoint,
// use this as the current Measurement
if (!measurement.timepoints[timepointID]) {
return measurement.lesionNumber;
lesionNumberCounter = measurement.lesionNumber;
return false;
}
lesionNumberCounter++;
}
});
return lesionNumberCounter;
}

View File

@ -43,7 +43,7 @@ Template.confirmDeleteDialog.events({
closeHandler();
},
'keypress #confirmDeleteDialog': function(e) {
'keydown #confirmDeleteDialog': function(e) {
if (e.which === keys.ESC) {
closeHandler();
}

View File

@ -246,7 +246,7 @@ Template.lesionLocationDialog.events({
var dialog = Template.lesionLocationDialog.dialog;
closeHandler(dialog);
},
'keypress #lesionLocationDialog, keypress #lesionLocationRelabelDialog': function(e) {
'keydown #lesionLocationDialog, keydown #lesionLocationRelabelDialog': function(e) {
var dialog = Template.lesionLocationDialog.dialog;
// If Enter is pressed, close the dialog

View File

@ -1,6 +1,6 @@
<template name="lesionTableRow">
<tr id="{{lesionNumber}}" class="lesionTableRow" data-measurementid="{{_id}}">
<td class='lesionNumber'>{{lesionNumber}}</td>
<td class='lesionNumber'>{{lesionNumberAbsolute}}</td>
<td class='location' tabindex="0">{{location}}</td>
<td class='target'>{{#if isTarget}} Y {{else}} N {{/if}}</td>
<!--Each time point as a column-->

View File

@ -19,14 +19,11 @@ Template.lesionTableTimepointCell.helpers({
var data = lesionData.timepoints[this.timepointID];
if (lesionData.isTarget === true) {
// TODO = Add short axis data here
//return 'LD: ' + data.longestDiameter;
if(data.shortestDiameter) {
return data.longestDiameter +" x "+ data.shortestDiameter;
if (data.shortestDiameter) {
return data.longestDiameter + " x " + data.shortestDiameter;
}
return data.longestDiameter;
return data.longestDiameter;
} else {
return data.response;
}

View File

@ -9,7 +9,7 @@
<select id="selectNonTargetLesionLocation">
<option value="-1"></option>
{{ #each lesionLocations}}
<option value='{{_id}}'>{{location}}</option>
<option value={{_id}}>{{location}}</option>
{{ /each}}
</select>
</div>
@ -19,9 +19,9 @@
<option value="-1"></option>
{{ #each locationResponses}}
{{ #if code }}
<option value='{{code}}'>{{code}} - {{text}}</option>
<option value={{code}}>{{code}} - {{text}}</option>
{{ else }}
<option value={{text}}}>{{text}}</option>
<option value={{text}}>{{text}}</option>
{{ /if }}
{{ /each}}
</select>

View File

@ -308,7 +308,7 @@ Template.nonTargetLesionDialog.events({
var dialog = Template.nonTargetLesionDialog.dialog;
closeHandler(dialog);
},
'keypress #lesionLocationDialog, keypress #lesionLocationRelabelDialog': function(e) {
'keydown #lesionLocationDialog, keydown #lesionLocationRelabelDialog': function(e) {
var dialog = Template.nonTargetLesionDialog.dialog;
// If Enter is pressed, close the dialog

View File

@ -133,7 +133,7 @@ Template.nonTargetResponseDialog.events({
var dialog = Template.nonTargetResponseDialog.dialog;
closeHandler(dialog);
},
'keypress #nonTargetResponseDialog': function(e) {
'keydown #nonTargetResponseDialog': function(e) {
var dialog = Template.nonTargetResponseDialog.dialog;
// If Enter is pressed, close the dialog

View File

@ -41,7 +41,7 @@ activateLesion = function(measurementId, templateData) {
}
// Loop through the viewports and display each timepoint
$(".imageViewerViewport").each(function(viewportIndex, element) {
$(".imageViewerViewport").not('.empty').each(function(viewportIndex, element) {
// Stop if we run out of timepoints before viewports
if (viewportIndex >= timepointsWithEntries.length) {
// Update the element anyway, to remove any other highlights that are present