LT-363: Fixes for removing association and retrieving only applicable timepoints / measurements for the open case
This commit is contained in:
1 parent
2895ce84b1
commit
c9e607a21c
5 files changed
+88
-35
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { measurementTools } from './measurementTools';
|
||||
|
||||
export const retrieveMeasurements = (filter) => {
|
||||
export const retrieveMeasurements = (patientId, timepointIds) => {
|
||||
console.log('retrieveMeasurements');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call('retrieveMeasurements', filter, (error, response) => {
|
||||
Meteor.call('retrieveMeasurements', patientId, timepointIds, (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
@@ -36,11 +36,11 @@ export const storeMeasurements = (measurementData, timepointIds) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const retrieveTimepoints = (filter) => {
|
||||
export const retrieveTimepoints = (patientId) => {
|
||||
console.log('retrieveTimepoints');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call('retrieveTimepoints', filter, (error, response) => {
|
||||
Meteor.call('retrieveTimepoints', patientId, (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
@@ -81,12 +81,12 @@ export const updateTimepoint = (timepointData, query) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const removeTimepoint = timepointData => {
|
||||
export const removeTimepoint = timepointId => {
|
||||
console.log('removeTimepoint');
|
||||
console.log(timepointData);
|
||||
console.log(timepointId);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call('removeTimepoint', timepointData, (error, response) => {
|
||||
Meteor.call('removeTimepoint', timepointId, (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
|
||||
@@ -79,10 +79,9 @@ Meteor.methods({
|
||||
});
|
||||
},
|
||||
|
||||
removeTimepoint(timepointData) {
|
||||
removeTimepoint(timepointId) {
|
||||
OHIF.log.info('Removing Timepoint from the Server');
|
||||
OHIF.log.info(JSON.stringify(timepointData, null, 2));
|
||||
Timepoints.remove(timepointData);
|
||||
Timepoints.remove({timepointId});
|
||||
},
|
||||
|
||||
updateTimepoint(timepointData, query) {
|
||||
@@ -92,9 +91,15 @@ Meteor.methods({
|
||||
Timepoints.update(timepointData, query);
|
||||
},
|
||||
|
||||
retrieveTimepoints(filter) {
|
||||
retrieveTimepoints(patientId) {
|
||||
OHIF.log.info('Retrieving Timepoints from the Server');
|
||||
return Timepoints.find(filter || {}).fetch();
|
||||
|
||||
const filter = {}
|
||||
if (patientId) {
|
||||
filter.patientId = patientId;
|
||||
};
|
||||
|
||||
return Timepoints.find(filter).fetch();
|
||||
},
|
||||
|
||||
storeMeasurements(measurementData, filter = {}) {
|
||||
@@ -115,13 +120,23 @@ Meteor.methods({
|
||||
});
|
||||
},
|
||||
|
||||
retrieveMeasurements(filter = {}) {
|
||||
retrieveMeasurements(patientId, timepointIds) {
|
||||
OHIF.log.info('Retrieving Measurements from the Server');
|
||||
let measurementData = {};
|
||||
|
||||
const filter = {}
|
||||
if (patientId) {
|
||||
filter.patientId = patientId;
|
||||
}
|
||||
|
||||
if (timepointIds) {
|
||||
filter.timepointId = {
|
||||
$in: timepointIds
|
||||
};
|
||||
}
|
||||
|
||||
measurementTools.forEach(tool => {
|
||||
measurementData[tool.id] = MeasurementCollections[tool.id].find(filter || {}).fetch();
|
||||
measurementData[tool.id] = MeasurementCollections[tool.id].find(filter).fetch();
|
||||
});
|
||||
|
||||
return measurementData;
|
||||
|
||||
@@ -28,18 +28,14 @@ class MeasurementApi {
|
||||
});
|
||||
}
|
||||
|
||||
retrieveMeasurements(timepointId) {
|
||||
if (!timepointId) {
|
||||
timepointId = this.currentTimepointId;
|
||||
}
|
||||
|
||||
retrieveMeasurements(patientId, timepointIds) {
|
||||
const retrievalFn = configuration.dataExchange.retrieve;
|
||||
if (!_.isFunction(retrievalFn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
retrievalFn(timepointId).then(measurementData => {
|
||||
retrievalFn(patientId, timepointIds).then(measurementData => {
|
||||
|
||||
OHIF.log.info('Measurement data retrieval');
|
||||
OHIF.log.info(measurementData);
|
||||
@@ -152,8 +148,27 @@ class MeasurementApi {
|
||||
});
|
||||
|
||||
let overallMeasurementNumber = 1;
|
||||
let specificToolMeasurementNumber = 1;
|
||||
|
||||
|
||||
const updateMeasurementNumber = (collection, toolType) => {
|
||||
return data => {
|
||||
const filter = {
|
||||
measurementNumber: data.measurementNumber,
|
||||
toolType
|
||||
}
|
||||
|
||||
collection.update(filter, {
|
||||
$set: {
|
||||
measurementNumber: specificToolMeasurementNumber
|
||||
}
|
||||
});
|
||||
|
||||
// Increment the overall measurement number
|
||||
specificToolMeasurementNumber += 1;
|
||||
};
|
||||
};
|
||||
|
||||
// Given a Collection and a
|
||||
const updateMeasurementNumberOverall = (collection, toolType) => {
|
||||
return data => {
|
||||
const filter = {
|
||||
@@ -182,6 +197,24 @@ class MeasurementApi {
|
||||
};
|
||||
};
|
||||
|
||||
// First, update Measurement Number and the displayed Measurements
|
||||
includedTools.forEach(tool => {
|
||||
const collection = this[tool.id];
|
||||
const toolType = tool.cornerstoneToolType;
|
||||
const measurements = collection.find({toolType}).fetch();
|
||||
const groupObject = _.groupBy(measurements, m => m.measurementNumber);
|
||||
const sortedByMeasurementNumber = Object.keys(groupObject).map(summarizeMeasurement(groupObject, toolType));
|
||||
sortedByMeasurementNumber.forEach(updateMeasurementNumber(collection, toolType))
|
||||
|
||||
measurements.forEach(measurement => {
|
||||
OHIF.measurements.syncMeasurementAndToolData(measurement);
|
||||
});
|
||||
|
||||
// Reset specificToolMeasurementNumber
|
||||
specificToolMeasurementNumber = 1;
|
||||
});
|
||||
|
||||
// Next, handle the overall measurement number.
|
||||
// First, handle data that has a measurement at baseline
|
||||
includedTools.forEach(tool => {
|
||||
const collection = this[tool.id];
|
||||
@@ -255,9 +288,10 @@ class MeasurementApi {
|
||||
syncFilter.measurementNumber = {
|
||||
$gt: measurementNumber - 1
|
||||
};
|
||||
|
||||
collection.find(syncFilter).forEach(measurement => {
|
||||
OHIF.measurements.syncMeasurementAndToolData(measurement);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fetch(measurementTypeId, selector, options) {
|
||||
|
||||
@@ -26,14 +26,14 @@ class TimepointApi {
|
||||
this.timepoints._debugName = 'Timepoints';
|
||||
}
|
||||
|
||||
retrieveTimepoints(filter) {
|
||||
retrieveTimepoints(patientId) {
|
||||
const retrievalFn = configuration.dataExchange.retrieve;
|
||||
if (!_.isFunction(retrievalFn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
retrievalFn(filter).then(timepointData => {
|
||||
retrievalFn(patientId).then(timepointData => {
|
||||
OHIF.log.info('Timepoint data retrieval');
|
||||
OHIF.log.info(timepointData);
|
||||
_.each(timepointData, timepoint => {
|
||||
|
||||
Reference in new issue
Block a user