LT-115: Linking the tool data with tool group data
This commit is contained in:
parent
f13080309e
commit
d6aeebe712
@ -6,9 +6,12 @@ const NonTargetSchema = new SimpleSchema({
|
||||
type: String,
|
||||
label: 'Tool ID'
|
||||
},
|
||||
toolItemUid: {
|
||||
toolItemId: {
|
||||
type: String,
|
||||
label: 'Tool Item UID'
|
||||
label: 'Tool Item ID'
|
||||
},
|
||||
createdAt: {
|
||||
type: Date
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -8,9 +8,12 @@ const TargetSchema = new SimpleSchema({
|
||||
type: String,
|
||||
label: 'Tool ID'
|
||||
},
|
||||
toolItemUid: {
|
||||
toolItemId: {
|
||||
type: String,
|
||||
label: 'Tool Item UID'
|
||||
label: 'Tool Item ID'
|
||||
},
|
||||
createdAt: {
|
||||
type: Date
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -7,9 +7,12 @@ const TempSchema = new SimpleSchema({
|
||||
type: String,
|
||||
label: 'Tool ID'
|
||||
},
|
||||
toolItemUid: {
|
||||
toolItemId: {
|
||||
type: String,
|
||||
label: 'Tool Item UID'
|
||||
label: 'Tool Item ID'
|
||||
},
|
||||
createdAt: {
|
||||
type: Date
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -23,16 +23,53 @@ class MeasurementApi {
|
||||
this.tools = {};
|
||||
|
||||
configuration.measurementTools.forEach(toolGroup => {
|
||||
const collection = new Mongo.Collection(null);
|
||||
collection._debugName = toolGroup.name;
|
||||
collection.attachSchema(toolGroup.schema);
|
||||
this.toolGroups[toolGroup.id] = collection;
|
||||
const groupCollection = new Mongo.Collection(null);
|
||||
groupCollection._debugName = toolGroup.name;
|
||||
groupCollection.attachSchema(toolGroup.schema);
|
||||
this.toolGroups[toolGroup.id] = groupCollection;
|
||||
|
||||
toolGroup.childTools.forEach(tool => {
|
||||
const collection = new Mongo.Collection(null);
|
||||
collection._debugName = tool.name;
|
||||
collection.attachSchema(tool.schema);
|
||||
this.tools[tool.id] = collection;
|
||||
|
||||
collection.find().observe({
|
||||
added(measurement) {
|
||||
groupCollection.insert({
|
||||
toolId: tool.id,
|
||||
toolItemUid: measurement._id,
|
||||
createdAt: measurement.createdAt
|
||||
});
|
||||
|
||||
const measurementCount = groupCollection.find().count();
|
||||
collection.update(measurement._id, {
|
||||
$set: {
|
||||
measurementNumber: measurementCount
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
removedAt(measurement, atIndex) {
|
||||
groupCollection.remove({
|
||||
toolItemUid: measurement._id
|
||||
});
|
||||
|
||||
toolGroup.childTools.forEach(childTool => {
|
||||
this.tools[childTool.id].update({
|
||||
measurementNumber: {
|
||||
$gt: atIndex
|
||||
}
|
||||
}, {
|
||||
$inc: {
|
||||
measurementNumber: -1
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,9 +75,7 @@ class MeasurementHandlers {
|
||||
Collection._c2._simpleSchema.clean(measurement);
|
||||
|
||||
// Insert the new measurement into the collection
|
||||
console.warn('>>>>INSERTING', measurement);
|
||||
measurementData._id = Collection.insert(measurement);
|
||||
console.warn('>>>>INSERTED', measurementData);
|
||||
|
||||
// Signal unsaved changes
|
||||
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.' + eventData.toolType);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user