Non-target response defaults to NM on baseline, Present on followup (LT-112)

This commit is contained in:
Erik Ziegler 2016-02-14 14:17:20 +01:00
parent ad52dffa94
commit 3c69caf92b
4 changed files with 64 additions and 54 deletions

View File

@ -21,7 +21,7 @@ LocationResponses.insert({
LocationResponses.insert({ LocationResponses.insert({
text: 'Present', text: 'Present',
code: false, code: 'Present',
description: '' description: ''
}); });
@ -42,3 +42,10 @@ LocationResponses.insert({
code: 'EX', code: 'EX',
description: '' description: ''
}); });
// TODO: Check if this is a copy of Not evaluable?
LocationResponses.insert({
text: 'Non-measurable',
code: 'NM',
description: ''
});

View File

@ -16,12 +16,11 @@
<div class="locationResponse"> <div class="locationResponse">
<label>Response</label> <label>Response</label>
<select id="selectNonTargetLesionLocationResponse"> <select id="selectNonTargetLesionLocationResponse">
<option value="-1"></option>
{{ #each locationResponses}} {{ #each locationResponses}}
{{ #if code }} {{ #if code }}
<option value={{code}}>{{code}} - {{text}}</option> <option value={{code}} selected={{selected}}>{{code}} - {{text}}</option>
{{ else }} {{ else }}
<option value={{text}}>{{text}}</option> <option value={{text}} selected={{selected}}>{{text}}</option>
{{ /if }} {{ /if }}
{{ /each}} {{ /each}}
</select> </select>
@ -49,7 +48,6 @@
<div class="locationResponse"> <div class="locationResponse">
<label>Response</label> <label>Response</label>
<select id="selectNonTargetLesionLocationResponse"> <select id="selectNonTargetLesionLocationResponse">
<option value="-1"></option>
{{ #each locationResponses}} {{ #each locationResponses}}
{{ #if code }} {{ #if code }}
<option value={{code}} selected={{selected}}>{{code}} - {{text}}</option> <option value={{code}} selected={{selected}}>{{code}} - {{text}}</option>

View File

@ -40,6 +40,31 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
doneCallback(lesionNumber); doneCallback(lesionNumber);
} }
function selectNonTargetResponse(responseCode) {
// First, disable all other responses
LocationResponses.update({}, {
$set: {
selected: false
}
}, {
multi: true
});
// If no response code is specified, leave them all disabled
if (!responseCode) {
return;
}
// Find the specified response by code and set it as selected
LocationResponses.update({
code: responseCode
}, {
$set: {
selected: true
}
});
}
// This event determines whether or not to show the Non-Target lesion dialog // This event determines whether or not to show the Non-Target lesion dialog
// If there already exists a lesion with this specific lesion number, // If there already exists a lesion with this specific lesion number,
// related to the chosen location. // related to the chosen location.
@ -60,10 +85,21 @@ function getLesionLocationCallback(measurementData, eventData) {
// Find the select option box // Find the select option box
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation'); var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
selectorLocation.find('option:first').prop('selected', 'selected'); selectorLocation.find('option:first').prop('selected', 'selected');
selectorResponse.find('option:first').prop('selected', 'selected');
// LT-112 "Non-target response shall default to non-measurable on baseline, present on follow-up"
var timepoint = Timepoints.findOne({
timepointId: measurementData.timepointId
});
if (timepoint && timepoint.timepointType === 'baseline') {
selectNonTargetResponse('NM');
} else if (timepoint && timepoint.timepointType === 'followup') {
selectNonTargetResponse('Present');
} else {
selectNonTargetResponse();
}
// Allow location selection // Allow location selection
selectorLocation.removeAttr('disabled'); selectorLocation.removeAttr('disabled');
@ -183,13 +219,11 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
return; return;
} }
LesionLocations.update({}, LesionLocations.update({}, {
{
$set: { $set: {
selected: false selected: false
} }
}, }, {
{
multi: true multi: true
}); });
@ -207,33 +241,8 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
} }
}); });
LocationResponses.update({},
{
$set: {
selected: false
}
},
{
multi: true
});
var response = measurement.timepoints[measurementData.timepointId].response; var response = measurement.timepoints[measurementData.timepointId].response;
selectNonTargetResponse(response);
// TODO = Standardize this. Searching by code probably isn't the best, we should use
// some sort of UID
var currentResponse = LocationResponses.findOne({
code: response
});
if (!currentResponse) {
return;
}
LocationResponses.update(currentResponse._id, {
$set: {
selected: true
}
});
}; };
var config = { var config = {
@ -245,17 +254,19 @@ var config = {
cornerstoneTools.nonTarget.setConfiguration(config); cornerstoneTools.nonTarget.setConfiguration(config);
Template.nonTargetLesionDialog.events({ Template.nonTargetLesionDialog.events({
'change #selectNonTargetLesionLocationResponse': function(e) {
var responseCode = $(e.currentTarget).val();
selectNonTargetResponse(responseCode);
},
'click #nonTargetLesionOK': function() { 'click #nonTargetLesionOK': function() {
var dialog = Template.nonTargetLesionDialog.dialog; var dialog = Template.nonTargetLesionDialog.dialog;
var measurementData = Template.nonTargetLesionDialog.measurementData; var measurementData = Template.nonTargetLesionDialog.measurementData;
// Find the select option box // Find the select option box
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation'); var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
// Get the current value of the selector // Get the current value of the selector
var selectedOptionId = selectorLocation.find('option:selected').val(); var selectedOptionId = selectorLocation.find('option:selected').val();
var responseOptionId = selectorResponse.find('option:selected').val();
// If the selected option is still the default (-1) // If the selected option is still the default (-1)
// then stop here // then stop here
@ -263,12 +274,6 @@ Template.nonTargetLesionDialog.events({
return; return;
} }
// If the selected response option is still the default (-1)
// then stop here
if (responseOptionId < 0) {
return;
}
// Get selected location data // Get selected location data
var locationObj = LesionLocations.findOne({ var locationObj = LesionLocations.findOne({
_id: selectedOptionId _id: selectedOptionId
@ -279,7 +284,7 @@ Template.nonTargetLesionDialog.events({
Measurements.update(measurementData.id, { Measurements.update(measurementData.id, {
$set: { $set: {
location: locationObj.location, location: locationObj.location,
locationId: locationObj.id, locationId: locationObj.id
} }
}); });
} else { } else {
@ -291,7 +296,7 @@ Template.nonTargetLesionDialog.events({
measurementData.isTarget = false; measurementData.isTarget = false;
// Response is set from location response list // Response is set from location response list
measurementData.response = responseOptionId; measurementData.response = LocationResponses.findOne({selected: true}).code;
// Adds lesion data to timepoints array // Adds lesion data to timepoints array
LesionManager.updateLesionData(measurementData); LesionManager.updateLesionData(measurementData);

View File

@ -61,8 +61,8 @@ function updateLesionData(lesionData) {
}; };
if (!lesionData.measurementType) { if (!lesionData.measurementType) {
// For debugging // For debugging, might want to switch to measurement types later
log.warn('No MeasurementType available?'); lesionData.measurementType = lesionData.isTarget ? 'bidirectional' : 'nonTarget';
} }
// Populate this timepoint's data with whichever values // Populate this timepoint's data with whichever values