Applied JSCS and added JSCS/jsHint config files
This commit is contained in:
parent
a9266608d2
commit
90a16a8059
38
.jscsrc
Normal file
38
.jscsrc
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"requireCurlyBraces": [ "if", "else", "for", "while", "do" ],
|
||||||
|
"requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return" ],
|
||||||
|
"requireSpacesInFunctionExpression": {
|
||||||
|
"beforeOpeningCurlyBrace": true
|
||||||
|
},
|
||||||
|
"disallowSpacesInFunctionExpression": {
|
||||||
|
"beforeOpeningRoundBrace": true
|
||||||
|
},
|
||||||
|
"disallowKeywordsOnNewLine": ["else"],
|
||||||
|
"disallowNewlineBeforeBlockStatements": true,
|
||||||
|
"requirePaddingNewLinesAfterUseStrict": true,
|
||||||
|
"requirePaddingNewLinesInObjects": true,
|
||||||
|
"requirePaddingNewLinesAfterBlocks": {
|
||||||
|
"allExcept": ["inCallExpressions", "inArrayExpressions", "inProperties"]
|
||||||
|
},
|
||||||
|
"requireObjectKeysOnNewLine": true,
|
||||||
|
"requireSemicolons": true,
|
||||||
|
"requireSpaceAfterBinaryOperators": true,
|
||||||
|
"requireSpaceBeforeObjectValues": true,
|
||||||
|
"requireSpacesInsideObjectBrackets": "all",
|
||||||
|
"requireSpacesInsideArrayBrackets": "all",
|
||||||
|
"requireLineBreakAfterVariableAssignment": true,
|
||||||
|
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||||
|
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-"],
|
||||||
|
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
|
||||||
|
"disallowKeywords": [ "with" ],
|
||||||
|
"disallowMultipleLineBreaks": true,
|
||||||
|
"disallowKeywordsOnNewLine": [ "else" ],
|
||||||
|
"requireLineFeedAtFileEnd": true,
|
||||||
|
"disallowSpaceAfterObjectKeys": true,
|
||||||
|
"disallowQuotedKeysInObjects": true,
|
||||||
|
"disallowMultipleSpaces": true,
|
||||||
|
"validateLineBreaks": "LF",
|
||||||
|
"validateIndentation": 4,
|
||||||
|
"validateQuoteMarks": { "mark": "'", "escape": true },
|
||||||
|
"validateParameterSeparator": ", "
|
||||||
|
}
|
||||||
114
.jshintrc
Normal file
114
.jshintrc
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
{
|
||||||
|
// JSHint Default Configuration File (as on JSHint website)
|
||||||
|
// See http://jshint.com/docs/ for more details
|
||||||
|
|
||||||
|
"maxerr" : 50, // {int} Maximum error before stopping
|
||||||
|
|
||||||
|
// Enforcing
|
||||||
|
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
|
||||||
|
"camelcase" : false, // true: Identifiers must be in camelCase
|
||||||
|
"curly" : true, // true: Require {} for every new block or scope
|
||||||
|
"eqeqeq" : true, // true: Require triple equals (===) for comparison
|
||||||
|
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
|
||||||
|
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
|
||||||
|
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
|
||||||
|
"latedef" : false, // true: Require variables/functions to be defined before being used
|
||||||
|
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
|
||||||
|
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
|
||||||
|
"noempty" : true, // true: Prohibit use of empty blocks
|
||||||
|
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
|
||||||
|
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
|
||||||
|
"plusplus" : false, // true: Prohibit use of `++` and `--`
|
||||||
|
"quotmark" : false, // Quotation mark consistency:
|
||||||
|
// false : do nothing (default)
|
||||||
|
// true : ensure whatever is used is consistent
|
||||||
|
// "single" : require single quotes
|
||||||
|
// "double" : require double quotes
|
||||||
|
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
|
||||||
|
"unused" : true, // Unused variables:
|
||||||
|
// true : all variables, last function parameter
|
||||||
|
// "vars" : all variables only
|
||||||
|
// "strict" : all variables, all function parameters
|
||||||
|
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
|
||||||
|
"maxparams" : false, // {int} Max number of formal params allowed per function
|
||||||
|
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
|
||||||
|
"maxstatements" : false, // {int} Max number statements per function
|
||||||
|
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
|
||||||
|
"maxlen" : false, // {int} Max number of characters per line
|
||||||
|
"varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.
|
||||||
|
|
||||||
|
// Relaxing
|
||||||
|
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
|
||||||
|
"boss" : false, // true: Tolerate assignments where comparisons would be expected
|
||||||
|
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
|
||||||
|
"eqnull" : false, // true: Tolerate use of `== null`
|
||||||
|
"es5" : true, // true: Allow ES5 syntax (ex: getters and setters)
|
||||||
|
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
|
||||||
|
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
|
||||||
|
// (ex: `for each`, multiple try/catch, function expression…)
|
||||||
|
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
|
||||||
|
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
|
||||||
|
"funcscope" : false, // true: Tolerate defining variables inside control statements
|
||||||
|
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
|
||||||
|
"iterator" : false, // true: Tolerate using the `__iterator__` property
|
||||||
|
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
|
||||||
|
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
|
||||||
|
"laxcomma" : false, // true: Tolerate comma-first style coding
|
||||||
|
"loopfunc" : false, // true: Tolerate functions being defined in loops
|
||||||
|
"multistr" : false, // true: Tolerate multi-line strings
|
||||||
|
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
|
||||||
|
"notypeof" : false, // true: Tolerate invalid typeof operator values
|
||||||
|
"proto" : false, // true: Tolerate using the `__proto__` property
|
||||||
|
"scripturl" : false, // true: Tolerate script-targeted URLs
|
||||||
|
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
|
||||||
|
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
|
||||||
|
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
|
||||||
|
"validthis" : false, // true: Tolerate using this in a non-constructor function
|
||||||
|
|
||||||
|
// Environments
|
||||||
|
"browser" : true, // Web Browser (window, document, etc)
|
||||||
|
"browserify" : false, // Browserify (node.js code in the browser)
|
||||||
|
"couch" : false, // CouchDB
|
||||||
|
"devel" : true, // Development/debugging (alert, confirm, etc)
|
||||||
|
"dojo" : false, // Dojo Toolkit
|
||||||
|
"jasmine" : false, // Jasmine
|
||||||
|
"jquery" : true, // jQuery
|
||||||
|
"mocha" : true, // Mocha
|
||||||
|
"mootools" : false, // MooTools
|
||||||
|
"node" : false, // Node.js
|
||||||
|
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
|
||||||
|
"phantom" : false, // PhantomJS
|
||||||
|
"prototypejs" : false, // Prototype and Scriptaculous
|
||||||
|
"qunit" : false, // QUnit
|
||||||
|
"rhino" : false, // Rhino
|
||||||
|
"shelljs" : false, // ShellJS
|
||||||
|
"typed" : false, // Globals for typed array constructions
|
||||||
|
"worker" : false, // Web Workers
|
||||||
|
"wsh" : false, // Windows Scripting Host
|
||||||
|
"yui" : false, // Yahoo User Interface
|
||||||
|
|
||||||
|
// Custom Globals
|
||||||
|
// additional predefined global variables
|
||||||
|
"globals" : {
|
||||||
|
console: true,
|
||||||
|
prompt: true,
|
||||||
|
$: true,
|
||||||
|
Hammer: true,
|
||||||
|
cornerstone: true,
|
||||||
|
cornerstoneMath: true,
|
||||||
|
cornerstoneTools: true,
|
||||||
|
cornerstoneTools: true,
|
||||||
|
|
||||||
|
// Meteor-specific Globals
|
||||||
|
Meteor: true,
|
||||||
|
Template: true,
|
||||||
|
UI: true,
|
||||||
|
|
||||||
|
// loglevel package
|
||||||
|
log: true,
|
||||||
|
|
||||||
|
// OHIF-package specific Globals
|
||||||
|
Timepoints: true,
|
||||||
|
Measurements: true
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,7 +6,7 @@ Template.viewer.onCreated(function() {
|
|||||||
|
|
||||||
var firstMeasurementsActivated = false;
|
var firstMeasurementsActivated = false;
|
||||||
|
|
||||||
log.info("viewer onCreated");
|
log.info('viewer onCreated');
|
||||||
|
|
||||||
OHIF = OHIF || {
|
OHIF = OHIF || {
|
||||||
viewer: {}
|
viewer: {}
|
||||||
@ -18,7 +18,6 @@ Template.viewer.onCreated(function() {
|
|||||||
OHIF.viewer.isPlaying = {};
|
OHIF.viewer.isPlaying = {};
|
||||||
var contentId = this.data.contentId;
|
var contentId = this.data.contentId;
|
||||||
|
|
||||||
|
|
||||||
OHIF.viewer.functionList = {
|
OHIF.viewer.functionList = {
|
||||||
invert: function(element) {
|
invert: function(element) {
|
||||||
var viewport = cornerstone.getViewport(element);
|
var viewport = cornerstone.getViewport(element);
|
||||||
@ -36,24 +35,25 @@ Template.viewer.onCreated(function() {
|
|||||||
} else {
|
} else {
|
||||||
cornerstoneTools.playClip(element);
|
cornerstoneTools.playClip(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
OHIF.viewer.isPlaying[viewportIndex] = !OHIF.viewer.isPlaying[viewportIndex];
|
OHIF.viewer.isPlaying[viewportIndex] = !OHIF.viewer.isPlaying[viewportIndex];
|
||||||
Session.set('UpdateCINE', Random.id());
|
Session.set('UpdateCINE', Random.id());
|
||||||
},
|
},
|
||||||
toggleLesionTrackerTools: toggleLesionTrackerTools,
|
toggleLesionTrackerTools: toggleLesionTrackerTools,
|
||||||
clearTools: clearTools,
|
clearTools: clearTools,
|
||||||
lesion: function() {
|
lesion: function() {
|
||||||
toolManager.setActiveTool("lesion");
|
toolManager.setActiveTool('lesion');
|
||||||
},
|
},
|
||||||
nonTarget: function() {
|
nonTarget: function() {
|
||||||
toolManager.setActiveTool("nonTarget");
|
toolManager.setActiveTool('nonTarget');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// The hotkey can also be an array (e.g. ["NUMPAD0", "0"])
|
// The hotkey can also be an array (e.g. ["NUMPAD0", "0"])
|
||||||
OHIF.viewer.defaultHotkeys.toggleLesionTrackerTools = "O";
|
OHIF.viewer.defaultHotkeys.toggleLesionTrackerTools = 'O';
|
||||||
OHIF.viewer.defaultHotkeys.lesion = "T"; // Target
|
OHIF.viewer.defaultHotkeys.lesion = 'T'; // Target
|
||||||
OHIF.viewer.defaultHotkeys.nonTarget = "N"; // Non-target
|
OHIF.viewer.defaultHotkeys.nonTarget = 'N'; // Non-target
|
||||||
|
|
||||||
if (isTouchDevice()) {
|
if (isTouchDevice()) {
|
||||||
OHIF.viewer.tooltipConfig = {
|
OHIF.viewer.tooltipConfig = {
|
||||||
@ -65,7 +65,6 @@ Template.viewer.onCreated(function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ViewerData[contentId].loadedSeriesData) {
|
if (ViewerData[contentId].loadedSeriesData) {
|
||||||
log.info('Reloading previous loadedSeriesData');
|
log.info('Reloading previous loadedSeriesData');
|
||||||
OHIF.viewer.loadedSeriesData = ViewerData[contentId].loadedSeriesData;
|
OHIF.viewer.loadedSeriesData = ViewerData[contentId].loadedSeriesData;
|
||||||
@ -114,7 +113,7 @@ Template.viewer.onCreated(function() {
|
|||||||
|
|
||||||
// If we do, stop here
|
// If we do, stop here
|
||||||
if (timepoint) {
|
if (timepoint) {
|
||||||
log.warn("A timepoint with that study date already exists!");
|
log.warn('A timepoint with that study date already exists!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +123,7 @@ Template.viewer.onCreated(function() {
|
|||||||
// If it relates to another subject, we need to stop here as well
|
// If it relates to another subject, we need to stop here as well
|
||||||
// because the tab may be changing.
|
// because the tab may be changing.
|
||||||
if (testTimepoint && testTimepoint.patientId !== study.patientId) {
|
if (testTimepoint && testTimepoint.patientId !== study.patientId) {
|
||||||
log.warn("Timepoints collection related to the wrong subject");
|
log.warn('Timepoints collection related to the wrong subject');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +148,7 @@ Template.viewer.onCreated(function() {
|
|||||||
// Activate first measurements in image box as default if exists
|
// Activate first measurements in image box as default if exists
|
||||||
if (!firstMeasurementsActivated) {
|
if (!firstMeasurementsActivated) {
|
||||||
var templateData = {
|
var templateData = {
|
||||||
contentId: Session.get("activeContentId")
|
contentId: Session.get('activeContentId')
|
||||||
};
|
};
|
||||||
|
|
||||||
// Activate measurement
|
// Activate measurement
|
||||||
@ -184,7 +183,7 @@ Template.viewer.onCreated(function() {
|
|||||||
// that were created after the current lesion by 1
|
// that were created after the current lesion by 1
|
||||||
Meteor.call('decrementLesionNumbers', data, function(error, response) {
|
Meteor.call('decrementLesionNumbers', data, function(error, response) {
|
||||||
if (error) {
|
if (error) {
|
||||||
log.warn(error)
|
log.warn(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync database data with toolData for all the measurements
|
// Sync database data with toolData for all the measurements
|
||||||
@ -214,7 +213,7 @@ Template.viewer.onCreated(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.updateImageSynchronizer);
|
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.updateImageSynchronizer);
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateRelatedElements(imageId) {
|
function updateRelatedElements(imageId) {
|
||||||
@ -311,7 +310,7 @@ Template.viewer.onRendered(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Template.viewer.onDestroyed(function() {
|
Template.viewer.onDestroyed(function() {
|
||||||
log.info("onDestroyed");
|
log.info('onDestroyed');
|
||||||
|
|
||||||
// Remove the Window resize listener
|
// Remove the Window resize listener
|
||||||
$(window).off('resize', handleResize);
|
$(window).off('resize', handleResize);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
Template.viewerMain.helpers({
|
Template.viewerMain.helpers({
|
||||||
'toolbarOptions': function() {
|
toolbarOptions: function() {
|
||||||
var toolbarOptions = {};
|
var toolbarOptions = {};
|
||||||
|
|
||||||
var buttonData = [];
|
var buttonData = [];
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
Router.onBeforeAction(function () {
|
Router.onBeforeAction(function() {
|
||||||
|
|
||||||
// User is logged in, go ahead and route them
|
// User is logged in, go ahead and route them
|
||||||
this.next();
|
this.next();
|
||||||
|
|||||||
@ -18,11 +18,10 @@ Router.configure({
|
|||||||
|
|
||||||
Router.onBeforeAction('loading');
|
Router.onBeforeAction('loading');
|
||||||
|
|
||||||
Router.route('/', function () {
|
Router.route('/', function() {
|
||||||
this.render('worklist');
|
this.render('worklist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Router.route('/viewer/:_id', {
|
Router.route('/viewer/:_id', {
|
||||||
layoutTemplate: 'layoutLesionTracker',
|
layoutTemplate: 'layoutLesionTracker',
|
||||||
name: 'viewer',
|
name: 'viewer',
|
||||||
@ -33,7 +32,9 @@ Router.route('/viewer/:_id', {
|
|||||||
|
|
||||||
// Check if this study is already loaded in a tab
|
// Check if this study is already loaded in a tab
|
||||||
// If it is, stop here so we don't keep adding tabs on hot-code reloads
|
// If it is, stop here so we don't keep adding tabs on hot-code reloads
|
||||||
var tab = WorklistTabs.find({'studyInstanceUid' : studyInstanceUid}).fetch();
|
var tab = WorklistTabs.find({
|
||||||
|
studyInstanceUid: studyInstanceUid
|
||||||
|
}).fetch();
|
||||||
if (tab) {
|
if (tab) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ Template.viewer.onCreated(function() {
|
|||||||
// Attach the Window resize listener
|
// Attach the Window resize listener
|
||||||
$(window).on('resize', handleResize);
|
$(window).on('resize', handleResize);
|
||||||
|
|
||||||
log.info("viewer onCreated");
|
log.info('viewer onCreated');
|
||||||
|
|
||||||
OHIF = window.OHIF || {
|
OHIF = window.OHIF || {
|
||||||
viewer: {}
|
viewer: {}
|
||||||
@ -35,7 +35,6 @@ Template.viewer.onCreated(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (isTouchDevice()) {
|
if (isTouchDevice()) {
|
||||||
OHIF.viewer.tooltipConfig = {
|
OHIF.viewer.tooltipConfig = {
|
||||||
trigger: 'manual'
|
trigger: 'manual'
|
||||||
@ -75,10 +74,10 @@ Template.viewer.onCreated(function() {
|
|||||||
ViewerStudies.insert(study);
|
ViewerStudies.insert(study);
|
||||||
});
|
});
|
||||||
|
|
||||||
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.updateImageSynchronizer);
|
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.updateImageSynchronizer);
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.viewer.onDestroyed(function() {
|
Template.viewer.onDestroyed(function() {
|
||||||
log.info("onDestroyed");
|
log.info('onDestroyed');
|
||||||
OHIF.viewer.updateImageSynchronizer.destroy();
|
OHIF.viewer.updateImageSynchronizer.destroy();
|
||||||
});
|
});
|
||||||
@ -1,4 +1,4 @@
|
|||||||
Router.onBeforeAction(function () {
|
Router.onBeforeAction(function() {
|
||||||
|
|
||||||
// User is logged in, go ahead and route them
|
// User is logged in, go ahead and route them
|
||||||
this.next();
|
this.next();
|
||||||
|
|||||||
@ -18,11 +18,10 @@ Router.configure({
|
|||||||
|
|
||||||
Router.onBeforeAction('loading');
|
Router.onBeforeAction('loading');
|
||||||
|
|
||||||
Router.route('/', function () {
|
Router.route('/', function() {
|
||||||
this.render('worklist');
|
this.render('worklist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Router.route('/viewer/:_id', {
|
Router.route('/viewer/:_id', {
|
||||||
layoutTemplate: 'layout',
|
layoutTemplate: 'layout',
|
||||||
name: 'viewer',
|
name: 'viewer',
|
||||||
@ -31,7 +30,9 @@ Router.route('/viewer/:_id', {
|
|||||||
|
|
||||||
// Check if this study is already loaded in a tab
|
// Check if this study is already loaded in a tab
|
||||||
// If it is, stop here so we don't keep adding tabs on hot-code reloads
|
// If it is, stop here so we don't keep adding tabs on hot-code reloads
|
||||||
var tab = WorklistTabs.find({studyInstanceUid: studyInstanceUid}).fetch();
|
var tab = WorklistTabs.find({
|
||||||
|
studyInstanceUid: studyInstanceUid
|
||||||
|
}).fetch();
|
||||||
if (tab) {
|
if (tab) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,46 +4,49 @@
|
|||||||
* @returns {Uint8Array} Uint8 Array of character codes
|
* @returns {Uint8Array} Uint8 Array of character codes
|
||||||
*/
|
*/
|
||||||
function stringToUint8Array(str) {
|
function stringToUint8Array(str) {
|
||||||
var uint=new Uint8Array(str.length);
|
var uint = new Uint8Array(str.length);
|
||||||
for(var i=0,j=str.length;i<j;i++){
|
for (var i = 0,j = str.length;i< j;i++){
|
||||||
uint[i]=str.charCodeAt(i);
|
uint[i] = str.charCodeAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint;
|
return uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkToken(token, data, dataOffset) {
|
function checkToken(token, data, dataOffset) {
|
||||||
if(dataOffset + token.length > data.length) {
|
if (dataOffset + token.length > data.length) {
|
||||||
//console.log('dataOffset >> ', dataOffset);
|
//console.log('dataOffset >> ', dataOffset);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < token.length; i++) {
|
for (var i = 0; i < token.length; i++) {
|
||||||
if(token[i] !== data[endIndex++]) {
|
if (token[i] !== data[endIndex++]) {
|
||||||
if(endIndex > 520000) {
|
if (endIndex > 520000) {
|
||||||
console.log('token=',uint8ArrayToString(token));
|
console.log('token=',uint8ArrayToString(token));
|
||||||
console.log('data=', uint8ArrayToString(data, dataOffset, endIndex-dataOffset));
|
console.log('data=', uint8ArrayToString(data, dataOffset, endIndex - dataOffset));
|
||||||
console.log('miss at %d %s dataOffset=%d', i, String.fromCharCode(data[endIndex]), endIndex);
|
console.log('miss at %d %s dataOffset=%d', i, String.fromCharCode(data[endIndex]), endIndex);
|
||||||
console.log('miss at %d %s dataOffset=%d', i, String.fromCharCode(token[endIndex]), endIndex);
|
console.log('miss at %d %s dataOffset=%d', i, String.fromCharCode(token[endIndex]), endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
findIndexOfString = function(data, str, offset) {
|
findIndexOfString = function(data, str, offset) {
|
||||||
offset = offset || 0;
|
offset = offset || 0;
|
||||||
|
|
||||||
var token = stringToUint8Array(str);
|
var token = stringToUint8Array(str);
|
||||||
|
|
||||||
for(var i=offset; i < data.length; i++) {
|
for (var i = offset; i < data.length; i++) {
|
||||||
if(data[i] === token[0]) {
|
if (data[i] === token[0]) {
|
||||||
//console.log('match @', i);
|
//console.log('match @', i);
|
||||||
if(checkToken(token, data, i)) {
|
if (checkToken(token, data, i)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
@ -8,10 +8,11 @@
|
|||||||
uint8ArrayToString = function(data, offset, length) {
|
uint8ArrayToString = function(data, offset, length) {
|
||||||
offset = offset || 0;
|
offset = offset || 0;
|
||||||
length = length || data.length - offset;
|
length = length || data.length - offset;
|
||||||
var str = "";
|
var str = '';
|
||||||
|
|
||||||
for(var i=offset; i < offset + length; i++) {
|
for (var i = offset; i < offset + length; i++) {
|
||||||
str += String.fromCharCode(data[i]);
|
str += String.fromCharCode(data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
Package.describe({
|
Package.describe({
|
||||||
name: "dicomweb",
|
name: 'dicomweb',
|
||||||
summary: "DICOM Web Helper Functions",
|
summary: 'DICOM Web Helper Functions',
|
||||||
version: '0.0.1'
|
version: '0.0.1'
|
||||||
});
|
});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function(api) {
|
||||||
api.use('http');
|
api.use('http');
|
||||||
|
|
||||||
// DICOMWeb API functions
|
// DICOMWeb API functions
|
||||||
@ -19,6 +19,6 @@ Package.onUse(function (api) {
|
|||||||
api.addFiles('lib/findIndexOfString.js', 'server');
|
api.addFiles('lib/findIndexOfString.js', 'server');
|
||||||
api.addFiles('lib/uint8ArrayToString.js', 'server');
|
api.addFiles('lib/uint8ArrayToString.js', 'server');
|
||||||
|
|
||||||
api.export("DICOMWeb", 'server');
|
api.export('DICOMWeb', 'server');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,20 @@
|
|||||||
function findBoundary(header) {
|
function findBoundary(header) {
|
||||||
for(var i=0; i < header.length; i++) {
|
for (var i = 0; i < header.length; i++) {
|
||||||
if(header[i].substr(0,2) === '--') {
|
if (header[i].substr(0,2) === '--') {
|
||||||
return header[i];
|
return header[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findContentType(header) {
|
function findContentType(header) {
|
||||||
for(var i=0; i < header.length; i++) {
|
for (var i = 0; i < header.length; i++) {
|
||||||
if(header[i].substr(0,13) === 'Content-Type:') {
|
if (header[i].substr(0,13) === 'Content-Type:') {
|
||||||
return header[i].substr(13).trim();
|
return header[i].substr(13).trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,10 +23,10 @@ DICOMWeb.getImageFrame = function(uri, mediaType) {
|
|||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = "arraybuffer";
|
xhr.responseType = 'arraybuffer';
|
||||||
xhr.open("get", uri, true);
|
xhr.open('get', uri, true);
|
||||||
xhr.setRequestHeader('Accept', 'multipart/related;type=' + mediaType);
|
xhr.setRequestHeader('Accept', 'multipart/related;type=' + mediaType);
|
||||||
xhr.onreadystatechange = function (oEvent) {
|
xhr.onreadystatechange = function(oEvent) {
|
||||||
// TODO: consider sending out progress messages here as we receive the pixel data
|
// TODO: consider sending out progress messages here as we receive the pixel data
|
||||||
if (xhr.readyState === 4) {
|
if (xhr.readyState === 4) {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
@ -33,21 +35,23 @@ DICOMWeb.getImageFrame = function(uri, mediaType) {
|
|||||||
var response = new Uint8Array(xhr.response);
|
var response = new Uint8Array(xhr.response);
|
||||||
// First look for the multipart mime header
|
// First look for the multipart mime header
|
||||||
var tokenIndex = findIndexOfString(response, '\n\r\n');
|
var tokenIndex = findIndexOfString(response, '\n\r\n');
|
||||||
if(tokenIndex === -1) {
|
if (tokenIndex === -1) {
|
||||||
reject('invalid response - no multipart mime header');
|
reject('invalid response - no multipart mime header');
|
||||||
}
|
}
|
||||||
|
|
||||||
var header = uint8ArrayToString(response, 0, tokenIndex);
|
var header = uint8ArrayToString(response, 0, tokenIndex);
|
||||||
// Now find the boundary marker
|
// Now find the boundary marker
|
||||||
var split = header.split('\r\n');
|
var split = header.split('\r\n');
|
||||||
var boundary = findBoundary(split);
|
var boundary = findBoundary(split);
|
||||||
if(!boundary) {
|
if (!boundary) {
|
||||||
reject('invalid response - no boundary marker');
|
reject('invalid response - no boundary marker');
|
||||||
}
|
}
|
||||||
|
|
||||||
var offset = tokenIndex + 4; // skip over the \n\r\n
|
var offset = tokenIndex + 4; // skip over the \n\r\n
|
||||||
|
|
||||||
// find the terminal boundary marker
|
// find the terminal boundary marker
|
||||||
var endIndex = findIndexOfString(response, boundary, offset);
|
var endIndex = findIndexOfString(response, boundary, offset);
|
||||||
if(endIndex === -1) {
|
if (endIndex === -1) {
|
||||||
reject('invalid response - terminating boundary not found');
|
reject('invalid response - terminating boundary not found');
|
||||||
}
|
}
|
||||||
// return the info for this pixel data
|
// return the info for this pixel data
|
||||||
@ -58,13 +62,13 @@ DICOMWeb.getImageFrame = function(uri, mediaType) {
|
|||||||
offset: offset,
|
offset: offset,
|
||||||
length: length
|
length: length
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// request failed, reject the deferred
|
// request failed, reject the deferred
|
||||||
reject(xhr.response);
|
reject(xhr.response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.send();
|
xhr.send();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1,7 +1,7 @@
|
|||||||
DICOMWeb.getJSON = function(url, options) {
|
DICOMWeb.getJSON = function(url, options) {
|
||||||
var getOptions = {
|
var getOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept' : 'application/json'
|
Accept: 'application/json'
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,19 +6,19 @@
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
DICOMWeb.getName = function(element, defaultValue) {
|
DICOMWeb.getName = function(element, defaultValue) {
|
||||||
if(!element) {
|
if (!element) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Value is not present if the attribute has a zero length value
|
// Value is not present if the attribute has a zero length value
|
||||||
if(!element.Value) {
|
if (!element.Value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Sanity check to make sure we have at least one entry in the array.
|
// Sanity check to make sure we have at least one entry in the array.
|
||||||
if(!element.Value.length) {
|
if (!element.Value.length) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Return the Alphabetic component group
|
// Return the Alphabetic component group
|
||||||
if(element.Value[0].Alphabetic) {
|
if (element.Value[0].Alphabetic) {
|
||||||
return element.Value[0].Alphabetic;
|
return element.Value[0].Alphabetic;
|
||||||
}
|
}
|
||||||
// Orthanc does not return PN properly so this is a temporary workaround
|
// Orthanc does not return PN properly so this is a temporary workaround
|
||||||
|
|||||||
@ -5,16 +5,17 @@
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
DICOMWeb.getNumber = function(element, defaultValue) {
|
DICOMWeb.getNumber = function(element, defaultValue) {
|
||||||
if(!element) {
|
if (!element) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Value is not present if the attribute has a zero length value
|
// Value is not present if the attribute has a zero length value
|
||||||
if(!element.Value) {
|
if (!element.Value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Sanity check to make sure we have at least one entry in the array.
|
// Sanity check to make sure we have at least one entry in the array.
|
||||||
if(!element.Value.length) {
|
if (!element.Value.length) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseFloat(element.Value[0]);
|
return parseFloat(element.Value[0]);
|
||||||
};
|
};
|
||||||
@ -6,15 +6,15 @@
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
DICOMWeb.getString = function(element, defaultValue) {
|
DICOMWeb.getString = function(element, defaultValue) {
|
||||||
if(!element) {
|
if (!element) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Value is not present if the attribute has a zero length value
|
// Value is not present if the attribute has a zero length value
|
||||||
if(!element.Value) {
|
if (!element.Value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Sanity check to make sure we have at least one entry in the array.
|
// Sanity check to make sure we have at least one entry in the array.
|
||||||
if(!element.Value.length) {
|
if (!element.Value.length) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Join the array together separated by backslash
|
// Join the array together separated by backslash
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
Package.describe({
|
Package.describe({
|
||||||
name: "dimseservice",
|
name: 'dimseservice',
|
||||||
summary: "DICOM DIMSE C-Service",
|
summary: 'DICOM DIMSE C-Service',
|
||||||
version: '0.0.1'
|
version: '0.0.1'
|
||||||
});
|
});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function(api) {
|
||||||
//api.use("weiwei:dicomservices");
|
//api.use("weiwei:dicomservices");
|
||||||
|
|
||||||
api.addFiles('server/require.js', 'server');
|
api.addFiles('server/require.js', 'server');
|
||||||
@ -18,5 +18,5 @@ Package.onUse(function (api) {
|
|||||||
api.addFiles('server/Connection.js', 'server');
|
api.addFiles('server/Connection.js', 'server');
|
||||||
api.addFiles('server/DIMSE.js', 'server');
|
api.addFiles('server/DIMSE.js', 'server');
|
||||||
|
|
||||||
api.export("DIMSE", 'server');
|
api.export('DIMSE', 'server');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,26 +5,27 @@ function time() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var DEFAULT_MAX_PACKAGE_SIZE = 32768;
|
var DEFAULT_MAX_PACKAGE_SIZE = 32768;
|
||||||
var DEFAULT_SOURCE_AE = "OHIFDCM";
|
var DEFAULT_SOURCE_AE = 'OHIFDCM';
|
||||||
|
|
||||||
var Envelope = function(conn, command, dataset) {
|
var Envelope = function(conn, command, dataset) {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(Envelope, EventEmitter);
|
util.inherits(Envelope, EventEmitter);
|
||||||
|
|
||||||
Envelope.prototype.send = function() {
|
Envelope.prototype.send = function() {
|
||||||
return this;
|
return this;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection = function(socket, options) {
|
Connection = function(socket, options) {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.options = Object.assign({
|
this.options = Object.assign({
|
||||||
hostAE: "",
|
hostAE: '',
|
||||||
sourceAE: "OHIFDCM",
|
sourceAE: 'OHIFDCM',
|
||||||
maxPackageSize: 32768,
|
maxPackageSize: 32768,
|
||||||
idle: 60,
|
idle: 60,
|
||||||
reconnect: true,
|
reconnect: true,
|
||||||
@ -56,50 +57,53 @@ Connection = function(socket, options) {
|
|||||||
|
|
||||||
//register hooks
|
//register hooks
|
||||||
var o = this;
|
var o = this;
|
||||||
this.socket.on("data", function(data) {
|
this.socket.on('data', function(data) {
|
||||||
o.received(data);
|
o.received(data);
|
||||||
});
|
});
|
||||||
this.socket.on("close", function(he) {
|
this.socket.on('close', function(he) {
|
||||||
o.closed(he);
|
o.closed(he);
|
||||||
o.emit("close", he);
|
o.emit('close', he);
|
||||||
});
|
});
|
||||||
this.socket.on("error", function(he) {
|
this.socket.on('error', function(he) {
|
||||||
o.error(he);
|
o.error(he);
|
||||||
});
|
});
|
||||||
this.socket.on("end", function() {
|
this.socket.on('end', function() {
|
||||||
if (o.intervalId) {
|
if (o.intervalId) {
|
||||||
clearInterval(o.intervalId);
|
clearInterval(o.intervalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.server) {
|
if (o.server) {
|
||||||
console.log("Closing server");
|
console.log('Closing server');
|
||||||
o.server.close();
|
o.server.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('ended');
|
console.log('ended');
|
||||||
})
|
});
|
||||||
this.on("released", function() {
|
this.on('released', function() {
|
||||||
this.released();
|
this.released();
|
||||||
});
|
});
|
||||||
this.on('aborted', function() {
|
this.on('aborted', function() {
|
||||||
this.released();
|
this.released();
|
||||||
})
|
});
|
||||||
this.on('message', function(pdvs) {
|
this.on('message', function(pdvs) {
|
||||||
this.receivedMessage(pdvs);
|
this.receivedMessage(pdvs);
|
||||||
});
|
});
|
||||||
this.on("init", this.ready);
|
this.on('init', this.ready);
|
||||||
|
|
||||||
//this.pause();
|
//this.pause();
|
||||||
if (this.options.listenHost && this.options.listenPort) {
|
if (this.options.listenHost && this.options.listenPort) {
|
||||||
this.server = net.createServer();
|
this.server = net.createServer();
|
||||||
this.server.listen(this.options.listenPort, this.options.listenHost);
|
this.server.listen(this.options.listenPort, this.options.listenHost);
|
||||||
this.server.on('listening', function() {
|
this.server.on('listening', function() {
|
||||||
console.log("listening on %j", this.address());
|
console.log('listening on %j', this.address());
|
||||||
});
|
});
|
||||||
this.server.on('connection', function(socket) {
|
this.server.on('connection', function(socket) {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.emit("init");
|
|
||||||
}
|
this.emit('init');
|
||||||
|
};
|
||||||
|
|
||||||
util.inherits(Connection, EventEmitter);
|
util.inherits(Connection, EventEmitter);
|
||||||
|
|
||||||
@ -129,7 +133,7 @@ Connection.prototype.getSoureceAE = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.ready = function() {
|
Connection.prototype.ready = function() {
|
||||||
console.log("Connection established");
|
console.log('Connection established');
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
this.started = time();
|
this.started = time();
|
||||||
|
|
||||||
@ -158,7 +162,7 @@ Connection.prototype.process = function(data) {
|
|||||||
//console.log("Data received");
|
//console.log("Data received");
|
||||||
if (this.receiving === null) {
|
if (this.receiving === null) {
|
||||||
if (this.minRecv) {
|
if (this.minRecv) {
|
||||||
data = Buffer.concat([this.minRecv, data], this.minRecv.length + data.length);
|
data = Buffer.concat([ this.minRecv, data ], this.minRecv.length + data.length);
|
||||||
this.minRecv = null;
|
this.minRecv = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,6 +186,7 @@ Connection.prototype.process = function(data) {
|
|||||||
process = data.slice(0, len + 6);
|
process = data.slice(0, len + 6);
|
||||||
remaining = data.slice(len + 6, cmp + 6);
|
remaining = data.slice(len + 6, cmp + 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetReceive();
|
this.resetReceive();
|
||||||
this.interpret(new ReadStream(process));
|
this.interpret(new ReadStream(process));
|
||||||
if (remaining) {
|
if (remaining) {
|
||||||
@ -189,7 +194,7 @@ Connection.prototype.process = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var newData = Buffer.concat([this.receiving, data], this.receiving.length + data.length),
|
var newData = Buffer.concat([ this.receiving, data ], this.receiving.length + data.length),
|
||||||
pduLength = newData.length - 6;
|
pduLength = newData.length - 6;
|
||||||
|
|
||||||
if (pduLength < this.receiveLength) {
|
if (pduLength < this.receiveLength) {
|
||||||
@ -200,6 +205,7 @@ Connection.prototype.process = function(data) {
|
|||||||
remaining = newData.slice(this.receiveLength + 6, pduLength + 6);
|
remaining = newData.slice(this.receiveLength + 6, pduLength + 6);
|
||||||
newData = newData.slice(0, this.receiveLength + 6);
|
newData = newData.slice(0, this.receiveLength + 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetReceive();
|
this.resetReceive();
|
||||||
this.interpret(new ReadStream(newData));
|
this.interpret(new ReadStream(newData));
|
||||||
if (remaining) {
|
if (remaining) {
|
||||||
@ -207,6 +213,7 @@ Connection.prototype.process = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -221,8 +228,9 @@ Connection.prototype.interpret = function(stream) {
|
|||||||
pdu.presentationContextItems.forEach(function(ctx) {
|
pdu.presentationContextItems.forEach(function(ctx) {
|
||||||
var requested = o.getContext(ctx.presentationContextID);
|
var requested = o.getContext(ctx.presentationContextID);
|
||||||
if (!requested) {
|
if (!requested) {
|
||||||
throw "Accepted presentation context not found";
|
throw 'Accepted presentation context not found';
|
||||||
}
|
}
|
||||||
|
|
||||||
o.negotiatedContexts[ctx.presentationContextID] = {
|
o.negotiatedContexts[ctx.presentationContextID] = {
|
||||||
id: ctx.presentationContextID,
|
id: ctx.presentationContextID,
|
||||||
transferSyntax: ctx.transferSyntaxesItems[0].transferSyntaxName,
|
transferSyntax: ctx.transferSyntaxesItems[0].transferSyntaxName,
|
||||||
@ -270,11 +278,13 @@ Connection.prototype.interpret = function(stream) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdvs[i].isLast) {
|
if (pdvs[i].isLast) {
|
||||||
this.emit('message', pdvs[i]);
|
this.emit('message', pdvs[i]);
|
||||||
} else {
|
} else {
|
||||||
this.pendingPDVs = [pdvs[i]];
|
this.pendingPDVs = [ pdvs[i] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
i = j;
|
i = j;
|
||||||
} else {
|
} else {
|
||||||
this.emit('message', pdvs[i++]);
|
this.emit('message', pdvs[i++]);
|
||||||
@ -287,17 +297,17 @@ Connection.prototype.interpret = function(stream) {
|
|||||||
|
|
||||||
Connection.prototype.newMessageId = function() {
|
Connection.prototype.newMessageId = function() {
|
||||||
return (++this.messageIdCounter) % 255;
|
return (++this.messageIdCounter) % 255;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.closed = function(had_error) {
|
Connection.prototype.closed = function(had_error) {
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
console.log("Connection closed", had_error);
|
console.log('Connection closed', had_error);
|
||||||
//this.destroy();
|
//this.destroy();
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.error = function(err) {
|
Connection.prototype.error = function(err) {
|
||||||
console.log("Error: ", err);
|
console.log('Error: ', err);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.send = function(pdu, afterCbk) {
|
Connection.prototype.send = function(pdu, afterCbk) {
|
||||||
//console.log('SEND PDU-TYPE: ', pdu.type);
|
//console.log('SEND PDU-TYPE: ', pdu.type);
|
||||||
@ -306,13 +316,13 @@ Connection.prototype.send = function(pdu, afterCbk) {
|
|||||||
this.socket.write(toSend, afterCbk ? afterCbk : function() {
|
this.socket.write(toSend, afterCbk ? afterCbk : function() {
|
||||||
//console.log('Data written');
|
//console.log('Data written');
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.getSyntax = function(contextId) {
|
Connection.prototype.getSyntax = function(contextId) {
|
||||||
if (!this.negotiatedContexts[contextId]) return null;
|
if (!this.negotiatedContexts[contextId]) return null;
|
||||||
|
|
||||||
return this.negotiatedContexts[contextId].transferSyntax;
|
return this.negotiatedContexts[contextId].transferSyntax;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.getContextByUID = function(uid) {
|
Connection.prototype.getContextByUID = function(uid) {
|
||||||
for (var k in this.negotiatedContexts) {
|
for (var k in this.negotiatedContexts) {
|
||||||
@ -321,22 +331,24 @@ Connection.prototype.getContextByUID = function(uid) {
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.getContextId = function(contextId) {
|
Connection.prototype.getContextId = function(contextId) {
|
||||||
if (!this.negotiatedContexts[contextId]) return null;
|
if (!this.negotiatedContexts[contextId]) return null;
|
||||||
|
|
||||||
return this.negotiatedContexts[contextId].id;
|
return this.negotiatedContexts[contextId].id;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.getContext = function(id) {
|
Connection.prototype.getContext = function(id) {
|
||||||
for (var k in this.presentationContexts) {
|
for (var k in this.presentationContexts) {
|
||||||
var ctx = this.presentationContexts[k];
|
var ctx = this.presentationContexts[k];
|
||||||
if (id == ctx.id) return ctx;
|
if (id == ctx.id) return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.setPresentationContexts = function(uids) {
|
Connection.prototype.setPresentationContexts = function(uids) {
|
||||||
var contexts = [],
|
var contexts = [],
|
||||||
@ -345,29 +357,29 @@ Connection.prototype.setPresentationContexts = function(uids) {
|
|||||||
contexts.push({
|
contexts.push({
|
||||||
id: ++id,
|
id: ++id,
|
||||||
abstractSyntax: uid,
|
abstractSyntax: uid,
|
||||||
transferSyntaxes: [C.IMPLICIT_LITTLE_ENDIAN, C.EXPLICIT_LITTLE_ENDIAN, C.EXPLICIT_BIG_ENDIAN]
|
transferSyntaxes: [ C.IMPLICIT_LITTLE_ENDIAN, C.EXPLICIT_LITTLE_ENDIAN, C.EXPLICIT_BIG_ENDIAN ]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.presentationContexts = contexts;
|
this.presentationContexts = contexts;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.verify = function() {
|
Connection.prototype.verify = function() {
|
||||||
this.setPresentationContexts([C.SOP_VERIFICATION]);
|
this.setPresentationContexts([ C.SOP_VERIFICATION ]);
|
||||||
this.startAssociationRequest(function() {
|
this.startAssociationRequest(function() {
|
||||||
//associated, we can release now
|
//associated, we can release now
|
||||||
this.release();
|
this.release();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.release = function() {
|
Connection.prototype.release = function() {
|
||||||
var releaseRQ = new ReleaseRQ();
|
var releaseRQ = new ReleaseRQ();
|
||||||
this.send(releaseRQ);
|
this.send(releaseRQ);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.addService = function(service) {
|
Connection.prototype.addService = function(service) {
|
||||||
service.setConnection(this);
|
service.setConnection(this);
|
||||||
this.services.push(service);
|
this.services.push(service);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.receivedMessage = function(pdv) {
|
Connection.prototype.receivedMessage = function(pdv) {
|
||||||
var syntax = this.getSyntax(pdv.contextId),
|
var syntax = this.getSyntax(pdv.contextId),
|
||||||
@ -380,9 +392,11 @@ Connection.prototype.receivedMessage = function(pdv) {
|
|||||||
if (msg.is(C.COMMAND_C_GET_RSP) || msg.is(C.COMMAND_C_MOVE_RSP)) {
|
if (msg.is(C.COMMAND_C_GET_RSP) || msg.is(C.COMMAND_C_MOVE_RSP)) {
|
||||||
//console.log('remaining', msg.getNumOfRemainingSubOperations(), msg.getNumOfCompletedSubOperations());
|
//console.log('remaining', msg.getNumOfRemainingSubOperations(), msg.getNumOfCompletedSubOperations());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.failure()) {
|
if (msg.failure()) {
|
||||||
//console.log("message failed with status ", msg.getStatus().toString(16));
|
//console.log("message failed with status ", msg.getStatus().toString(16));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.isFinal()) {
|
if (msg.isFinal()) {
|
||||||
var replyId = msg.respondedTo();
|
var replyId = msg.respondedTo();
|
||||||
if (this.messages[replyId].listener) {
|
if (this.messages[replyId].listener) {
|
||||||
@ -408,7 +422,7 @@ Connection.prototype.receivedMessage = function(pdv) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!this.lastCommand) {
|
if (!this.lastCommand) {
|
||||||
throw "Only dataset?";
|
throw 'Only dataset?';
|
||||||
} else if (!this.lastCommand.haveData()) {
|
} else if (!this.lastCommand.haveData()) {
|
||||||
throw "Last command didn't indicate presence of data";
|
throw "Last command didn't indicate presence of data";
|
||||||
}
|
}
|
||||||
@ -418,7 +432,7 @@ Connection.prototype.receivedMessage = function(pdv) {
|
|||||||
if (this.messages[replyId].listener) {
|
if (this.messages[replyId].listener) {
|
||||||
var flag = this.lastCommand.failure() ? true : false;
|
var flag = this.lastCommand.failure() ? true : false;
|
||||||
|
|
||||||
this.messages[replyId].listener.emit("result", msg, flag);
|
this.messages[replyId].listener.emit('result', msg, flag);
|
||||||
|
|
||||||
if (this.lastCommand.failure()) {
|
if (this.lastCommand.failure()) {
|
||||||
delete this.messages[replyId];
|
delete this.messages[replyId];
|
||||||
@ -434,14 +448,14 @@ Connection.prototype.receivedMessage = function(pdv) {
|
|||||||
if (this.lastGets.length > 0) {
|
if (this.lastGets.length > 0) {
|
||||||
useId = this.lastGets[0];
|
useId = this.lastGets[0];
|
||||||
} else {
|
} else {
|
||||||
throw "Where does this c-store came from?";
|
throw 'Where does this c-store came from?';
|
||||||
}
|
}
|
||||||
} else console.log('move ', moveMessageId);
|
} else console.log('move ', moveMessageId);
|
||||||
//this.storeResponse(useId, msg);
|
//this.storeResponse(useId, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.storeResponse = function(messageId, msg) {
|
Connection.prototype.storeResponse = function(messageId, msg) {
|
||||||
var rq = this.messages[messageId];
|
var rq = this.messages[messageId];
|
||||||
@ -456,10 +470,10 @@ Connection.prototype.storeResponse = function(messageId, msg) {
|
|||||||
replyMessage.setReplyMessageId(this.lastCommand.messageId);
|
replyMessage.setReplyMessageId(this.lastCommand.messageId);
|
||||||
this.sendMessage(replyMessage, null, null, storeSr);
|
this.sendMessage(replyMessage, null, null, storeSr);
|
||||||
} else {
|
} else {
|
||||||
throw "Missing store status";
|
throw 'Missing store status';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.sendMessage = function(context, command, dataset, listener) {
|
Connection.prototype.sendMessage = function(context, command, dataset, listener) {
|
||||||
var nContext = this.getContextByUID(context),
|
var nContext = this.getContextByUID(context),
|
||||||
@ -489,8 +503,9 @@ Connection.prototype.sendMessage = function(context, command, dataset, listener)
|
|||||||
if (command.is(C.COMMAND_C_GET_RQ)) {
|
if (command.is(C.COMMAND_C_GET_RQ)) {
|
||||||
this.lastGets.push(messageId);
|
this.lastGets.push(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
pdv.setMessage(command);
|
pdv.setMessage(command);
|
||||||
pdata.setPresentationDataValueItems([pdv]);
|
pdata.setPresentationDataValueItems([ pdv ]);
|
||||||
|
|
||||||
msgData.command = command;
|
msgData.command = command;
|
||||||
this.messages[messageId] = msgData;
|
this.messages[messageId] = msgData;
|
||||||
@ -507,9 +522,10 @@ Connection.prototype.sendMessage = function(context, command, dataset, listener)
|
|||||||
dPdv = new PresentationDataValueItem(cid);
|
dPdv = new PresentationDataValueItem(cid);
|
||||||
|
|
||||||
dPdv.setMessage(dataset);
|
dPdv.setMessage(dataset);
|
||||||
dsData.setPresentationDataValueItems([dPdv]);
|
dsData.setPresentationDataValueItems([ dPdv ]);
|
||||||
this.send(dsData);
|
this.send(dsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return msgData.listener;
|
return msgData.listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -517,6 +533,7 @@ Connection.prototype.associate = function(options, callback) {
|
|||||||
if (callback) {
|
if (callback) {
|
||||||
this.once('associated', callback);
|
this.once('associated', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.associated) {
|
if (this.associated) {
|
||||||
this.emit('associated');
|
this.emit('associated');
|
||||||
return;
|
return;
|
||||||
@ -525,7 +542,7 @@ Connection.prototype.associate = function(options, callback) {
|
|||||||
if (options.contexts) {
|
if (options.contexts) {
|
||||||
this.setPresentationContexts(options.contexts);
|
this.setPresentationContexts(options.contexts);
|
||||||
} else {
|
} else {
|
||||||
throw "No services attached";
|
throw 'No services attached';
|
||||||
}
|
}
|
||||||
|
|
||||||
var associateRQ = new AssociateRQ();
|
var associateRQ = new AssociateRQ();
|
||||||
@ -534,7 +551,7 @@ Connection.prototype.associate = function(options, callback) {
|
|||||||
associateRQ.setCallingAETitle(sourceAE);
|
associateRQ.setCallingAETitle(sourceAE);
|
||||||
associateRQ.setApplicationContextItem(new ApplicationContextItem());
|
associateRQ.setApplicationContextItem(new ApplicationContextItem());
|
||||||
|
|
||||||
var contextItems = []
|
var contextItems = [];
|
||||||
this.presentationContexts.forEach(function(context) {
|
this.presentationContexts.forEach(function(context) {
|
||||||
var contextItem = new PresentationContextItem(),
|
var contextItem = new PresentationContextItem(),
|
||||||
syntaxes = [];
|
syntaxes = [];
|
||||||
@ -563,12 +580,12 @@ Connection.prototype.associate = function(options, callback) {
|
|||||||
maxLengthItem.setMaximumLengthReceived(packageSize);
|
maxLengthItem.setMaximumLengthReceived(packageSize);
|
||||||
|
|
||||||
var userInfo = new UserInformationItem();
|
var userInfo = new UserInformationItem();
|
||||||
userInfo.setUserDataItems([maxLengthItem, classUIDItem, versionItem]);
|
userInfo.setUserDataItems([ maxLengthItem, classUIDItem, versionItem ]);
|
||||||
|
|
||||||
associateRQ.setUserInformationItem(userInfo);
|
associateRQ.setUserInformationItem(userInfo);
|
||||||
|
|
||||||
this.send(associateRQ);
|
this.send(associateRQ);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.wrapMessage = function(data) {
|
Connection.prototype.wrapMessage = function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -576,60 +593,60 @@ Connection.prototype.wrapMessage = function(data) {
|
|||||||
datasetMessage.setElements(data);
|
datasetMessage.setElements(data);
|
||||||
return datasetMessage;
|
return datasetMessage;
|
||||||
} else return data;
|
} else return data;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.setFindContext = function(ctx) {
|
Connection.prototype.setFindContext = function(ctx) {
|
||||||
this.findContext = ctx;
|
this.findContext = ctx;
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.find = function(params, callback) {
|
Connection.prototype.find = function(params, callback) {
|
||||||
return this.sendMessage(this.findContext, new CFindRQ(), this.wrapMessage(params), callback);
|
return this.sendMessage(this.findContext, new CFindRQ(), this.wrapMessage(params), callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.findPatients = function(params, callback) {
|
Connection.prototype.findPatients = function(params, callback) {
|
||||||
var sendParams = Object.assign({
|
var sendParams = Object.assign({
|
||||||
0x00080052: C.QUERY_RETRIEVE_LEVEL_PATIENT,
|
0x00080052: C.QUERY_RETRIEVE_LEVEL_PATIENT,
|
||||||
0x00100010: "",
|
0x00100010: '',
|
||||||
0x00100020: "",
|
0x00100020: '',
|
||||||
0x00100030: "",
|
0x00100030: '',
|
||||||
0x00100040: "",
|
0x00100040: '',
|
||||||
}, params);
|
}, params);
|
||||||
|
|
||||||
return this.find(sendParams, callback);
|
return this.find(sendParams, callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.findStudies = function(params, callback) {
|
Connection.prototype.findStudies = function(params, callback) {
|
||||||
var sendParams = Object.assign({
|
var sendParams = Object.assign({
|
||||||
0x00080052: C.QUERY_RETRIEVE_LEVEL_STUDY,
|
0x00080052: C.QUERY_RETRIEVE_LEVEL_STUDY,
|
||||||
0x00080020: "",
|
0x00080020: '',
|
||||||
0x00100010: "",
|
0x00100010: '',
|
||||||
0x00080061: "",
|
0x00080061: '',
|
||||||
0x0020000D: ""
|
0x0020000D: ''
|
||||||
}, params);
|
}, params);
|
||||||
|
|
||||||
return this.find(sendParams, callback);
|
return this.find(sendParams, callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.findSeries = function(params, callback) {
|
Connection.prototype.findSeries = function(params, callback) {
|
||||||
var sendParams = Object.assign({
|
var sendParams = Object.assign({
|
||||||
0x00080052: C.QUERY_RETRIEVE_LEVEL_SERIES,
|
0x00080052: C.QUERY_RETRIEVE_LEVEL_SERIES,
|
||||||
0x00080020: "",
|
0x00080020: '',
|
||||||
0x0020000E: "",
|
0x0020000E: '',
|
||||||
0x0008103E: "",
|
0x0008103E: '',
|
||||||
0x0020000D: ""
|
0x0020000D: ''
|
||||||
}, params);
|
}, params);
|
||||||
|
|
||||||
return this.find(sendParams, callback);
|
return this.find(sendParams, callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
Connection.prototype.findInstances = function(params, callback) {
|
Connection.prototype.findInstances = function(params, callback) {
|
||||||
var sendParams = Object.assign({
|
var sendParams = Object.assign({
|
||||||
0x00080052: C.QUERY_RETRIEVE_LEVEL_IMAGE,
|
0x00080052: C.QUERY_RETRIEVE_LEVEL_IMAGE,
|
||||||
0x00080020: "",
|
0x00080020: '',
|
||||||
0x0020000E: "",
|
0x0020000E: '',
|
||||||
0x0008103E: "",
|
0x0008103E: '',
|
||||||
0x0020000D: ""
|
0x0020000D: ''
|
||||||
}, params);
|
}, params);
|
||||||
|
|
||||||
return this.find(sendParams, callback);
|
return this.find(sendParams, callback);
|
||||||
}
|
};
|
||||||
|
|||||||
@ -34,14 +34,14 @@ DIMSE.associate = function(contexts, callback) {
|
|||||||
DIMSE.retrievePatients = function(params) {
|
DIMSE.retrievePatients = function(params) {
|
||||||
//var start = new Date();
|
//var start = new Date();
|
||||||
var future = new Future;
|
var future = new Future;
|
||||||
DIMSE.associate([C.SOP_PATIENT_ROOT_FIND], function(pdu) {
|
DIMSE.associate([ C.SOP_PATIENT_ROOT_FIND ], function(pdu) {
|
||||||
var defaultParams = {
|
var defaultParams = {
|
||||||
0x00100010: "",
|
0x00100010: '',
|
||||||
0x00100020: "",
|
0x00100020: '',
|
||||||
0x00100030: "",
|
0x00100030: '',
|
||||||
0x00100040: "",
|
0x00100040: '',
|
||||||
0x00101010: "",
|
0x00101010: '',
|
||||||
0x00101040: ""
|
0x00101040: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setFindContext(C.SOP_PATIENT_ROOT_FIND);
|
this.setFindContext(C.SOP_PATIENT_ROOT_FIND);
|
||||||
@ -68,18 +68,18 @@ DIMSE.retrievePatients = function(params) {
|
|||||||
DIMSE.retrieveStudies = function(params) {
|
DIMSE.retrieveStudies = function(params) {
|
||||||
//var start = new Date();
|
//var start = new Date();
|
||||||
var future = new Future;
|
var future = new Future;
|
||||||
DIMSE.associate([C.SOP_STUDY_ROOT_FIND], function(pdu) {
|
DIMSE.associate([ C.SOP_STUDY_ROOT_FIND ], function(pdu) {
|
||||||
var defaultParams = {
|
var defaultParams = {
|
||||||
0x0020000D: "",
|
0x0020000D: '',
|
||||||
0x00080060: "",
|
0x00080060: '',
|
||||||
0x00080005: "",
|
0x00080005: '',
|
||||||
0x00080020: "",
|
0x00080020: '',
|
||||||
0x00080030: "",
|
0x00080030: '',
|
||||||
0x00080090: "",
|
0x00080090: '',
|
||||||
0x00100010: "",
|
0x00100010: '',
|
||||||
0x00100020: "",
|
0x00100020: '',
|
||||||
0x00200010: "",
|
0x00200010: '',
|
||||||
0x00100030: ""
|
0x00100030: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setFindContext(C.SOP_STUDY_ROOT_FIND);
|
this.setFindContext(C.SOP_STUDY_ROOT_FIND);
|
||||||
@ -105,19 +105,19 @@ DIMSE.retrieveStudies = function(params) {
|
|||||||
|
|
||||||
DIMSE.retrieveSeries = function(studyInstanceUID, params) {
|
DIMSE.retrieveSeries = function(studyInstanceUID, params) {
|
||||||
var future = new Future;
|
var future = new Future;
|
||||||
DIMSE.associate([C.SOP_STUDY_ROOT_FIND], function(pdu) {
|
DIMSE.associate([ C.SOP_STUDY_ROOT_FIND ], function(pdu) {
|
||||||
var defaultParams = {
|
var defaultParams = {
|
||||||
0x0020000D: studyInstanceUID ? studyInstanceUID : "",
|
0x0020000D: studyInstanceUID ? studyInstanceUID : '',
|
||||||
0x00080005: "",
|
0x00080005: '',
|
||||||
0x00080020: "",
|
0x00080020: '',
|
||||||
0x00080030: "",
|
0x00080030: '',
|
||||||
0x00080090: "",
|
0x00080090: '',
|
||||||
0x00100010: "",
|
0x00100010: '',
|
||||||
0x00100020: "",
|
0x00100020: '',
|
||||||
0x00200010: "",
|
0x00200010: '',
|
||||||
0x0008103E: "",
|
0x0008103E: '',
|
||||||
0x0020000E: "",
|
0x0020000E: '',
|
||||||
0x00200011: ""
|
0x00200011: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setFindContext(C.SOP_STUDY_ROOT_FIND);
|
this.setFindContext(C.SOP_STUDY_ROOT_FIND);
|
||||||
@ -142,26 +142,26 @@ DIMSE.retrieveSeries = function(studyInstanceUID, params) {
|
|||||||
|
|
||||||
DIMSE.retrieveInstances = function(studyInstanceUID, seriesInstanceUID, params) {
|
DIMSE.retrieveInstances = function(studyInstanceUID, seriesInstanceUID, params) {
|
||||||
var future = new Future;
|
var future = new Future;
|
||||||
DIMSE.associate([C.SOP_STUDY_ROOT_FIND], function(pdu) {
|
DIMSE.associate([ C.SOP_STUDY_ROOT_FIND ], function(pdu) {
|
||||||
var defaultParams = {
|
var defaultParams = {
|
||||||
0x0020000D: studyInstanceUID ? studyInstanceUID : "",
|
0x0020000D: studyInstanceUID ? studyInstanceUID : '',
|
||||||
0x0020000E: (studyInstanceUID && seriesInstanceUID) ? seriesInstanceUID : "",
|
0x0020000E: (studyInstanceUID && seriesInstanceUID) ? seriesInstanceUID : '',
|
||||||
0x00080005: "",
|
0x00080005: '',
|
||||||
0x00080020: "",
|
0x00080020: '',
|
||||||
0x00080030: "",
|
0x00080030: '',
|
||||||
0x00080090: "",
|
0x00080090: '',
|
||||||
0x00100010: "",
|
0x00100010: '',
|
||||||
0x00100020: "",
|
0x00100020: '',
|
||||||
0x00200010: "",
|
0x00200010: '',
|
||||||
0x0008103E: "",
|
0x0008103E: '',
|
||||||
0x00200011: "",
|
0x00200011: '',
|
||||||
0x00080016: "",
|
0x00080016: '',
|
||||||
0x00080018: "",
|
0x00080018: '',
|
||||||
0x00200013: "",
|
0x00200013: '',
|
||||||
0x00280010: "",
|
0x00280010: '',
|
||||||
0x00280011: "",
|
0x00280011: '',
|
||||||
0x00280100: "",
|
0x00280100: '',
|
||||||
0x00280103: ""
|
0x00280103: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setFindContext(C.SOP_STUDY_ROOT_FIND);
|
this.setFindContext(C.SOP_STUDY_ROOT_FIND);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -5,30 +5,32 @@ Field = function(type, value) {
|
|||||||
|
|
||||||
Field.prototype.length = function() {
|
Field.prototype.length = function() {
|
||||||
return calcLength(this.type, this.value);
|
return calcLength(this.type, this.value);
|
||||||
}
|
};
|
||||||
|
|
||||||
Field.prototype.write = function(stream) {
|
Field.prototype.write = function(stream) {
|
||||||
stream.write(this.type, this.value);
|
stream.write(this.type, this.value);
|
||||||
}
|
};
|
||||||
|
|
||||||
Field.prototype.isNumeric = function() {
|
Field.prototype.isNumeric = function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
StringField = function(str) {
|
StringField = function(str) {
|
||||||
Field.call(this, C.TYPE_ASCII, typeof str == 'string' ? str : "");
|
Field.call(this, C.TYPE_ASCII, typeof str == 'string' ? str : '');
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(StringField, Field);
|
util.inherits(StringField, Field);
|
||||||
|
|
||||||
FilledField = function(value, length) {
|
FilledField = function(value, length) {
|
||||||
Field.call(this, C.TYPE_COMPOSITE, value);
|
Field.call(this, C.TYPE_COMPOSITE, value);
|
||||||
this.fillLength = length;
|
this.fillLength = length;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(FilledField, Field);
|
util.inherits(FilledField, Field);
|
||||||
|
|
||||||
FilledField.prototype.length = function() {
|
FilledField.prototype.length = function() {
|
||||||
return this.fillLength;
|
return this.fillLength;
|
||||||
}
|
};
|
||||||
|
|
||||||
FilledField.prototype.write = function(stream) {
|
FilledField.prototype.write = function(stream) {
|
||||||
var len = this.value.length;
|
var len = this.value.length;
|
||||||
@ -36,93 +38,104 @@ FilledField.prototype.write = function(stream) {
|
|||||||
if (len > 0)
|
if (len > 0)
|
||||||
stream.write(C.TYPE_ASCII, this.value);
|
stream.write(C.TYPE_ASCII, this.value);
|
||||||
var zeroLength = this.fillLength - len;
|
var zeroLength = this.fillLength - len;
|
||||||
stream.write(C.TYPE_HEX, "20".repeat(zeroLength));
|
stream.write(C.TYPE_HEX, '20'.repeat(zeroLength));
|
||||||
} else if (len == this.fillLength) {
|
} else if (len == this.fillLength) {
|
||||||
stream.write(C.TYPE_ASCII, this.value);
|
stream.write(C.TYPE_ASCII, this.value);
|
||||||
} else {
|
} else {
|
||||||
throw "Length mismatch";
|
throw 'Length mismatch';
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
HexField = function(hex) {
|
HexField = function(hex) {
|
||||||
Field.call(this, C.TYPE_HEX, hex);
|
Field.call(this, C.TYPE_HEX, hex);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(HexField, Field);
|
util.inherits(HexField, Field);
|
||||||
|
|
||||||
ReservedField = function(length) {
|
ReservedField = function(length) {
|
||||||
length = length || 1;
|
length = length || 1;
|
||||||
Field.call(this, C.TYPE_HEX, "00".repeat(length));
|
Field.call(this, C.TYPE_HEX, '00'.repeat(length));
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(ReservedField, Field);
|
util.inherits(ReservedField, Field);
|
||||||
|
|
||||||
UInt8Field = function(value) {
|
UInt8Field = function(value) {
|
||||||
Field.call(this, C.TYPE_UINT8, value);
|
Field.call(this, C.TYPE_UINT8, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(UInt8Field, Field);
|
util.inherits(UInt8Field, Field);
|
||||||
|
|
||||||
UInt8Field.prototype.isNumeric = function() {
|
UInt8Field.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
UInt16Field = function(value) {
|
UInt16Field = function(value) {
|
||||||
Field.call(this, C.TYPE_UINT16, value);
|
Field.call(this, C.TYPE_UINT16, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(UInt16Field, Field);
|
util.inherits(UInt16Field, Field);
|
||||||
|
|
||||||
UInt16Field.prototype.isNumeric = function() {
|
UInt16Field.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
UInt32Field = function(value) {
|
UInt32Field = function(value) {
|
||||||
Field.call(this, C.TYPE_UINT32, value);
|
Field.call(this, C.TYPE_UINT32, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(UInt32Field, Field);
|
util.inherits(UInt32Field, Field);
|
||||||
|
|
||||||
UInt32Field.prototype.isNumeric = function() {
|
UInt32Field.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
Int8Field = function(value) {
|
Int8Field = function(value) {
|
||||||
Field.call(this, C.TYPE_INT8, value);
|
Field.call(this, C.TYPE_INT8, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(Int8Field, Field);
|
util.inherits(Int8Field, Field);
|
||||||
|
|
||||||
Int8Field.prototype.isNumeric = function() {
|
Int8Field.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
Int16Field = function(value) {
|
Int16Field = function(value) {
|
||||||
Field.call(this, C.TYPE_INT16, value);
|
Field.call(this, C.TYPE_INT16, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(Int16Field, Field);
|
util.inherits(Int16Field, Field);
|
||||||
|
|
||||||
Int16Field.prototype.isNumeric = function() {
|
Int16Field.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
Int32Field = function(value) {
|
Int32Field = function(value) {
|
||||||
Field.call(this, C.TYPE_INT32, value);
|
Field.call(this, C.TYPE_INT32, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(Int32Field, Field);
|
util.inherits(Int32Field, Field);
|
||||||
|
|
||||||
Int32Field.prototype.isNumeric = function() {
|
Int32Field.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
FloatField = function(value) {
|
FloatField = function(value) {
|
||||||
Field.call(this, C.TYPE_FLOAT, value);
|
Field.call(this, C.TYPE_FLOAT, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(FloatField, Field);
|
util.inherits(FloatField, Field);
|
||||||
|
|
||||||
FloatField.prototype.isNumeric = function() {
|
FloatField.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
DoubleField = function(value) {
|
DoubleField = function(value) {
|
||||||
Field.call(this, C.TYPE_DOUBLE, value);
|
Field.call(this, C.TYPE_DOUBLE, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(DoubleField, Field);
|
util.inherits(DoubleField, Field);
|
||||||
|
|
||||||
DoubleField.prototype.isNumeric = function() {
|
DoubleField.prototype.isNumeric = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ DicomMessage = function(syntax) {
|
|||||||
|
|
||||||
DicomMessage.prototype.isCommand = function() {
|
DicomMessage.prototype.isCommand = function() {
|
||||||
return this.type == C.DATA_TYPE_COMMAND;
|
return this.type == C.DATA_TYPE_COMMAND;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setSyntax = function(syntax) {
|
DicomMessage.prototype.setSyntax = function(syntax) {
|
||||||
this.syntax = syntax;
|
this.syntax = syntax;
|
||||||
@ -15,15 +15,15 @@ DicomMessage.prototype.setSyntax = function(syntax) {
|
|||||||
for (var tag in this.elementPairs) {
|
for (var tag in this.elementPairs) {
|
||||||
this.elementPairs[tag].setSyntax(this.syntax);
|
this.elementPairs[tag].setSyntax(this.syntax);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setMessageId = function(id) {
|
DicomMessage.prototype.setMessageId = function(id) {
|
||||||
this.messageId = id;
|
this.messageId = id;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setReplyMessageId = function(id) {
|
DicomMessage.prototype.setReplyMessageId = function(id) {
|
||||||
this.replyMessageId = id;
|
this.replyMessageId = id;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.command = function(cmds) {
|
DicomMessage.prototype.command = function(cmds) {
|
||||||
cmds.unshift(this.newElement(0x00000800, this.dataSetPresent ? C.DATA_SET_PRESENT : C.DATE_SET_ABSENCE));
|
cmds.unshift(this.newElement(0x00000800, this.dataSetPresent ? C.DATA_SET_PRESENT : C.DATE_SET_ABSENCE));
|
||||||
@ -39,7 +39,7 @@ DicomMessage.prototype.command = function(cmds) {
|
|||||||
|
|
||||||
cmds.unshift(this.newElement(0x00000000, length));
|
cmds.unshift(this.newElement(0x00000000, length));
|
||||||
return cmds;
|
return cmds;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.response = function(cmds) {
|
DicomMessage.prototype.response = function(cmds) {
|
||||||
cmds.unshift(this.newElement(0x00000800, this.dataSetPresent ? C.DATA_SET_PRESENT : C.DATE_SET_ABSENCE));
|
cmds.unshift(this.newElement(0x00000800, this.dataSetPresent ? C.DATA_SET_PRESENT : C.DATE_SET_ABSENCE));
|
||||||
@ -54,145 +54,149 @@ DicomMessage.prototype.response = function(cmds) {
|
|||||||
|
|
||||||
cmds.unshift(this.newElement(0x00000000, length));
|
cmds.unshift(this.newElement(0x00000000, length));
|
||||||
return cmds;
|
return cmds;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setElements = function(pairs) {
|
DicomMessage.prototype.setElements = function(pairs) {
|
||||||
var p = {};
|
var p = {};
|
||||||
for (var tag in pairs) {
|
for (var tag in pairs) {
|
||||||
p[tag] = this.newElement(tag, pairs[tag]);
|
p[tag] = this.newElement(tag, pairs[tag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.elementPairs = p;
|
this.elementPairs = p;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.newElement = function(tag, value) {
|
DicomMessage.prototype.newElement = function(tag, value) {
|
||||||
return elementByType(tag, value, this.syntax);
|
return elementByType(tag, value, this.syntax);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setElement = function(key, value) {
|
DicomMessage.prototype.setElement = function(key, value) {
|
||||||
this.elementPairs[key] = elementByType(key, value);
|
this.elementPairs[key] = elementByType(key, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setElementPairs = function(pairs) {
|
DicomMessage.prototype.setElementPairs = function(pairs) {
|
||||||
this.elementPairs = pairs;
|
this.elementPairs = pairs;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setContextId = function(context) {
|
DicomMessage.prototype.setContextId = function(context) {
|
||||||
this.contextUID = context;
|
this.contextUID = context;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setPriority = function(pri) {
|
DicomMessage.prototype.setPriority = function(pri) {
|
||||||
this.priority = pri;
|
this.priority = pri;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setType = function(type) {
|
DicomMessage.prototype.setType = function(type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.setDataSetPresent = function(present) {
|
DicomMessage.prototype.setDataSetPresent = function(present) {
|
||||||
this.dataSetPresent = present == 0x0101 ? false : true;
|
this.dataSetPresent = present == 0x0101 ? false : true;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.haveData = function() {
|
DicomMessage.prototype.haveData = function() {
|
||||||
return this.dataSetPresent;
|
return this.dataSetPresent;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.tags = function() {
|
DicomMessage.prototype.tags = function() {
|
||||||
return Object.keys(this.elementPairs);
|
return Object.keys(this.elementPairs);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.key = function(tag) {
|
DicomMessage.prototype.key = function(tag) {
|
||||||
return elementKeywordByTag(tag);
|
return elementKeywordByTag(tag);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.getValue = function(tag) {
|
DicomMessage.prototype.getValue = function(tag) {
|
||||||
return this.elementPairs[tag] ? this.elementPairs[tag].getValue() : null;
|
return this.elementPairs[tag] ? this.elementPairs[tag].getValue() : null;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.affectedSOPClassUID = function() {
|
DicomMessage.prototype.affectedSOPClassUID = function() {
|
||||||
return this.getValue(0x00000002);
|
return this.getValue(0x00000002);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.getMessageId = function() {
|
DicomMessage.prototype.getMessageId = function() {
|
||||||
return this.getValue(0x00000110);
|
return this.getValue(0x00000110);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.getFields = function() {
|
DicomMessage.prototype.getFields = function() {
|
||||||
var eles = [];
|
var eles = [];
|
||||||
for (var tag in this.elementPairs) {
|
for (var tag in this.elementPairs) {
|
||||||
eles.push(this.elementPairs[tag]);
|
eles.push(this.elementPairs[tag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return eles;
|
return eles;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.length = function(elems) {
|
DicomMessage.prototype.length = function(elems) {
|
||||||
var len = 0;
|
var len = 0;
|
||||||
elems.forEach(function(elem){
|
elems.forEach(function(elem) {
|
||||||
len += elem.length(elem.getFields());
|
len += elem.length(elem.getFields());
|
||||||
});
|
});
|
||||||
return len;
|
return len;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.isResponse = function() {
|
DicomMessage.prototype.isResponse = function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.is = function(type) {
|
DicomMessage.prototype.is = function(type) {
|
||||||
return this.commandType == type;
|
return this.commandType == type;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.write = function(stream) {
|
DicomMessage.prototype.write = function(stream) {
|
||||||
var fields = this.getFields(), o = this;
|
var fields = this.getFields(), o = this;
|
||||||
fields.forEach(function(field){
|
fields.forEach(function(field) {
|
||||||
field.setSyntax(o.syntax);
|
field.setSyntax(o.syntax);
|
||||||
field.write(stream);
|
field.write(stream);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.printElements = function(pairs, indent) {
|
DicomMessage.prototype.printElements = function(pairs, indent) {
|
||||||
var typeName = "";
|
var typeName = '';
|
||||||
for (var tag in pairs) {
|
for (var tag in pairs) {
|
||||||
var value = pairs[tag].getValue();
|
var value = pairs[tag].getValue();
|
||||||
typeName += (" ".repeat(indent)) + this.key(tag) + " : ";
|
typeName += (' '.repeat(indent)) + this.key(tag) + ' : ';
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
var o = this;
|
var o = this;
|
||||||
value.forEach(function(p) {
|
value.forEach(function(p) {
|
||||||
if (typeof p == "object") {
|
if (typeof p == 'object') {
|
||||||
typeName += "[\n" + o.printElements(p, indent + 2) + (" ".repeat(indent)) + "]";
|
typeName += '[\n' + o.printElements(p, indent + 2) + (' '.repeat(indent)) + ']';
|
||||||
} else {
|
} else {
|
||||||
typeName += "[" + p + "]";
|
typeName += '[' + p + ']';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (typeName[typeName.length-1] != "\n") {
|
if (typeName[typeName.length - 1] != '\n') {
|
||||||
typeName += "\n";
|
typeName += '\n';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
typeName += value + "\n";
|
typeName += value + '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return typeName;
|
return typeName;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.toString = function() {
|
DicomMessage.prototype.toString = function() {
|
||||||
var typeName = "";
|
var typeName = '';
|
||||||
if (!this.isCommand()) {
|
if (!this.isCommand()) {
|
||||||
typeName = "DateSet Message";
|
typeName = 'DateSet Message';
|
||||||
} else {
|
} else {
|
||||||
switch (this.commandType) {
|
switch (this.commandType) {
|
||||||
case C.COMMAND_C_GET_RSP : typeName = "C-GET-RSP"; break;
|
case C.COMMAND_C_GET_RSP : typeName = 'C-GET-RSP'; break;
|
||||||
case C.COMMAND_C_MOVE_RSP : typeName = "C-MOVE-RSP"; break;
|
case C.COMMAND_C_MOVE_RSP : typeName = 'C-MOVE-RSP'; break;
|
||||||
case C.COMMAND_C_GET_RQ : typeName = "C-GET-RQ"; break;
|
case C.COMMAND_C_GET_RQ : typeName = 'C-GET-RQ'; break;
|
||||||
case C.COMMAND_C_STORE_RQ : typeName = "C-STORE-RQ"; break;
|
case C.COMMAND_C_STORE_RQ : typeName = 'C-STORE-RQ'; break;
|
||||||
case C.COMMAND_C_FIND_RSP : typeName = "C-FIND-RSP"; break;
|
case C.COMMAND_C_FIND_RSP : typeName = 'C-FIND-RSP'; break;
|
||||||
case C.COMMAND_C_MOVE_RQ : typeName = "C-MOVE-RQ"; break;
|
case C.COMMAND_C_MOVE_RQ : typeName = 'C-MOVE-RQ'; break;
|
||||||
case C.COMMAND_C_FIND_RQ : typeName = "C-FIND-RQ"; break;
|
case C.COMMAND_C_FIND_RQ : typeName = 'C-FIND-RQ'; break;
|
||||||
case C.COMMAND_C_STORE_RSP : typeName = "C-STORE-RSP"; break;
|
case C.COMMAND_C_STORE_RSP : typeName = 'C-STORE-RSP'; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typeName += " [\n";
|
|
||||||
|
typeName += ' [\n';
|
||||||
typeName += this.printElements(this.elementPairs, 0);
|
typeName += this.printElements(this.elementPairs, 0);
|
||||||
typeName += "]";
|
typeName += ']';
|
||||||
return typeName;
|
return typeName;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.walkObject = function(pairs) {
|
DicomMessage.prototype.walkObject = function(pairs) {
|
||||||
var obj = {}, o = this;
|
var obj = {}, o = this;
|
||||||
@ -206,15 +210,16 @@ DicomMessage.prototype.walkObject = function(pairs) {
|
|||||||
} else u.push(a);
|
} else u.push(a);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
obj[tag] = u;
|
obj[tag] = u;
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.toObject = function() {
|
DicomMessage.prototype.toObject = function() {
|
||||||
return this.walkObject(this.elementPairs);
|
return this.walkObject(this.elementPairs);
|
||||||
}
|
};
|
||||||
|
|
||||||
readMessage = function(stream, type, syntax, options) {
|
readMessage = function(stream, type, syntax, options) {
|
||||||
var elements = [], pairs = {}, useSyntax = type == C.DATA_TYPE_COMMAND ? C.IMPLICIT_LITTLE_ENDIAN : syntax;
|
var elements = [], pairs = {}, useSyntax = type == C.DATA_TYPE_COMMAND ? C.IMPLICIT_LITTLE_ENDIAN : syntax;
|
||||||
@ -224,6 +229,7 @@ readMessage = function(stream, type, syntax, options) {
|
|||||||
if (options) {
|
if (options) {
|
||||||
elem.setOptions(options);
|
elem.setOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.setSyntax(useSyntax);
|
elem.setSyntax(useSyntax);
|
||||||
elem.readBytes(stream);//return;
|
elem.readBytes(stream);//return;
|
||||||
pairs[elem.tag.value] = elem;
|
pairs[elem.tag.value] = elem;
|
||||||
@ -239,7 +245,7 @@ readMessage = function(stream, type, syntax, options) {
|
|||||||
case 0x8010 : message = new CGetRSP(useSyntax); break;
|
case 0x8010 : message = new CGetRSP(useSyntax); break;
|
||||||
case 0x0001 : message = new CStoreRQ(useSyntax); break;
|
case 0x0001 : message = new CStoreRQ(useSyntax); break;
|
||||||
case 0x0020 : message = new CFindRQ(useSyntax); break;
|
case 0x0020 : message = new CFindRQ(useSyntax); break;
|
||||||
default : throw "Unrecognized command type " + cmdType.toString(16); break;
|
default : throw 'Unrecognized command type ' + cmdType.toString(16); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.setElementPairs(pairs);
|
message.setElementPairs(pairs);
|
||||||
@ -254,121 +260,128 @@ readMessage = function(stream, type, syntax, options) {
|
|||||||
message = new DataSetMessage(useSyntax);
|
message = new DataSetMessage(useSyntax);
|
||||||
message.setElementPairs(pairs);
|
message.setElementPairs(pairs);
|
||||||
} else {
|
} else {
|
||||||
throw "Unrecognized message type";
|
throw 'Unrecognized message type';
|
||||||
}
|
}
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataSetMessage = function(syntax){
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
|
DataSetMessage = function(syntax) {
|
||||||
DicomMessage.call(this, syntax);
|
DicomMessage.call(this, syntax);
|
||||||
this.type = C.DATA_TYPE_DATA;
|
this.type = C.DATA_TYPE_DATA;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(DataSetMessage, DicomMessage);
|
util.inherits(DataSetMessage, DicomMessage);
|
||||||
|
|
||||||
DataSetMessage.prototype.is = function(type) {
|
DataSetMessage.prototype.is = function(type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandMessage = function(syntax) {
|
CommandMessage = function(syntax) {
|
||||||
DicomMessage.call(this, syntax);
|
DicomMessage.call(this, syntax);
|
||||||
this.type = C.DATA_TYPE_COMMAND;
|
this.type = C.DATA_TYPE_COMMAND;
|
||||||
this.priority = C.PRIORITY_MEDIUM;
|
this.priority = C.PRIORITY_MEDIUM;
|
||||||
this.dataSetPresent = true;
|
this.dataSetPresent = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(CommandMessage, DicomMessage);
|
util.inherits(CommandMessage, DicomMessage);
|
||||||
|
|
||||||
CommandMessage.prototype.getFields = function() {
|
CommandMessage.prototype.getFields = function() {
|
||||||
return this.command(CommandMessage.super_.prototype.getFields.call(this));
|
return this.command(CommandMessage.super_.prototype.getFields.call(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse = function(syntax) {
|
CommandResponse = function(syntax) {
|
||||||
DicomMessage.call(this, syntax);
|
DicomMessage.call(this, syntax);
|
||||||
this.type = C.DATA_TYPE_COMMAND;
|
this.type = C.DATA_TYPE_COMMAND;
|
||||||
this.dataSetPresent = true;
|
this.dataSetPresent = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CommandResponse, DicomMessage);
|
util.inherits(CommandResponse, DicomMessage);
|
||||||
|
|
||||||
CommandResponse.prototype.isResponse = function() {
|
CommandResponse.prototype.isResponse = function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.respondedTo = function() {
|
CommandResponse.prototype.respondedTo = function() {
|
||||||
return this.getValue(0x00000120);
|
return this.getValue(0x00000120);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.isFinal = function() {
|
CommandResponse.prototype.isFinal = function() {
|
||||||
return this.success() || this.failure() || this.cancel();
|
return this.success() || this.failure() || this.cancel();
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.warning = function() {
|
CommandResponse.prototype.warning = function() {
|
||||||
var status = this.getStatus();
|
var status = this.getStatus();
|
||||||
return (status == 0x0001) || (status >> 12 == 0xb);
|
return (status == 0x0001) || (status >> 12 == 0xb);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.success = function() {
|
CommandResponse.prototype.success = function() {
|
||||||
return this.getStatus() == 0x0000;
|
return this.getStatus() == 0x0000;
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.failure = function() {
|
CommandResponse.prototype.failure = function() {
|
||||||
var status = this.getStatus();
|
var status = this.getStatus();
|
||||||
return (status >> 12 == 0xa) || (status >> 12 == 0xc) || (status >> 8 == 0x1)
|
return (status >> 12 == 0xa) || (status >> 12 == 0xc) || (status >> 8 == 0x1);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.cancel = function() {
|
CommandResponse.prototype.cancel = function() {
|
||||||
return this.getStatus() == C.STATUS_CANCEL;
|
return this.getStatus() == C.STATUS_CANCEL;
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.pending = function() {
|
CommandResponse.prototype.pending = function() {
|
||||||
var status = this.getStatus();
|
var status = this.getStatus();
|
||||||
return (status == 0xff00) || (status == 0xff01);
|
return (status == 0xff00) || (status == 0xff01);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.getStatus = function() {
|
CommandResponse.prototype.getStatus = function() {
|
||||||
return this.getValue(0x00000900);
|
return this.getValue(0x00000900);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.setStatus = function(status) {
|
CommandResponse.prototype.setStatus = function(status) {
|
||||||
this.setElement(0x00000900, status);
|
this.setElement(0x00000900, status);
|
||||||
}
|
};
|
||||||
|
|
||||||
// following four methods only available to C-GET-RSP and C-MOVE-RSP
|
// following four methods only available to C-GET-RSP and C-MOVE-RSP
|
||||||
CommandResponse.prototype.getNumOfRemainingSubOperations = function() {
|
CommandResponse.prototype.getNumOfRemainingSubOperations = function() {
|
||||||
return this.getValue(0x00001020);
|
return this.getValue(0x00001020);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.getNumOfCompletedSubOperations = function() {
|
CommandResponse.prototype.getNumOfCompletedSubOperations = function() {
|
||||||
return this.getValue(0x00001021);
|
return this.getValue(0x00001021);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.getNumOfFailedSubOperations = function() {
|
CommandResponse.prototype.getNumOfFailedSubOperations = function() {
|
||||||
return this.getValue(0x00001022);
|
return this.getValue(0x00001022);
|
||||||
}
|
};
|
||||||
|
|
||||||
CommandResponse.prototype.getNumOfWarningSubOperations = function() {
|
CommandResponse.prototype.getNumOfWarningSubOperations = function() {
|
||||||
return this.getValue(0x00001023);
|
return this.getValue(0x00001023);
|
||||||
}
|
};
|
||||||
//end
|
//end
|
||||||
|
|
||||||
CommandResponse.prototype.getFields = function() {
|
CommandResponse.prototype.getFields = function() {
|
||||||
return this.response(CommandResponse.super_.prototype.getFields.call(this));
|
return this.response(CommandResponse.super_.prototype.getFields.call(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
CFindRSP = function(syntax) {
|
CFindRSP = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
this.commandType = 0x8020;
|
this.commandType = 0x8020;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CFindRSP, CommandResponse);
|
util.inherits(CFindRSP, CommandResponse);
|
||||||
|
|
||||||
CGetRSP = function(syntax) {
|
CGetRSP = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
this.commandType = 0x8010;
|
this.commandType = 0x8010;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CGetRSP, CommandResponse);
|
util.inherits(CGetRSP, CommandResponse);
|
||||||
|
|
||||||
CMoveRSP = function(syntax) {
|
CMoveRSP = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
this.commandType = 0x8021;
|
this.commandType = 0x8021;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CMoveRSP, CommandResponse);
|
util.inherits(CMoveRSP, CommandResponse);
|
||||||
|
|
||||||
CFindRQ = function(syntax) {
|
CFindRQ = function(syntax) {
|
||||||
@ -376,25 +389,27 @@ CFindRQ = function(syntax) {
|
|||||||
this.commandType = 0x20;
|
this.commandType = 0x20;
|
||||||
this.contextUID = C.SOP_STUDY_ROOT_FIND;
|
this.contextUID = C.SOP_STUDY_ROOT_FIND;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CFindRQ, CommandMessage);
|
util.inherits(CFindRQ, CommandMessage);
|
||||||
|
|
||||||
CMoveRQ = function(syntax, destination) {
|
CMoveRQ = function(syntax, destination) {
|
||||||
CommandMessage.call(this, syntax);
|
CommandMessage.call(this, syntax);
|
||||||
this.commandType = 0x21;
|
this.commandType = 0x21;
|
||||||
this.contextUID = C.SOP_STUDY_ROOT_MOVE;
|
this.contextUID = C.SOP_STUDY_ROOT_MOVE;
|
||||||
this.setDestination(destination || "");
|
this.setDestination(destination || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CMoveRQ, CommandMessage);
|
util.inherits(CMoveRQ, CommandMessage);
|
||||||
|
|
||||||
CMoveRQ.prototype.setStore = function(cstr) {
|
CMoveRQ.prototype.setStore = function(cstr) {
|
||||||
this.store = cstr;
|
this.store = cstr;
|
||||||
}
|
};
|
||||||
|
|
||||||
CMoveRQ.prototype.setDestination = function(dest) {
|
CMoveRQ.prototype.setDestination = function(dest) {
|
||||||
this.setElements({
|
this.setElements({
|
||||||
0x00000600 : dest
|
0x00000600: dest
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
CGetRQ = function(syntax) {
|
CGetRQ = function(syntax) {
|
||||||
CommandMessage.call(this, syntax);
|
CommandMessage.call(this, syntax);
|
||||||
@ -402,30 +417,32 @@ CGetRQ = function(syntax) {
|
|||||||
this.contextUID = C.SOP_STUDY_ROOT_GET;
|
this.contextUID = C.SOP_STUDY_ROOT_GET;
|
||||||
this.store = null;
|
this.store = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CGetRQ, CommandMessage);
|
util.inherits(CGetRQ, CommandMessage);
|
||||||
|
|
||||||
CGetRQ.prototype.setStore = function(cstr) {
|
CGetRQ.prototype.setStore = function(cstr) {
|
||||||
this.store = cstr;
|
this.store = cstr;
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRQ = function(syntax) {
|
CStoreRQ = function(syntax) {
|
||||||
CommandMessage.call(this, syntax);
|
CommandMessage.call(this, syntax);
|
||||||
this.commandType = 0x01;
|
this.commandType = 0x01;
|
||||||
this.contextUID = C.SOP_STUDY_ROOT_GET;
|
this.contextUID = C.SOP_STUDY_ROOT_GET;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CStoreRQ, CommandMessage);
|
util.inherits(CStoreRQ, CommandMessage);
|
||||||
|
|
||||||
CStoreRQ.prototype.getOriginAETitle = function() {
|
CStoreRQ.prototype.getOriginAETitle = function() {
|
||||||
return this.getValue(0x00001030);
|
return this.getValue(0x00001030);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRQ.prototype.getMoveMessageId = function() {
|
CStoreRQ.prototype.getMoveMessageId = function() {
|
||||||
return this.getValue(0x00001031);
|
return this.getValue(0x00001031);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRQ.prototype.getSOPInstanceUID = function() {
|
CStoreRQ.prototype.getSOPInstanceUID = function() {
|
||||||
return this.getValue(0x00001000);
|
return this.getValue(0x00001000);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRSP = function(syntax) {
|
CStoreRSP = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
@ -433,12 +450,14 @@ CStoreRSP = function(syntax) {
|
|||||||
this.contextUID = C.SOP_STUDY_ROOT_GET;
|
this.contextUID = C.SOP_STUDY_ROOT_GET;
|
||||||
this.dataSetPresent = false;
|
this.dataSetPresent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CStoreRSP, CommandResponse);
|
util.inherits(CStoreRSP, CommandResponse);
|
||||||
|
|
||||||
CStoreRSP.prototype.setAffectedSOPInstanceUID = function(uid) {
|
CStoreRSP.prototype.setAffectedSOPInstanceUID = function(uid) {
|
||||||
this.setElement(0x00001000, uid);
|
this.setElement(0x00001000, uid);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRSP.prototype.getAffectedSOPInstanceUID = function(uid) {
|
CStoreRSP.prototype.getAffectedSOPInstanceUID = function(uid) {
|
||||||
return this.getValue(0x00001000);
|
return this.getValue(0x00001000);
|
||||||
}
|
};
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
PDU = function() {
|
PDU = function() {
|
||||||
this.fields = [];
|
this.fields = [];
|
||||||
this.lengthBytes = 4;
|
this.lengthBytes = 4;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.length = function(fields) {
|
PDU.prototype.length = function(fields) {
|
||||||
var len = 0;
|
var len = 0;
|
||||||
@ -9,11 +9,11 @@ PDU.prototype.length = function(fields) {
|
|||||||
len += !f.getFields ? f.length() : f.length(f.getFields());
|
len += !f.getFields ? f.length() : f.length(f.getFields());
|
||||||
});
|
});
|
||||||
return len;
|
return len;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.is = function(type) {
|
PDU.prototype.is = function(type) {
|
||||||
return this.type == type;
|
return this.type == type;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.getFields = function(fields) {
|
PDU.prototype.getFields = function(fields) {
|
||||||
var len = this.lengthField(fields);
|
var len = this.lengthField(fields);
|
||||||
@ -24,7 +24,7 @@ PDU.prototype.getFields = function(fields) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.lengthField = function(fields) {
|
PDU.prototype.lengthField = function(fields) {
|
||||||
if (this.lengthBytes == 4) {
|
if (this.lengthBytes == 4) {
|
||||||
@ -32,19 +32,19 @@ PDU.prototype.lengthField = function(fields) {
|
|||||||
} else if (this.lengthBytes == 2) {
|
} else if (this.lengthBytes == 2) {
|
||||||
return new UInt16Field(this.length(fields));
|
return new UInt16Field(this.length(fields));
|
||||||
} else {
|
} else {
|
||||||
throw "Invalid length bytes";
|
throw 'Invalid length bytes';
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.read = function(stream) {
|
PDU.prototype.read = function(stream) {
|
||||||
stream.read(C.TYPE_HEX, 1);
|
stream.read(C.TYPE_HEX, 1);
|
||||||
var length = stream.read(C.TYPE_UINT32);
|
var length = stream.read(C.TYPE_UINT32);
|
||||||
this.readBytes(stream, length);
|
this.readBytes(stream, length);
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.load = function(stream) {
|
PDU.prototype.load = function(stream) {
|
||||||
return pduByStream(stream);
|
return pduByStream(stream);
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.loadPDV = function(stream, length) {
|
PDU.prototype.loadPDV = function(stream, length) {
|
||||||
if (stream.end()) return false;
|
if (stream.end()) return false;
|
||||||
@ -59,32 +59,32 @@ PDU.prototype.loadPDV = function(stream, length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return pdvs;
|
return pdvs;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.loadDicomMessage = function(stream, isCommand, isLast) {
|
PDU.prototype.loadDicomMessage = function(stream, isCommand, isLast) {
|
||||||
var message = readMessage(stream, isCommand, isLast);
|
var message = readMessage(stream, isCommand, isLast);
|
||||||
return message;
|
return message;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.stream = function() {
|
PDU.prototype.stream = function() {
|
||||||
var stream = new WriteStream(),
|
var stream = new WriteStream(),
|
||||||
fields = this.getFields();
|
fields = this.getFields();
|
||||||
|
|
||||||
// writing to buffer
|
// writing to buffer
|
||||||
fields.forEach(function(field){
|
fields.forEach(function(field) {
|
||||||
field.write(stream);
|
field.write(stream);
|
||||||
});
|
});
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
};
|
||||||
|
|
||||||
PDU.prototype.buffer = function() {
|
PDU.prototype.buffer = function() {
|
||||||
return this.stream().buffer();
|
return this.stream().buffer();
|
||||||
}
|
};
|
||||||
|
|
||||||
var interpretCommand = function(stream, isLast) {
|
var interpretCommand = function(stream, isLast) {
|
||||||
parseDicomMessage(stream);
|
parseDicomMessage(stream);
|
||||||
}
|
};
|
||||||
|
|
||||||
mergePDVs = function(pdvs) {
|
mergePDVs = function(pdvs) {
|
||||||
var merges = [], count = pdvs.length, i = 0;
|
var merges = [], count = pdvs.length, i = 0;
|
||||||
@ -94,14 +94,16 @@ mergePDVs = function(pdvs) {
|
|||||||
while (!pdvs[j++].isLast && j < count) {
|
while (!pdvs[j++].isLast && j < count) {
|
||||||
pdvs[i].messageStream.concat(pdvs[j].messageStream);
|
pdvs[i].messageStream.concat(pdvs[j].messageStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
merges.push(pdvs[i]);
|
merges.push(pdvs[i]);
|
||||||
i = j;
|
i = j;
|
||||||
} else {
|
} else {
|
||||||
merges.push(pdvs[i++]);
|
merges.push(pdvs[i++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return merges;
|
return merges;
|
||||||
}
|
};
|
||||||
|
|
||||||
pduByStream = function(stream) {
|
pduByStream = function(stream) {
|
||||||
if (stream.end()) return null;
|
if (stream.end()) return null;
|
||||||
@ -123,13 +125,13 @@ pduByStream = function(stream) {
|
|||||||
case 0x51 : pdu = new MaximumLengthItem(); break;
|
case 0x51 : pdu = new MaximumLengthItem(); break;
|
||||||
case 0x52 : pdu = new ImplementationClassUIDItem(); break;
|
case 0x52 : pdu = new ImplementationClassUIDItem(); break;
|
||||||
case 0x55 : pdu = new ImplementationVersionNameItem(); break;
|
case 0x55 : pdu = new ImplementationVersionNameItem(); break;
|
||||||
default : throw "Unrecoginized pdu type " + pduType; break;
|
default : throw 'Unrecoginized pdu type ' + pduType; break;
|
||||||
}
|
}
|
||||||
if (pdu)
|
if (pdu)
|
||||||
pdu.read(stream);
|
pdu.read(stream);
|
||||||
|
|
||||||
return pdu;
|
return pdu;
|
||||||
}
|
};
|
||||||
|
|
||||||
var nextItemIs = function(stream, pduType) {
|
var nextItemIs = function(stream, pduType) {
|
||||||
if (stream.end()) return false;
|
if (stream.end()) return false;
|
||||||
@ -137,47 +139,48 @@ var nextItemIs = function(stream, pduType) {
|
|||||||
var nextType = stream.read(C.TYPE_HEX, 1);
|
var nextType = stream.read(C.TYPE_HEX, 1);
|
||||||
stream.increment(-1);
|
stream.increment(-1);
|
||||||
return pduType == nextType;
|
return pduType == nextType;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ = function() {
|
AssociateRQ = function() {
|
||||||
PDU.call(this);
|
PDU.call(this);
|
||||||
this.type = C.ITEM_TYPE_PDU_ASSOCIATE_RQ;
|
this.type = C.ITEM_TYPE_PDU_ASSOCIATE_RQ;
|
||||||
this.protocolVersion = 1;
|
this.protocolVersion = 1;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(AssociateRQ, PDU);
|
util.inherits(AssociateRQ, PDU);
|
||||||
|
|
||||||
AssociateRQ.prototype.setProtocolVersion = function(version) {
|
AssociateRQ.prototype.setProtocolVersion = function(version) {
|
||||||
this.protocolVersion = version;
|
this.protocolVersion = version;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.setCalledAETitle = function(title) {
|
AssociateRQ.prototype.setCalledAETitle = function(title) {
|
||||||
this.calledAETitle = title;
|
this.calledAETitle = title;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.setCallingAETitle = function(title) {
|
AssociateRQ.prototype.setCallingAETitle = function(title) {
|
||||||
this.callingAETitle = title;
|
this.callingAETitle = title;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.setApplicationContextItem = function(item) {
|
AssociateRQ.prototype.setApplicationContextItem = function(item) {
|
||||||
this.applicationContextItem = item;
|
this.applicationContextItem = item;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.setPresentationContextItems = function(items) {
|
AssociateRQ.prototype.setPresentationContextItems = function(items) {
|
||||||
this.presentationContextItems = items;
|
this.presentationContextItems = items;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.setUserInformationItem = function(item) {
|
AssociateRQ.prototype.setUserInformationItem = function(item) {
|
||||||
this.userInformationItem = item;
|
this.userInformationItem = item;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.allAccepted = function() {
|
AssociateRQ.prototype.allAccepted = function() {
|
||||||
for (var i in this.presentationContextItems) {
|
for (var i in this.presentationContextItems) {
|
||||||
var item = this.presentationContextItems[i];
|
var item = this.presentationContextItems[i];
|
||||||
if (!item.accepted()) return false;
|
if (!item.accepted()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.getFields = function() {
|
AssociateRQ.prototype.getFields = function() {
|
||||||
var f = [
|
var f = [
|
||||||
@ -185,12 +188,12 @@ AssociateRQ.prototype.getFields = function() {
|
|||||||
new FilledField(this.calledAETitle, 16), new FilledField(this.callingAETitle, 16),
|
new FilledField(this.calledAETitle, 16), new FilledField(this.callingAETitle, 16),
|
||||||
new ReservedField(32), this.applicationContextItem
|
new ReservedField(32), this.applicationContextItem
|
||||||
];
|
];
|
||||||
this.presentationContextItems.forEach(function(context){
|
this.presentationContextItems.forEach(function(context) {
|
||||||
f.push(context);
|
f.push(context);
|
||||||
});
|
});
|
||||||
f.push(this.userInformationItem);
|
f.push(this.userInformationItem);
|
||||||
return AssociateRQ.super_.prototype.getFields.call(this, f);
|
return AssociateRQ.super_.prototype.getFields.call(this, f);
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.readBytes = function(stream, length) {
|
AssociateRQ.prototype.readBytes = function(stream, length) {
|
||||||
this.type = C.ITEM_TYPE_PDU_ASSOCIATE_RQ;
|
this.type = C.ITEM_TYPE_PDU_ASSOCIATE_RQ;
|
||||||
@ -214,11 +217,11 @@ AssociateRQ.prototype.readBytes = function(stream, length) {
|
|||||||
|
|
||||||
var userItem = this.load(stream);
|
var userItem = this.load(stream);
|
||||||
this.setUserInformationItem(userItem);
|
this.setUserInformationItem(userItem);
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateRQ.prototype.buffer = function() {
|
AssociateRQ.prototype.buffer = function() {
|
||||||
return AssociateRQ.super_.prototype.buffer.call(this);
|
return AssociateRQ.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateAC = function() {
|
AssociateAC = function() {
|
||||||
AssociateRQ.call(this);
|
AssociateRQ.call(this);
|
||||||
@ -243,24 +246,24 @@ AssociateAC.prototype.readBytes = function(stream, length) {
|
|||||||
|
|
||||||
var userItem = this.load(stream);
|
var userItem = this.load(stream);
|
||||||
this.setUserInformationItem(userItem);
|
this.setUserInformationItem(userItem);
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateAbort = function() {
|
AssociateAbort = function() {
|
||||||
this.type = C.ITEM_TYPE_PDU_AABORT;
|
this.type = C.ITEM_TYPE_PDU_AABORT;
|
||||||
this.source = 1;
|
this.source = 1;
|
||||||
this.reason = 0;
|
this.reason = 0;
|
||||||
PDU.call(this);
|
PDU.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(AssociateAbort, PDU);
|
util.inherits(AssociateAbort, PDU);
|
||||||
|
|
||||||
AssociateAbort.prototype.setSource = function(src) {
|
AssociateAbort.prototype.setSource = function(src) {
|
||||||
this.source = src;
|
this.source = src;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateAbort.prototype.setReason = function(reason) {
|
AssociateAbort.prototype.setReason = function(reason) {
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateAbort.prototype.readBytes = function(stream, length) {
|
AssociateAbort.prototype.readBytes = function(stream, length) {
|
||||||
stream.increment(2);
|
stream.increment(2);
|
||||||
@ -270,14 +273,14 @@ AssociateAbort.prototype.readBytes = function(stream, length) {
|
|||||||
|
|
||||||
var reason = stream.read(C.TYPE_UINT8);
|
var reason = stream.read(C.TYPE_UINT8);
|
||||||
this.setReason(reason);
|
this.setReason(reason);
|
||||||
}
|
};
|
||||||
|
|
||||||
AssociateAbort.prototype.getFields = function() {
|
AssociateAbort.prototype.getFields = function() {
|
||||||
return AssociateAbort.super_.prototype.getFields.call(this, [
|
return AssociateAbort.super_.prototype.getFields.call(this, [
|
||||||
new ReservedField(), new ReservedField(),
|
new ReservedField(), new ReservedField(),
|
||||||
new UInt8Field(this.source), new UInt8Field(this.reason)
|
new UInt8Field(this.source), new UInt8Field(this.reason)
|
||||||
]);
|
]);
|
||||||
}
|
};
|
||||||
|
|
||||||
ReleaseRQ = function() {
|
ReleaseRQ = function() {
|
||||||
this.type = C.ITEM_TYPE_PDU_RELEASE_RQ;
|
this.type = C.ITEM_TYPE_PDU_RELEASE_RQ;
|
||||||
@ -287,13 +290,13 @@ ReleaseRQ = function() {
|
|||||||
util.inherits(ReleaseRQ, PDU);
|
util.inherits(ReleaseRQ, PDU);
|
||||||
|
|
||||||
ReleaseRQ.prototype.getFields = function() {
|
ReleaseRQ.prototype.getFields = function() {
|
||||||
return ReleaseRQ.super_.prototype.getFields.call(this, [new ReservedField(4)]);
|
return ReleaseRQ.super_.prototype.getFields.call(this, [ new ReservedField(4) ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
ReleaseRP = function() {
|
ReleaseRP = function() {
|
||||||
this.type = C.ITEM_TYPE_PDU_RELEASE_RP;
|
this.type = C.ITEM_TYPE_PDU_RELEASE_RP;
|
||||||
PDU.call(this);
|
PDU.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(ReleaseRP, PDU);
|
util.inherits(ReleaseRP, PDU);
|
||||||
|
|
||||||
@ -302,52 +305,54 @@ ReleaseRP.prototype.readBytes = function(stream, length) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ReleaseRP.prototype.getFields = function() {
|
ReleaseRP.prototype.getFields = function() {
|
||||||
return ReleaseRP.super_.prototype.getFields.call(this, [new ReservedField(4)]);
|
return ReleaseRP.super_.prototype.getFields.call(this, [ new ReservedField(4) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
PDataTF = function() {
|
PDataTF = function() {
|
||||||
this.type = C.ITEM_TYPE_PDU_PDATA;
|
this.type = C.ITEM_TYPE_PDU_PDATA;
|
||||||
this.presentationDataValueItems = [];
|
this.presentationDataValueItems = [];
|
||||||
PDU.call(this);
|
PDU.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(PDataTF, PDU);
|
util.inherits(PDataTF, PDU);
|
||||||
|
|
||||||
PDataTF.prototype.setPresentationDataValueItems = function(items) {
|
PDataTF.prototype.setPresentationDataValueItems = function(items) {
|
||||||
this.presentationDataValueItems = items ? items : [];
|
this.presentationDataValueItems = items ? items : [];
|
||||||
}
|
};
|
||||||
|
|
||||||
PDataTF.prototype.getFields = function() {
|
PDataTF.prototype.getFields = function() {
|
||||||
var fields = this.presentationDataValueItems;
|
var fields = this.presentationDataValueItems;
|
||||||
|
|
||||||
return PDataTF.super_.prototype.getFields.call(this, fields);
|
return PDataTF.super_.prototype.getFields.call(this, fields);
|
||||||
}
|
};
|
||||||
|
|
||||||
PDataTF.prototype.readBytes = function(stream, length) {
|
PDataTF.prototype.readBytes = function(stream, length) {
|
||||||
var pdvs = this.loadPDV(stream, length);
|
var pdvs = this.loadPDV(stream, length);
|
||||||
//let merges = mergePDVs(pdvs);
|
//let merges = mergePDVs(pdvs);
|
||||||
|
|
||||||
this.setPresentationDataValueItems(pdvs);
|
this.setPresentationDataValueItems(pdvs);
|
||||||
}
|
};
|
||||||
|
|
||||||
Item = function() {
|
Item = function() {
|
||||||
PDU.call(this);
|
PDU.call(this);
|
||||||
this.lengthBytes = 2;
|
this.lengthBytes = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(Item, PDU);
|
util.inherits(Item, PDU);
|
||||||
|
|
||||||
Item.prototype.read = function(stream) {
|
Item.prototype.read = function(stream) {
|
||||||
stream.read(C.TYPE_HEX, 1);
|
stream.read(C.TYPE_HEX, 1);
|
||||||
var length = stream.read(C.TYPE_UINT16);
|
var length = stream.read(C.TYPE_UINT16);
|
||||||
this.readBytes(stream, length);
|
this.readBytes(stream, length);
|
||||||
}
|
};
|
||||||
|
|
||||||
Item.prototype.write = function(stream) {
|
Item.prototype.write = function(stream) {
|
||||||
stream.concat(this.stream());
|
stream.concat(this.stream());
|
||||||
}
|
};
|
||||||
|
|
||||||
Item.prototype.getFields = function(fields) {
|
Item.prototype.getFields = function(fields) {
|
||||||
return Item.super_.prototype.getFields.call(this, fields);
|
return Item.super_.prototype.getFields.call(this, fields);
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem = function(context) {
|
PresentationDataValueItem = function(context) {
|
||||||
this.type = null;
|
this.type = null;
|
||||||
@ -359,27 +364,28 @@ PresentationDataValueItem = function(context) {
|
|||||||
|
|
||||||
this.lengthBytes = 4;
|
this.lengthBytes = 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(PresentationDataValueItem, Item);
|
util.inherits(PresentationDataValueItem, Item);
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.setContextId = function(id) {
|
PresentationDataValueItem.prototype.setContextId = function(id) {
|
||||||
this.contextId = id;
|
this.contextId = id;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.setFlag = function(flag) {
|
PresentationDataValueItem.prototype.setFlag = function(flag) {
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.setPresentationDataValue = function(pdv) {
|
PresentationDataValueItem.prototype.setPresentationDataValue = function(pdv) {
|
||||||
this.pdv = pdv;
|
this.pdv = pdv;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.setMessage = function(msg) {
|
PresentationDataValueItem.prototype.setMessage = function(msg) {
|
||||||
this.dataFragment = msg;
|
this.dataFragment = msg;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.getMessage = function() {
|
PresentationDataValueItem.prototype.getMessage = function() {
|
||||||
return this.dataFragment;
|
return this.dataFragment;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.readBytes = function(stream, length) {
|
PresentationDataValueItem.prototype.readBytes = function(stream, length) {
|
||||||
this.contextId = stream.read(C.TYPE_UINT8);
|
this.contextId = stream.read(C.TYPE_UINT8);
|
||||||
@ -389,77 +395,79 @@ PresentationDataValueItem.prototype.readBytes = function(stream, length) {
|
|||||||
|
|
||||||
//load dicom messages
|
//load dicom messages
|
||||||
this.messageStream = stream.more(length - 2);
|
this.messageStream = stream.more(length - 2);
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationDataValueItem.prototype.getFields = function() {
|
PresentationDataValueItem.prototype.getFields = function() {
|
||||||
var fields = [new UInt8Field(this.contextId)];
|
var fields = [ new UInt8Field(this.contextId) ];
|
||||||
//define header
|
//define header
|
||||||
var messageHeader = (1 & this.dataFragment.type) | ((this.isLast ? 1 : 0) << 1);
|
var messageHeader = (1 & this.dataFragment.type) | ((this.isLast ? 1 : 0) << 1);
|
||||||
fields.push(new UInt8Field(messageHeader));
|
fields.push(new UInt8Field(messageHeader));
|
||||||
|
|
||||||
fields.push(this.dataFragment);
|
fields.push(this.dataFragment);
|
||||||
/*var stream = new WriteStream();this.dataFragment.write(stream);
|
/*var stream = new WriteStream();this.dataFragment.write(stream);
|
||||||
//var f = this.dataFragment.getFields();
|
//var f = this.dataFragment.getFields();
|
||||||
//var wr = new WriteStream();f[0].setSyntax(this.dataFragment.syntax);f[0].write(wr);
|
//var wr = new WriteStream();f[0].setSyntax(this.dataFragment.syntax);f[0].write(wr);
|
||||||
var rst = stream.toReadBuffer();
|
var rst = stream.toReadBuffer();
|
||||||
rst.setEndian(C.LITTLE_ENDIAN);
|
rst.setEndian(C.LITTLE_ENDIAN);
|
||||||
var group = rst.read(C.TYPE_UINT16),
|
var group = rst.read(C.TYPE_UINT16),
|
||||||
element = rst.read(C.TYPE_UINT16),
|
element = rst.read(C.TYPE_UINT16),
|
||||||
tag = tagFromNumbers(group, element);
|
tag = tagFromNumbers(group, element);
|
||||||
|
|
||||||
console.log(tag.toString(), rst.read(C.TYPE_UINT32));*/
|
console.log(tag.toString(), rst.read(C.TYPE_UINT32));*/
|
||||||
return PresentationDataValueItem.super_.prototype.getFields.call(this, fields);
|
return PresentationDataValueItem.super_.prototype.getFields.call(this, fields);
|
||||||
}
|
};
|
||||||
|
|
||||||
ApplicationContextItem = function() {
|
ApplicationContextItem = function() {
|
||||||
this.type = C.ITEM_TYPE_APPLICATION_CONTEXT;
|
this.type = C.ITEM_TYPE_APPLICATION_CONTEXT;
|
||||||
this.applicationContextName = C.APPLICATION_CONTEXT_NAME;
|
this.applicationContextName = C.APPLICATION_CONTEXT_NAME;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(ApplicationContextItem, Item);
|
util.inherits(ApplicationContextItem, Item);
|
||||||
|
|
||||||
ApplicationContextItem.prototype.setApplicationContextName = function(name) {
|
ApplicationContextItem.prototype.setApplicationContextName = function(name) {
|
||||||
this.applicationContextName = name;
|
this.applicationContextName = name;
|
||||||
}
|
};
|
||||||
|
|
||||||
ApplicationContextItem.prototype.getFields = function() {
|
ApplicationContextItem.prototype.getFields = function() {
|
||||||
return ApplicationContextItem.super_.prototype.getFields.call(this, [new StringField(this.applicationContextName)]);
|
return ApplicationContextItem.super_.prototype.getFields.call(this, [ new StringField(this.applicationContextName) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
ApplicationContextItem.prototype.readBytes = function(stream, length) {
|
ApplicationContextItem.prototype.readBytes = function(stream, length) {
|
||||||
var appContext = stream.read(C.TYPE_ASCII, length);
|
var appContext = stream.read(C.TYPE_ASCII, length);
|
||||||
this.setApplicationContextName(appContext);
|
this.setApplicationContextName(appContext);
|
||||||
}
|
};
|
||||||
|
|
||||||
ApplicationContextItem.prototype.buffer = function() {
|
ApplicationContextItem.prototype.buffer = function() {
|
||||||
return ApplicationContextItem.super_.prototype.buffer.call(this);
|
return ApplicationContextItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem = function() {
|
PresentationContextItem = function() {
|
||||||
this.type = C.ITEM_TYPE_PRESENTATION_CONTEXT;
|
this.type = C.ITEM_TYPE_PRESENTATION_CONTEXT;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(PresentationContextItem, Item);
|
util.inherits(PresentationContextItem, Item);
|
||||||
|
|
||||||
PresentationContextItem.prototype.setPresentationContextID = function(id) {
|
PresentationContextItem.prototype.setPresentationContextID = function(id) {
|
||||||
this.presentationContextID = id;
|
this.presentationContextID = id;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.setAbstractSyntaxItem = function(item) {
|
PresentationContextItem.prototype.setAbstractSyntaxItem = function(item) {
|
||||||
this.abstractSyntaxItem = item;
|
this.abstractSyntaxItem = item;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.setTransferSyntaxesItems = function(items) {
|
PresentationContextItem.prototype.setTransferSyntaxesItems = function(items) {
|
||||||
this.transferSyntaxesItems = items;
|
this.transferSyntaxesItems = items;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.setResultReason = function(reason) {
|
PresentationContextItem.prototype.setResultReason = function(reason) {
|
||||||
this.resultReason = reason;
|
this.resultReason = reason;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.accepted = function() {
|
PresentationContextItem.prototype.accepted = function() {
|
||||||
return this.resultReason == 0;
|
return this.resultReason == 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.readBytes = function(stream, length) {
|
PresentationContextItem.prototype.readBytes = function(stream, length) {
|
||||||
var contextId = stream.read(C.TYPE_UINT8);
|
var contextId = stream.read(C.TYPE_UINT8);
|
||||||
@ -476,27 +484,28 @@ PresentationContextItem.prototype.readBytes = function(stream, length) {
|
|||||||
transContexts.push(this.load(stream));
|
transContexts.push(this.load(stream));
|
||||||
} while (nextItemIs(stream, C.ITEM_TYPE_TRANSFER_CONTEXT));
|
} while (nextItemIs(stream, C.ITEM_TYPE_TRANSFER_CONTEXT));
|
||||||
this.setTransferSyntaxesItems(transContexts);
|
this.setTransferSyntaxesItems(transContexts);
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.getFields = function() {
|
PresentationContextItem.prototype.getFields = function() {
|
||||||
var f = [
|
var f = [
|
||||||
new UInt8Field(this.presentationContextID),
|
new UInt8Field(this.presentationContextID),
|
||||||
new ReservedField(), new ReservedField(), new ReservedField(), this.abstractSyntaxItem
|
new ReservedField(), new ReservedField(), new ReservedField(), this.abstractSyntaxItem
|
||||||
];
|
];
|
||||||
this.transferSyntaxesItems.forEach(function(syntaxItem){
|
this.transferSyntaxesItems.forEach(function(syntaxItem) {
|
||||||
f.push(syntaxItem);
|
f.push(syntaxItem);
|
||||||
});
|
});
|
||||||
return PresentationContextItem.super_.prototype.getFields.call(this, f);
|
return PresentationContextItem.super_.prototype.getFields.call(this, f);
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItem.prototype.buffer = function() {
|
PresentationContextItem.prototype.buffer = function() {
|
||||||
return PresentationContextItem.super_.prototype.buffer.call(this);
|
return PresentationContextItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
PresentationContextItemAC = function() {
|
PresentationContextItemAC = function() {
|
||||||
this.type = C.ITEM_TYPE_PRESENTATION_CONTEXT_AC;
|
this.type = C.ITEM_TYPE_PRESENTATION_CONTEXT_AC;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(PresentationContextItemAC, PresentationContextItem);
|
util.inherits(PresentationContextItemAC, PresentationContextItem);
|
||||||
|
|
||||||
PresentationContextItemAC.prototype.readBytes = function(stream, length) {
|
PresentationContextItemAC.prototype.readBytes = function(stream, length) {
|
||||||
@ -508,64 +517,67 @@ PresentationContextItemAC.prototype.readBytes = function(stream, length) {
|
|||||||
stream.increment(1);
|
stream.increment(1);
|
||||||
|
|
||||||
var transItem = this.load(stream);
|
var transItem = this.load(stream);
|
||||||
this.setTransferSyntaxesItems([transItem]);
|
this.setTransferSyntaxesItems([ transItem ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
AbstractSyntaxItem = function() {
|
AbstractSyntaxItem = function() {
|
||||||
this.type = C.ITEM_TYPE_ABSTRACT_CONTEXT;
|
this.type = C.ITEM_TYPE_ABSTRACT_CONTEXT;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(AbstractSyntaxItem, Item);
|
util.inherits(AbstractSyntaxItem, Item);
|
||||||
|
|
||||||
AbstractSyntaxItem.prototype.setAbstractSyntaxName = function(name) {
|
AbstractSyntaxItem.prototype.setAbstractSyntaxName = function(name) {
|
||||||
this.abstractSyntaxName = name;
|
this.abstractSyntaxName = name;
|
||||||
}
|
};
|
||||||
|
|
||||||
AbstractSyntaxItem.prototype.getFields = function() {
|
AbstractSyntaxItem.prototype.getFields = function() {
|
||||||
return AbstractSyntaxItem.super_.prototype.getFields.call(this, [new StringField(this.abstractSyntaxName)]);
|
return AbstractSyntaxItem.super_.prototype.getFields.call(this, [ new StringField(this.abstractSyntaxName) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
AbstractSyntaxItem.prototype.buffer = function() {
|
AbstractSyntaxItem.prototype.buffer = function() {
|
||||||
return AbstractSyntaxItem.super_.prototype.buffer.call(this);
|
return AbstractSyntaxItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
AbstractSyntaxItem.prototype.readBytes = function(stream, length) {
|
AbstractSyntaxItem.prototype.readBytes = function(stream, length) {
|
||||||
var name = stream.read(C.TYPE_ASCII, length);
|
var name = stream.read(C.TYPE_ASCII, length);
|
||||||
this.setAbstractSyntaxName(name);
|
this.setAbstractSyntaxName(name);
|
||||||
}
|
};
|
||||||
|
|
||||||
TransferSyntaxItem = function() {
|
TransferSyntaxItem = function() {
|
||||||
this.type = C.ITEM_TYPE_TRANSFER_CONTEXT;
|
this.type = C.ITEM_TYPE_TRANSFER_CONTEXT;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(TransferSyntaxItem, Item);
|
util.inherits(TransferSyntaxItem, Item);
|
||||||
|
|
||||||
TransferSyntaxItem.prototype.setTransferSyntaxName = function(name) {
|
TransferSyntaxItem.prototype.setTransferSyntaxName = function(name) {
|
||||||
this.transferSyntaxName = name;
|
this.transferSyntaxName = name;
|
||||||
}
|
};
|
||||||
|
|
||||||
TransferSyntaxItem.prototype.readBytes = function(stream, length) {
|
TransferSyntaxItem.prototype.readBytes = function(stream, length) {
|
||||||
var transfer = stream.read(C.TYPE_ASCII, length);
|
var transfer = stream.read(C.TYPE_ASCII, length);
|
||||||
this.setTransferSyntaxName(transfer);
|
this.setTransferSyntaxName(transfer);
|
||||||
}
|
};
|
||||||
|
|
||||||
TransferSyntaxItem.prototype.getFields = function() {
|
TransferSyntaxItem.prototype.getFields = function() {
|
||||||
return TransferSyntaxItem.super_.prototype.getFields.call(this, [new StringField(this.transferSyntaxName)]);
|
return TransferSyntaxItem.super_.prototype.getFields.call(this, [ new StringField(this.transferSyntaxName) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
TransferSyntaxItem.prototype.buffer = function() {
|
TransferSyntaxItem.prototype.buffer = function() {
|
||||||
return TransferSyntaxItem.super_.prototype.buffer.call(this);
|
return TransferSyntaxItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
UserInformationItem = function() {
|
UserInformationItem = function() {
|
||||||
this.type = C.ITEM_TYPE_USER_INFORMATION;
|
this.type = C.ITEM_TYPE_USER_INFORMATION;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(UserInformationItem, Item);
|
util.inherits(UserInformationItem, Item);
|
||||||
|
|
||||||
UserInformationItem.prototype.setUserDataItems = function(items) {
|
UserInformationItem.prototype.setUserDataItems = function(items) {
|
||||||
this.userDataItems = items;
|
this.userDataItems = items;
|
||||||
}
|
};
|
||||||
|
|
||||||
UserInformationItem.prototype.readBytes = function(stream, length) {
|
UserInformationItem.prototype.readBytes = function(stream, length) {
|
||||||
var items = [], pdu = this.load(stream);
|
var items = [], pdu = this.load(stream);
|
||||||
@ -574,87 +586,90 @@ UserInformationItem.prototype.readBytes = function(stream, length) {
|
|||||||
items.push(pdu);
|
items.push(pdu);
|
||||||
} while (pdu = this.load(stream));
|
} while (pdu = this.load(stream));
|
||||||
this.setUserDataItems(items);
|
this.setUserDataItems(items);
|
||||||
}
|
};
|
||||||
|
|
||||||
UserInformationItem.prototype.getFields = function() {
|
UserInformationItem.prototype.getFields = function() {
|
||||||
var f = [];
|
var f = [];
|
||||||
this.userDataItems.forEach(function(userData){
|
this.userDataItems.forEach(function(userData) {
|
||||||
f.push(userData);
|
f.push(userData);
|
||||||
});
|
});
|
||||||
return UserInformationItem.super_.prototype.getFields.call(this, f);
|
return UserInformationItem.super_.prototype.getFields.call(this, f);
|
||||||
}
|
};
|
||||||
|
|
||||||
UserInformationItem.prototype.buffer = function() {
|
UserInformationItem.prototype.buffer = function() {
|
||||||
return UserInformationItem.super_.prototype.buffer.call(this);
|
return UserInformationItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationClassUIDItem = function() {
|
ImplementationClassUIDItem = function() {
|
||||||
this.type = C.ITEM_TYPE_IMPLEMENTATION_UID;
|
this.type = C.ITEM_TYPE_IMPLEMENTATION_UID;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(ImplementationClassUIDItem, Item);
|
util.inherits(ImplementationClassUIDItem, Item);
|
||||||
|
|
||||||
ImplementationClassUIDItem.prototype.setImplementationClassUID = function(id) {
|
ImplementationClassUIDItem.prototype.setImplementationClassUID = function(id) {
|
||||||
this.implementationClassUID = id;
|
this.implementationClassUID = id;
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationClassUIDItem.prototype.readBytes = function(stream, length) {
|
ImplementationClassUIDItem.prototype.readBytes = function(stream, length) {
|
||||||
var uid = stream.read(C.TYPE_ASCII, length);
|
var uid = stream.read(C.TYPE_ASCII, length);
|
||||||
this.setImplementationClassUID(uid);
|
this.setImplementationClassUID(uid);
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationClassUIDItem.prototype.getFields = function() {
|
ImplementationClassUIDItem.prototype.getFields = function() {
|
||||||
return ImplementationClassUIDItem.super_.prototype.getFields.call(this, [new StringField(this.implementationClassUID)]);
|
return ImplementationClassUIDItem.super_.prototype.getFields.call(this, [ new StringField(this.implementationClassUID) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationClassUIDItem.prototype.buffer = function() {
|
ImplementationClassUIDItem.prototype.buffer = function() {
|
||||||
return ImplementationClassUIDItem.super_.prototype.buffer.call(this);
|
return ImplementationClassUIDItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationVersionNameItem = function() {
|
ImplementationVersionNameItem = function() {
|
||||||
this.type = C.ITEM_TYPE_IMPLEMENTATION_VERSION;
|
this.type = C.ITEM_TYPE_IMPLEMENTATION_VERSION;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(ImplementationVersionNameItem, Item);
|
util.inherits(ImplementationVersionNameItem, Item);
|
||||||
|
|
||||||
ImplementationVersionNameItem.prototype.setImplementationVersionName = function(name) {
|
ImplementationVersionNameItem.prototype.setImplementationVersionName = function(name) {
|
||||||
this.implementationVersionName = name;
|
this.implementationVersionName = name;
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationVersionNameItem.prototype.readBytes = function(stream, length) {
|
ImplementationVersionNameItem.prototype.readBytes = function(stream, length) {
|
||||||
var name = stream.read(C.TYPE_ASCII, length);
|
var name = stream.read(C.TYPE_ASCII, length);
|
||||||
this.setImplementationVersionName(name);
|
this.setImplementationVersionName(name);
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationVersionNameItem.prototype.getFields = function() {
|
ImplementationVersionNameItem.prototype.getFields = function() {
|
||||||
return ImplementationVersionNameItem.super_.prototype.getFields.call(this, [new StringField(this.implementationVersionName)]);
|
return ImplementationVersionNameItem.super_.prototype.getFields.call(this, [ new StringField(this.implementationVersionName) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
ImplementationVersionNameItem.prototype.buffer = function() {
|
ImplementationVersionNameItem.prototype.buffer = function() {
|
||||||
return ImplementationVersionNameItem.super_.prototype.buffer.call(this);
|
return ImplementationVersionNameItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
MaximumLengthItem = function() {
|
MaximumLengthItem = function() {
|
||||||
this.type = C.ITEM_TYPE_MAXIMUM_LENGTH;
|
this.type = C.ITEM_TYPE_MAXIMUM_LENGTH;
|
||||||
this.maximumLengthReceived = 32768;
|
this.maximumLengthReceived = 32768;
|
||||||
Item.call(this);
|
Item.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(MaximumLengthItem, Item);
|
util.inherits(MaximumLengthItem, Item);
|
||||||
|
|
||||||
MaximumLengthItem.prototype.setMaximumLengthReceived = function(length) {
|
MaximumLengthItem.prototype.setMaximumLengthReceived = function(length) {
|
||||||
this.maximumLengthReceived = length;
|
this.maximumLengthReceived = length;
|
||||||
}
|
};
|
||||||
|
|
||||||
MaximumLengthItem.prototype.readBytes = function(stream, length) {
|
MaximumLengthItem.prototype.readBytes = function(stream, length) {
|
||||||
var l = stream.read(C.TYPE_UINT32);
|
var l = stream.read(C.TYPE_UINT32);
|
||||||
this.setMaximumLengthReceived(l);
|
this.setMaximumLengthReceived(l);
|
||||||
}
|
};
|
||||||
|
|
||||||
MaximumLengthItem.prototype.getFields = function() {
|
MaximumLengthItem.prototype.getFields = function() {
|
||||||
return MaximumLengthItem.super_.prototype.getFields.call(this, [new UInt32Field(this.maximumLengthReceived)]);
|
return MaximumLengthItem.super_.prototype.getFields.call(this, [ new UInt32Field(this.maximumLengthReceived) ]);
|
||||||
}
|
};
|
||||||
|
|
||||||
MaximumLengthItem.prototype.buffer = function() {
|
MaximumLengthItem.prototype.buffer = function() {
|
||||||
return MaximumLengthItem.super_.prototype.buffer.call(this);
|
return MaximumLengthItem.super_.prototype.buffer.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ calcLength = function(type, value) {
|
|||||||
default :break;
|
default :break;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
};
|
||||||
|
|
||||||
var RWStream = function() {
|
var RWStream = function() {
|
||||||
this.endian = C.BIG_ENDIAN;
|
this.endian = C.BIG_ENDIAN;
|
||||||
@ -28,19 +28,19 @@ var RWStream = function() {
|
|||||||
|
|
||||||
RWStream.prototype.setEndian = function(endian) {
|
RWStream.prototype.setEndian = function(endian) {
|
||||||
this.endian = endian;
|
this.endian = endian;
|
||||||
}
|
};
|
||||||
|
|
||||||
RWStream.prototype.getEncoding = function(type) {
|
RWStream.prototype.getEncoding = function(type) {
|
||||||
return RWStream.encodings[type];
|
return RWStream.encodings[type];
|
||||||
}
|
};
|
||||||
|
|
||||||
RWStream.prototype.getWriteType = function(type) {
|
RWStream.prototype.getWriteType = function(type) {
|
||||||
return RWStream.writes[this.endian][type];
|
return RWStream.writes[this.endian][type];
|
||||||
}
|
};
|
||||||
|
|
||||||
RWStream.prototype.getReadType = function(type) {
|
RWStream.prototype.getReadType = function(type) {
|
||||||
return RWStream.reads[this.endian][type];
|
return RWStream.reads[this.endian][type];
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream = function() {
|
WriteStream = function() {
|
||||||
RWStream.call(this);
|
RWStream.call(this);
|
||||||
@ -48,7 +48,7 @@ WriteStream = function() {
|
|||||||
this.rawBuffer = new Buffer(this.defaultBufferSize);
|
this.rawBuffer = new Buffer(this.defaultBufferSize);
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
this.contentSize = 0;
|
this.contentSize = 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(WriteStream, RWStream);
|
util.inherits(WriteStream, RWStream);
|
||||||
|
|
||||||
@ -57,15 +57,15 @@ WriteStream.prototype.increment = function(add) {
|
|||||||
if (this.offset > this.contentSize) {
|
if (this.offset > this.contentSize) {
|
||||||
this.contentSize = this.offset;
|
this.contentSize = this.offset;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.size = function() {
|
WriteStream.prototype.size = function() {
|
||||||
return this.contentSize;
|
return this.contentSize;
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.skip = function(amount) {
|
WriteStream.prototype.skip = function(amount) {
|
||||||
this.increment(amount);
|
this.increment(amount);
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.checkSize = function(length) {
|
WriteStream.prototype.checkSize = function(length) {
|
||||||
if (this.offset + length > this.rawBuffer.length) {
|
if (this.offset + length > this.rawBuffer.length) {
|
||||||
@ -75,15 +75,15 @@ WriteStream.prototype.checkSize = function(length) {
|
|||||||
this.rawBuffer.copy(newBuffer, 0, 0, this.contentSize);
|
this.rawBuffer.copy(newBuffer, 0, 0, this.contentSize);
|
||||||
this.rawBuffer = newBuffer;
|
this.rawBuffer = newBuffer;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.writeToBuffer = function(type, value, length) {
|
WriteStream.prototype.writeToBuffer = function(type, value, length) {
|
||||||
if (value === "" || value === null) return;
|
if (value === '' || value === null) return;
|
||||||
|
|
||||||
this.checkSize(length);
|
this.checkSize(length);
|
||||||
this.rawBuffer[this.getWriteType(type)](value, this.offset);
|
this.rawBuffer[this.getWriteType(type)](value, this.offset);
|
||||||
this.increment(length);
|
this.increment(length);
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.write = function(type, value) {
|
WriteStream.prototype.write = function(type, value) {
|
||||||
if (isString(type)) {
|
if (isString(type)) {
|
||||||
@ -91,28 +91,28 @@ WriteStream.prototype.write = function(type, value) {
|
|||||||
} else {
|
} else {
|
||||||
this.writeToBuffer(type, value, calcLength(type));
|
this.writeToBuffer(type, value, calcLength(type));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.writeString = function(string, type) {
|
WriteStream.prototype.writeString = function(string, type) {
|
||||||
var encoding = this.getEncoding(type), length = Buffer.byteLength(string, encoding);
|
var encoding = this.getEncoding(type), length = Buffer.byteLength(string, encoding);
|
||||||
this.rawBuffer.write(string, this.offset, length, encoding);
|
this.rawBuffer.write(string, this.offset, length, encoding);
|
||||||
this.increment(length);
|
this.increment(length);
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.buffer = function() {
|
WriteStream.prototype.buffer = function() {
|
||||||
return this.rawBuffer.slice(0, this.contentSize);
|
return this.rawBuffer.slice(0, this.contentSize);
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.toReadBuffer = function() {
|
WriteStream.prototype.toReadBuffer = function() {
|
||||||
return new ReadStream(this.buffer());
|
return new ReadStream(this.buffer());
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.concat = function(newStream) {
|
WriteStream.prototype.concat = function(newStream) {
|
||||||
var newSize = this.size() + newStream.size();
|
var newSize = this.size() + newStream.size();
|
||||||
this.rawBuffer = Buffer.concat([this.buffer(), newStream.buffer()], newSize);
|
this.rawBuffer = Buffer.concat([ this.buffer(), newStream.buffer() ], newSize);
|
||||||
this.contentSize = newSize;
|
this.contentSize = newSize;
|
||||||
this.offset = newSize;
|
this.offset = newSize;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream = function(buffer) {
|
ReadStream = function(buffer) {
|
||||||
RWStream.call(this);
|
RWStream.call(this);
|
||||||
@ -124,26 +124,26 @@ util.inherits(ReadStream, RWStream);
|
|||||||
|
|
||||||
ReadStream.prototype.size = function() {
|
ReadStream.prototype.size = function() {
|
||||||
return this.rawBuffer.length;
|
return this.rawBuffer.length;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.increment = function(add) {
|
ReadStream.prototype.increment = function(add) {
|
||||||
this.offset += add;
|
this.offset += add;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.more = function(length) {
|
ReadStream.prototype.more = function(length) {
|
||||||
var newBuf = this.rawBuffer.slice(this.offset, this.offset + length);
|
var newBuf = this.rawBuffer.slice(this.offset, this.offset + length);
|
||||||
this.increment(length);
|
this.increment(length);
|
||||||
return new ReadStream(newBuf);
|
return new ReadStream(newBuf);
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.reset = function() {
|
ReadStream.prototype.reset = function() {
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
return this;
|
return this;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.end = function() {
|
ReadStream.prototype.end = function() {
|
||||||
return this.offset >= this.size();
|
return this.offset >= this.size();
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.readFromBuffer = function(type, length) {
|
ReadStream.prototype.readFromBuffer = function(type, length) {
|
||||||
//this.checkSize(length);
|
//this.checkSize(length);
|
||||||
@ -151,7 +151,7 @@ ReadStream.prototype.readFromBuffer = function(type, length) {
|
|||||||
var value = this.rawBuffer[this.getReadType(type)](this.offset);
|
var value = this.rawBuffer[this.getReadType(type)](this.offset);
|
||||||
this.increment(length);
|
this.increment(length);
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.read = function(type, length) {
|
ReadStream.prototype.read = function(type, length) {
|
||||||
var value = null;
|
var value = null;
|
||||||
@ -162,68 +162,68 @@ ReadStream.prototype.read = function(type, length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.readString = function(length, type) {
|
ReadStream.prototype.readString = function(length, type) {
|
||||||
var encoding = this.getEncoding(type),
|
var encoding = this.getEncoding(type),
|
||||||
str = this.rawBuffer.toString(encoding, this.offset, this.offset + length);
|
str = this.rawBuffer.toString(encoding, this.offset, this.offset + length);
|
||||||
this.increment(length);
|
this.increment(length);
|
||||||
return str;
|
return str;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.buffer = function() {
|
ReadStream.prototype.buffer = function() {
|
||||||
return this.rawBuffer;
|
return this.rawBuffer;
|
||||||
}
|
};
|
||||||
|
|
||||||
ReadStream.prototype.concat = function(newStream) {
|
ReadStream.prototype.concat = function(newStream) {
|
||||||
var newSize = this.size() + newStream.size();
|
var newSize = this.size() + newStream.size();
|
||||||
this.rawBuffer = Buffer.concat([this.buffer(), newStream.buffer()], newSize);
|
this.rawBuffer = Buffer.concat([ this.buffer(), newStream.buffer() ], newSize);
|
||||||
this.contentSize = newSize;
|
this.contentSize = newSize;
|
||||||
this.offset = newSize;
|
this.offset = newSize;
|
||||||
}
|
};
|
||||||
|
|
||||||
RWStream.writes = {};
|
RWStream.writes = {};
|
||||||
RWStream.writes[C.BIG_ENDIAN] = {};
|
RWStream.writes[C.BIG_ENDIAN] = {};
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_UINT8] = "writeUInt8";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_UINT8] = 'writeUInt8';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_UINT16] = "writeUInt16BE";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_UINT16] = 'writeUInt16BE';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_UINT32] = "writeUInt32BE";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_UINT32] = 'writeUInt32BE';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_INT8] = "writeInt8";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_INT8] = 'writeInt8';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_INT16] = "writeInt16BE";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_INT16] = 'writeInt16BE';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_INT32] = "writeInt32BE";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_INT32] = 'writeInt32BE';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_FLOAT] = "writeFloatBE";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_FLOAT] = 'writeFloatBE';
|
||||||
RWStream.writes[C.BIG_ENDIAN][C.TYPE_DOUBLE] = "writeDoubleBE";
|
RWStream.writes[C.BIG_ENDIAN][C.TYPE_DOUBLE] = 'writeDoubleBE';
|
||||||
|
|
||||||
RWStream.writes[C.LITTLE_ENDIAN] = {};
|
RWStream.writes[C.LITTLE_ENDIAN] = {};
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_UINT8] = "writeUInt8";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_UINT8] = 'writeUInt8';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_UINT16] = "writeUInt16LE";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_UINT16] = 'writeUInt16LE';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_UINT32] = "writeUInt32LE";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_UINT32] = 'writeUInt32LE';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_INT8] = "writeInt8";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_INT8] = 'writeInt8';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_INT16] = "writeInt16LE";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_INT16] = 'writeInt16LE';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_INT32] = "writeInt32LE";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_INT32] = 'writeInt32LE';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_FLOAT] = "writeFloatLE";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_FLOAT] = 'writeFloatLE';
|
||||||
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_DOUBLE] = "writeDoubleLE";
|
RWStream.writes[C.LITTLE_ENDIAN][C.TYPE_DOUBLE] = 'writeDoubleLE';
|
||||||
|
|
||||||
RWStream.reads = {};
|
RWStream.reads = {};
|
||||||
RWStream.reads[C.BIG_ENDIAN] = {};
|
RWStream.reads[C.BIG_ENDIAN] = {};
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_UINT8] = "readUInt8";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_UINT8] = 'readUInt8';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_UINT16] = "readUInt16BE";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_UINT16] = 'readUInt16BE';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_UINT32] = "readUInt32BE";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_UINT32] = 'readUInt32BE';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_INT8] = "readInt8";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_INT8] = 'readInt8';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_INT16] = "readInt16BE";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_INT16] = 'readInt16BE';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_INT32] = "readInt32BE";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_INT32] = 'readInt32BE';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_FLOAT] = "readFloatBE";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_FLOAT] = 'readFloatBE';
|
||||||
RWStream.reads[C.BIG_ENDIAN][C.TYPE_DOUBLE] = "readDoubleBE";
|
RWStream.reads[C.BIG_ENDIAN][C.TYPE_DOUBLE] = 'readDoubleBE';
|
||||||
|
|
||||||
RWStream.reads[C.LITTLE_ENDIAN] = {};
|
RWStream.reads[C.LITTLE_ENDIAN] = {};
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_UINT8] = "readUInt8";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_UINT8] = 'readUInt8';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_UINT16] = "readUInt16LE";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_UINT16] = 'readUInt16LE';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_UINT32] = "readUInt32LE";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_UINT32] = 'readUInt32LE';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_INT8] = "readInt8";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_INT8] = 'readInt8';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_INT16] = "readInt16LE";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_INT16] = 'readInt16LE';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_INT32] = "readInt32LE";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_INT32] = 'readInt32LE';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_FLOAT] = "readFloatLE";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_FLOAT] = 'readFloatLE';
|
||||||
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_DOUBLE] = "readDoubleLE";
|
RWStream.reads[C.LITTLE_ENDIAN][C.TYPE_DOUBLE] = 'readDoubleLE';
|
||||||
|
|
||||||
RWStream.encodings = {};
|
RWStream.encodings = {};
|
||||||
RWStream.encodings[C.TYPE_HEX] = "hex";
|
RWStream.encodings[C.TYPE_HEX] = 'hex';
|
||||||
RWStream.encodings[C.TYPE_ASCII] = "ascii";
|
RWStream.encodings[C.TYPE_ASCII] = 'ascii';
|
||||||
|
|||||||
@ -1,98 +1,98 @@
|
|||||||
C = {
|
C = {
|
||||||
IMPLEM_UID : "1.2.840.0.1.3680045.8.641",
|
IMPLEM_UID: '1.2.840.0.1.3680045.8.641',
|
||||||
IMPLEM_VERSION : "OHIF-DCM-0.1",
|
IMPLEM_VERSION: 'OHIF-DCM-0.1',
|
||||||
APPLICATION_CONTEXT_NAME : "1.2.840.10008.3.1.1.1",
|
APPLICATION_CONTEXT_NAME: '1.2.840.10008.3.1.1.1',
|
||||||
PROTOCOL_VERSION : "0001",
|
PROTOCOL_VERSION: '0001',
|
||||||
ITEM_TYPE_RESERVED : "00",
|
ITEM_TYPE_RESERVED: '00',
|
||||||
ITEM_TYPE_APPLICATION_CONTEXT : "10",
|
ITEM_TYPE_APPLICATION_CONTEXT: '10',
|
||||||
ITEM_TYPE_PDU_ASSOCIATE_RQ : "01",
|
ITEM_TYPE_PDU_ASSOCIATE_RQ: '01',
|
||||||
ITEM_TYPE_PDU_ASSOCIATE_AC : "02",
|
ITEM_TYPE_PDU_ASSOCIATE_AC: '02',
|
||||||
ITEM_TYPE_PDU_PDATA : "04",
|
ITEM_TYPE_PDU_PDATA: '04',
|
||||||
ITEM_TYPE_PDU_RELEASE_RQ : "05",
|
ITEM_TYPE_PDU_RELEASE_RQ: '05',
|
||||||
ITEM_TYPE_PDU_RELEASE_RP : "06",
|
ITEM_TYPE_PDU_RELEASE_RP: '06',
|
||||||
ITEM_TYPE_PDU_AABORT : "07",
|
ITEM_TYPE_PDU_AABORT: '07',
|
||||||
ITEM_TYPE_PRESENTATION_CONTEXT : "20",
|
ITEM_TYPE_PRESENTATION_CONTEXT: '20',
|
||||||
ITEM_TYPE_PRESENTATION_CONTEXT_AC : "21",
|
ITEM_TYPE_PRESENTATION_CONTEXT_AC: '21',
|
||||||
ITEM_TYPE_ABSTRACT_CONTEXT : "30",
|
ITEM_TYPE_ABSTRACT_CONTEXT: '30',
|
||||||
ITEM_TYPE_TRANSFER_CONTEXT : "40",
|
ITEM_TYPE_TRANSFER_CONTEXT: '40',
|
||||||
ITEM_TYPE_USER_INFORMATION : "50",
|
ITEM_TYPE_USER_INFORMATION: '50',
|
||||||
ITEM_TYPE_MAXIMUM_LENGTH : "51",
|
ITEM_TYPE_MAXIMUM_LENGTH: '51',
|
||||||
ITEM_TYPE_IMPLEMENTATION_UID : "52",
|
ITEM_TYPE_IMPLEMENTATION_UID: '52',
|
||||||
ITEM_TYPE_IMPLEMENTATION_VERSION : "55",
|
ITEM_TYPE_IMPLEMENTATION_VERSION: '55',
|
||||||
IMPLICIT_LITTLE_ENDIAN : "1.2.840.10008.1.2",
|
IMPLICIT_LITTLE_ENDIAN: '1.2.840.10008.1.2',
|
||||||
EXPLICIT_LITTLE_ENDIAN : "1.2.840.10008.1.2.1",
|
EXPLICIT_LITTLE_ENDIAN: '1.2.840.10008.1.2.1',
|
||||||
EXPLICIT_BIG_ENDIAN : "1.2.840.10008.1.2.2",
|
EXPLICIT_BIG_ENDIAN: '1.2.840.10008.1.2.2',
|
||||||
SOP_PATIENT_ROOT_FIND : "1.2.840.10008.5.1.4.1.2.1.1",
|
SOP_PATIENT_ROOT_FIND: '1.2.840.10008.5.1.4.1.2.1.1',
|
||||||
SOP_PATIENT_ROOT_MOVE : "1.2.840.10008.5.1.4.1.2.1.2",
|
SOP_PATIENT_ROOT_MOVE: '1.2.840.10008.5.1.4.1.2.1.2',
|
||||||
SOP_PATIENT_ROOT_GET : "1.2.840.10008.5.1.4.1.2.1.3",
|
SOP_PATIENT_ROOT_GET: '1.2.840.10008.5.1.4.1.2.1.3',
|
||||||
SOP_STUDY_ROOT_FIND : "1.2.840.10008.5.1.4.1.2.2.1",
|
SOP_STUDY_ROOT_FIND: '1.2.840.10008.5.1.4.1.2.2.1',
|
||||||
SOP_STUDY_ROOT_MOVE : "1.2.840.10008.5.1.4.1.2.2.2",
|
SOP_STUDY_ROOT_MOVE: '1.2.840.10008.5.1.4.1.2.2.2',
|
||||||
SOP_STUDY_ROOT_GET : "1.2.840.10008.5.1.4.1.2.2.3",
|
SOP_STUDY_ROOT_GET: '1.2.840.10008.5.1.4.1.2.2.3',
|
||||||
SOP_VERIFICATION : "1.2.840.10008.1.1",
|
SOP_VERIFICATION: '1.2.840.10008.1.1',
|
||||||
SOP_HANGING_PROTOCOL_FIND : "1.2.840.10008.5.1.4.38.2",
|
SOP_HANGING_PROTOCOL_FIND: '1.2.840.10008.5.1.4.38.2',
|
||||||
SOP_MR_IMAGE_STORAGE : "1.2.840.10008.5.1.4.1.1.4",
|
SOP_MR_IMAGE_STORAGE: '1.2.840.10008.5.1.4.1.1.4',
|
||||||
TYPE_ASCII : 1,
|
TYPE_ASCII: 1,
|
||||||
TYPE_HEX : 2,
|
TYPE_HEX: 2,
|
||||||
TYPE_UINT8 : 3,
|
TYPE_UINT8: 3,
|
||||||
TYPE_UINT16 : 4,
|
TYPE_UINT16: 4,
|
||||||
TYPE_UINT32 : 5,
|
TYPE_UINT32: 5,
|
||||||
TYPE_COMPOSITE : 6,
|
TYPE_COMPOSITE: 6,
|
||||||
TYPE_FLOAT : 7,
|
TYPE_FLOAT: 7,
|
||||||
TYPE_DOUBLE : 8,
|
TYPE_DOUBLE: 8,
|
||||||
TYPE_INT8 : 9,
|
TYPE_INT8: 9,
|
||||||
TYPE_INT16 : 10,
|
TYPE_INT16: 10,
|
||||||
TYPE_INT32 : 11,
|
TYPE_INT32: 11,
|
||||||
RESULT_REASON_ACCEPTANCE : 0,
|
RESULT_REASON_ACCEPTANCE: 0,
|
||||||
RESULT_REASON_USER_REJECTION : 1,
|
RESULT_REASON_USER_REJECTION: 1,
|
||||||
RESULT_REASON_NO_REASON :2,
|
RESULT_REASON_NO_REASON: 2,
|
||||||
RESULT_REASON_ABSTRACT_NOT_SUPPORTED : 3,
|
RESULT_REASON_ABSTRACT_NOT_SUPPORTED: 3,
|
||||||
RESULT_REASON_TRANSFER_NOT_SUPPORTED : 4,
|
RESULT_REASON_TRANSFER_NOT_SUPPORTED: 4,
|
||||||
DEFAULT_MESSAGE_ID : 1,
|
DEFAULT_MESSAGE_ID: 1,
|
||||||
LITTLE_ENDIAN : 1,
|
LITTLE_ENDIAN: 1,
|
||||||
BIG_ENDIAN : 2,
|
BIG_ENDIAN: 2,
|
||||||
VM_SINGLE :1,
|
VM_SINGLE: 1,
|
||||||
VM_TWO : 3,
|
VM_TWO: 3,
|
||||||
VM_THREE : 4,
|
VM_THREE: 4,
|
||||||
VM_FOUR : 5,
|
VM_FOUR: 5,
|
||||||
VM_1N : 6,
|
VM_1N: 6,
|
||||||
VM_2N :7,
|
VM_2N: 7,
|
||||||
VM_3N :8,
|
VM_3N: 8,
|
||||||
VM_6N :9,
|
VM_6N: 9,
|
||||||
VM_3_3N : 10,
|
VM_3_3N: 10,
|
||||||
VM_2_2N : 11,
|
VM_2_2N: 11,
|
||||||
VM_16 : 12,
|
VM_16: 12,
|
||||||
VM_1_2 : 13,
|
VM_1_2: 13,
|
||||||
VM_1_3 : 18,
|
VM_1_3: 18,
|
||||||
VM_SIX : 14,
|
VM_SIX: 14,
|
||||||
VM_NINE : 15,
|
VM_NINE: 15,
|
||||||
VM_1_32 : 16,
|
VM_1_32: 16,
|
||||||
VM_1_99 : 17,
|
VM_1_99: 17,
|
||||||
PRIORITY_LOW : 0x2,
|
PRIORITY_LOW: 0x2,
|
||||||
PRIORITY_MEDIUM : 0x0,
|
PRIORITY_MEDIUM: 0x0,
|
||||||
PRIORITY_HIGH : 0x1,
|
PRIORITY_HIGH: 0x1,
|
||||||
DATA_SET_PRESENT : 1,
|
DATA_SET_PRESENT: 1,
|
||||||
DATE_SET_ABSENCE : 0x0101,
|
DATE_SET_ABSENCE: 0x0101,
|
||||||
DATA_TYPE_COMMAND : 1,
|
DATA_TYPE_COMMAND: 1,
|
||||||
DATA_TYPE_DATA : 0,
|
DATA_TYPE_DATA: 0,
|
||||||
DATA_IS_LAST : 1,
|
DATA_IS_LAST: 1,
|
||||||
DATA_NOT_LAST : 0,
|
DATA_NOT_LAST: 0,
|
||||||
SOURCE_SERVICE_USER : 0,
|
SOURCE_SERVICE_USER: 0,
|
||||||
SOURCE_SERVICE_PROVIDER : 2,
|
SOURCE_SERVICE_PROVIDER: 2,
|
||||||
QUERY_RETRIEVE_LEVEL_PATIENT : "PATIENT",
|
QUERY_RETRIEVE_LEVEL_PATIENT: 'PATIENT',
|
||||||
QUERY_RETRIEVE_LEVEL_STUDY : "STUDY",
|
QUERY_RETRIEVE_LEVEL_STUDY: 'STUDY',
|
||||||
QUERY_RETRIEVE_LEVEL_SERIES : "SERIES",
|
QUERY_RETRIEVE_LEVEL_SERIES: 'SERIES',
|
||||||
QUERY_RETRIEVE_LEVEL_IMAGE : "IMAGE",
|
QUERY_RETRIEVE_LEVEL_IMAGE: 'IMAGE',
|
||||||
VALUE_LENGTH_UNDEFINED : 0xffffffff,
|
VALUE_LENGTH_UNDEFINED: 0xffffffff,
|
||||||
STATUS_SUCCESS : 0x0000,
|
STATUS_SUCCESS: 0x0000,
|
||||||
STATUS_CANCEL : 0xfe00,
|
STATUS_CANCEL: 0xfe00,
|
||||||
STATUS_CFIND_CONT_OK : 0xff00,
|
STATUS_CFIND_CONT_OK: 0xff00,
|
||||||
STATUS_CFIND_CONT_WARN : 0xff01,
|
STATUS_CFIND_CONT_WARN: 0xff01,
|
||||||
COMMAND_C_GET_RSP : 0x8010,
|
COMMAND_C_GET_RSP: 0x8010,
|
||||||
COMMAND_C_MOVE_RSP : 0x8021,
|
COMMAND_C_MOVE_RSP: 0x8021,
|
||||||
COMMAND_C_GET_RQ : 0x10,
|
COMMAND_C_GET_RQ: 0x10,
|
||||||
COMMAND_C_STORE_RQ : 0x01,
|
COMMAND_C_STORE_RQ: 0x01,
|
||||||
COMMAND_C_FIND_RSP : 0x8020,
|
COMMAND_C_FIND_RSP: 0x8020,
|
||||||
COMMAND_C_MOVE_RQ : 0x21,
|
COMMAND_C_MOVE_RQ: 0x21,
|
||||||
COMMAND_C_FIND_RQ : 0x20,
|
COMMAND_C_FIND_RQ: 0x20,
|
||||||
COMMAND_C_STORE_RSP : 0x8001
|
COMMAND_C_STORE_RSP: 0x8001
|
||||||
};
|
};
|
||||||
@ -1 +1 @@
|
|||||||
util = Npm.require("util");
|
util = Npm.require('util');
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
Package.describe({
|
Package.describe({
|
||||||
name: "hangingprotocols",
|
name: 'hangingprotocols',
|
||||||
summary: "Support functions for using DICOM Hanging Protocols",
|
summary: 'Support functions for using DICOM Hanging Protocols',
|
||||||
version: '0.0.1'
|
version: '0.0.1'
|
||||||
});
|
});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function(api) {
|
||||||
api.use('cornerstone');;
|
api.use('cornerstone');;
|
||||||
|
|
||||||
api.addFiles('server/namespace.js', 'server');
|
api.addFiles('server/namespace.js', 'server');
|
||||||
@ -13,5 +13,5 @@ Package.onUse(function (api) {
|
|||||||
|
|
||||||
api.export('instanceDataToJsObject', 'server');
|
api.export('instanceDataToJsObject', 'server');
|
||||||
api.export('TAG_DICT', 'server');
|
api.export('TAG_DICT', 'server');
|
||||||
api.export("DICOMHP", ['client', 'server']);
|
api.export('DICOMHP', [ 'client', 'server' ]);
|
||||||
});
|
});
|
||||||
File diff suppressed because it is too large
Load Diff
@ -4,14 +4,14 @@
|
|||||||
* @param dataSet
|
* @param dataSet
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
dataSetToJsWithDictionary = function (dataSet, dictionary, options) {
|
dataSetToJsWithDictionary = function(dataSet, dictionary, options) {
|
||||||
if (!dataSet) {
|
if (!dataSet) {
|
||||||
throw 'dataSetToJsWithDictionary: missing required parameter dataSet';
|
throw 'dataSetToJsWithDictionary: missing required parameter dataSet';
|
||||||
}
|
}
|
||||||
|
|
||||||
options = options || {
|
options = options || {
|
||||||
omitPrivateAttibutes: true, // true if private elements should be omitted
|
omitPrivateAttibutes: true, // true if private elements should be omitted
|
||||||
maxElementLength : 128 // maximum element length to try and convert to string format
|
maxElementLength: 128 // maximum element length to try and convert to string format
|
||||||
};
|
};
|
||||||
|
|
||||||
// For the purpose of inserting a comma into the tag in order
|
// For the purpose of inserting a comma into the tag in order
|
||||||
@ -20,7 +20,7 @@ dataSetToJsWithDictionary = function (dataSet, dictionary, options) {
|
|||||||
|
|
||||||
var result = {};
|
var result = {};
|
||||||
|
|
||||||
for(var tag in dataSet.elements) {
|
for (var tag in dataSet.elements) {
|
||||||
var element = dataSet.elements[tag];
|
var element = dataSet.elements[tag];
|
||||||
|
|
||||||
// Reformat the tag from x00020010 to "0002,0010" to suit the dictionary
|
// Reformat the tag from x00020010 to "0002,0010" to suit the dictionary
|
||||||
@ -43,18 +43,18 @@ dataSetToJsWithDictionary = function (dataSet, dictionary, options) {
|
|||||||
element.vr = tagDictionaryEntry.vr;
|
element.vr = tagDictionaryEntry.vr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// skip this element if it a private element and our options specify that we should
|
// skip this element if it a private element and our options specify that we should
|
||||||
if(options.omitPrivateAttibutes === true && dicomParser.isPrivateTag(tag)) {
|
if (options.omitPrivateAttibutes === true && dicomParser.isPrivateTag(tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(element.items) {
|
if (element.items) {
|
||||||
// handle sequences
|
// handle sequences
|
||||||
var sequenceItems = [];
|
var sequenceItems = [];
|
||||||
for(var i=0; i < element.items.length; i++) {
|
for (var i = 0; i < element.items.length; i++) {
|
||||||
sequenceItems.push(dicomParser.dataSetToJsWithDictionary(element.items[i].dataSet, dictionary, options));
|
sequenceItems.push(dicomParser.dataSetToJsWithDictionary(element.items[i].dataSet, dictionary, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
result[tagName] = sequenceItems;
|
result[tagName] = sequenceItems;
|
||||||
} else {
|
} else {
|
||||||
var asString;
|
var asString;
|
||||||
@ -63,12 +63,12 @@ dataSetToJsWithDictionary = function (dataSet, dictionary, options) {
|
|||||||
asString = dicomParser.explicitElementToString(dataSet, element);
|
asString = dicomParser.explicitElementToString(dataSet, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(asString !== undefined) {
|
if (asString !== undefined) {
|
||||||
result[tagName] = asString;
|
result[tagName] = asString;
|
||||||
} else {
|
} else {
|
||||||
result[tagName] = {
|
result[tagName] = {
|
||||||
dataOffset: element.dataOffset,
|
dataOffset: element.dataOffset,
|
||||||
length : element.length
|
length: element.length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ var valueRepresentationTypes = {
|
|||||||
* @param instance
|
* @param instance
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
instanceDataToJsObject = function (instance, dictionary) {
|
instanceDataToJsObject = function(instance, dictionary) {
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
throw 'instanceDataToJsObject: missing required parameter dataSet';
|
throw 'instanceDataToJsObject: missing required parameter dataSet';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,51 +1,52 @@
|
|||||||
DICOMHP.select = function(hpInstance) {
|
DICOMHP.select = function(hpInstance) {
|
||||||
var imageSetsSequence = hpInstance["00720020"].Value;
|
var imageSetsSequence = hpInstance['00720020'].Value;
|
||||||
if (!imageSetsSequence) {
|
if (!imageSetsSequence) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var matchedImageSets = [];
|
var matchedImageSets = [];
|
||||||
imageSetsSequence.forEach(function(imageSet) {
|
imageSetsSequence.forEach(function(imageSet) {
|
||||||
var selectorSequence = imageSet["00720022"].Value;
|
var selectorSequence = imageSet['00720022'].Value;
|
||||||
selectorSequence.forEach(function(selector){
|
selectorSequence.forEach(function(selector) {
|
||||||
var usageFlag = selector["00720024"].Value[0],
|
var usageFlag = selector['00720024'].Value[0],
|
||||||
selectorAttribute = selector["00720026"].Value[0],
|
selectorAttribute = selector['00720026'].Value[0],
|
||||||
selectorAttributeVR = selector["00720050"].Value[0],
|
selectorAttributeVR = selector['00720050'].Value[0],
|
||||||
selectorAttributeValue = null;
|
selectorAttributeValue = null;
|
||||||
|
|
||||||
if (selectorAttributeVR == 'SQ') {
|
if (selectorAttributeVR == 'SQ') {
|
||||||
return;
|
return;
|
||||||
} else if (selectorAttributeVR == 'AT') {
|
} else if (selectorAttributeVR == 'AT') {
|
||||||
selectorAttributeValue = selector["00720060"].Value[0];
|
selectorAttributeValue = selector['00720060'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'CS') {
|
} else if (selectorAttributeVR == 'CS') {
|
||||||
selectorAttributeValue = selector["00720062"].Value[0];
|
selectorAttributeValue = selector['00720062'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'IS') {
|
} else if (selectorAttributeVR == 'IS') {
|
||||||
selectorAttributeValue = selector["00720064"].Value[0];
|
selectorAttributeValue = selector['00720064'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'LO') {
|
} else if (selectorAttributeVR == 'LO') {
|
||||||
selectorAttributeValue = selector["00720066"].Value[0];
|
selectorAttributeValue = selector['00720066'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'LT') {
|
} else if (selectorAttributeVR == 'LT') {
|
||||||
selectorAttributeValue = selector["00720068"].Value[0];
|
selectorAttributeValue = selector['00720068'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'PN') {
|
} else if (selectorAttributeVR == 'PN') {
|
||||||
selectorAttributeValue = selector["0072006A"].Value[0];
|
selectorAttributeValue = selector['0072006A'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'SH') {
|
} else if (selectorAttributeVR == 'SH') {
|
||||||
selectorAttributeValue = selector["0072006C"].Value[0];
|
selectorAttributeValue = selector['0072006C'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'ST') {
|
} else if (selectorAttributeVR == 'ST') {
|
||||||
selectorAttributeValue = selector["0072006E"].Value[0];
|
selectorAttributeValue = selector['0072006E'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'UT') {
|
} else if (selectorAttributeVR == 'UT') {
|
||||||
selectorAttributeValue = selector["00720070"].Value[0];
|
selectorAttributeValue = selector['00720070'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'DS') {
|
} else if (selectorAttributeVR == 'DS') {
|
||||||
selectorAttributeValue = selector["00720072"].Value[0];
|
selectorAttributeValue = selector['00720072'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'FD') {
|
} else if (selectorAttributeVR == 'FD') {
|
||||||
selectorAttributeValue = selector["00720074"].Value[0];
|
selectorAttributeValue = selector['00720074'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'FL') {
|
} else if (selectorAttributeVR == 'FL') {
|
||||||
selectorAttributeValue = selector["00720076"].Value[0];
|
selectorAttributeValue = selector['00720076'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'UL') {
|
} else if (selectorAttributeVR == 'UL') {
|
||||||
selectorAttributeValue = selector["00720078"].Value[0];
|
selectorAttributeValue = selector['00720078'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'US') {
|
} else if (selectorAttributeVR == 'US') {
|
||||||
selectorAttributeValue = selector["0072007A"].Value[0];
|
selectorAttributeValue = selector['0072007A'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'SL') {
|
} else if (selectorAttributeVR == 'SL') {
|
||||||
selectorAttributeValue = selector["0072007C"].Value[0];
|
selectorAttributeValue = selector['0072007C'].Value[0];
|
||||||
} else if (selectorAttributeVR == 'SS') {
|
} else if (selectorAttributeVR == 'SS') {
|
||||||
selectorAttributeValue = selector["0072007E"].Value[0];
|
selectorAttributeValue = selector['0072007E'].Value[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectorAttributeValue !== null) {
|
if (selectorAttributeValue !== null) {
|
||||||
@ -53,18 +54,18 @@ DICOMHP.select = function(hpInstance) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var timeBasedImageSetsSequence = imageSet["00720030"].Value;
|
var timeBasedImageSetsSequence = imageSet['00720030'].Value;
|
||||||
timeBasedImageSetsSequence.forEach(function(timeImageSet){
|
timeBasedImageSetsSequence.forEach(function(timeImageSet) {
|
||||||
var setNumber = timeImageSet["00720032"].Value[0], selectorCategory = timeImageSet["00720034"].Value[0];
|
var setNumber = timeImageSet['00720032'].Value[0], selectorCategory = timeImageSet['00720034'].Value[0];
|
||||||
|
|
||||||
var mImageSet = new DICOMHP.imageSet(setNumber, selectorCategory);
|
var mImageSet = new DICOMHP.imageSet(setNumber, selectorCategory);
|
||||||
if (selectorCategory == 'RELATIVE_TIME') {
|
if (selectorCategory == 'RELATIVE_TIME') {
|
||||||
var relativeTime = timeImageSet["00720038"].Value[0], timeUnits = timeImageSet["0072003A"].Value[0];
|
var relativeTime = timeImageSet['00720038'].Value[0], timeUnits = timeImageSet['0072003A'].Value[0];
|
||||||
|
|
||||||
mImageSet.setRelativeTime(relativeTime);
|
mImageSet.setRelativeTime(relativeTime);
|
||||||
mImageSet.setTimeUnits(timeUnits);
|
mImageSet.setTimeUnits(timeUnits);
|
||||||
} else if (selectorCategory == 'ABSTRACT_PRIOR') {
|
} else if (selectorCategory == 'ABSTRACT_PRIOR') {
|
||||||
var priorValue = timeImageSet["0072003C"].Value[0];
|
var priorValue = timeImageSet['0072003C'].Value[0];
|
||||||
|
|
||||||
mImageSet.setPriorValue(priorValue);
|
mImageSet.setPriorValue(priorValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,106 +3,106 @@ LesionLocations = new Meteor.Collection(null);
|
|||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'liverLeft',
|
id: 'liverLeft',
|
||||||
group: 'liver',
|
group: 'liver',
|
||||||
location: "Liver Left",
|
location: 'Liver Left',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'liverRight',
|
id: 'liverRight',
|
||||||
group: 'liver',
|
group: 'liver',
|
||||||
location: "Liver Right",
|
location: 'Liver Right',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'liverCaudate',
|
id: 'liverCaudate',
|
||||||
group: 'liver',
|
group: 'liver',
|
||||||
location: "Liver Caudate",
|
location: 'Liver Caudate',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'lungLLL',
|
id: 'lungLLL',
|
||||||
group: 'lung',
|
group: 'lung',
|
||||||
location: "Lung LLL",
|
location: 'Lung LLL',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'lungLUL',
|
id: 'lungLUL',
|
||||||
group: 'lung',
|
group: 'lung',
|
||||||
location: "Lung LUL",
|
location: 'Lung LUL',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'lungRLL',
|
id: 'lungRLL',
|
||||||
group: 'lung',
|
group: 'lung',
|
||||||
location: "Lung RLL",
|
location: 'Lung RLL',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'lungRML',
|
id: 'lungRML',
|
||||||
group: 'lung',
|
group: 'lung',
|
||||||
location: "Lung RML",
|
location: 'Lung RML',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'lungRUL',
|
id: 'lungRUL',
|
||||||
group: 'lung',
|
group: 'lung',
|
||||||
location: "Lung RUL",
|
location: 'Lung RUL',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'pleuraLeft',
|
id: 'pleuraLeft',
|
||||||
group: 'pleura',
|
group: 'pleura',
|
||||||
location: "Pleura Left",
|
location: 'Pleura Left',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'pleuraRight',
|
id: 'pleuraRight',
|
||||||
group: 'pleura',
|
group: 'pleura',
|
||||||
location: "Pleura Right",
|
location: 'Pleura Right',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'kidneyLeft',
|
id: 'kidneyLeft',
|
||||||
group: 'kidney',
|
group: 'kidney',
|
||||||
location: "Kidney Left",
|
location: 'Kidney Left',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: "",
|
description: '',
|
||||||
selected: false
|
selected: false
|
||||||
});
|
});
|
||||||
|
|
||||||
LesionLocations.insert({
|
LesionLocations.insert({
|
||||||
id: 'kidneyRight',
|
id: 'kidneyRight',
|
||||||
group: 'kidney',
|
group: 'kidney',
|
||||||
location: "Kidney Right",
|
location: 'Kidney Right',
|
||||||
hasDescription: false,
|
hasDescription: false,
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
@ -1,43 +1,43 @@
|
|||||||
LocationResponses = new Meteor.Collection(null);
|
LocationResponses = new Meteor.Collection(null);
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Complete response",
|
text: 'Complete response',
|
||||||
code: "CR",
|
code: 'CR',
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Progressive disease",
|
text: 'Progressive disease',
|
||||||
code: "PD",
|
code: 'PD',
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Stable disease",
|
text: 'Stable disease',
|
||||||
code: "SD",
|
code: 'SD',
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Present",
|
text: 'Present',
|
||||||
code: false,
|
code: false,
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Not Evaluable",
|
text: 'Not Evaluable',
|
||||||
code: "NE",
|
code: 'NE',
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Non-CR/Non-PD",
|
text: 'Non-CR/Non-PD',
|
||||||
code: "NN",
|
code: 'NN',
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.insert({
|
LocationResponses.insert({
|
||||||
text: "Excluded from Assessment",
|
text: 'Excluded from Assessment',
|
||||||
code: "EX",
|
code: 'EX',
|
||||||
description: ""
|
description: ''
|
||||||
});
|
});
|
||||||
@ -29,7 +29,9 @@ var LesionManager = (function() {
|
|||||||
function updateLesionData(lesionData) {
|
function updateLesionData(lesionData) {
|
||||||
// Find the related Timepoint from the Timepoints Collection
|
// Find the related Timepoint from the Timepoints Collection
|
||||||
var timepointID = lesionData.timepointID;
|
var timepointID = lesionData.timepointID;
|
||||||
var timepoint = Timepoints.findOne({timepointID: timepointID});
|
var timepoint = Timepoints.findOne({
|
||||||
|
timepointID: timepointID
|
||||||
|
});
|
||||||
if (!timepoint) {
|
if (!timepoint) {
|
||||||
log.warn('Timepoint in an image is not present in the Timepoints Collection?');
|
log.warn('Timepoint in an image is not present in the Timepoints Collection?');
|
||||||
return;
|
return;
|
||||||
@ -126,7 +128,9 @@ var LesionManager = (function() {
|
|||||||
var measurements = Measurements.find({
|
var measurements = Measurements.find({
|
||||||
isTarget: isTarget
|
isTarget: isTarget
|
||||||
}, {
|
}, {
|
||||||
sort: {lesionNumber: 1}
|
sort: {
|
||||||
|
lesionNumber: 1
|
||||||
|
}
|
||||||
}).fetch();
|
}).fetch();
|
||||||
|
|
||||||
// If measurements exist, find the last lesion number
|
// If measurements exist, find the last lesion number
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
nearbyToolIndex,
|
nearbyToolIndex,
|
||||||
nearbyToolType;
|
nearbyToolType;
|
||||||
|
|
||||||
toolTypes.forEach(function(toolType){
|
toolTypes.forEach(function(toolType) {
|
||||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||||
if (!toolData) {
|
if (!toolData) {
|
||||||
return;
|
return;
|
||||||
@ -75,7 +75,7 @@
|
|||||||
if (keyCode === keys.DELETE ||
|
if (keyCode === keys.DELETE ||
|
||||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||||
|
|
||||||
var toolTypes = ["lesion", "nonTarget"];
|
var toolTypes = [ 'lesion', 'nonTarget' ];
|
||||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||||
|
|
||||||
if (!nearbyToolData) {
|
if (!nearbyToolData) {
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||||
|
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
var toolType = "lesion";
|
var toolType = 'lesion';
|
||||||
|
|
||||||
var configuration = {
|
var configuration = {
|
||||||
setLesionNumberCallback: setLesionNumberCallback,
|
setLesionNumberCallback: setLesionNumberCallback,
|
||||||
@ -221,6 +221,7 @@
|
|||||||
if (!handle.boundingBox) {
|
if (!handle.boundingBox) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
|
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,7 +515,7 @@
|
|||||||
// Sets drawnIndependently property of control points(handles)
|
// Sets drawnIndependently property of control points(handles)
|
||||||
function setControlPoints(handles, value) {
|
function setControlPoints(handles, value) {
|
||||||
Object.keys(handles).forEach(function(name) {
|
Object.keys(handles).forEach(function(name) {
|
||||||
if (name !== "textBox") {
|
if (name !== 'textBox') {
|
||||||
var handle = handles[name];
|
var handle = handles[name];
|
||||||
handle.drawnIndependently = value;
|
handle.drawnIndependently = value;
|
||||||
}
|
}
|
||||||
@ -730,7 +731,6 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function findDottedLinePosition(data) {
|
function findDottedLinePosition(data) {
|
||||||
|
|
||||||
var distancesArr = [];
|
var distancesArr = [];
|
||||||
@ -775,6 +775,7 @@
|
|||||||
minDistance = distanceToPerpendicularEnd;
|
minDistance = distanceToPerpendicularEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < distancesArr.length; i++) {
|
for (var i = 0; i < distancesArr.length; i++) {
|
||||||
var obj = distancesArr[i];
|
var obj = distancesArr[i];
|
||||||
if (obj.distance === minDistance) {
|
if (obj.distance === minDistance) {
|
||||||
@ -840,7 +841,7 @@
|
|||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.strokeStyle = color;
|
context.strokeStyle = color;
|
||||||
context.lineWidth = lineWidth;
|
context.lineWidth = lineWidth;
|
||||||
context.setLineDash([2, 3]);
|
context.setLineDash([ 2, 3 ]);
|
||||||
|
|
||||||
// Set position of text
|
// Set position of text
|
||||||
var perpendicularStartCanvas = cornerstone.pixelToCanvas(element, findDottedLinePosition(data));
|
var perpendicularStartCanvas = cornerstone.pixelToCanvas(element, findDottedLinePosition(data));
|
||||||
@ -858,7 +859,6 @@
|
|||||||
var wy = (data.handles.perpendicularStart.y - data.handles.perpendicularEnd.y) * (eventData.image.rowPixelSpacing || 1);
|
var wy = (data.handles.perpendicularStart.y - data.handles.perpendicularEnd.y) * (eventData.image.rowPixelSpacing || 1);
|
||||||
var width = Math.sqrt(wx * wx + wy * wy);
|
var width = Math.sqrt(wx * wx + wy * wy);
|
||||||
|
|
||||||
|
|
||||||
var suffix = ' mm';
|
var suffix = ' mm';
|
||||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||||
suffix = ' pixels';
|
suffix = ' pixels';
|
||||||
@ -866,7 +866,7 @@
|
|||||||
|
|
||||||
var lengthText = ' L ' + length.toFixed(1) + suffix;
|
var lengthText = ' L ' + length.toFixed(1) + suffix;
|
||||||
var widthText = ' W ' + width.toFixed(1) + suffix;
|
var widthText = ' W ' + width.toFixed(1) + suffix;
|
||||||
var textLines = ['Target ' + data.lesionNumber, lengthText, widthText];
|
var textLines = [ 'Target ' + data.lesionNumber, lengthText, widthText ];
|
||||||
|
|
||||||
var boundingBox = cornerstoneTools.drawTextBox(context,
|
var boundingBox = cornerstoneTools.drawTextBox(context,
|
||||||
textLines,
|
textLines,
|
||||||
|
|||||||
@ -68,7 +68,7 @@
|
|||||||
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||||
// delete the measurement
|
// delete the measurement
|
||||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||||
}else{
|
}else {
|
||||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -150,6 +150,7 @@
|
|||||||
if (!handle.boundingBox) {
|
if (!handle.boundingBox) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
|
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +218,7 @@
|
|||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.strokeStyle = color;
|
context.strokeStyle = color;
|
||||||
context.lineWidth = lineWidth;
|
context.lineWidth = lineWidth;
|
||||||
context.setLineDash([2, 3]);
|
context.setLineDash([ 2, 3 ]);
|
||||||
|
|
||||||
context.moveTo(mid.x, mid.y);
|
context.moveTo(mid.x, mid.y);
|
||||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||||
@ -254,6 +255,7 @@
|
|||||||
if (measurementData.lesionName === undefined) {
|
if (measurementData.lesionName === undefined) {
|
||||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
|
|
||||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||||
@ -266,14 +268,12 @@
|
|||||||
|
|
||||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||||
|
|
||||||
|
|
||||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||||
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function doubleClickCallback(e, eventData) {
|
function doubleClickCallback(e, eventData) {
|
||||||
var element = eventData.element;
|
var element = eventData.element;
|
||||||
var data;
|
var data;
|
||||||
@ -339,5 +339,4 @@
|
|||||||
// pressCallback: doubleClickCallback
|
// pressCallback: doubleClickCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||||
|
|||||||
@ -12,14 +12,17 @@
|
|||||||
|
|
||||||
var startPoint = {
|
var startPoint = {
|
||||||
x: config.verticalLine.start.x,
|
x: config.verticalLine.start.x,
|
||||||
y: config.verticalLine.start.y + i*config.verticalMinorTick
|
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||||
};
|
};
|
||||||
|
|
||||||
var endPoint = {x: 0, y: config.verticalLine.start.y + i*config.verticalMinorTick};
|
var endPoint = {
|
||||||
if (i%5 === 0) {
|
x: 0,
|
||||||
|
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||||
|
};
|
||||||
|
if (i% 5 === 0) {
|
||||||
|
|
||||||
endPoint.x = config.verticalLine.start.x - config.majorTickLength;
|
endPoint.x = config.verticalLine.start.x - config.majorTickLength;
|
||||||
} else{
|
} else {
|
||||||
|
|
||||||
endPoint.x = config.verticalLine.start.x - config.minorTickLength;
|
endPoint.x = config.verticalLine.start.x - config.minorTickLength;
|
||||||
}
|
}
|
||||||
@ -38,17 +41,19 @@
|
|||||||
|
|
||||||
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.right) {
|
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.right) {
|
||||||
|
|
||||||
|
|
||||||
startPoint = {
|
startPoint = {
|
||||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||||
y: config.horizontalLine.start.y
|
y: config.horizontalLine.start.y
|
||||||
};
|
};
|
||||||
|
|
||||||
endPoint = {x: config.horizontalLine.start.x + i * config.horizontalMinorTick, y: 0};
|
endPoint = {
|
||||||
if (i%5 === 0) {
|
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||||
|
y: 0
|
||||||
|
};
|
||||||
|
if (i% 5 === 0) {
|
||||||
|
|
||||||
endPoint.y = config.horizontalLine.start.y - config.majorTickLength;
|
endPoint.y = config.horizontalLine.start.y - config.majorTickLength;
|
||||||
} else{
|
} else {
|
||||||
|
|
||||||
endPoint.y = config.horizontalLine.start.y - config.minorTickLength;
|
endPoint.y = config.horizontalLine.start.y - config.minorTickLength;
|
||||||
}
|
}
|
||||||
@ -70,8 +75,14 @@
|
|||||||
function drawFrameLines(context, config){
|
function drawFrameLines(context, config){
|
||||||
|
|
||||||
// Vertical Line
|
// Vertical Line
|
||||||
var startPoint = {x: config.verticalLine.start.x, y: config.verticalLine.start.y};
|
var startPoint = {
|
||||||
var endPoint = {x: config.verticalLine.end.x, y: config.verticalLine.end.y};
|
x: config.verticalLine.start.x,
|
||||||
|
y: config.verticalLine.start.y
|
||||||
|
};
|
||||||
|
var endPoint = {
|
||||||
|
x: config.verticalLine.end.x,
|
||||||
|
y: config.verticalLine.end.y
|
||||||
|
};
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.strokeStyle = config.color;
|
context.strokeStyle = config.color;
|
||||||
@ -80,10 +91,15 @@
|
|||||||
context.lineTo(endPoint.x, endPoint.y);
|
context.lineTo(endPoint.x, endPoint.y);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
|
|
||||||
|
|
||||||
// Horizontal line
|
// Horizontal line
|
||||||
startPoint = {x: config.horizontalLine.start.x , y: config.horizontalLine.start.y};
|
startPoint = {
|
||||||
endPoint = {x: config.horizontalLine.end.x, y: config.horizontalLine.end.y};
|
x: config.horizontalLine.start.x ,
|
||||||
|
y: config.horizontalLine.start.y
|
||||||
|
};
|
||||||
|
endPoint = {
|
||||||
|
x: config.horizontalLine.end.x,
|
||||||
|
y: config.horizontalLine.end.y
|
||||||
|
};
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.strokeStyle = config.color;
|
context.strokeStyle = config.color;
|
||||||
@ -101,30 +117,24 @@
|
|||||||
var intersectLeftRight;
|
var intersectLeftRight;
|
||||||
var intersectTopBottom;
|
var intersectTopBottom;
|
||||||
|
|
||||||
if (canvasBounds.width >= 0)
|
if (canvasBounds.width >= 0) {
|
||||||
{
|
|
||||||
if (imageBounds.width >= 0)
|
if (imageBounds.width >= 0)
|
||||||
intersectLeftRight = !((canvasBounds.right <= imageBounds.left) || (imageBounds.right <= canvasBounds.left));
|
intersectLeftRight = !((canvasBounds.right <= imageBounds.left) || (imageBounds.right <= canvasBounds.left));
|
||||||
else
|
else
|
||||||
intersectLeftRight = !((canvasBounds.right <= imageBounds.right) || (imageBounds.left <= canvasBounds.left));
|
intersectLeftRight = !((canvasBounds.right <= imageBounds.right) || (imageBounds.left <= canvasBounds.left));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (imageBounds.width >= 0)
|
if (imageBounds.width >= 0)
|
||||||
intersectLeftRight = !((canvasBounds.left <= imageBounds.left) || (imageBounds.right <= canvasBounds.right));
|
intersectLeftRight = !((canvasBounds.left <= imageBounds.left) || (imageBounds.right <= canvasBounds.right));
|
||||||
else
|
else
|
||||||
intersectLeftRight = !((canvasBounds.left <= imageBounds.right) || (imageBounds.left <= canvasBounds.right));
|
intersectLeftRight = !((canvasBounds.left <= imageBounds.right) || (imageBounds.left <= canvasBounds.right));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvasBounds.height >= 0)
|
if (canvasBounds.height >= 0) {
|
||||||
{
|
|
||||||
if (imageBounds.height >= 0)
|
if (imageBounds.height >= 0)
|
||||||
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.top));
|
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.top));
|
||||||
else
|
else
|
||||||
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.top));
|
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.top));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (imageBounds.height >= 0)
|
if (imageBounds.height >= 0)
|
||||||
intersectTopBottom = !((canvasBounds.top <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.bottom));
|
intersectTopBottom = !((canvasBounds.top <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.bottom));
|
||||||
else
|
else
|
||||||
@ -142,60 +152,42 @@
|
|||||||
bottom: 0
|
bottom: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!doesIntersect(canvasBounds, imageBounds)) {
|
if (!doesIntersect(canvasBounds, imageBounds)) {
|
||||||
return intersectPoints;
|
return intersectPoints;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvasBounds.width >= 0)
|
if (canvasBounds.width >= 0) {
|
||||||
{
|
if (imageBounds.width >= 0) {
|
||||||
if (imageBounds.width >= 0)
|
|
||||||
{
|
|
||||||
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.left);
|
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.left);
|
||||||
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.right);
|
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.right);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.right);
|
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.right);
|
||||||
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.left);
|
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.left);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (imageBounds.width >= 0) {
|
||||||
{
|
|
||||||
if (imageBounds.width >= 0)
|
|
||||||
{
|
|
||||||
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.right);
|
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.right);
|
||||||
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.left);
|
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.left);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.left);
|
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.left);
|
||||||
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.right);
|
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvasBounds.height >= 0)
|
if (canvasBounds.height >= 0) {
|
||||||
{
|
if (imageBounds.height >= 0) {
|
||||||
if (imageBounds.height >= 0)
|
|
||||||
{
|
|
||||||
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.top);
|
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.top);
|
||||||
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.bottom);
|
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.bottom);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.bottom);
|
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.bottom);
|
||||||
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.top);
|
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.top);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (imageBounds.height >= 0) {
|
||||||
{
|
|
||||||
if (imageBounds.height >= 0)
|
|
||||||
{
|
|
||||||
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.bottom);
|
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.bottom);
|
||||||
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.top);
|
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.top);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.top);
|
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.top);
|
||||||
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.bottom);
|
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.bottom);
|
||||||
}
|
}
|
||||||
@ -228,9 +220,18 @@
|
|||||||
height: canvasBounds.height - 2 * vReduction
|
height: canvasBounds.height - 2 * vReduction
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPoint = {x: 0, y: 0};
|
var startPoint = {
|
||||||
var startPointImageBounds = {x: startPoint.x, y: startPoint.y};
|
x: 0,
|
||||||
var endPointImageBounds = {x: startPoint.x + imageSize.width, y: startPoint.y + imageSize.height};
|
y: 0
|
||||||
|
};
|
||||||
|
var startPointImageBounds = {
|
||||||
|
x: startPoint.x,
|
||||||
|
y: startPoint.y
|
||||||
|
};
|
||||||
|
var endPointImageBounds = {
|
||||||
|
x: startPoint.x + imageSize.width,
|
||||||
|
y: startPoint.y + imageSize.height
|
||||||
|
};
|
||||||
|
|
||||||
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
|
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
|
||||||
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
|
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
|
||||||
@ -238,7 +239,6 @@
|
|||||||
var imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
|
var imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
|
||||||
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
|
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
|
||||||
|
|
||||||
|
|
||||||
hReduction = horizontalReduction * imageBoundsWidth;
|
hReduction = horizontalReduction * imageBoundsWidth;
|
||||||
vReduction = verticalReduction * imageBoundsHeight;
|
vReduction = verticalReduction * imageBoundsHeight;
|
||||||
|
|
||||||
@ -268,14 +268,19 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var canvasSize = { width: eventData.enabledElement.canvas.width, height: eventData.enabledElement.canvas.height};
|
var canvasSize = {
|
||||||
var imageSize = {width: eventData.enabledElement.image.width , height: eventData.enabledElement.image.height};
|
width: eventData.enabledElement.canvas.width,
|
||||||
|
height: eventData.enabledElement.canvas.height
|
||||||
|
};
|
||||||
|
var imageSize = {
|
||||||
|
width: eventData.enabledElement.image.width ,
|
||||||
|
height: eventData.enabledElement.image.height
|
||||||
|
};
|
||||||
|
|
||||||
// Distance between intervals is 10mm
|
// Distance between intervals is 10mm
|
||||||
var verticalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
var verticalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||||
var horizontalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
var horizontalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||||
|
|
||||||
|
|
||||||
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height ) {
|
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -294,12 +299,24 @@
|
|||||||
minorTickLength: 12.5,
|
minorTickLength: 12.5,
|
||||||
majorTickLength: 25,
|
majorTickLength: 25,
|
||||||
verticalLine: {
|
verticalLine: {
|
||||||
start: {x: vscaleBounds.right , y: vscaleBounds.top},
|
start: {
|
||||||
end: {x: vscaleBounds.right, y: vscaleBounds.bottom}
|
x: vscaleBounds.right ,
|
||||||
|
y: vscaleBounds.top
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
x: vscaleBounds.right,
|
||||||
|
y: vscaleBounds.bottom
|
||||||
|
}
|
||||||
},
|
},
|
||||||
horizontalLine: {
|
horizontalLine: {
|
||||||
start: {x: hscaleBounds.left, y: hscaleBounds.bottom},
|
start: {
|
||||||
end: {x: hscaleBounds.right, y: hscaleBounds.bottom}
|
x: hscaleBounds.left,
|
||||||
|
y: hscaleBounds.bottom
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
x: hscaleBounds.right,
|
||||||
|
y: hscaleBounds.bottom
|
||||||
|
}
|
||||||
},
|
},
|
||||||
color: cornerstoneTools.toolColors.getToolColor(),
|
color: cornerstoneTools.toolColors.getToolColor(),
|
||||||
lineWidth: cornerstoneTools.toolStyle.getToolWidth()
|
lineWidth: cornerstoneTools.toolStyle.getToolWidth()
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
function closeHandler() {
|
function closeHandler() {
|
||||||
// Hide the lesion dialog
|
// Hide the lesion dialog
|
||||||
$("#confirmDeleteDialog").css('display', 'none');
|
$('#confirmDeleteDialog').css('display', 'none');
|
||||||
|
|
||||||
// Remove the backdrop
|
// Remove the backdrop
|
||||||
$(".removableBackdrop").remove();
|
$('.removableBackdrop').remove();
|
||||||
|
|
||||||
// Remove the callback from the template data
|
// Remove the callback from the template data
|
||||||
delete Template.confirmDeleteDialog.doneCallback;
|
delete Template.confirmDeleteDialog.doneCallback;
|
||||||
@ -17,18 +17,18 @@ showConfirmDialog = function(doneCallback, options) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
UI.renderWithData(Template.removableBackdrop, options, document.body);
|
UI.renderWithData(Template.removableBackdrop, options, document.body);
|
||||||
|
|
||||||
var confirmDeleteDialog = $("#confirmDeleteDialog");
|
var confirmDeleteDialog = $('#confirmDeleteDialog');
|
||||||
confirmDeleteDialog.remove();
|
confirmDeleteDialog.remove();
|
||||||
|
|
||||||
var viewer = document.getElementById('viewer');
|
var viewer = document.getElementById('viewer');
|
||||||
UI.renderWithData(Template.confirmDeleteDialog, options, viewer);
|
UI.renderWithData(Template.confirmDeleteDialog, options, viewer);
|
||||||
|
|
||||||
// Make sure the context menu is closed when the user clicks away
|
// Make sure the context menu is closed when the user clicks away
|
||||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||||
closeHandler();
|
closeHandler();
|
||||||
});
|
});
|
||||||
|
|
||||||
confirmDeleteDialog = $("#confirmDeleteDialog");
|
confirmDeleteDialog = $('#confirmDeleteDialog');
|
||||||
confirmDeleteDialog.css('display', 'block');
|
confirmDeleteDialog.css('display', 'block');
|
||||||
confirmDeleteDialog.focus();
|
confirmDeleteDialog.focus();
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ function closeHandler(dialog) {
|
|||||||
$(dialog).css('display', 'none');
|
$(dialog).css('display', 'none');
|
||||||
|
|
||||||
// Remove the backdrop
|
// Remove the backdrop
|
||||||
$(".removableBackdrop").remove();
|
$('.removableBackdrop').remove();
|
||||||
|
|
||||||
// Restore the focus to the active viewport
|
// Restore the focus to the active viewport
|
||||||
setFocusToActiveViewport();
|
setFocusToActiveViewport();
|
||||||
@ -17,7 +17,9 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
|||||||
var imageId = enabledElement.image.imageId;
|
var imageId = enabledElement.image.imageId;
|
||||||
|
|
||||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||||
var timepoint = Timepoints.findOne({timepointName: study.studyDate});
|
var timepoint = Timepoints.findOne({
|
||||||
|
timepointName: study.studyDate
|
||||||
|
});
|
||||||
if (!timepoint) {
|
if (!timepoint) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -26,7 +28,7 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
|||||||
|
|
||||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||||
// exists at a different timepoint
|
// exists at a different timepoint
|
||||||
var lesionNumber = LesionManager.getNewLesionNumber(measurementData.timepointID, isTarget=true);
|
var lesionNumber = LesionManager.getNewLesionNumber(measurementData.timepointID, isTarget = true);
|
||||||
measurementData.lesionNumber = lesionNumber;
|
measurementData.lesionNumber = lesionNumber;
|
||||||
|
|
||||||
// Set lesion number
|
// Set lesion number
|
||||||
@ -43,20 +45,20 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
Template.lesionLocationDialog.doneCallback = undefined;
|
Template.lesionLocationDialog.doneCallback = undefined;
|
||||||
|
|
||||||
// Get the lesion location dialog
|
// Get the lesion location dialog
|
||||||
var dialog = $("#lesionLocationDialog");
|
var dialog = $('#lesionLocationDialog');
|
||||||
Template.lesionLocationDialog.dialog = dialog;
|
Template.lesionLocationDialog.dialog = dialog;
|
||||||
|
|
||||||
// Show the backdrop
|
// Show the backdrop
|
||||||
UI.render(Template.removableBackdrop, document.body);
|
UI.render(Template.removableBackdrop, document.body);
|
||||||
|
|
||||||
// Make sure the context menu is closed when the user clicks away
|
// Make sure the context menu is closed when the user clicks away
|
||||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||||
closeHandler(dialog);
|
closeHandler(dialog);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Select the first option for now
|
// Select the first option for now
|
||||||
var selector = dialog.find("select.selectLesionLocation");
|
var selector = dialog.find('select.selectLesionLocation');
|
||||||
selector.find("option:first").prop("selected", true);
|
selector.find('option:first').prop('selected', true);
|
||||||
|
|
||||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||||
// If it is, stop here because we don't need the dialog.
|
// If it is, stop here because we don't need the dialog.
|
||||||
@ -91,7 +93,7 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
// If device is touch device, set position center of screen vertically and horizontally
|
// If device is touch device, set position center of screen vertically and horizontally
|
||||||
if (isTouchDevice()) {
|
if (isTouchDevice()) {
|
||||||
// add dialogMobile class to provide a black,transparent background
|
// add dialogMobile class to provide a black,transparent background
|
||||||
dialog.addClass("dialogMobile");
|
dialog.addClass('dialogMobile');
|
||||||
dialogProperty.top = 0;
|
dialogProperty.top = 0;
|
||||||
dialogProperty.left = 0;
|
dialogProperty.left = 0;
|
||||||
dialogProperty.right = 0;
|
dialogProperty.right = 0;
|
||||||
@ -107,14 +109,14 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
|
|||||||
Template.lesionLocationDialog.doneCallback = doneCallback;
|
Template.lesionLocationDialog.doneCallback = doneCallback;
|
||||||
|
|
||||||
// Get the lesion location dialog
|
// Get the lesion location dialog
|
||||||
var dialog = $("#lesionLocationRelabelDialog");
|
var dialog = $('#lesionLocationRelabelDialog');
|
||||||
Template.lesionLocationDialog.dialog = dialog;
|
Template.lesionLocationDialog.dialog = dialog;
|
||||||
|
|
||||||
// Show the backdrop
|
// Show the backdrop
|
||||||
UI.render(Template.removableBackdrop, document.body);
|
UI.render(Template.removableBackdrop, document.body);
|
||||||
|
|
||||||
// Make sure the context menu is closed when the user clicks away
|
// Make sure the context menu is closed when the user clicks away
|
||||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||||
closeHandler(dialog);
|
closeHandler(dialog);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,7 +129,7 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
|
|||||||
// If device is touch device, set position center of screen vertically and horizontally
|
// If device is touch device, set position center of screen vertically and horizontally
|
||||||
if (!eventData || isTouchDevice()) {
|
if (!eventData || isTouchDevice()) {
|
||||||
// add dialogMobile class to provide a black,transparent background
|
// add dialogMobile class to provide a black,transparent background
|
||||||
dialog.addClass("dialogMobile");
|
dialog.addClass('dialogMobile');
|
||||||
dialogProperty.top = 0;
|
dialogProperty.top = 0;
|
||||||
dialogProperty.left = 0;
|
dialogProperty.left = 0;
|
||||||
dialogProperty.right = 0;
|
dialogProperty.right = 0;
|
||||||
@ -146,8 +148,14 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
LesionLocations.update({},
|
LesionLocations.update({},
|
||||||
{$set: {selected: false}},
|
{
|
||||||
{ multi: true });
|
$set: {
|
||||||
|
selected: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
multi: true
|
||||||
|
});
|
||||||
|
|
||||||
var currentLocation = LesionLocations.findOne({
|
var currentLocation = LesionLocations.findOne({
|
||||||
id: measurement.locationId
|
id: measurement.locationId
|
||||||
@ -188,10 +196,14 @@ Template.lesionLocationDialog.events({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get selected location data
|
// Get selected location data
|
||||||
var locationObj = LesionLocations.findOne({_id: selectedOptionId});
|
var locationObj = LesionLocations.findOne({
|
||||||
|
_id: selectedOptionId
|
||||||
|
});
|
||||||
|
|
||||||
var id;
|
var id;
|
||||||
var existingLocation = PatientLocations.findOne({location: locationObj.location});
|
var existingLocation = PatientLocations.findOne({
|
||||||
|
location: locationObj.location
|
||||||
|
});
|
||||||
if (existingLocation) {
|
if (existingLocation) {
|
||||||
id = existingLocation._id;
|
id = existingLocation._id;
|
||||||
} else {
|
} else {
|
||||||
@ -269,7 +281,7 @@ Template.lesionLocationDialog.events({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Template.lesionLocationDialog.helpers({
|
Template.lesionLocationDialog.helpers({
|
||||||
'lesionLocations': function() {
|
lesionLocations: function() {
|
||||||
return LesionLocations.find();
|
return LesionLocations.find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1,5 +1,5 @@
|
|||||||
Template.lesionTable.helpers({
|
Template.lesionTable.helpers({
|
||||||
'measurement': function() {
|
measurement: function() {
|
||||||
// All Targets shall be listed first followed by Non-Targets
|
// All Targets shall be listed first followed by Non-Targets
|
||||||
return Measurements.find({}, {
|
return Measurements.find({}, {
|
||||||
sort: {
|
sort: {
|
||||||
@ -8,7 +8,7 @@ Template.lesionTable.helpers({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'timepoints': function() {
|
timepoints: function() {
|
||||||
return Timepoints.find({}, {
|
return Timepoints.find({}, {
|
||||||
sort: {
|
sort: {
|
||||||
timepointName: 1
|
timepointName: 1
|
||||||
@ -49,10 +49,10 @@ Template.lesionTable.events({
|
|||||||
height: newHeight
|
height: newHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
var viewportAndLesionTableHeight = $("#viewportAndLesionTable").height();
|
var viewportAndLesionTableHeight = $('#viewportAndLesionTable').height();
|
||||||
var newPercentageHeightofLesionTable = (startHeight - topPosition) / viewportAndLesionTableHeight * 100;
|
var newPercentageHeightofLesionTable = (startHeight - topPosition) / viewportAndLesionTableHeight * 100;
|
||||||
var newPercentageHeightofViewermain = 100 - newPercentageHeightofLesionTable;
|
var newPercentageHeightofViewermain = 100 - newPercentageHeightofLesionTable;
|
||||||
$(".viewerMain").height(newPercentageHeightofViewermain + "%");
|
$('.viewerMain').height(newPercentageHeightofViewermain + '%');
|
||||||
|
|
||||||
// Resize viewport
|
// Resize viewport
|
||||||
resizeViewportElements();
|
resizeViewportElements();
|
||||||
@ -71,19 +71,19 @@ Template.lesionTable.onRendered(function() {
|
|||||||
// Put a visual indicator (<) in timepoint header in lesion table for active timepoints
|
// Put a visual indicator (<) in timepoint header in lesion table for active timepoints
|
||||||
// timepointLoaded property is used to put indicator for loaded timepoints in viewport
|
// timepointLoaded property is used to put indicator for loaded timepoints in viewport
|
||||||
self.autorun(function() {
|
self.autorun(function() {
|
||||||
var ViewerData = Session.get("ViewerData");
|
var ViewerData = Session.get('ViewerData');
|
||||||
var contentId = Session.get("activeContentId");
|
var contentId = Session.get('activeContentId');
|
||||||
if (contentId) {
|
if (contentId) {
|
||||||
var viewerData = ViewerData[contentId];
|
var viewerData = ViewerData[contentId];
|
||||||
if (viewerData) {
|
if (viewerData) {
|
||||||
if (viewerData.loadedSeriesData) {
|
if (viewerData.loadedSeriesData) {
|
||||||
// Get study dates of imageViewerViewport elements
|
// Get study dates of imageViewerViewport elements
|
||||||
var loadedStudyDates = {
|
var loadedStudyDates = {
|
||||||
patientId: "",
|
patientId: '',
|
||||||
dates: []
|
dates: []
|
||||||
};
|
};
|
||||||
|
|
||||||
$(".imageViewerViewport").each(function(viewportIndex, element) {
|
$('.imageViewerViewport').each(function(viewportIndex, element) {
|
||||||
var enabledElement = cornerstone.getEnabledElement(element);
|
var enabledElement = cornerstone.getEnabledElement(element);
|
||||||
if (!enabledElement || !enabledElement.image) {
|
if (!enabledElement || !enabledElement.image) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
Template.lesionTableRow.helpers({
|
Template.lesionTableRow.helpers({
|
||||||
'timepoints': function() {
|
timepoints: function() {
|
||||||
return Timepoints.find({}, {sort: {timepointName: 1}});
|
return Timepoints.find({}, {
|
||||||
|
sort: {
|
||||||
|
timepointName: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -9,7 +13,7 @@ function doneCallback(measurementData, deleteTool) {
|
|||||||
// opened by the Lesion Table, we should clear the data for
|
// opened by the Lesion Table, we should clear the data for
|
||||||
// the specified Timepoint Cell
|
// the specified Timepoint Cell
|
||||||
if (deleteTool === true) {
|
if (deleteTool === true) {
|
||||||
Meteor.call("removeMeasurement", measurementData.id, function(error, response) {
|
Meteor.call('removeMeasurement', measurementData.id, function(error, response) {
|
||||||
if (error) {
|
if (error) {
|
||||||
log.warn(error);
|
log.warn(error);
|
||||||
}
|
}
|
||||||
@ -47,7 +51,7 @@ Template.lesionTableRow.events({
|
|||||||
};
|
};
|
||||||
|
|
||||||
showConfirmDialog(function() {
|
showConfirmDialog(function() {
|
||||||
Meteor.call("removeMeasurement", currentMeasurement._id, function(error, response) {
|
Meteor.call('removeMeasurement', currentMeasurement._id, function(error, response) {
|
||||||
if (error) {
|
if (error) {
|
||||||
log.warn(error);
|
log.warn(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
Template.lesionTableTimepointCell.helpers({
|
Template.lesionTableTimepointCell.helpers({
|
||||||
'hasDataAtThisTimepoint': function() {
|
hasDataAtThisTimepoint: function() {
|
||||||
// This simple function just checks whether or not timepoint data
|
// This simple function just checks whether or not timepoint data
|
||||||
// exists for this Measurement at this Timepoint
|
// exists for this Measurement at this Timepoint
|
||||||
var lesionData = Template.parentData(1);
|
var lesionData = Template.parentData(1);
|
||||||
@ -7,7 +7,7 @@ Template.lesionTableTimepointCell.helpers({
|
|||||||
lesionData.timepoints &&
|
lesionData.timepoints &&
|
||||||
lesionData.timepoints[this.timepointID]);
|
lesionData.timepoints[this.timepointID]);
|
||||||
},
|
},
|
||||||
'displayData': function() {
|
displayData: function() {
|
||||||
// Search Measurements by lesion and timepoint
|
// Search Measurements by lesion and timepoint
|
||||||
var lesionData = Template.parentData(1);
|
var lesionData = Template.parentData(1);
|
||||||
if (!lesionData ||
|
if (!lesionData ||
|
||||||
@ -20,7 +20,7 @@ Template.lesionTableTimepointCell.helpers({
|
|||||||
|
|
||||||
if (lesionData.isTarget === true) {
|
if (lesionData.isTarget === true) {
|
||||||
if (data.shortestDiameter) {
|
if (data.shortestDiameter) {
|
||||||
return data.longestDiameter + " x " + data.shortestDiameter;
|
return data.longestDiameter + ' x ' + data.shortestDiameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.longestDiameter;
|
return data.longestDiameter;
|
||||||
@ -28,7 +28,7 @@ Template.lesionTableTimepointCell.helpers({
|
|||||||
return data.response;
|
return data.response;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'isTarget': function() {
|
isTarget: function() {
|
||||||
var lesionData = Template.parentData(1);
|
var lesionData = Template.parentData(1);
|
||||||
return lesionData.isTarget;
|
return lesionData.isTarget;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +1,26 @@
|
|||||||
Template.lesionTableTimepointHeader.events({
|
Template.lesionTableTimepointHeader.events({
|
||||||
'click th': function(e, template){
|
'click th.lesionTableTimepointCell': function(e, template) {
|
||||||
|
|
||||||
var parentPosition = getPosition(e.currentTarget);
|
var parentPosition = getPosition(e.currentTarget);
|
||||||
var cellText = e.currentTarget.innerText;
|
var cellText = e.currentTarget.innerText;
|
||||||
|
|
||||||
// Remove spaces in string
|
// Remove spaces in string
|
||||||
cellText = cellText.replace(/\s/g, ''); // Remove spaces
|
cellText = cellText.replace(/\s/g, ''); // Remove spaces
|
||||||
cellText = cellText.replace('<', ''); // Remove <
|
cellText = cellText.replace('<', ''); // Remove <
|
||||||
var splitCellText = cellText.split('/');
|
var splitCellText = cellText.split('/');
|
||||||
var dateStr = splitCellText[2].replace(/\D/g,'') + "" + splitCellText[0].replace(/\D/g,'') + ""+splitCellText[1].replace(/\D/g,''); // Remove non-digit chars
|
var dateStr = splitCellText[2].replace(/\D/g,'') + '' + splitCellText[0].replace(/\D/g,'') + '' + splitCellText[1].replace(/\D/g,''); // Remove non-digit chars
|
||||||
|
|
||||||
// Check patient has a timepointText as Baseline
|
// Check patient has a timepointText as Baseline
|
||||||
var patientId = template.data.patientId;
|
var patientId = template.data.patientId;
|
||||||
|
|
||||||
// Open popup
|
// Open popup
|
||||||
var timepointTextDialog = $("#timepointTextDialog");
|
var timepointTextDialog = $('#timepointTextDialog');
|
||||||
var dialogDisplay = timepointTextDialog.css("display");
|
var dialogDisplay = timepointTextDialog.css('display');
|
||||||
if(dialogDisplay === "none") {
|
if (dialogDisplay === 'none') {
|
||||||
|
var isBaselineInCollection = Timepoints.findOne({
|
||||||
var isBaselineInCollection = Timepoints.findOne({patientId: patientId, timepointName: dateStr, timepointText: "Baseline"});
|
patientId: patientId,
|
||||||
|
timepointName: dateStr,
|
||||||
|
timepointText: 'Baseline'
|
||||||
|
});
|
||||||
|
|
||||||
// If isBaselineInCollection is true, "Baseline" is found in collection for patient and set checkbox as checked
|
// If isBaselineInCollection is true, "Baseline" is found in collection for patient and set checkbox as checked
|
||||||
if (isBaselineInCollection) {
|
if (isBaselineInCollection) {
|
||||||
@ -34,25 +37,26 @@ Template.lesionTableTimepointHeader.events({
|
|||||||
left: parentPosition.x,
|
left: parentPosition.x,
|
||||||
display: 'block'
|
display: 'block'
|
||||||
};
|
};
|
||||||
|
|
||||||
timepointTextDialog.css(dialogProperty);
|
timepointTextDialog.css(dialogProperty);
|
||||||
|
} else {
|
||||||
} else if(dialogDisplay === "block") {
|
|
||||||
|
|
||||||
// Get timepoints of patient
|
// Get timepoints of patient
|
||||||
// Set timepointText as Baseline for selected timepoint
|
// Set timepointText as Baseline for selected timepoint
|
||||||
var timepoints = Timepoints.find({patientId: patientId}).fetch();
|
var timepoints = Timepoints.find({
|
||||||
|
patientId: patientId
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
// Check checkbox is selected
|
// Check checkbox is selected
|
||||||
var checkboxBaselineChecked = $("#checkBoxBaseline").is(":checked");
|
var checkboxBaselineChecked = $('#checkBoxBaseline').is(':checked');
|
||||||
|
|
||||||
timepoints.forEach(function(timepoint) {
|
timepoints.forEach(function(timepoint) {
|
||||||
// timepointText defines a custom text for timepoint such as Baseline, Nadir, Current
|
// timepointText defines a custom text for timepoint such as Baseline, Nadir, Current
|
||||||
if (timepoint.timepointName === dateStr) {
|
if (timepoint.timepointName === dateStr) {
|
||||||
// If checkbox is selected, set timepointText as Baseline
|
// If checkbox is selected, set timepointText as Baseline
|
||||||
// Else set timepointText as ""
|
// Else set timepointText as ""
|
||||||
var timepointText = "Baseline";
|
var timepointText = 'Baseline';
|
||||||
if(!checkboxBaselineChecked) {
|
if (!checkboxBaselineChecked) {
|
||||||
timepointText = "";
|
timepointText = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
Timepoints.update(timepoint._id,{
|
Timepoints.update(timepoint._id,{
|
||||||
@ -60,36 +64,29 @@ Template.lesionTableTimepointHeader.events({
|
|||||||
timepointText: timepointText
|
timepointText: timepointText
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else{
|
} else {
|
||||||
// Set timepointText as empty
|
// Set timepointText as empty
|
||||||
Timepoints.update(timepoint._id,{
|
Timepoints.update(timepoint._id,{
|
||||||
$set: {
|
$set: {
|
||||||
timepointText: ""
|
timepointText: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Close dialog
|
// Close dialog
|
||||||
timepointTextDialog.css("display", "none");
|
timepointTextDialog.css('display', 'none');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.lesionTableTimepointHeader.helpers({
|
Template.lesionTableTimepointHeader.helpers({
|
||||||
'timepointTextFound': function(){
|
timepointTextFound: function() {
|
||||||
var timepointText = this.timepointText;
|
var timepointText = this.timepointText;
|
||||||
if(timepointText && timepointText === 'Baseline') {
|
return (timepointText && timepointText === 'Baseline');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Gets parent's position of element which mouse pointer is clicked in
|
// Gets parent's position of element which mouse pointer is clicked in
|
||||||
function getPosition(element) {
|
function getPosition(element) {
|
||||||
var xPosition = 0;
|
var xPosition = 0;
|
||||||
@ -100,5 +97,9 @@ function getPosition(element) {
|
|||||||
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
|
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
|
||||||
element = element.offsetParent;
|
element = element.offsetParent;
|
||||||
}
|
}
|
||||||
return { x: xPosition, y: yPosition };
|
|
||||||
|
return {
|
||||||
|
x: xPosition,
|
||||||
|
y: yPosition
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@ function closeHandler(dialog) {
|
|||||||
$(dialog).css('display', 'none');
|
$(dialog).css('display', 'none');
|
||||||
|
|
||||||
// Remove the backdrop
|
// Remove the backdrop
|
||||||
$(".removableBackdrop").remove();
|
$('.removableBackdrop').remove();
|
||||||
|
|
||||||
// Restore the focus to the active viewport
|
// Restore the focus to the active viewport
|
||||||
setFocusToActiveViewport();
|
setFocusToActiveViewport();
|
||||||
@ -17,7 +17,9 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
|||||||
var imageId = enabledElement.image.imageId;
|
var imageId = enabledElement.image.imageId;
|
||||||
|
|
||||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||||
var timepoint = Timepoints.findOne({timepointName: study.studyDate});
|
var timepoint = Timepoints.findOne({
|
||||||
|
timepointName: study.studyDate
|
||||||
|
});
|
||||||
if (!timepoint) {
|
if (!timepoint) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -29,7 +31,7 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
|||||||
|
|
||||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||||
// exists at a different timepoint
|
// exists at a different timepoint
|
||||||
var lesionNumber = LesionManager.getNewLesionNumber(measurementData.timepointID, isTarget=false);
|
var lesionNumber = LesionManager.getNewLesionNumber(measurementData.timepointID, isTarget = false);
|
||||||
measurementData.lesionNumber = lesionNumber;
|
measurementData.lesionNumber = lesionNumber;
|
||||||
|
|
||||||
// Set lesion number
|
// Set lesion number
|
||||||
@ -43,26 +45,26 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
Template.nonTargetLesionDialog.measurementData = measurementData;
|
Template.nonTargetLesionDialog.measurementData = measurementData;
|
||||||
|
|
||||||
// Get the non-target lesion location dialog
|
// Get the non-target lesion location dialog
|
||||||
var dialog = $("#nonTargetLesionLocationDialog");
|
var dialog = $('#nonTargetLesionLocationDialog');
|
||||||
Template.nonTargetLesionDialog.dialog = dialog;
|
Template.nonTargetLesionDialog.dialog = dialog;
|
||||||
|
|
||||||
// Show the backdrop
|
// Show the backdrop
|
||||||
UI.render(Template.removableBackdrop, document.body);
|
UI.render(Template.removableBackdrop, document.body);
|
||||||
|
|
||||||
// Make sure the context menu is closed when the user clicks away
|
// Make sure the context menu is closed when the user clicks away
|
||||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||||
closeHandler(dialog);
|
closeHandler(dialog);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find the select option box
|
// Find the select option box
|
||||||
var selectorLocation = dialog.find("select#selectNonTargetLesionLocation");
|
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||||
var selectorResponse = dialog.find("select#selectNonTargetLesionLocationResponse");
|
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||||
|
|
||||||
selectorLocation.find("option:first").prop("selected", "selected");
|
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||||
selectorResponse.find("option:first").prop("selected", "selected");
|
selectorResponse.find('option:first').prop('selected', 'selected');
|
||||||
|
|
||||||
// Allow location selection
|
// Allow location selection
|
||||||
selectorLocation.removeAttr("disabled");
|
selectorLocation.removeAttr('disabled');
|
||||||
|
|
||||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||||
// If it is, disable selector location
|
// If it is, disable selector location
|
||||||
@ -83,11 +85,11 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
selectorLocation.find('option').each(function() {
|
selectorLocation.find('option').each(function() {
|
||||||
if ($(this).text() === locationName) {
|
if ($(this).text() === locationName) {
|
||||||
// Select location in locations dropdown list
|
// Select location in locations dropdown list
|
||||||
selectorLocation.find('option').eq($(this).index()).prop("selected", true);
|
selectorLocation.find('option').eq($(this).index()).prop('selected', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
selectorLocation.prop("disabled", true);
|
selectorLocation.prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the nonTargetLesion dialog above
|
// Show the nonTargetLesion dialog above
|
||||||
@ -109,7 +111,7 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
// If device is touch device, set position center of screen vertically and horizontally
|
// If device is touch device, set position center of screen vertically and horizontally
|
||||||
if (isTouchDevice()) {
|
if (isTouchDevice()) {
|
||||||
// add dialogMobile class to provide a black,transparent background
|
// add dialogMobile class to provide a black,transparent background
|
||||||
dialog.addClass("dialogMobile");
|
dialog.addClass('dialogMobile');
|
||||||
dialogProperty.top = 0;
|
dialogProperty.top = 0;
|
||||||
dialogProperty.left = 0;
|
dialogProperty.left = 0;
|
||||||
dialogProperty.right = 0;
|
dialogProperty.right = 0;
|
||||||
@ -125,14 +127,14 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
|
|||||||
Template.nonTargetLesionDialog.doneCallback = doneCallback;
|
Template.nonTargetLesionDialog.doneCallback = doneCallback;
|
||||||
|
|
||||||
// Get the non-target lesion location dialog
|
// Get the non-target lesion location dialog
|
||||||
var dialog = $("#nonTargetLesionRelabelDialog");
|
var dialog = $('#nonTargetLesionRelabelDialog');
|
||||||
Template.nonTargetLesionDialog.dialog = dialog;
|
Template.nonTargetLesionDialog.dialog = dialog;
|
||||||
|
|
||||||
// Show the backdrop
|
// Show the backdrop
|
||||||
UI.render(Template.removableBackdrop, document.body);
|
UI.render(Template.removableBackdrop, document.body);
|
||||||
|
|
||||||
// Make sure the context menu is closed when the user clicks away
|
// Make sure the context menu is closed when the user clicks away
|
||||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||||
closeHandler(dialog);
|
closeHandler(dialog);
|
||||||
|
|
||||||
if (doneCallback && typeof doneCallback === 'function') {
|
if (doneCallback && typeof doneCallback === 'function') {
|
||||||
@ -142,14 +144,14 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Find the select option box
|
// Find the select option box
|
||||||
var selectorLocation = dialog.find("select#selectNonTargetLesionLocation");
|
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||||
var selectorResponse = dialog.find("select#selectNonTargetLesionLocationResponse");
|
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||||
|
|
||||||
selectorLocation.find("option:first").prop("selected", "selected");
|
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||||
selectorResponse.find("option:first").prop("selected", "selected");
|
selectorResponse.find('option:first').prop('selected', 'selected');
|
||||||
|
|
||||||
// Allow location selection
|
// Allow location selection
|
||||||
selectorLocation.removeAttr("disabled");
|
selectorLocation.removeAttr('disabled');
|
||||||
|
|
||||||
// Show the nonTargetLesion dialog above
|
// Show the nonTargetLesion dialog above
|
||||||
var dialogProperty = {
|
var dialogProperty = {
|
||||||
@ -160,7 +162,7 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
|
|||||||
// If device is touch device, set position center of screen vertically and horizontally
|
// If device is touch device, set position center of screen vertically and horizontally
|
||||||
if (!eventData || isTouchDevice()) {
|
if (!eventData || isTouchDevice()) {
|
||||||
// add dialogMobile class to provide a black,transparent background
|
// add dialogMobile class to provide a black,transparent background
|
||||||
dialog.addClass("dialogMobile");
|
dialog.addClass('dialogMobile');
|
||||||
dialogProperty.top = 0;
|
dialogProperty.top = 0;
|
||||||
dialogProperty.left = 0;
|
dialogProperty.left = 0;
|
||||||
dialogProperty.right = 0;
|
dialogProperty.right = 0;
|
||||||
@ -179,8 +181,14 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
LesionLocations.update({},
|
LesionLocations.update({},
|
||||||
{$set: {selected: false}},
|
{
|
||||||
{ multi: true });
|
$set: {
|
||||||
|
selected: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
multi: true
|
||||||
|
});
|
||||||
|
|
||||||
var currentLocation = LesionLocations.findOne({
|
var currentLocation = LesionLocations.findOne({
|
||||||
id: measurement.locationId
|
id: measurement.locationId
|
||||||
@ -197,8 +205,14 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
|
|||||||
});
|
});
|
||||||
|
|
||||||
LocationResponses.update({},
|
LocationResponses.update({},
|
||||||
{$set: {selected: false}},
|
{
|
||||||
{ multi: true });
|
$set: {
|
||||||
|
selected: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
multi: true
|
||||||
|
});
|
||||||
|
|
||||||
var response = measurement.timepoints[measurementData.timepointID].response;
|
var response = measurement.timepoints[measurementData.timepointID].response;
|
||||||
|
|
||||||
@ -233,12 +247,12 @@ Template.nonTargetLesionDialog.events({
|
|||||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||||
|
|
||||||
// Find the select option box
|
// Find the select option box
|
||||||
var selectorLocation = dialog.find("select#selectNonTargetLesionLocation");
|
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||||
var selectorResponse = dialog.find("select#selectNonTargetLesionLocationResponse");
|
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||||
|
|
||||||
// Get the current value of the selector
|
// Get the current value of the selector
|
||||||
var selectedOptionId = selectorLocation.find("option:selected").val();
|
var selectedOptionId = selectorLocation.find('option:selected').val();
|
||||||
var responseOptionId = selectorResponse.find("option:selected").val();
|
var responseOptionId = selectorResponse.find('option:selected').val();
|
||||||
|
|
||||||
// If the selected option is still the default (-1)
|
// If the selected option is still the default (-1)
|
||||||
// then stop here
|
// then stop here
|
||||||
@ -253,15 +267,21 @@ Template.nonTargetLesionDialog.events({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get selected location data
|
// Get selected location data
|
||||||
var locationObj = LesionLocations.findOne({_id: selectedOptionId});
|
var locationObj = LesionLocations.findOne({
|
||||||
|
_id: selectedOptionId
|
||||||
|
});
|
||||||
|
|
||||||
var id;
|
var id;
|
||||||
var existingLocation = PatientLocations.findOne({location: locationObj.location});
|
var existingLocation = PatientLocations.findOne({
|
||||||
|
location: locationObj.location
|
||||||
|
});
|
||||||
if (existingLocation) {
|
if (existingLocation) {
|
||||||
id = existingLocation._id;
|
id = existingLocation._id;
|
||||||
} else {
|
} else {
|
||||||
// Adds location data to PatientLocation and retrieve the location ID
|
// Adds location data to PatientLocation and retrieve the location ID
|
||||||
id = PatientLocations.insert({location: locationObj.location});
|
id = PatientLocations.insert({
|
||||||
|
location: locationObj.location
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (measurementData.id) {
|
if (measurementData.id) {
|
||||||
@ -323,12 +343,11 @@ Template.nonTargetLesionDialog.events({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Template.nonTargetLesionDialog.helpers({
|
Template.nonTargetLesionDialog.helpers({
|
||||||
'lesionLocations': function() {
|
lesionLocations: function() {
|
||||||
return LesionLocations.find();
|
return LesionLocations.find();
|
||||||
},
|
},
|
||||||
'locationResponses': function() {
|
locationResponses: function() {
|
||||||
return LocationResponses.find();
|
return LocationResponses.find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3,7 +3,7 @@ function closeHandler(dialog) {
|
|||||||
$(dialog).css('display', 'none');
|
$(dialog).css('display', 'none');
|
||||||
|
|
||||||
// Remove the backdrop
|
// Remove the backdrop
|
||||||
$(".removableBackdrop").remove();
|
$('.removableBackdrop').remove();
|
||||||
|
|
||||||
// Restore the focus to the active viewport
|
// Restore the focus to the active viewport
|
||||||
setFocusToActiveViewport();
|
setFocusToActiveViewport();
|
||||||
@ -14,14 +14,14 @@ changeNonTargetResponse = function(measurementData, eventData, doneCallback) {
|
|||||||
Template.nonTargetResponseDialog.doneCallback = doneCallback;
|
Template.nonTargetResponseDialog.doneCallback = doneCallback;
|
||||||
|
|
||||||
// Get the non-target lesion location dialog
|
// Get the non-target lesion location dialog
|
||||||
var dialog = $("#nonTargetResponseDialog");
|
var dialog = $('#nonTargetResponseDialog');
|
||||||
Template.nonTargetResponseDialog.dialog = dialog;
|
Template.nonTargetResponseDialog.dialog = dialog;
|
||||||
|
|
||||||
// Show the backdrop
|
// Show the backdrop
|
||||||
UI.render(Template.removableBackdrop, document.body);
|
UI.render(Template.removableBackdrop, document.body);
|
||||||
|
|
||||||
// Make sure the context menu is closed when the user clicks away
|
// Make sure the context menu is closed when the user clicks away
|
||||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||||
closeHandler(dialog);
|
closeHandler(dialog);
|
||||||
|
|
||||||
if (doneCallback && typeof doneCallback === 'function') {
|
if (doneCallback && typeof doneCallback === 'function') {
|
||||||
@ -39,7 +39,7 @@ changeNonTargetResponse = function(measurementData, eventData, doneCallback) {
|
|||||||
// If device is touch device, set position center of screen vertically and horizontally
|
// If device is touch device, set position center of screen vertically and horizontally
|
||||||
if (!eventData || isTouchDevice()) {
|
if (!eventData || isTouchDevice()) {
|
||||||
// add dialogMobile class to provide a black,transparent background
|
// add dialogMobile class to provide a black,transparent background
|
||||||
dialog.addClass("dialogMobile");
|
dialog.addClass('dialogMobile');
|
||||||
dialogProperty.top = 0;
|
dialogProperty.top = 0;
|
||||||
dialogProperty.left = 0;
|
dialogProperty.left = 0;
|
||||||
dialogProperty.right = 0;
|
dialogProperty.right = 0;
|
||||||
@ -90,10 +90,10 @@ Template.nonTargetResponseDialog.events({
|
|||||||
var measurementData = Template.nonTargetResponseDialog.measurementData;
|
var measurementData = Template.nonTargetResponseDialog.measurementData;
|
||||||
|
|
||||||
// Find the select option box
|
// Find the select option box
|
||||||
var selectorResponse = dialog.find("select#selectNonTargetLesionLocationResponse");
|
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||||
|
|
||||||
// Get the current value of the selector
|
// Get the current value of the selector
|
||||||
var responseOptionId = selectorResponse.find("option:selected").val();
|
var responseOptionId = selectorResponse.find('option:selected').val();
|
||||||
|
|
||||||
// If the selected response option is still the default (-1)
|
// If the selected response option is still the default (-1)
|
||||||
// then stop here
|
// then stop here
|
||||||
@ -148,9 +148,8 @@ Template.nonTargetResponseDialog.events({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Template.nonTargetResponseDialog.helpers({
|
Template.nonTargetResponseDialog.helpers({
|
||||||
'locationResponses': function() {
|
locationResponses: function() {
|
||||||
return LocationResponses.find();
|
return LocationResponses.find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -12,10 +12,14 @@ Template.studyDateList.helpers({
|
|||||||
// since the WorklistStudies Collection only contains the studies on-screen
|
// since the WorklistStudies Collection only contains the studies on-screen
|
||||||
|
|
||||||
// Check which study is currently loaded into the study browser
|
// Check which study is currently loaded into the study browser
|
||||||
var currentStudyInBrowser = ViewerStudies.findOne({selected: true});
|
var currentStudyInBrowser = ViewerStudies.findOne({
|
||||||
|
selected: true
|
||||||
|
});
|
||||||
|
|
||||||
// Find studies which have the same patientId as the currently selected study
|
// Find studies which have the same patientId as the currently selected study
|
||||||
var relatedStudies = WorklistStudies.find({patientId: currentStudyInBrowser.patientId}).fetch();
|
var relatedStudies = WorklistStudies.find({
|
||||||
|
patientId: currentStudyInBrowser.patientId
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
// Modify the array of related studies so the default option is the currently selected study
|
// Modify the array of related studies so the default option is the currently selected study
|
||||||
relatedStudies.forEach(function(study) {
|
relatedStudies.forEach(function(study) {
|
||||||
@ -31,7 +35,6 @@ Template.studyDateList.helpers({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Template.studyDateList.events({
|
Template.studyDateList.events({
|
||||||
/**
|
/**
|
||||||
* When the study date selector combo box is changed, we will
|
* When the study date selector combo box is changed, we will
|
||||||
@ -65,16 +68,26 @@ Template.studyDateList.events({
|
|||||||
|
|
||||||
// Set "Selected" to false for the entire collection
|
// Set "Selected" to false for the entire collection
|
||||||
ViewerStudies.update({},
|
ViewerStudies.update({},
|
||||||
{$set: {selected: false}},
|
{
|
||||||
{ multi: true });
|
$set: {
|
||||||
|
selected: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
multi: true
|
||||||
|
});
|
||||||
|
|
||||||
// Check if this study already exists in the ViewerStudies collection
|
// Check if this study already exists in the ViewerStudies collection
|
||||||
// of loaded studies. If it does, set it's 'selected' value to true.
|
// of loaded studies. If it does, set it's 'selected' value to true.
|
||||||
var existingStudy = ViewerStudies.findOne({studyInstanceUid: studyInstanceUid});
|
var existingStudy = ViewerStudies.findOne({
|
||||||
|
studyInstanceUid: studyInstanceUid
|
||||||
|
});
|
||||||
if (existingStudy) {
|
if (existingStudy) {
|
||||||
// Set the current finding in the collection to true
|
// Set the current finding in the collection to true
|
||||||
ViewerStudies.update(existingStudy._id, {
|
ViewerStudies.update(existingStudy._id, {
|
||||||
$set: {selected: true}
|
$set: {
|
||||||
|
selected: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,15 +99,17 @@ Template.studyDateList.events({
|
|||||||
|
|
||||||
var timepointID = uuid.v4();
|
var timepointID = uuid.v4();
|
||||||
|
|
||||||
var timepoint = Timepoints.findOne({timepointName: study.studyDate});
|
var timepoint = Timepoints.findOne({
|
||||||
|
timepointName: study.studyDate
|
||||||
|
});
|
||||||
if (timepoint) {
|
if (timepoint) {
|
||||||
log.warn("A timepoint with that study date already exists!");
|
log.warn('A timepoint with that study date already exists!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var testTimepoint = Timepoints.findOne({});
|
var testTimepoint = Timepoints.findOne({});
|
||||||
if (testTimepoint && testTimepoint.patientId !== study.patientId) {
|
if (testTimepoint && testTimepoint.patientId !== study.patientId) {
|
||||||
log.warn("Timepoints collection related to the wrong subject");
|
log.warn('Timepoints collection related to the wrong subject');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
activateLesion = function(measurementId, templateData) {
|
activateLesion = function(measurementId, templateData) {
|
||||||
|
|
||||||
// Set background color of selected row
|
// Set background color of selected row
|
||||||
$("tr[data-measurementid=" + measurementId + "]").addClass("selectedRow").siblings().removeClass("selectedRow");
|
$('tr[data-measurementid=' + measurementId + ']').addClass('selectedRow').siblings().removeClass('selectedRow');
|
||||||
|
|
||||||
var measurementData = Measurements.findOne(measurementId);
|
var measurementData = Measurements.findOne(measurementId);
|
||||||
|
|
||||||
@ -26,9 +26,9 @@ activateLesion = function(measurementId, templateData) {
|
|||||||
Object.keys(timepoints).forEach(function(key) {
|
Object.keys(timepoints).forEach(function(key) {
|
||||||
var timepoint = timepoints[key];
|
var timepoint = timepoints[key];
|
||||||
|
|
||||||
if (timepoint.imageId === "" ||
|
if (timepoint.imageId === '' ||
|
||||||
timepoint.studyInstanceUid === "" ||
|
timepoint.studyInstanceUid === '' ||
|
||||||
timepoint.seriesInstanceUid === "") {
|
timepoint.seriesInstanceUid === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ activateLesion = function(measurementId, templateData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop through the viewports and display each timepoint
|
// Loop through the viewports and display each timepoint
|
||||||
$(".imageViewerViewport").not('.empty').each(function(viewportIndex, element) {
|
$('.imageViewerViewport').not('.empty').each(function(viewportIndex, element) {
|
||||||
// Stop if we run out of timepoints before viewports
|
// Stop if we run out of timepoints before viewports
|
||||||
if (viewportIndex >= timepointsWithEntries.length) {
|
if (viewportIndex >= timepointsWithEntries.length) {
|
||||||
// Update the element anyway, to remove any other highlights that are present
|
// Update the element anyway, to remove any other highlights that are present
|
||||||
|
|||||||
@ -20,7 +20,7 @@ clearMeasurementTimepointData = function(measurementId, timepointId) {
|
|||||||
delete data.timepoints[timepointId];
|
delete data.timepoints[timepointId];
|
||||||
|
|
||||||
if (Object.keys(data.timepoints).length === 0) {
|
if (Object.keys(data.timepoints).length === 0) {
|
||||||
Meteor.call("removeMeasurement", measurementId, function(error, response) {
|
Meteor.call('removeMeasurement', measurementId, function(error, response) {
|
||||||
console.log('Removed!');
|
console.log('Removed!');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
clearTools = function() {
|
clearTools = function() {
|
||||||
var patientId = Session.get("patientId");
|
var patientId = Session.get('patientId');
|
||||||
var toolTypes = ["lesion", "nonTarget"];
|
var toolTypes = [ 'lesion', 'nonTarget' ];
|
||||||
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||||
var toolStateKeys = Object.keys(toolState).slice(0);
|
var toolStateKeys = Object.keys(toolState).slice(0);
|
||||||
|
|
||||||
// Set null array for toolState data found by imageId and toolType
|
// Set null array for toolState data found by imageId and toolType
|
||||||
toolStateKeys.forEach(function (imageId) {
|
toolStateKeys.forEach(function(imageId) {
|
||||||
toolTypes.forEach(function (toolType) {
|
toolTypes.forEach(function(toolType) {
|
||||||
var toolTypeData = toolState[imageId][toolType];
|
var toolTypeData = toolState[imageId][toolType];
|
||||||
if(toolTypeData && toolTypeData.data.length > 0) {
|
if (toolTypeData && toolTypeData.data.length > 0) {
|
||||||
if(toolTypeData.data[0].patientId === patientId) {
|
if (toolTypeData.data[0].patientId === patientId) {
|
||||||
toolState[imageId][toolType] = {
|
toolState[imageId][toolType] = {
|
||||||
data: []
|
data: []
|
||||||
};
|
};
|
||||||
@ -19,7 +19,7 @@ clearTools = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Update imageViewerViewport elements to remove lesions on current image
|
// Update imageViewerViewport elements to remove lesions on current image
|
||||||
var viewportElements = $(".imageViewerViewport").not('.empty');
|
var viewportElements = $('.imageViewerViewport').not('.empty');
|
||||||
viewportElements.each(function(index, element) {
|
viewportElements.each(function(index, element) {
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,5 +9,8 @@ getTimepointObject = function(imageId) {
|
|||||||
if (!study) {
|
if (!study) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return Timepoints.findOne({timepointName: study.studyDate});
|
|
||||||
|
return Timepoints.findOne({
|
||||||
|
timepointName: study.studyDate
|
||||||
|
});
|
||||||
};
|
};
|
||||||
@ -4,9 +4,8 @@ sign = function(x) {
|
|||||||
return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
|
return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Returns intersection points of lines and whether lines are intersected
|
// Returns intersection points of lines and whether lines are intersected
|
||||||
getLineIntersection = function (point1, point2, point3, point4) {
|
getLineIntersection = function(point1, point2, point3, point4) {
|
||||||
|
|
||||||
var intersectionPoint = {};
|
var intersectionPoint = {};
|
||||||
|
|
||||||
@ -33,8 +32,7 @@ getLineIntersection = function (point1, point2, point3, point4) {
|
|||||||
|
|
||||||
if (r3 != 0 &&
|
if (r3 != 0 &&
|
||||||
r4 != 0 &&
|
r4 != 0 &&
|
||||||
sign(r3) == sign(r4))
|
sign(r3) == sign(r4)) {
|
||||||
{
|
|
||||||
intersectionPoint.x = 0;
|
intersectionPoint.x = 0;
|
||||||
intersectionPoint.y = 0;
|
intersectionPoint.y = 0;
|
||||||
intersectionPoint.intersected = false;
|
intersectionPoint.intersected = false;
|
||||||
@ -59,8 +57,7 @@ getLineIntersection = function (point1, point2, point3, point4) {
|
|||||||
|
|
||||||
if (r1 != 0 &&
|
if (r1 != 0 &&
|
||||||
r2 != 0 &&
|
r2 != 0 &&
|
||||||
sign(r1) == sign(r2))
|
sign(r1) == sign(r2)) {
|
||||||
{
|
|
||||||
intersectionPoint.x = 0;
|
intersectionPoint.x = 0;
|
||||||
intersectionPoint.y = 0;
|
intersectionPoint.y = 0;
|
||||||
intersectionPoint.intersected = false;
|
intersectionPoint.intersected = false;
|
||||||
@ -98,7 +95,7 @@ getDistance = function(point1, point2) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Returns distance from point to a line
|
// Returns distance from point to a line
|
||||||
getDistanceFromPointToLine = function (ptTest, pt1, pt2) {
|
getDistanceFromPointToLine = function(ptTest, pt1, pt2) {
|
||||||
var ptNearest = {};
|
var ptNearest = {};
|
||||||
|
|
||||||
// Point on line segment nearest to pt0
|
// Point on line segment nearest to pt0
|
||||||
@ -106,29 +103,23 @@ getDistanceFromPointToLine = function (ptTest, pt1, pt2) {
|
|||||||
var dy = pt2.y - pt1.y;
|
var dy = pt2.y - pt1.y;
|
||||||
|
|
||||||
// It's a point, not a line
|
// It's a point, not a line
|
||||||
if (dx == 0 && dy == 0)
|
if (dx == 0 && dy == 0) {
|
||||||
{
|
|
||||||
ptNearest.x = pt1.x;
|
ptNearest.x = pt1.x;
|
||||||
ptNearest.y = pt1.y;
|
ptNearest.y = pt1.y;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Parameter
|
// Parameter
|
||||||
var t = ((ptTest.x - pt1.x) * dx + (ptTest.y - pt1.y) * dy) / (dx * dx + dy * dy);
|
var t = ((ptTest.x - pt1.x) * dx + (ptTest.y - pt1.y) * dy) / (dx * dx + dy * dy);
|
||||||
|
|
||||||
// Nearest point is pt1
|
// Nearest point is pt1
|
||||||
if (t < 0)
|
if (t < 0) {
|
||||||
{
|
|
||||||
ptNearest = pt1;
|
ptNearest = pt1;
|
||||||
}
|
}
|
||||||
// Nearest point is pt2
|
// Nearest point is pt2
|
||||||
else if (t > 1)
|
else if (t > 1) {
|
||||||
{
|
|
||||||
ptNearest = pt2;
|
ptNearest = pt2;
|
||||||
}
|
}
|
||||||
// Nearest point is on the line segment
|
// Nearest point is on the line segment
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// Parametric equation
|
// Parametric equation
|
||||||
ptNearest.x = (pt1.x + t * dx);
|
ptNearest.x = (pt1.x + t * dx);
|
||||||
ptNearest.y = (pt1.y + t * dy);
|
ptNearest.y = (pt1.y + t * dy);
|
||||||
|
|||||||
@ -15,10 +15,10 @@ toggleLesionTrackerTools = function() {
|
|||||||
|
|
||||||
// Hide the tools (set them all to disabled)
|
// Hide the tools (set them all to disabled)
|
||||||
var toolDefaultStates = {
|
var toolDefaultStates = {
|
||||||
activate: ['deleteLesionKeyboardTool'],
|
activate: [ 'deleteLesionKeyboardTool' ],
|
||||||
deactivate: [],
|
deactivate: [],
|
||||||
enable: [],
|
enable: [],
|
||||||
disable: ['lesion', 'nonTarget', 'scaleOverlayTool', 'length']
|
disable: [ 'lesion', 'nonTarget', 'scaleOverlayTool', 'length' ]
|
||||||
};
|
};
|
||||||
|
|
||||||
toolManager.setToolDefaultStates(toolDefaultStates);
|
toolManager.setToolDefaultStates(toolDefaultStates);
|
||||||
|
|||||||
@ -134,7 +134,7 @@
|
|||||||
var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
|
var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
|
||||||
|
|
||||||
// Time since last uuid creation (in msecs)
|
// Time since last uuid creation (in msecs)
|
||||||
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
|
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs) / 10000;
|
||||||
|
|
||||||
// Per 4.2.1.2, Bump clockseq on clock regression
|
// Per 4.2.1.2, Bump clockseq on clock regression
|
||||||
if (dt < 0 && options.clockseq == null) {
|
if (dt < 0 && options.clockseq == null) {
|
||||||
@ -201,6 +201,7 @@
|
|||||||
buf = options == 'binary' ? new BufferClass(16) : null;
|
buf = options == 'binary' ? new BufferClass(16) : null;
|
||||||
options = null;
|
options = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var rnds = options.random || (options.rng || _rng)();
|
var rnds = options.random || (options.rng || _rng)();
|
||||||
@ -234,7 +235,6 @@
|
|||||||
// Publish as AMD module
|
// Publish as AMD module
|
||||||
define(function() {return uuid;});
|
define(function() {return uuid;});
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Publish as global (in browsers)
|
// Publish as global (in browsers)
|
||||||
var _previousRoot = _global.uuid;
|
var _previousRoot = _global.uuid;
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
Package.describe({
|
Package.describe({
|
||||||
name: "lesiontracker",
|
name: 'lesiontracker',
|
||||||
summary: "OHIF Lesion Tracker Tools",
|
summary: 'OHIF Lesion Tracker Tools',
|
||||||
version: '0.0.1'
|
version: '0.0.1'
|
||||||
});
|
});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function(api) {
|
||||||
api.versionsFrom('1.2.0.2');
|
api.versionsFrom('1.2.0.2');
|
||||||
|
|
||||||
api.use('standard-app-packages');
|
api.use('standard-app-packages');
|
||||||
@ -15,16 +15,26 @@ Package.onUse(function (api) {
|
|||||||
// Our custom package
|
// Our custom package
|
||||||
api.use('cornerstone');
|
api.use('cornerstone');
|
||||||
|
|
||||||
api.addFiles('log.js', ['client', 'server']);
|
api.addFiles('log.js', [ 'client', 'server' ]);
|
||||||
|
|
||||||
api.addFiles('client/collections/LesionLocations.js', 'client');
|
api.addFiles('client/collections/LesionLocations.js', 'client');
|
||||||
api.addFiles('client/collections/LocationResponses.js', 'client');
|
api.addFiles('client/collections/LocationResponses.js', 'client');
|
||||||
|
|
||||||
api.addFiles('client/compatibility/lesionTool.js', 'client', {bare: true});
|
api.addFiles('client/compatibility/lesionTool.js', 'client', {
|
||||||
api.addFiles('client/compatibility/nonTargetTool.js', 'client', {bare: true});
|
bare: true
|
||||||
api.addFiles('client/compatibility/scaleOverlayTool.js', 'client', {bare: true});
|
});
|
||||||
api.addFiles('client/compatibility/deleteLesionKeyboardTool.js', 'client', {bare: true});
|
api.addFiles('client/compatibility/nonTargetTool.js', 'client', {
|
||||||
api.addFiles('client/compatibility/LesionManager.js', 'client', {bare: true});
|
bare: true
|
||||||
|
});
|
||||||
|
api.addFiles('client/compatibility/scaleOverlayTool.js', 'client', {
|
||||||
|
bare: true
|
||||||
|
});
|
||||||
|
api.addFiles('client/compatibility/deleteLesionKeyboardTool.js', 'client', {
|
||||||
|
bare: true
|
||||||
|
});
|
||||||
|
api.addFiles('client/compatibility/LesionManager.js', 'client', {
|
||||||
|
bare: true
|
||||||
|
});
|
||||||
|
|
||||||
api.addFiles('client/components/lesionLocationDialog/lesionLocationDialog.html', 'client');
|
api.addFiles('client/components/lesionLocationDialog/lesionLocationDialog.html', 'client');
|
||||||
api.addFiles('client/components/lesionLocationDialog/lesionLocationDialog.js', 'client');
|
api.addFiles('client/components/lesionLocationDialog/lesionLocationDialog.js', 'client');
|
||||||
@ -66,10 +76,10 @@ Package.onUse(function (api) {
|
|||||||
|
|
||||||
// Server functions
|
// Server functions
|
||||||
api.addFiles('server/collections.js', 'server');
|
api.addFiles('server/collections.js', 'server');
|
||||||
api.addFiles('server/removeCollections.js', ['server']);
|
api.addFiles('server/removeCollections.js', [ 'server' ]);
|
||||||
|
|
||||||
// Both client and server functions
|
// Both client and server functions
|
||||||
api.addFiles('both/collections.js', ['client', 'server']);
|
api.addFiles('both/collections.js', [ 'client', 'server' ]);
|
||||||
|
|
||||||
// Library functions
|
// Library functions
|
||||||
api.addFiles('lib/uuid.js', 'client');
|
api.addFiles('lib/uuid.js', 'client');
|
||||||
@ -83,7 +93,6 @@ Package.onUse(function (api) {
|
|||||||
api.addFiles('lib/clearTools.js', 'client');
|
api.addFiles('lib/clearTools.js', 'client');
|
||||||
api.addFiles('lib/mathUtils.js', 'client');
|
api.addFiles('lib/mathUtils.js', 'client');
|
||||||
|
|
||||||
|
|
||||||
// Export gloabal functions
|
// Export gloabal functions
|
||||||
api.export('activateLesion','client');
|
api.export('activateLesion','client');
|
||||||
api.export('activateMeasurements','client');
|
api.export('activateMeasurements','client');
|
||||||
@ -107,6 +116,6 @@ Package.onUse(function (api) {
|
|||||||
api.export('PatientLocations', 'client');
|
api.export('PatientLocations', 'client');
|
||||||
|
|
||||||
// Export collections spanning both client and server
|
// Export collections spanning both client and server
|
||||||
api.export('Measurements', ['client', 'server']);
|
api.export('Measurements', [ 'client', 'server' ]);
|
||||||
api.export('Timepoints', ['client', 'server']);
|
api.export('Timepoints', [ 'client', 'server' ]);
|
||||||
});
|
});
|
||||||
@ -10,7 +10,6 @@ Meteor.publish('measurements', function(patientId) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Temporary fix to drop all Collections on server restart
|
// 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
|
// http://stackoverflow.com/questions/23891631/meteor-how-can-i-drop-all-mongo-collections-and-clear-all-data-on-startup
|
||||||
Meteor.startup(function() {
|
Meteor.startup(function() {
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
"removeMeasurement": function(id) {
|
removeMeasurement: function(id) {
|
||||||
Measurements.remove(id);
|
Measurements.remove(id);
|
||||||
},
|
},
|
||||||
"removeMeasurementsByPatientId": function(patientId) {
|
removeMeasurementsByPatientId: function(patientId) {
|
||||||
Measurements.remove({patientId: patientId});
|
Measurements.remove({
|
||||||
|
patientId: patientId
|
||||||
|
});
|
||||||
},
|
},
|
||||||
"decrementLesionNumbers": function(lesionData) {
|
decrementLesionNumbers: function(lesionData) {
|
||||||
// Update all Measurements to decrement the lesion numbers for those
|
// Update all Measurements to decrement the lesion numbers for those
|
||||||
// that were created after the current lesion by 1
|
// that were created after the current lesion by 1
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user