LT-55: Exposing grouping measurements method in OHIF namespace
This commit is contained in:
1 parent
fc3eb30f8b
commit
28ac391c52
6 files changed
+125
-129
No files matched your search
+8
-17
@@ -1,22 +1,13 @@
|
||||
<template name="measurementTableView">
|
||||
<div class="measurementTableView scrollArea">
|
||||
{{#let config=measurementConfiguration}}
|
||||
{{#each toolGroup in config.measurementTools}}
|
||||
{{#if shallDisplayGroup toolGroup.id}}
|
||||
{{#let collection=(groupByMeasurementNumber toolGroup.id)}}
|
||||
{{>measurementTableHeaderRow
|
||||
measurementType=toolGroup
|
||||
measurements=collection
|
||||
currentTimepointId=currentTimepointId
|
||||
timepointApi=timepointApi
|
||||
measurementApi=measurementApi
|
||||
conformanceCriteria=conformanceCriteria}}
|
||||
|
||||
{{#each entry in collection}}
|
||||
{{>measurementTableRow (clone this rowItem=entry)}}
|
||||
{{/each}}
|
||||
{{/let}}
|
||||
{{/if}}
|
||||
{{#let config=measurementConfiguration measurementGroups=getMeasurementsGroupedByNumber}}
|
||||
{{#each measurementGroup in measurementGroups}}
|
||||
{{>measurementTableHeaderRow (clone this
|
||||
toolGroup=measurementGroup.toolGroup
|
||||
measurementRows=measurementGroup.measurementRows)}}
|
||||
{{#each rowItem in measurementGroup.measurementRows}}
|
||||
{{>measurementTableRow (clone this rowItem=rowItem)}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
|
||||
{{#if config.newMeasurementTool}}
|
||||
|
||||
+10
-89
@@ -2,34 +2,6 @@ import { Template } from 'meteor/templating';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.measurements.getLocation = collection => {
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
if (collection[i].location) {
|
||||
return collection[i].location;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Template.measurementTableView.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const configuration = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||
|
||||
instance.displayToolGroupMap = {};
|
||||
instance.displayToolList = [];
|
||||
configuration.measurementTools.forEach(toolGroup => {
|
||||
instance.displayToolGroupMap[toolGroup.id] = false;
|
||||
toolGroup.childTools.forEach(tool => {
|
||||
const willDisplay = !!(tool.options && tool.options.measurementTable && tool.options.measurementTable.displayFunction);
|
||||
if (willDisplay) {
|
||||
instance.displayToolList.push(tool.id);
|
||||
instance.displayToolGroupMap[toolGroup.id] = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Template.measurementTableView.helpers({
|
||||
getNewMeasurementType(tool) {
|
||||
// TODO: Check Conformance criteria here.
|
||||
@@ -42,56 +14,9 @@ Template.measurementTableView.helpers({
|
||||
};
|
||||
},
|
||||
|
||||
shallDisplayGroup(toolGroupId) {
|
||||
const instance = Template.instance();
|
||||
return instance.displayToolGroupMap[toolGroupId];
|
||||
},
|
||||
|
||||
groupByMeasurementNumber(measurementTypeId) {
|
||||
const instance = Template.instance();
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
const baseline = timepointApi.baseline();
|
||||
if (!measurementApi || !timepointApi || !baseline) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve all the data for this Measurement type (e.g. 'targets')
|
||||
// which was recorded at 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, {
|
||||
toolId: {
|
||||
$in: instance.displayToolList
|
||||
},
|
||||
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 => {
|
||||
const anEntry = groupObject[key][0];
|
||||
|
||||
return {
|
||||
measurementTypeId: measurementTypeId,
|
||||
measurementNumber: key,
|
||||
location: OHIF.measurements.getLocation(groupObject[key]),
|
||||
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
||||
entries: groupObject[key]
|
||||
};
|
||||
});
|
||||
getMeasurementsGroupedByNumber() {
|
||||
const { measurementApi, timepointApi } = Template.instance().data;
|
||||
return OHIF.measurements.getMeasurementsGroupedByNumber(measurementApi, timepointApi);
|
||||
},
|
||||
|
||||
newMeasurements(measurementType) {
|
||||
@@ -135,16 +60,12 @@ Template.measurementTableView.helpers({
|
||||
const groupObject = _.groupBy(data, entry => entry.measurementNumber);
|
||||
|
||||
// Reformat the data for display in the table
|
||||
return Object.keys(groupObject).map(key => {
|
||||
const anEntry = groupObject[key][0];
|
||||
|
||||
return {
|
||||
measurementTypeId: measurementTypeId,
|
||||
measurementNumber: key,
|
||||
location: OHIF.measurements.getLocation(groupObject[key]),
|
||||
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: OHIF.measurements.getLocation(groupObject[key]),
|
||||
responseStatus: false, // TODO: Get the latest timepoint and determine the response status
|
||||
entries: groupObject[key]
|
||||
}));
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user