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}}
{{#if rowItem.responseStatus}}
<div class="response-status-icon">
{{ rowItem.responseStatus }}
{{rowItem.responseStatus}}
</div>
{{/if}}
</div>

View File

@ -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() {

View File

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

View File

@ -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