LT-115: Fixing Add Label on follow ups that already have a location
This commit is contained in:
parent
dfbd63fcb7
commit
d63aace48f
@ -22,7 +22,7 @@ Template.dialogNonTargetMeasurement.onCreated(() => {
|
|||||||
toolItemId: instance.data.measurementData._id
|
toolItemId: instance.data.measurementData._id
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the Overall Measurement Numbers for all Measurements
|
// Sync the new measurement data with cornerstone tools
|
||||||
|
|
||||||
// Commenting this out for now, we need the timepointApi
|
// Commenting this out for now, we need the timepointApi
|
||||||
//const baseline = timepointApi.baseline();
|
//const baseline = timepointApi.baseline();
|
||||||
|
|||||||
@ -4,9 +4,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
|
|
||||||
Template.measurementLocationDialog.onCreated(() => {
|
Template.measurementLocationDialog.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const measurementTypeId = 'bidirectional';
|
|
||||||
const measurementApi = instance.data.measurementApi;
|
const measurementApi = instance.data.measurementApi;
|
||||||
const timepointApi = instance.data.timepointApi;
|
|
||||||
|
|
||||||
const toggleLabel = (measurementData, eventData, doneCallback) => {
|
const toggleLabel = (measurementData, eventData, doneCallback) => {
|
||||||
delete measurementData.isCreating;
|
delete measurementData.isCreating;
|
||||||
@ -26,7 +24,7 @@ Template.measurementLocationDialog.onCreated(() => {
|
|||||||
measurementId: measurementData._id,
|
measurementId: measurementData._id,
|
||||||
toolType: measurementData.toolType,
|
toolType: measurementData.toolType,
|
||||||
element: eventData.element,
|
element: eventData.element,
|
||||||
measurementApi: instance.data.measurementApi,
|
measurementApi,
|
||||||
position: position,
|
position: position,
|
||||||
direction: {
|
direction: {
|
||||||
x: getDirection('x'),
|
x: getDirection('x'),
|
||||||
@ -41,7 +39,6 @@ Template.measurementLocationDialog.onCreated(() => {
|
|||||||
changeMeasurementLocationCallback: toggleLabel,
|
changeMeasurementLocationCallback: toggleLabel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO: Reconcile this with the configuration in toolManager
|
// TODO: Reconcile this with the configuration in toolManager
|
||||||
// it would be better to have this all in one place.
|
// it would be better to have this all in one place.
|
||||||
const bidirectionalConfig = cornerstoneTools.bidirectional.getConfiguration();
|
const bidirectionalConfig = cornerstoneTools.bidirectional.getConfiguration();
|
||||||
@ -61,12 +58,12 @@ Template.measurementLocationDialog.onCreated(() => {
|
|||||||
|
|
||||||
// Note: None of these events work anymore
|
// Note: None of these events work anymore
|
||||||
Template.measurementLocationDialog.events({
|
Template.measurementLocationDialog.events({
|
||||||
'click #removeMeasurement': function() {
|
'click #removeMeasurement'() {
|
||||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
const measurementData = Template.measurementLocationDialog.measurementData;
|
||||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
const doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||||
var dialog = Template.measurementLocationDialog.dialog;
|
const dialog = Template.measurementLocationDialog.dialog;
|
||||||
|
|
||||||
var options = {
|
const options = {
|
||||||
keyPressAllowed: false,
|
keyPressAllowed: false,
|
||||||
title: 'Remove measurement?',
|
title: 'Remove measurement?',
|
||||||
text: 'Are you sure you would like to remove the entire measurement?'
|
text: 'Are you sure you would like to remove the entire measurement?'
|
||||||
@ -74,16 +71,17 @@ Template.measurementLocationDialog.events({
|
|||||||
|
|
||||||
showConfirmDialog(function() {
|
showConfirmDialog(function() {
|
||||||
if (doneCallback && typeof doneCallback === 'function') {
|
if (doneCallback && typeof doneCallback === 'function') {
|
||||||
var deleteTool = true;
|
const deleteTool = true;
|
||||||
doneCallback(measurementData, deleteTool);
|
doneCallback(measurementData, deleteTool);
|
||||||
}
|
}
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
closeHandler(dialog);
|
closeHandler(dialog);
|
||||||
},
|
},
|
||||||
'click #convertToNonTarget': function() {
|
|
||||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
'click #convertToNonTarget'() {
|
||||||
var dialog = Template.measurementLocationDialog.dialog;
|
const measurementData = Template.measurementLocationDialog.measurementData;
|
||||||
|
const dialog = Template.measurementLocationDialog.dialog;
|
||||||
|
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const measurementApi = instance.data.measurementApi;
|
const measurementApi = instance.data.measurementApi;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class MeasurementApi {
|
|||||||
|
|
||||||
this.toolGroups = {};
|
this.toolGroups = {};
|
||||||
this.tools = {};
|
this.tools = {};
|
||||||
|
this.toolsGroupsMap = {};
|
||||||
|
|
||||||
configuration.measurementTools.forEach(toolGroup => {
|
configuration.measurementTools.forEach(toolGroup => {
|
||||||
const groupCollection = new Mongo.Collection(null);
|
const groupCollection = new Mongo.Collection(null);
|
||||||
@ -32,8 +33,10 @@ class MeasurementApi {
|
|||||||
collection._debugName = tool.name;
|
collection._debugName = tool.name;
|
||||||
collection.attachSchema(tool.schema);
|
collection.attachSchema(tool.schema);
|
||||||
this.tools[tool.id] = collection;
|
this.tools[tool.id] = collection;
|
||||||
|
this.toolsGroupsMap[tool.id] = toolGroup.id;
|
||||||
|
|
||||||
const addedHandler = measurement => {
|
const addedHandler = measurement => {
|
||||||
|
// Get the measurement number
|
||||||
const timepoint = this.timepointApi.timepoints.findOne({
|
const timepoint = this.timepointApi.timepoints.findOne({
|
||||||
studyInstanceUids: measurement.studyInstanceUid
|
studyInstanceUids: measurement.studyInstanceUid
|
||||||
});
|
});
|
||||||
@ -42,6 +45,18 @@ class MeasurementApi {
|
|||||||
}).count() + 1;
|
}).count() + 1;
|
||||||
measurement.measurementNumber = measurementNumber;
|
measurement.measurementNumber = measurementNumber;
|
||||||
|
|
||||||
|
// Get the current location (if already defined)
|
||||||
|
let location;
|
||||||
|
const baselineTimepoint = timepointApi.baseline();
|
||||||
|
const baselineGroupEntry = groupCollection.findOne({
|
||||||
|
timepointId: baselineTimepoint.timepointId
|
||||||
|
});
|
||||||
|
if (baselineGroupEntry) {
|
||||||
|
const tool = this.tools[baselineGroupEntry.toolId];
|
||||||
|
location = tool.findOne({ measurementNumber }).location;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reflect the entry in the tool group collection
|
||||||
groupCollection.insert({
|
groupCollection.insert({
|
||||||
toolId: tool.id,
|
toolId: tool.id,
|
||||||
toolItemId: measurement._id,
|
toolItemId: measurement._id,
|
||||||
@ -51,10 +66,12 @@ class MeasurementApi {
|
|||||||
measurementNumber
|
measurementNumber
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set the timepoint ID, measurement number and location
|
||||||
collection.update(measurement._id, {
|
collection.update(measurement._id, {
|
||||||
$set: {
|
$set: {
|
||||||
|
timepointId: timepoint.timepointId,
|
||||||
measurementNumber,
|
measurementNumber,
|
||||||
timepointId: timepoint.timepointId
|
location
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -14,11 +14,6 @@ const Measurement = new SimpleSchema({
|
|||||||
label: 'Measurement Number',
|
label: 'Measurement Number',
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
measurementNumberOverall: {
|
|
||||||
type: Number,
|
|
||||||
label: 'Measurement Number Overall',
|
|
||||||
optional: true
|
|
||||||
},
|
|
||||||
timepointId: {
|
timepointId: {
|
||||||
type: String,
|
type: String,
|
||||||
label: 'Timepoint ID',
|
label: 'Timepoint ID',
|
||||||
|
|||||||
@ -64,7 +64,7 @@ Template.measurementTableRow.events({
|
|||||||
// Remove all the measurements with the given type and number
|
// Remove all the measurements with the given type and number
|
||||||
measurementApi.deleteMeasurements(measurementTypeId, { measurementNumber });
|
measurementApi.deleteMeasurements(measurementTypeId, { measurementNumber });
|
||||||
|
|
||||||
// Update the Overall Measurement Numbers for all Measurements
|
// Sync the new measurement data with cornerstone tools
|
||||||
const baseline = timepointApi.baseline();
|
const baseline = timepointApi.baseline();
|
||||||
measurementApi.sortMeasurements(baseline.timepointId);
|
measurementApi.sortMeasurements(baseline.timepointId);
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,6 @@ Template.measurementTableView.helpers({
|
|||||||
return {
|
return {
|
||||||
measurementTypeId: measurementTypeId,
|
measurementTypeId: measurementTypeId,
|
||||||
measurementNumber: key,
|
measurementNumber: key,
|
||||||
measurementNumberOverall: anEntry.measurementNumberOverall,
|
|
||||||
location: OHIF.measurements.getLocation(groupObject[key]),
|
location: OHIF.measurements.getLocation(groupObject[key]),
|
||||||
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
||||||
entries: groupObject[key]
|
entries: groupObject[key]
|
||||||
@ -142,7 +141,6 @@ Template.measurementTableView.helpers({
|
|||||||
return {
|
return {
|
||||||
measurementTypeId: measurementTypeId,
|
measurementTypeId: measurementTypeId,
|
||||||
measurementNumber: key,
|
measurementNumber: key,
|
||||||
measurementNumberOverall: anEntry.measurementNumberOverall,
|
|
||||||
location: OHIF.measurements.getLocation(groupObject[key]),
|
location: OHIF.measurements.getLocation(groupObject[key]),
|
||||||
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
||||||
entries: groupObject[key]
|
entries: groupObject[key]
|
||||||
|
|||||||
@ -17,7 +17,8 @@ OHIF.measurements.toggleLabelButton = options => {
|
|||||||
removeButtonView();
|
removeButtonView();
|
||||||
}
|
}
|
||||||
|
|
||||||
const toolCollection = options.measurementApi.tools[options.toolType];
|
const measurementApi = options.measurementApi;
|
||||||
|
const toolCollection = measurementApi.tools[options.toolType];
|
||||||
const measurement = toolCollection.findOne(options.measurementId);
|
const measurement = toolCollection.findOne(options.measurementId);
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
@ -29,17 +30,21 @@ OHIF.measurements.toggleLabelButton = options => {
|
|||||||
autoClick: options.autoClick,
|
autoClick: options.autoClick,
|
||||||
doneCallback: removeButtonView,
|
doneCallback: removeButtonView,
|
||||||
updateCallback(location, description) {
|
updateCallback(location, description) {
|
||||||
toolCollection.update({
|
const groupId = measurementApi.toolsGroupsMap[measurement.toolType];
|
||||||
measurementNumber: measurement.measurementNumber,
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||||
toolType: measurement.toolType,
|
const group = _.findWhere(config.measurementTools, { id: groupId });
|
||||||
patientId: measurement.patientId
|
group.childTools.forEach(tool => {
|
||||||
}, {
|
measurementApi.tools[tool.id].update({
|
||||||
$set: {
|
measurementNumber: measurement.measurementNumber,
|
||||||
location,
|
patientId: measurement.patientId
|
||||||
description
|
}, {
|
||||||
}
|
$set: {
|
||||||
}, {
|
location,
|
||||||
multi: true
|
description
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
multi: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user