LT-293: send proper timepoint id to server when removing an association and update the view, removing this associations
This commit is contained in:
parent
998cdce9fb
commit
987be26047
@ -1,7 +1,7 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
import { measurementTools } from './measurementTools';
|
import { measurementTools } from './measurementTools';
|
||||||
import { retrieveMeasurements, storeMeasurements, retrieveTimepoints, storeTimepoints } from './dataExchange';
|
import { retrieveMeasurements, storeMeasurements, retrieveTimepoints, storeTimepoints, removeTimepoint, updateTimepoint } from './dataExchange';
|
||||||
import { validateMeasurements } from './dataValidation';
|
import { validateMeasurements } from './dataValidation';
|
||||||
|
|
||||||
console.log('OHIF-LesionTracker: Defining Configuration for Measurements');
|
console.log('OHIF-LesionTracker: Defining Configuration for Measurements');
|
||||||
@ -26,6 +26,8 @@ OHIF.measurements.MeasurementApi.setConfiguration({
|
|||||||
OHIF.measurements.TimepointApi.setConfiguration({
|
OHIF.measurements.TimepointApi.setConfiguration({
|
||||||
dataExchange: {
|
dataExchange: {
|
||||||
retrieve: retrieveTimepoints,
|
retrieve: retrieveTimepoints,
|
||||||
store: storeTimepoints
|
store: storeTimepoints,
|
||||||
|
remove: removeTimepoint,
|
||||||
|
update: updateTimepoint
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -64,3 +64,34 @@ export const storeTimepoints = (timepointData) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateTimepoint = (timepointData, query) => {
|
||||||
|
console.log('updateTimepoint');
|
||||||
|
console.log(timepointData);
|
||||||
|
console.log(query);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
Meteor.call('updateTimepoint', timepointData, query, (error, response) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const removeTimepoint = timepointData => {
|
||||||
|
console.log('removeTimepoint');
|
||||||
|
console.log(timepointData);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
Meteor.call('removeTimepoint', timepointData, (error, response) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@ -37,6 +37,19 @@ Meteor.methods({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeTimepoint(timepointData) {
|
||||||
|
OHIF.log.info('Removing Timepoint off the Server');
|
||||||
|
OHIF.log.info(JSON.stringify(timepointData, null, 2));
|
||||||
|
Timepoints.remove(timepointData);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateTimepoint(timepointData, query) {
|
||||||
|
OHIF.log.info('Updating Timepoint on the Server');
|
||||||
|
OHIF.log.info(JSON.stringify(timepointData, null, 2));
|
||||||
|
OHIF.log.info(JSON.stringify(query, null, 2));
|
||||||
|
Timepoints.update(timepointData, query);
|
||||||
|
},
|
||||||
|
|
||||||
retrieveTimepoints(filter) {
|
retrieveTimepoints(filter) {
|
||||||
OHIF.log.info('Retrieving Timepoints from the Server');
|
OHIF.log.info('Retrieving Timepoints from the Server');
|
||||||
return Timepoints.find(filter || {}).fetch();
|
return Timepoints.find(filter || {}).fetch();
|
||||||
|
|||||||
@ -59,6 +59,45 @@ class TimepointApi {
|
|||||||
storeFn(timepointData).then(() => OHIF.log.info('Timepoint storage completed'));
|
storeFn(timepointData).then(() => OHIF.log.info('Timepoint storage completed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeTimepoint(timepointId) {
|
||||||
|
const removeFn = configuration.dataExchange.remove;
|
||||||
|
if (!_.isFunction(removeFn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timepointData = {
|
||||||
|
timepointId
|
||||||
|
};
|
||||||
|
|
||||||
|
OHIF.log.info('Preparing to remove timepoint');
|
||||||
|
OHIF.log.info(JSON.stringify(timepointData, null, 2));
|
||||||
|
|
||||||
|
removeFn(timepointData).then(() => {
|
||||||
|
OHIF.log.info('Timepoint removal completed');
|
||||||
|
this.timepoints.remove(timepointData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTimepoint(timepointId, query) {
|
||||||
|
const updateFn = configuration.dataExchange.update;
|
||||||
|
if (!_.isFunction(updateFn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timepointData = {
|
||||||
|
timepointId
|
||||||
|
};
|
||||||
|
|
||||||
|
OHIF.log.info('Preparing to update timepoint');
|
||||||
|
OHIF.log.info(JSON.stringify(timepointData, null, 2));
|
||||||
|
OHIF.log.info(JSON.stringify(query, null, 2));
|
||||||
|
|
||||||
|
updateFn(timepointData, query).then(() => {
|
||||||
|
OHIF.log.info('Timepoint updated completed');
|
||||||
|
this.timepoints.update(timepointData, query);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Return all timepoints
|
// Return all timepoints
|
||||||
all() {
|
all() {
|
||||||
return this.timepoints.find().fetch();
|
return this.timepoints.find().fetch();
|
||||||
|
|||||||
@ -25,7 +25,7 @@ function removeTimepointAssociations() {
|
|||||||
// Loop through the Cursor of Selected Studies
|
// Loop through the Cursor of Selected Studies
|
||||||
selectedStudies.forEach(function(selectedStudy) {
|
selectedStudies.forEach(function(selectedStudy) {
|
||||||
// Find the Timepoint that was previously referenced
|
// Find the Timepoint that was previously referenced
|
||||||
const timepointApi = Template.instance().timepointApi;
|
const timepointApi = StudyList.timepointApi;
|
||||||
if (!timepointApi) {
|
if (!timepointApi) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ function removeTimepointAssociations() {
|
|||||||
if (timepoint.studyInstanceUids.length) {
|
if (timepoint.studyInstanceUids.length) {
|
||||||
// Update the Timepoints Collection with this modified array for the
|
// Update the Timepoints Collection with this modified array for the
|
||||||
// studyInstanceUids attribute
|
// studyInstanceUids attribute
|
||||||
Timepoints.update(timepoint._id, {
|
timepointApi.updateTimepoint(timepoint.timepointId, {
|
||||||
$set: {
|
$set: {
|
||||||
studyInstanceUids: timepoint.studyInstanceUids
|
studyInstanceUids: timepoint.studyInstanceUids
|
||||||
}
|
}
|
||||||
@ -68,25 +68,7 @@ function removeTimepointAssociations() {
|
|||||||
HipaaLogger.logEvent(hipaaEvent);
|
HipaaLogger.logEvent(hipaaEvent);
|
||||||
} else {
|
} else {
|
||||||
// If no more Studies are associated with this Timepoint, we should remove it
|
// If no more Studies are associated with this Timepoint, we should remove it
|
||||||
// from the Timepoints Collection via a server call
|
timepointApi.removeTimepoint(timepoint.timepointId);
|
||||||
Meteor.call('removeTimepoint', timepoint._id, function(error) {
|
|
||||||
if (error) {
|
|
||||||
OHIF.log.warn(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log
|
|
||||||
const hipaaEvent = {
|
|
||||||
eventType: 'delete',
|
|
||||||
userId: Meteor.userId(),
|
|
||||||
userName: Meteor.user().profile.fullName,
|
|
||||||
collectionName: 'Timepoints',
|
|
||||||
recordId: selectedStudy.timepointId,
|
|
||||||
patientId: selectedStudy.patientId,
|
|
||||||
patientName: selectedStudy.patientName
|
|
||||||
};
|
|
||||||
HipaaLogger.logEvent(hipaaEvent);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user