diff --git a/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.html b/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.html index 58e44efee..2fb1a6f9e 100644 --- a/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.html +++ b/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.html @@ -13,7 +13,7 @@ {{/unless}} {{#if rowItem.responseStatus}}
- {{ rowItem.responseStatus }} + {{rowItem.responseStatus}}
{{/if}} diff --git a/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.js b/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.js index dd1747d57..234135c39 100644 --- a/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.js +++ b/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.js @@ -1,31 +1,30 @@ import { Template } from 'meteor/templating'; +import { ReactiveVar } from 'meteor/reactive-var'; import { OHIF } from 'meteor/ohif:core'; Template.measurementTableView.helpers({ - isFollowup() { - const instance = Template.instance(); - const current = instance.data.timepointApi.current(); - return (current && current.timepointType === 'followup'); - }, - groupByMeasurementNumber(measurementTypeId) { - const api = Template.instance().data.measurementApi; - const Collection = api[measurementTypeId]; - const data = Collection.find().fetch(); + const api = Template.instance().data.measurementApi; + const Collection = api[measurementTypeId]; + const data = Collection.find().fetch(); const groupObject = _.groupBy(data, entry => entry.measurementNumber); - return Object.keys(groupObject).map(key => { - const anEntry = groupObject[key][0]; + const getLocation = collection => { + for (let i = 0; i < collection.length; i++) { + if (collection[i].location) { + return collection[i].location; + } + } + }; - return { - measurementTypeId: measurementTypeId, - measurementNumber: key, - location: anEntry.location, - responseStatus: false, // TODO: Get the latest timepoint and determine the response status - entries: groupObject[key] - }; - }); + return Object.keys(groupObject).map(key => ({ + measurementTypeId: measurementTypeId, + measurementNumber: key, + location: getLocation(groupObject[key]), + responseStatus: false, // TODO: Get the latest timepoint and determine the response status + entries: groupObject[key] + })); }, newMeasurements() { diff --git a/Packages/ohif-measurements/client/lib/MeasurementHandlers.js b/Packages/ohif-measurements/client/lib/MeasurementHandlers.js index b88aca1d8..8be20828c 100644 --- a/Packages/ohif-measurements/client/lib/MeasurementHandlers.js +++ b/Packages/ohif-measurements/client/lib/MeasurementHandlers.js @@ -68,6 +68,18 @@ class MeasurementHandlers { measurement.measurementNumber = numCurrentMeasurementsInStudy + 1; } + // Get the related timepoint by the measurement number and use its location if defined + const relatedTimepoint = Collection.findOne({ + measurementNumber: measurement.measurementNumber, + toolType: measurementData.toolType, + patientId, + }); + + // Use the related timepoint location if found and defined + if (relatedTimepoint && relatedTimepoint.location) { + measurement.location = relatedTimepoint.location; + } + // Clean the measurement according to the Schema measurementToolConfiguration.schema.clean(measurement); diff --git a/Packages/ohif-measurements/client/lib/toggleLabelButton.js b/Packages/ohif-measurements/client/lib/toggleLabelButton.js index 032f5ca35..b1b2a3326 100644 --- a/Packages/ohif-measurements/client/lib/toggleLabelButton.js +++ b/Packages/ohif-measurements/client/lib/toggleLabelButton.js @@ -27,17 +27,19 @@ OHIF.measurements.toggleLabelButton = options => { const data = { measurement, - tool, position: options.position, threeColumns: true, hideCommon: true, - toolType: options.toolData.toolType, doneCallback(location, description) { if (_.isFunction(options.callback)) { options.callback(options, location, description); } - toolCollection.update(measurement._id, { + toolCollection.update({ + measurementNumber: measurement.measurementNumber, + toolType: measurement.toolType, + patientId: measurement.patientId + }, { $set: { location, description