Improving "Add/Edit Description" workflow

This commit is contained in:
Bruno Alves de Faria 2018-03-07 08:22:47 -03:00
parent d486ebd551
commit 3bd44fd7bc
12 changed files with 69 additions and 19 deletions

View File

@ -29,5 +29,6 @@ OHIF.ui.handleError = error => {
cancelClass: 'btn-secondary'
}, 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);
};

View File

@ -2,12 +2,12 @@ import { Template } from 'meteor/templating';
import { Blaze } from 'meteor/blaze';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { OHIF } from 'meteor/ohif:core';
import { cornerstone } from 'meteor/ohif:cornerstone';
Template.dialogNonTargetMeasurement.onCreated(() => {
const instance = Template.instance();
instance.measurementTypeId = 'nonTarget';
const timepointApi = instance.data.timepointApi;
const config = OHIF.measurements.MeasurementApi.getConfiguration();
instance.schema = new SimpleSchema({

View File

@ -83,8 +83,11 @@ class MeasurementApi {
measurement.measurementNumber = measurementNumber;
// Get the current location (if already defined)
let location;
// Get the current location/description (if already defined)
const updateObject = {
timepointId: timepoint.timepointId,
measurementNumber
};
const baselineTimepoint = timepointApi.baseline();
const baselineGroupEntry = groupCollection.findOne({
timepointId: baselineTimepoint.timepointId
@ -93,18 +96,15 @@ class MeasurementApi {
const tool = this.tools[baselineGroupEntry.toolId];
const found = tool.findOne({ measurementNumber });
if (found) {
location = found.location;
updateObject.location = found.location;
if (found.description) {
updateObject.description = found.description;
}
}
}
// Set the timepoint ID, measurement number and location
collection.update(measurement._id, {
$set: {
timepointId: timepoint.timepointId,
measurementNumber,
location
}
});
// Set the timepoint ID, measurement number, location and description
collection.update(measurement._id, { $set: updateObject });
if (!emptyItem) {
// Reflect the entry in the tool group collection
@ -122,7 +122,7 @@ class MeasurementApi {
this.changeObserver.changed();
};
const changedHandler = () => {
const changedHandler = measurement => {
this.changeObserver.changed();
};

View File

@ -76,6 +76,11 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
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
Collection._c2._simpleSchema.clean(measurement);

View File

@ -36,6 +36,11 @@ export default function ({ instance, eventData, tool }) {
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
Collection._c2._simpleSchema.clean(measurement);

View File

@ -14,7 +14,8 @@ function activateTool(measurementData) {
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
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) {
return;
}

View File

@ -2,8 +2,6 @@ import { OHIF } from 'meteor/ohif:core';
import { $ } from 'meteor/jquery';
import { cornerstone, cornerstoneMath, cornerstoneTools } from 'meteor/ohif:cornerstone';
window.resolve = [];
OHIF.measurements.getImageDataUrl = ({
imageType='image/jpeg',
quality=1,
@ -24,7 +22,6 @@ OHIF.measurements.getImageDataUrl = ({
}
return new Promise((resolve, reject) => {
window.resolve.push(resolve);
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
cornerstone[loadMethod](imageId).then(image => {
// Create a cornerstone enabled element to handle the image

View 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;
};

View File

@ -8,6 +8,7 @@ import './getActiveTimepoint';
import './getImageDataUrl';
import './getMeasurementsGroupedByNumber';
import './getLocationLabel';
import './getParentToolData';
import './getTimepointName';
import './getToolConfiguration';
import './hangingProtocolCustomizations';
@ -19,3 +20,4 @@ import './saveMeasurements';
import './syncMeasurementAndToolData';
import './toggleLabelButton';
import './triggerTimepointUnsavedChanges';
import './updateMeasurementsDescription';

View File

@ -60,7 +60,7 @@ OHIF.measurements.toggleLabelButton = options => {
options.measurement.description = description;
// Notify that viewer suffered changes
OHIF.measurements.triggerTimepointUnsavedChanges('renamed');
OHIF.measurements.triggerTimepointUnsavedChanges('relabel');
}
};
buttonView = Blaze.renderWithData(Template.measureFlow, data, document.body);

View File

@ -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');
};

View File

@ -88,6 +88,7 @@ OHIF.studies.retrieveStudyMetadata = (studyInstanceUid, seriesInstanceUids) => {
study.displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(studyMetadata);
study.displaySets.forEach(displaySet => {
OHIF.viewerbase.stackManager.makeAndAddStack(study, displaySet);
studyMetadata.addDisplaySet(displaySet);
});
// Resolve the promise with the final study metadata object