LT-254: Display maximum number of target measurements in Lesion Table based on Trial Criteria

This commit is contained in:
Erik Ziegler committed 2016-07-22 11:08:27 +02:00
1 parent a58e237418
commit 7cb8ed6c9f
7 files changed
+84 -39

No files matched your search

@@ -1,38 +1,75 @@
const toolTypesById = {
target: 'bidirectional',
nonTarget: 'nonTarget',
newLesion: 'bidirectional'
};
const namesById = {
target: 'Targets',
nonTarget: 'Non-Targets',
newLesion: 'New Lesions'
};
Template.lesionTableHeaderRow.onCreated(() => {
const instance = Template.instance();
instance.maxNumLesions = new ReactiveVar();
if (!instance.data.currentTimepointId) {
console.warn('Case has no timepointId');
return;
}
// Give the header a proper name
instance.data.type = namesById[instance.data.id];
const currentTimepointId = instance.data.currentTimepointId;
const timepoint = Timepoints.findOne({
timepointId: currentTimepointId
});
const timepointType = timepoint.timepointType;
// TODO: Check if we have criteria where maximum limits are applied to
// Non-Targets and/or New Lesions
if (timepointType === 'baseline' && instance.data.id === 'target') {
instance.autorun(() => {
// Identify which Trial Conformance Criteria are currently being used
// Note that there may be more than one.
const criteriaTypes = TrialCriteriaTypes.find({
selected: true
}).map(function(criteria) {
return criteria.id;
});
const currentConstraints = getTrialCriteriaConstraints(criteriaTypes);
if (!currentConstraints) {
return;
}
// TODO: Fix Trial Conformance Criteria, it appears that totalNumberOfLesions
// is applied to both Targets and Non-Targets, when it should typically only be
// for Targets
const criteria = currentConstraints[timepointType];
const maxNumLesions = criteria.group.totalNumberOfLesions.numericality.lessThanOrEqualTo;
instance.maxNumLesions.set(maxNumLesions);
});
}
});
Template.lesionTableHeaderRow.helpers({
numberOfLesions: function() {
var instance = Template.instance();
const instance = Template.instance();
return instance.data.measurements.count();
},
maxNumLesions: function() {
var instance = Template.instance();
var lesionType = instance.id;
// TODO: Check what we are annotating
var timepointType = 'baseline';
// Identify which Trial Conformance Criteria are currently being used
// Note that there may be more than one.
var criteriaTypes = TrialCriteriaTypes.find({
selected: true
}).map(function(criteria) {
return criteria.id;
});
var currentConstraints = getTrialCriteriaConstraints(criteriaTypes);
if (!currentConstraints) {
// For testing
return 10;
}
var criteria = currentConstraints[timepointType][lesionType];
return criteria.group.totalNumberOfLesions;
return Template.instance().maxNumLesions.get();
}
});
Template.lesionTableHeaderRow.events({
'click .add': function() {
console.log('Add was clicked');
// TODO: Set active tool to new type
'click .js-setTool': function(event, instance) {
const id = instance.data.id;
const toolType = toolTypesById[id];
toolManager.setActiveTool(toolType);
}
});
});