LT-298: Updating location on all timepoints when updated on any of them

This commit is contained in:
Bruno Alves de Faria 2016-11-10 07:14:52 -02:00 committed by Erik Ziegler
parent 820ba1e969
commit 2cc7fcc846
4 changed files with 36 additions and 23 deletions

View File

@ -13,7 +13,7 @@
{{/unless}} {{/unless}}
{{#if rowItem.responseStatus}} {{#if rowItem.responseStatus}}
<div class="response-status-icon"> <div class="response-status-icon">
{{ rowItem.responseStatus }} {{rowItem.responseStatus}}
</div> </div>
{{/if}} {{/if}}
</div> </div>

View File

@ -1,31 +1,30 @@
import { Template } from 'meteor/templating'; import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
Template.measurementTableView.helpers({ Template.measurementTableView.helpers({
isFollowup() {
const instance = Template.instance();
const current = instance.data.timepointApi.current();
return (current && current.timepointType === 'followup');
},
groupByMeasurementNumber(measurementTypeId) { groupByMeasurementNumber(measurementTypeId) {
const api = Template.instance().data.measurementApi; const api = Template.instance().data.measurementApi;
const Collection = api[measurementTypeId]; const Collection = api[measurementTypeId];
const data = Collection.find().fetch(); const data = Collection.find().fetch();
const groupObject = _.groupBy(data, entry => entry.measurementNumber); const groupObject = _.groupBy(data, entry => entry.measurementNumber);
return Object.keys(groupObject).map(key => { const getLocation = collection => {
const anEntry = groupObject[key][0]; for (let i = 0; i < collection.length; i++) {
if (collection[i].location) {
return collection[i].location;
}
}
};
return { return Object.keys(groupObject).map(key => ({
measurementTypeId: measurementTypeId, measurementTypeId: measurementTypeId,
measurementNumber: key, measurementNumber: key,
location: anEntry.location, location: getLocation(groupObject[key]),
responseStatus: false, // TODO: Get the latest timepoint and determine the response status responseStatus: false, // TODO: Get the latest timepoint and determine the response status
entries: groupObject[key] entries: groupObject[key]
}; }));
});
}, },
newMeasurements() { newMeasurements() {

View File

@ -68,6 +68,18 @@ class MeasurementHandlers {
measurement.measurementNumber = numCurrentMeasurementsInStudy + 1; 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 // Clean the measurement according to the Schema
measurementToolConfiguration.schema.clean(measurement); measurementToolConfiguration.schema.clean(measurement);

View File

@ -27,17 +27,19 @@ OHIF.measurements.toggleLabelButton = options => {
const data = { const data = {
measurement, measurement,
tool,
position: options.position, position: options.position,
threeColumns: true, threeColumns: true,
hideCommon: true, hideCommon: true,
toolType: options.toolData.toolType,
doneCallback(location, description) { doneCallback(location, description) {
if (_.isFunction(options.callback)) { if (_.isFunction(options.callback)) {
options.callback(options, location, description); options.callback(options, location, description);
} }
toolCollection.update(measurement._id, { toolCollection.update({
measurementNumber: measurement.measurementNumber,
toolType: measurement.toolType,
patientId: measurement.patientId
}, {
$set: { $set: {
location, location,
description description