LT-305: Lesions that are New after baseline are displayed properly in the measurement table
This commit is contained in:
parent
987be26047
commit
7d9efc2b71
@ -1,3 +1,6 @@
|
|||||||
|
import { Template } from 'meteor/templating';
|
||||||
|
import { ReactiveVar } from 'meteor/reactive-var';
|
||||||
|
|
||||||
Template.measurementTable.onCreated(() => {
|
Template.measurementTable.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
|
|
||||||
@ -45,10 +48,8 @@ Template.measurementTable.onRendered(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Template.measurementTable.onRendered(() => {
|
Template.measurementTable.onRendered(() => {
|
||||||
const instance = Template.instance();
|
|
||||||
|
|
||||||
// Find the first measurement by Lesion Number
|
// Find the first measurement by Lesion Number
|
||||||
let firstLesion = undefined; // = instance.data.measurementApi.firstLesion();
|
let firstLesion; // = instance.data.measurementApi.firstLesion();
|
||||||
|
|
||||||
// Create an object to store the ContentId inside
|
// Create an object to store the ContentId inside
|
||||||
const templateData = {
|
const templateData = {
|
||||||
|
|||||||
@ -19,11 +19,12 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
{{#if config.newMeasurementTool}}
|
{{#if config.newMeasurementTool}}
|
||||||
{{#let new=newMeasurements}}
|
{{#let measurementType=(getNewMeasurementType config.newMeasurementTool)}}
|
||||||
{{#if new}}
|
{{#let newMeasure=(newMeasurements measurementType)}}
|
||||||
{{#let collection=new tool=config.newMeasurementTool}}
|
{{#if newMeasure}}
|
||||||
|
{{#let collection=newMeasure}}
|
||||||
{{>measurementTableHeaderRow
|
{{>measurementTableHeaderRow
|
||||||
measurementType=tool.measurementType
|
measurementType=measurementType
|
||||||
measurements=collection
|
measurements=collection
|
||||||
currentTimepointId=currentTimepointId
|
currentTimepointId=currentTimepointId
|
||||||
timepointApi=timepointApi
|
timepointApi=timepointApi
|
||||||
@ -35,6 +36,7 @@
|
|||||||
{{/let}}
|
{{/let}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/let}}
|
{{/let}}
|
||||||
|
{{/let}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/let}}
|
{{/let}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,23 +1,54 @@
|
|||||||
import { Template } from 'meteor/templating';
|
import { Template } from 'meteor/templating';
|
||||||
import { ReactiveVar } from 'meteor/reactive-var';
|
import { _ } from 'meteor/underscore';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
|
||||||
|
|
||||||
Template.measurementTableView.helpers({
|
const getLocation = collection => {
|
||||||
groupByMeasurementNumber(measurementTypeId) {
|
|
||||||
const api = Template.instance().data.measurementApi;
|
|
||||||
const Collection = api[measurementTypeId];
|
|
||||||
const data = Collection.find().fetch();
|
|
||||||
|
|
||||||
const groupObject = _.groupBy(data, entry => entry.measurementNumber);
|
|
||||||
|
|
||||||
const getLocation = collection => {
|
|
||||||
for (let i = 0; i < collection.length; i++) {
|
for (let i = 0; i < collection.length; i++) {
|
||||||
if (collection[i].location) {
|
if (collection[i].location) {
|
||||||
return collection[i].location;
|
return collection[i].location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Template.measurementTableView.helpers({
|
||||||
|
getNewMeasurementType(tool) {
|
||||||
|
// TODO: Check Conformance criteria here.
|
||||||
|
// RECIST should be targets, irRC should be nonTargets
|
||||||
|
return {
|
||||||
|
id: tool.id,
|
||||||
|
name: tool.name,
|
||||||
|
cornerstoneToolType: 'bidirectional',
|
||||||
|
measurementTypeId: 'targets'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
groupByMeasurementNumber(measurementTypeId) {
|
||||||
|
const instance = Template.instance();
|
||||||
|
const measurementApi = instance.data.measurementApi;
|
||||||
|
const timepointApi = instance.data.timepointApi;
|
||||||
|
|
||||||
|
// Retrieve all the data for this Measurement type (e.g. 'targets')
|
||||||
|
// which was recorded at baseline.
|
||||||
|
const baseline = timepointApi.baseline();
|
||||||
|
const atBaseline = measurementApi.fetch(measurementTypeId, {
|
||||||
|
timepointId: baseline.timepointId
|
||||||
|
});
|
||||||
|
|
||||||
|
// Obtain a list of the Measurement Numbers from the
|
||||||
|
// measurements which have baseline data
|
||||||
|
const numbers = atBaseline.map(m => m.measurementNumber);
|
||||||
|
|
||||||
|
// Retrieve all the data for this Measurement type which
|
||||||
|
// match the Measurement Numbers obtained above
|
||||||
|
const data = measurementApi.fetch(measurementTypeId, {
|
||||||
|
measurementNumber: {
|
||||||
|
$in: numbers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Group the Measurements by Measurement Number
|
||||||
|
const groupObject = _.groupBy(data, entry => entry.measurementNumber);
|
||||||
|
|
||||||
|
// Reformat the data for display in the table
|
||||||
return Object.keys(groupObject).map(key => ({
|
return Object.keys(groupObject).map(key => ({
|
||||||
measurementTypeId: measurementTypeId,
|
measurementTypeId: measurementTypeId,
|
||||||
measurementNumber: key,
|
measurementNumber: key,
|
||||||
@ -27,17 +58,16 @@ Template.measurementTableView.helpers({
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
newMeasurements() {
|
newMeasurements(measurementType) {
|
||||||
// Find all measurements from this timepoint which do not have a corresponding measurement
|
|
||||||
// at the prior timepoint.
|
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
if (!instance.data.timepointApi) {
|
const measurementApi = instance.data.measurementApi;
|
||||||
|
const timepointApi = instance.data.timepointApi;
|
||||||
|
const measurementTypeId = measurementType.measurementTypeId;
|
||||||
|
|
||||||
|
if (!timepointApi) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
|
||||||
const measurementTools = config.measurementTools;
|
|
||||||
|
|
||||||
// If this is a baseline, stop here since there are no new measurements to display
|
// If this is a baseline, stop here since there are no new measurements to display
|
||||||
const current = instance.data.timepointApi.current();
|
const current = instance.data.timepointApi.current();
|
||||||
if (!current || current.timepointType === 'baseline') {
|
if (!current || current.timepointType === 'baseline') {
|
||||||
@ -45,57 +75,35 @@ Template.measurementTableView.helpers({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = [];
|
// Retrieve all the data for this Measurement type (e.g. 'targets')
|
||||||
measurementTools.forEach(tool => {
|
// which was recorded at baseline.
|
||||||
// Handle only tools which are meant to be displayed in the measurement table
|
const baseline = timepointApi.baseline();
|
||||||
if (!tool || !tool.options || !tool.options.showInMeasurementTable) {
|
const atBaseline = measurementApi.fetch(measurementTypeId, {
|
||||||
return;
|
timepointId: baseline.timepointId
|
||||||
}
|
});
|
||||||
|
|
||||||
// Find only those measurements made at this timepoint
|
// Obtain a list of the Measurement Numbers from the
|
||||||
const selector = {
|
// measurements which have baseline data
|
||||||
timepointId: current.timepointId
|
const numbers = atBaseline.map(m => m.measurementNumber);
|
||||||
};
|
|
||||||
|
|
||||||
// Sort ascending by measurement number
|
// Retrieve all the data for this Measurement type which
|
||||||
const options = {
|
// do NOT match the Measurement Numbers obtained above
|
||||||
sort: {
|
const data = measurementApi.fetch(measurementTypeId, {
|
||||||
measurementNumber: 1
|
measurementNumber: {
|
||||||
}
|
$nin: numbers
|
||||||
};
|
|
||||||
|
|
||||||
// Retrieve measurements made at this timepoint
|
|
||||||
const api = Template.instance().data.measurementApi;
|
|
||||||
const measurementTypeId = tool.id;
|
|
||||||
const Collection = api[measurementTypeId];
|
|
||||||
const measurements = Collection.find(selector, options);
|
|
||||||
|
|
||||||
// For each measurement, check if a previous measurement exists with an identical measurement number
|
|
||||||
let newMeasurements = [];
|
|
||||||
measurements.forEach(measurement => {
|
|
||||||
// If no previous measurements exist, add it to the array of new measurements
|
|
||||||
const selector = {
|
|
||||||
measurementNumber: measurement.measurementNumber,
|
|
||||||
timepointId: {
|
|
||||||
$ne: current.timepointId
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const previousMeasurements = Collection.find(selector).fetch();
|
|
||||||
if (previousMeasurements.length === 0) {
|
|
||||||
newMeasurements.push(measurement);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Concatenate new measurements of all measurement types
|
// Group the Measurements by Measurement Number
|
||||||
data = data.concat(newMeasurements);
|
const groupObject = _.groupBy(data, entry => entry.measurementNumber);
|
||||||
});
|
|
||||||
|
|
||||||
const groupObject = _.groupBy(data, entry => { return entry.measurementNumber });
|
|
||||||
|
|
||||||
|
// Reformat the data for display in the table
|
||||||
return Object.keys(groupObject).map(key => {
|
return Object.keys(groupObject).map(key => {
|
||||||
return {
|
return {
|
||||||
|
measurementTypeId: measurementTypeId,
|
||||||
measurementNumber: key,
|
measurementNumber: key,
|
||||||
|
location: getLocation(groupObject[key]),
|
||||||
|
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
||||||
entries: groupObject[key]
|
entries: groupObject[key]
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user