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