Work on refactoring measurements out of Lesion Tracker package
- Removed AssociatedStudies Collection - Measurement API is generated from configuration files - Data exchange methods are defined in configuration
This commit is contained in:
1 parent
c511edd419
commit
ab4d4c9008
537 files changed
+5122
-3545
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { measurementTools } from 'meteor/ohif:lesiontracker/both/configuration/measurementTools';
|
||||
|
||||
let MeasurementCollections = {};
|
||||
measurementTools.forEach(tool => {
|
||||
MeasurementCollections[tool.id] = new Mongo.Collection(tool.id);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Timepoints = new Mongo.Collection('timepoints');
|
||||
|
||||
// Drop our collections for testing purposes
|
||||
Meteor.startup(() => {
|
||||
Timepoints.remove({});
|
||||
measurementTools.forEach(tool => {
|
||||
MeasurementCollections[tool.id].remove({});
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
// TODO: Make storage use update instead of clearing the entire collection and
|
||||
// re-inserting everything.
|
||||
Meteor.methods({
|
||||
storeTimepoints(timepoints) {
|
||||
console.log('Storing Timepoints on the Server')
|
||||
console.log(JSON.stringify(timepoints, null, 2));
|
||||
Timepoints.remove({});
|
||||
timepoints.forEach(timepoint => {
|
||||
delete timepoint._id;
|
||||
Timepoints.insert(timepoint);
|
||||
});
|
||||
},
|
||||
|
||||
retrieveTimepoints() {
|
||||
console.log('Retrieving Timepoints from the Server');
|
||||
return Timepoints.find().fetch();
|
||||
},
|
||||
|
||||
storeMeasurements(measurementData) {
|
||||
console.log('Storing Measurements on the Server')
|
||||
console.log(JSON.stringify(measurementData, null, 2));
|
||||
|
||||
Object.keys(measurementData).forEach(toolId => {
|
||||
MeasurementCollections[toolId].remove({});
|
||||
|
||||
const measurements = measurementData[toolId];
|
||||
measurements.forEach(measurement => {
|
||||
MeasurementCollections[toolId].insert(measurement);
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
retrieveMeasurements() {
|
||||
console.log('Retrieving Measurements from the Server');
|
||||
let measurementData = {};
|
||||
|
||||
measurementTools.forEach(tool => {
|
||||
measurementData[tool.id] = MeasurementCollections[tool.id].find().fetch();
|
||||
});
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
Meteor.publish('timepoints', function() {
|
||||
return Timepoints.find();
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientTimepoints', function(patientId) {
|
||||
return Timepoints.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('studies', function() {
|
||||
return Studies.find();
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientAssociatedStudies', function(patientId) {
|
||||
return Studies.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientMeasurements', function(patientId) {
|
||||
return Measurements.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientImageMeasurements', function(patientId) {
|
||||
return ImageMeasurements.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('additionalFindings', function() {
|
||||
return AdditionalFindings.find();
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientAdditionalFindings', function(patientId) {
|
||||
return AdditionalFindings.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('reviewers', function() {
|
||||
return Reviewers.find();
|
||||
});
|
||||
|
||||
// Temporary fix to drop all Collections on server restart
|
||||
// http://stackoverflow.com/questions/23891631/meteor-how-can-i-drop-all-mongo-collections-and-clear-all-data-on-startup
|
||||
Meteor.startup(function() {
|
||||
for (var property in global) {
|
||||
var object = global[property];
|
||||
if (object instanceof Meteor.Collection) {
|
||||
if (!(/^server|currentServer$/).test(object._name)) {
|
||||
object.remove({});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user