PWV-3: Creating ohif:log package and partially refactoring ohif:measurements

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-11-15 08:21:46 +01:00
1 parent f3f32518c6
commit 60aa1d0982
76 files changed
+410 -479

No files matched your search

@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
Session.setDefault('showLoadingText', true);
Template.studylistResult.helpers({
@@ -149,7 +151,7 @@ function search() {
Meteor.call('StudyListSearch', filter, (error, studies) => {
console.log('StudyListSearch');
if (error) {
log.warn(error);
OHIF.log.warn(error);
return;
}
@@ -1,9 +1,11 @@
import { OHIF } from 'meteor/ohif:core';
// Maybe we should use regular StudyList collection?
StudyListSelectedStudies = new Meteor.Collection(null);
StudyListSelectedStudies._debugName = 'StudyListSelectedStudies';
function handleShiftClick(studyRow, data) {
//log.info('shiftKey');
//OHIF.log.info('shiftKey');
var studyInstanceUid = studyRow.attr('studyInstanceUid');
// Select all rows in between these two rows
@@ -60,7 +62,7 @@ function handleShiftClick(studyRow, data) {
}
function handleCtrlClick(studyRow, data) {
//log.info('ctrlKey');
//OHIF.log.info('ctrlKey');
var studyInstanceUid = studyRow.attr('studyInstanceUid');
if (studyRow.hasClass('active')) {
@@ -78,7 +80,7 @@ function handleCtrlClick(studyRow, data) {
// Set this as the previously selected row, so the user can
// use Shift to select from this point onwards
StudyList.previouslySelected = studyRow;
log.info('StudyList PreviouslySelected set: ' + studyRow.index());
OHIF.log.info('StudyList PreviouslySelected set: ' + studyRow.index());
}
}
@@ -113,7 +115,7 @@ Template.studylistStudy.events({
handleCtrlClick(studyRow, data);
} else {
// Select a single study
//log.info('Regular click');
//OHIF.log.info('Regular click');
// Clear all selected studies
StudyListSelectedStudies.remove({});
@@ -121,7 +123,7 @@ Template.studylistStudy.events({
// Set the previous study to the currently clicked-on study
StudyList.previouslySelected = studyRow;
//log.info('StudyList PreviouslySelected set: ' + studyRow.index());
//OHIF.log.info('StudyList PreviouslySelected set: ' + studyRow.index());
// Set the current study as selected
StudyListSelectedStudies.insert(data);
@@ -163,4 +165,4 @@ Template.studylistStudy.events({
}
}
});
});
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Retrieves metaData for multiple studies at once.
*
@@ -50,9 +52,9 @@ getStudiesMetadata = function(studyInstanceUids, doneCallback, failCallback) {
doneCallback(studies);
}
}).fail(function(error) {
log.warn(error);
OHIF.log.warn(error);
if (failCallback && typeof failCallback === 'function') {
failCallback(error);
}
});
};
};
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
// Define the StudyMetaData object. This is used as a cache
// to store study meta data information to prevent unnecessary
// calls to the server
@@ -20,7 +22,7 @@ getStudyMetadata = function(studyInstanceUid, doneCallback, failCallback) {
doneCallback(study);
return;
}
console.time('getStudyMetadata');
// If no study metadata is in the cache variable, we need to retrieve it from
@@ -42,7 +44,7 @@ getStudyMetadata = function(studyInstanceUid, doneCallback, failCallback) {
}
if (error) {
log.warn(error);
OHIF.log.warn(error);
failCallback(error);
return;
}
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Imports selected studies from local into studylist
* @param filesToImport Files located in the client machine to import
@@ -44,7 +46,7 @@ importStudies = function(filesToImport, importCallback) {
if (fileUploadStatus.numberOfFilesFailed > 0) {
//TODO: Some files failed to upload, so let user know
log.info("Failed to upload " + fileUploadStatus.numberOfFilesFailed + " of " + numberOfFilesToUpload + " files");
OHIF.log.info("Failed to upload " + fileUploadStatus.numberOfFilesFailed + " of " + numberOfFilesToUpload + " files");
}
}
};
@@ -128,4 +130,4 @@ function importStudiesInternal(studiesToImport, importCallback) {
// Import studies with study import status id to get callbacks
Meteor.call("importStudies", studiesToImport, studyImportStatusId);
});
}
}
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Switches to a new tab in the tabbed studylist container
* This function renders either the StudyList or the Viewer template with new data.
@@ -9,7 +11,7 @@ switchToTab = function(contentId) {
return;
}
log.info('Switching to tab: ' + contentId);
OHIF.log.info('Switching to tab: ' + contentId);
$('.tabTitle').removeClass('active');
$('.tabTitle a[data-target="#' + contentId + '"]').addClass('active');
@@ -78,7 +80,7 @@ switchToTab = function(contentId) {
function viewStudiesInTab(contentId, studies) {
// Tab closed while study data was being retrieved, stop here
if (!ViewerData[contentId]) {
log.warn('Tab closed while study data was being retrieved');
OHIF.log.warn('Tab closed while study data was being retrieved');
return;
}
-3
View File
@@ -1,3 +0,0 @@
// Create package logger using loglevel
// https://atmospherejs.com/spacejamio/loglevel
log = loglevel.createPackageLogger('studylist', defaultLevel = 'info');
-6
View File
@@ -12,7 +12,6 @@ Package.onUse(function (api) {
api.use('jquery');
api.use('stylus');
api.use('http');
api.use('practicalmeteor:loglevel');
api.use('random');
api.use('silentcicero:jszip');
api.use('aldeed:simple-schema');
@@ -35,11 +34,6 @@ Package.onUse(function (api) {
// TODO: Replace with NPM dependency
api.use('ohif:cornerstone'); // Only for HammerJS
// This sets the default logging level of the package using the
// loglevel package. It can be overridden in the JavaScript
// console for debugging purposes
api.addFiles('log.js');
api.addFiles('both/collections.js', ['client', 'server']);
api.addFiles('both/schema/servers.js', ['client', 'server']);
api.addFiles('both/lib/getCurrentServer.js', ['client', 'server']);
@@ -1,10 +1,12 @@
import { OHIF } from 'meteor/ohif:core';
Meteor.methods({
/**
* Retrieves Study metadata given a Study Instance UID
* This Meteor method is available from both the client and the server
*/
GetStudyMetadata: function(studyInstanceUid) {
log.info('GetStudyMetadata(%s)', studyInstanceUid);
OHIF.log.info('GetStudyMetadata(%s)', studyInstanceUid);
// Get the server data. This is user-defined in the config.json files or through servers
// configuration modal
@@ -1,4 +1,20 @@
import { parseFloatArray } from '../../lib/parseFloatArray';
import { OHIF } from 'meteor/ohif:core';
import { parseFloatArray } from 'meteor/ohif:study-list/server/lib/parseFloatArray';
/**
* Returns the value of the element (e.g. '00280009')
*
* @param element - The group/element of the element (e.g. '00280009')
* @param defaultValue - The default value to return if the element does not exist
* @returns {*}
*/
function getValue(element, defaultValue) {
if (!element || !element.value) {
return defaultValue;
}
return element.value;
}
/**
* Parses the SourceImageSequence, if it exists, in order
@@ -18,21 +34,6 @@ function getSourceImageInstanceUid(instance) {
}
}
/**
* Returns the value of the element (e.g. '00280009')
*
* @param element - The group/element of the element (e.g. '00280009')
* @param defaultValue - The default value to return if the element does not exist
* @returns {*}
*/
function getValue(element, defaultValue) {
if (!element || !element.value) {
return defaultValue;
}
return element.value;
}
/**
* Parses result data from a DIMSE search into Study MetaData
* Returns an object populated with study metadata, including the
@@ -43,7 +44,7 @@ function getValue(element, defaultValue) {
* @returns {{seriesList: Array, patientName: *, patientId: *, accessionNumber: *, studyDate: *, modalities: *, studyDescription: *, imageCount: *, studyInstanceUid: *}}
*/
function resultDataToStudyMetadata(studyInstanceUid, resultData) {
log.info('resultDataToStudyMetadata');
OHIF.log.info('resultDataToStudyMetadata');
var seriesMap = {};
var seriesList = [];
@@ -161,4 +162,4 @@ Services.DIMSE.RetrieveMetadata = function(studyInstanceUid) {
}
return resultDataToStudyMetadata(studyInstanceUid, results);
};
};
@@ -1,59 +1,59 @@
import { moment } from 'meteor/mrt:moment';
/**
* Parses resulting data from a QIDO call into a set of Study MetaData
*
* @param resultData
* @returns {Array} An array of Study MetaData objects
*/
function resultDataToStudies(resultData) {
var studies = [];
resultData.forEach(function(studyRaw) {
var study = studyRaw.toObject();
studies.push({
studyInstanceUid: study[0x0020000D],
// 00080005 = SpecificCharacterSet
studyDate: study[0x00080020],
studyTime: study[0x00080030],
accessionNumber: study[0x00080050],
referringPhysicianName: study[0x00080090],
// 00081190 = URL
patientName: study[0x00100010],
patientId: study[0x00100020],
patientBirthdate: study[0x00100030],
patientSex: study[0x00100040],
imageCount: study[0x00201208],
studyId: study[0x00200010],
studyDescription: study[0x00081030],
modalities: study[0x00080061]
});
});
return studies;
}
Services.DIMSE.Studies = function(filter) {
log.info('Services.DIMSE.Studies');
let filterStudyDate = '';
if (filter.studyDateFrom && filter.studyDateTo) {
const convertDate = date => moment(date, 'MM/DD/YYYY').format('YYYYMMDD');
const dateFrom = convertDate(filter.studyDateFrom);
const dateTo = convertDate(filter.studyDateTo);
filterStudyDate = `${dateFrom}-${dateTo}`;
}
var parameters = {
0x00100010: filter.patientName,
0x00100020: filter.patientId,
0x00080050: filter.accessionNumber,
0x00080020: filterStudyDate,
0x00081030: filter.studyDescription,
0x00100040: '',
0x00201208: '',
0x00080061: filter.modalitiesInStudy
};
var results = DIMSE.retrieveStudies(parameters);
return resultDataToStudies(results);
};
import { OHIF } from 'meteor/ohif:core';
/**
* Parses resulting data from a QIDO call into a set of Study MetaData
*
* @param resultData
* @returns {Array} An array of Study MetaData objects
*/
function resultDataToStudies(resultData) {
var studies = [];
resultData.forEach(function(studyRaw) {
var study = studyRaw.toObject();
studies.push({
studyInstanceUid: study[0x0020000D],
// 00080005 = SpecificCharacterSet
studyDate: study[0x00080020],
studyTime: study[0x00080030],
accessionNumber: study[0x00080050],
referringPhysicianName: study[0x00080090],
// 00081190 = URL
patientName: study[0x00100010],
patientId: study[0x00100020],
patientBirthdate: study[0x00100030],
patientSex: study[0x00100040],
imageCount: study[0x00201208],
studyId: study[0x00200010],
studyDescription: study[0x00081030],
modalities: study[0x00080061]
});
});
return studies;
}
Services.DIMSE.Studies = function(filter) {
OHIF.log.info('Services.DIMSE.Studies');
let filterStudyDate = '';
if (filter.studyDateFrom && filter.studyDateTo) {
const convertDate = date => moment(date, 'MM/DD/YYYY').format('YYYYMMDD');
const dateFrom = convertDate(filter.studyDateFrom);
const dateTo = convertDate(filter.studyDateTo);
filterStudyDate = `${dateFrom}-${dateTo}`;
}
var parameters = {
0x00100010: filter.patientName,
0x00100020: filter.patientId,
0x00080050: filter.accessionNumber,
0x00080020: filterStudyDate,
0x00081030: filter.studyDescription,
0x00100040: '',
0x00201208: '',
0x00080061: filter.modalitiesInStudy
};
var results = DIMSE.retrieveStudies(parameters);
return resultDataToStudies(results);
};