Improving "Add/Edit Description" workflow
This commit is contained in:
parent
d486ebd551
commit
3bd44fd7bc
@ -29,5 +29,6 @@ OHIF.ui.handleError = error => {
|
|||||||
cancelClass: 'btn-secondary'
|
cancelClass: 'btn-secondary'
|
||||||
}, error || {});
|
}, error || {});
|
||||||
|
|
||||||
OHIF.ui.showDialog('dialogForm', data);
|
// TODO: Find a better way to handle errors instead of displaying a dialog for all of them.
|
||||||
|
// OHIF.ui.showDialog('dialogForm', data);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,12 +2,12 @@ import { Template } from 'meteor/templating';
|
|||||||
import { Blaze } from 'meteor/blaze';
|
import { Blaze } from 'meteor/blaze';
|
||||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
import { cornerstone } from 'meteor/ohif:cornerstone';
|
||||||
|
|
||||||
Template.dialogNonTargetMeasurement.onCreated(() => {
|
Template.dialogNonTargetMeasurement.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
|
|
||||||
instance.measurementTypeId = 'nonTarget';
|
instance.measurementTypeId = 'nonTarget';
|
||||||
const timepointApi = instance.data.timepointApi;
|
|
||||||
|
|
||||||
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||||
instance.schema = new SimpleSchema({
|
instance.schema = new SimpleSchema({
|
||||||
|
|||||||
@ -83,8 +83,11 @@ class MeasurementApi {
|
|||||||
|
|
||||||
measurement.measurementNumber = measurementNumber;
|
measurement.measurementNumber = measurementNumber;
|
||||||
|
|
||||||
// Get the current location (if already defined)
|
// Get the current location/description (if already defined)
|
||||||
let location;
|
const updateObject = {
|
||||||
|
timepointId: timepoint.timepointId,
|
||||||
|
measurementNumber
|
||||||
|
};
|
||||||
const baselineTimepoint = timepointApi.baseline();
|
const baselineTimepoint = timepointApi.baseline();
|
||||||
const baselineGroupEntry = groupCollection.findOne({
|
const baselineGroupEntry = groupCollection.findOne({
|
||||||
timepointId: baselineTimepoint.timepointId
|
timepointId: baselineTimepoint.timepointId
|
||||||
@ -93,18 +96,15 @@ class MeasurementApi {
|
|||||||
const tool = this.tools[baselineGroupEntry.toolId];
|
const tool = this.tools[baselineGroupEntry.toolId];
|
||||||
const found = tool.findOne({ measurementNumber });
|
const found = tool.findOne({ measurementNumber });
|
||||||
if (found) {
|
if (found) {
|
||||||
location = found.location;
|
updateObject.location = found.location;
|
||||||
|
if (found.description) {
|
||||||
|
updateObject.description = found.description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the timepoint ID, measurement number and location
|
// Set the timepoint ID, measurement number, location and description
|
||||||
collection.update(measurement._id, {
|
collection.update(measurement._id, { $set: updateObject });
|
||||||
$set: {
|
|
||||||
timepointId: timepoint.timepointId,
|
|
||||||
measurementNumber,
|
|
||||||
location
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!emptyItem) {
|
if (!emptyItem) {
|
||||||
// Reflect the entry in the tool group collection
|
// Reflect the entry in the tool group collection
|
||||||
@ -122,7 +122,7 @@ class MeasurementApi {
|
|||||||
this.changeObserver.changed();
|
this.changeObserver.changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
const changedHandler = () => {
|
const changedHandler = measurement => {
|
||||||
this.changeObserver.changed();
|
this.changeObserver.changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -76,6 +76,11 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
|
|||||||
measurement.location = relatedTimepoint.location;
|
measurement.location = relatedTimepoint.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the related timepoint description if found and defined
|
||||||
|
if (relatedTimepoint && relatedTimepoint.description) {
|
||||||
|
measurement.description = relatedTimepoint.description;
|
||||||
|
}
|
||||||
|
|
||||||
// Clean the measurement according to the Schema
|
// Clean the measurement according to the Schema
|
||||||
Collection._c2._simpleSchema.clean(measurement);
|
Collection._c2._simpleSchema.clean(measurement);
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,11 @@ export default function ({ instance, eventData, tool }) {
|
|||||||
measurement.location = relatedTimepoint.location;
|
measurement.location = relatedTimepoint.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the related timepoint description if found and defined
|
||||||
|
if (relatedTimepoint && relatedTimepoint.description) {
|
||||||
|
measurement.description = relatedTimepoint.description;
|
||||||
|
}
|
||||||
|
|
||||||
// Clean the measurement according to the Schema
|
// Clean the measurement according to the Schema
|
||||||
Collection._c2._simpleSchema.clean(measurement);
|
Collection._c2._simpleSchema.clean(measurement);
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,8 @@ function activateTool(measurementData) {
|
|||||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
|
||||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||||
|
|
||||||
const toolData = toolState[imageId][toolType];
|
const imageToolState = toolState[imageId];
|
||||||
|
const toolData = imageToolState && imageToolState[toolType];
|
||||||
if (!toolData || !toolData.data || !toolData.data.length) {
|
if (!toolData || !toolData.data || !toolData.data.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,6 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
import { $ } from 'meteor/jquery';
|
import { $ } from 'meteor/jquery';
|
||||||
import { cornerstone, cornerstoneMath, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
import { cornerstone, cornerstoneMath, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
||||||
|
|
||||||
window.resolve = [];
|
|
||||||
|
|
||||||
OHIF.measurements.getImageDataUrl = ({
|
OHIF.measurements.getImageDataUrl = ({
|
||||||
imageType='image/jpeg',
|
imageType='image/jpeg',
|
||||||
quality=1,
|
quality=1,
|
||||||
@ -24,7 +22,6 @@ OHIF.measurements.getImageDataUrl = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
window.resolve.push(resolve);
|
|
||||||
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
|
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
|
||||||
cornerstone[loadMethod](imageId).then(image => {
|
cornerstone[loadMethod](imageId).then(image => {
|
||||||
// Create a cornerstone enabled element to handle the image
|
// Create a cornerstone enabled element to handle the image
|
||||||
|
|||||||
15
Packages/ohif-measurements/client/lib/getParentToolData.js
Normal file
15
Packages/ohif-measurements/client/lib/getParentToolData.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the parent tool data if it's a child tool or the tool data itself if not
|
||||||
|
*
|
||||||
|
* @param measurementData measurement data that must contain the toolType and measurement's _id
|
||||||
|
* @returns {Object} Parent measurement data
|
||||||
|
*/
|
||||||
|
OHIF.measurements.getParentToolData = measurementData => {
|
||||||
|
const { toolType, _id } = measurementData;
|
||||||
|
const { tool } = OHIF.measurements.getToolConfiguration(toolType);
|
||||||
|
const parentToolType = tool.parentTool || toolType;
|
||||||
|
const parentToolData = OHIF.viewer.measurementApi.tools[parentToolType].findOne(_id);
|
||||||
|
return parentToolData;
|
||||||
|
};
|
||||||
@ -8,6 +8,7 @@ import './getActiveTimepoint';
|
|||||||
import './getImageDataUrl';
|
import './getImageDataUrl';
|
||||||
import './getMeasurementsGroupedByNumber';
|
import './getMeasurementsGroupedByNumber';
|
||||||
import './getLocationLabel';
|
import './getLocationLabel';
|
||||||
|
import './getParentToolData';
|
||||||
import './getTimepointName';
|
import './getTimepointName';
|
||||||
import './getToolConfiguration';
|
import './getToolConfiguration';
|
||||||
import './hangingProtocolCustomizations';
|
import './hangingProtocolCustomizations';
|
||||||
@ -19,3 +20,4 @@ import './saveMeasurements';
|
|||||||
import './syncMeasurementAndToolData';
|
import './syncMeasurementAndToolData';
|
||||||
import './toggleLabelButton';
|
import './toggleLabelButton';
|
||||||
import './triggerTimepointUnsavedChanges';
|
import './triggerTimepointUnsavedChanges';
|
||||||
|
import './updateMeasurementsDescription';
|
||||||
|
|||||||
@ -60,7 +60,7 @@ OHIF.measurements.toggleLabelButton = options => {
|
|||||||
options.measurement.description = description;
|
options.measurement.description = description;
|
||||||
|
|
||||||
// Notify that viewer suffered changes
|
// Notify that viewer suffered changes
|
||||||
OHIF.measurements.triggerTimepointUnsavedChanges('renamed');
|
OHIF.measurements.triggerTimepointUnsavedChanges('relabel');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
buttonView = Blaze.renderWithData(Template.measureFlow, data, document.body);
|
buttonView = Blaze.renderWithData(Template.measureFlow, data, document.body);
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the measurements' description for a measurement number across all timepoints
|
||||||
|
*
|
||||||
|
* @param measurementData base measurement data that must contain toolType and measurementNumber
|
||||||
|
* @param description measurement description that will be used
|
||||||
|
*/
|
||||||
|
OHIF.measurements.updateMeasurementsDescription = (measurementData, description) => {
|
||||||
|
const { toolType, measurementNumber } = measurementData;
|
||||||
|
measurementData.description = description;
|
||||||
|
const filter = { measurementNumber };
|
||||||
|
const operator = { $set: { description } };
|
||||||
|
const options = { multi: true };
|
||||||
|
const { toolGroup } = OHIF.measurements.getToolConfiguration(toolType);
|
||||||
|
toolGroup.childTools.forEach(childTool => {
|
||||||
|
const collection = OHIF.viewer.measurementApi.tools[childTool.id];
|
||||||
|
collection.update(filter, operator, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Notify that viewer suffered changes
|
||||||
|
OHIF.measurements.triggerTimepointUnsavedChanges('relabel');
|
||||||
|
};
|
||||||
@ -88,6 +88,7 @@ OHIF.studies.retrieveStudyMetadata = (studyInstanceUid, seriesInstanceUids) => {
|
|||||||
study.displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(studyMetadata);
|
study.displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(studyMetadata);
|
||||||
study.displaySets.forEach(displaySet => {
|
study.displaySets.forEach(displaySet => {
|
||||||
OHIF.viewerbase.stackManager.makeAndAddStack(study, displaySet);
|
OHIF.viewerbase.stackManager.makeAndAddStack(study, displaySet);
|
||||||
|
studyMetadata.addDisplaySet(displaySet);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Resolve the promise with the final study metadata object
|
// Resolve the promise with the final study metadata object
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user