Add ServerConfiguration schema to validate Meteor settings, removed defaultSettings, ran JSCS for DIMSEService package
This commit is contained in:
parent
356abd0978
commit
d4b014847a
@ -1,54 +0,0 @@
|
|||||||
import { Meteor } from 'meteor/meteor';
|
|
||||||
|
|
||||||
Meteor.startup(function() {
|
|
||||||
if (Object.keys(Meteor.settings).length > 1) {
|
|
||||||
console.log('Using custom LesionTracker settings');
|
|
||||||
console.log(Meteor.settings);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Meteor.settings = {
|
|
||||||
servers: {
|
|
||||||
dicomWeb: [{
|
|
||||||
name: 'Orthanc',
|
|
||||||
wadoUriRootNOTE: 'either this uri is not correct for wado-uri or wado-uri is not configured on orthanc currently',
|
|
||||||
wadoUriRoot: 'http://localhost:8043/wado',
|
|
||||||
qidoRoot: 'http://localhost:8042/dicom-web',
|
|
||||||
wadoRoot: 'http://localhost:8042/dicom-web',
|
|
||||||
qidoSupportsIncludeField: false,
|
|
||||||
imageRendering: 'wadouri',
|
|
||||||
requestOptions: {
|
|
||||||
auth: 'orthanc:orthanc',
|
|
||||||
logRequests: true,
|
|
||||||
logResponses: false,
|
|
||||||
logTiming: true
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
dimse: [{
|
|
||||||
name: "ORTHANC_DIMSE",
|
|
||||||
peers: [{
|
|
||||||
host: 'localhost',
|
|
||||||
port: 4242,
|
|
||||||
aeTitle: 'ORTHANC',
|
|
||||||
default: true
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
"defaultServiceType": 'dicomWeb',
|
|
||||||
"public": {
|
|
||||||
"verifyEmail": false,
|
|
||||||
"ui": {
|
|
||||||
"studyListFunctionsEnabled": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//defaultServiceType: 'dimse'
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log('Using default LesionTracker settings with service: ' + Meteor.settings.defaultServiceType);
|
|
||||||
|
|
||||||
// Bind events if window is closed
|
|
||||||
$(window).bind('beforeunload', function (e) {
|
|
||||||
// have to return null, unless you want a chrome popup alert
|
|
||||||
// return 'If you leave this page then any unsaved changes will be lost.';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -39,3 +39,4 @@ clinical:router
|
|||||||
fastclick@1.0.12
|
fastclick@1.0.12
|
||||||
standard-minifier-css@1.1.8
|
standard-minifier-css@1.1.8
|
||||||
standard-minifier-js@1.1.8
|
standard-minifier-js@1.1.8
|
||||||
|
aldeed:simple-schema
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
aldeed:simple-schema@1.5.3
|
||||||
allow-deny@1.0.5
|
allow-deny@1.0.5
|
||||||
arsnebula:reactive-promise@0.9.1
|
arsnebula:reactive-promise@0.9.1
|
||||||
autoupdate@1.3.11
|
autoupdate@1.3.11
|
||||||
@ -49,6 +50,7 @@ jquery@1.11.9
|
|||||||
launch-screen@1.0.12
|
launch-screen@1.0.12
|
||||||
livedata@1.0.18
|
livedata@1.0.18
|
||||||
logging@1.1.14
|
logging@1.1.14
|
||||||
|
mdg:validation-error@0.2.0
|
||||||
meteor@1.2.16
|
meteor@1.2.16
|
||||||
meteor-base@1.0.4
|
meteor-base@1.0.4
|
||||||
meteor-platform@1.2.6
|
meteor-platform@1.2.6
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
import { Meteor } from 'meteor/meteor';
|
|
||||||
|
|
||||||
Meteor.startup(function() {
|
|
||||||
if (Object.keys(Meteor.settings).length > 1) {
|
|
||||||
console.log('Using custom LesionTracker settings: ');
|
|
||||||
console.log(Meteor.settings);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Meteor.settings = {
|
|
||||||
servers: {
|
|
||||||
dicomWeb: [{
|
|
||||||
name: 'Orthanc',
|
|
||||||
wadoUriRootNOTE: 'either this uri is not correct for wado-uri or wado-uri is not configured on orthanc currently',
|
|
||||||
wadoUriRoot: 'http://localhost:8043/wado',
|
|
||||||
qidoRoot: 'http://localhost:8042/dicom-web',
|
|
||||||
wadoRoot: 'http://localhost:8042/dicom-web',
|
|
||||||
qidoSupportsIncludeField: false,
|
|
||||||
imageRendering: 'wadouri',
|
|
||||||
requestOptions: {
|
|
||||||
auth: 'orthanc:orthanc',
|
|
||||||
logRequests: true,
|
|
||||||
logResponses: false,
|
|
||||||
logTiming: true
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
dimse: [{
|
|
||||||
name: "ORTHANC_DIMSE",
|
|
||||||
peers: [{
|
|
||||||
host: 'localhost',
|
|
||||||
port: 4242,
|
|
||||||
hostAE: 'ORTHANC'
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
defaultServiceType: 'dicomWeb',
|
|
||||||
//defaultServiceType: 'dimse'
|
|
||||||
public: {
|
|
||||||
ui: {
|
|
||||||
studyListFunctionsEnabled: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@ -5,8 +5,9 @@ Package.describe({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Package.onUse(function(api) {
|
Package.onUse(function(api) {
|
||||||
//api.use("weiwei:dicomservices");
|
api.versionsFrom('1.4');
|
||||||
|
|
||||||
|
api.use('ecmascript');
|
||||||
api.addFiles('server/require.js', 'server');
|
api.addFiles('server/require.js', 'server');
|
||||||
api.addFiles('server/constants.js', 'server');
|
api.addFiles('server/constants.js', 'server');
|
||||||
api.addFiles('server/elements_data.js', 'server');
|
api.addFiles('server/elements_data.js', 'server');
|
||||||
|
|||||||
@ -5,14 +5,15 @@ function time() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getRandomInt(min, max) {
|
function getRandomInt(min, max) {
|
||||||
return Math.floor(Math.random() * (max - min)) + min;
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Envelope = function(command, dataset) {
|
var Envelope = function(command, dataset) {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(Envelope, EventEmitter);
|
util.inherits(Envelope, EventEmitter);
|
||||||
|
|
||||||
CSocket = function(socket, options) {
|
CSocket = function(socket, options) {
|
||||||
@ -39,35 +40,43 @@ CSocket = function(socket, options) {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
var o = this;
|
var o = this;
|
||||||
this.socket.on("connect", function(){
|
this.socket.on('connect', function() {
|
||||||
|
console.log('Connect');
|
||||||
o.ready();
|
o.ready();
|
||||||
});
|
});
|
||||||
this.socket.on("data", function(data) {
|
this.socket.on('data', function(data) {
|
||||||
o.received(data);
|
o.received(data);
|
||||||
});
|
});
|
||||||
this.socket.on("error", function(he) {
|
this.socket.on('error', function(he) {
|
||||||
console.log("Error: ", he);
|
console.log('Error: ', he);
|
||||||
|
throw 'Error: ' + he;
|
||||||
});
|
});
|
||||||
this.socket.on("close", function() {
|
this.socket.on('timeout', function(he) {
|
||||||
|
console.log('Timeout: ', he);
|
||||||
|
throw 'Timeout: ' + he;
|
||||||
|
});
|
||||||
|
this.socket.on('close', function() {
|
||||||
if (o.intervalId) {
|
if (o.intervalId) {
|
||||||
clearInterval(o.intervalId);
|
clearInterval(o.intervalId);
|
||||||
}
|
}
|
||||||
o.connected = false;
|
|
||||||
console.log("Connection closed");
|
|
||||||
o.emit('close');
|
|
||||||
})
|
|
||||||
|
|
||||||
this.on("released", function() {
|
o.connected = false;
|
||||||
|
console.log('Connection closed');
|
||||||
|
o.emit('close');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.on('released', function() {
|
||||||
this.released();
|
this.released();
|
||||||
});
|
});
|
||||||
this.on('aborted', function(pdu) {
|
this.on('aborted', function(pdu) {
|
||||||
console.log('Assocation aborted with reason ' + pdu.reason);
|
console.warn('Association aborted with reason ' + pdu.reason);
|
||||||
this.released();
|
this.released();
|
||||||
})
|
});
|
||||||
this.on('message', function(pdvs) {
|
this.on('message', function(pdvs) {
|
||||||
this.receivedMessage(pdvs);
|
this.receivedMessage(pdvs);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CSocket, EventEmitter);
|
util.inherits(CSocket, EventEmitter);
|
||||||
|
|
||||||
CSocket.prototype.setCallingAE = function(ae) {
|
CSocket.prototype.setCallingAE = function(ae) {
|
||||||
@ -84,22 +93,23 @@ CSocket.prototype.associate = function() {
|
|||||||
associateRQ.setCallingAETitle(this.callingAe);
|
associateRQ.setCallingAETitle(this.callingAe);
|
||||||
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 = [];
|
||||||
context.transferSyntaxes.forEach(function(transferSyntax) {
|
|
||||||
var transfer = new TransferSyntaxItem();
|
|
||||||
transfer.setTransferSyntaxName(transferSyntax);
|
|
||||||
syntaxes.push(transfer);
|
|
||||||
});
|
|
||||||
contextItem.setTransferSyntaxesItems(syntaxes);
|
|
||||||
contextItem.setPresentationContextID(context.id);
|
|
||||||
|
|
||||||
var abstractItem = new AbstractSyntaxItem();
|
context.transferSyntaxes.forEach(function(transferSyntax) {
|
||||||
abstractItem.setAbstractSyntaxName(context.abstractSyntax);
|
var transfer = new TransferSyntaxItem();
|
||||||
contextItem.setAbstractSyntaxItem(abstractItem);
|
transfer.setTransferSyntaxName(transferSyntax);
|
||||||
contextItems.push(contextItem);
|
syntaxes.push(transfer);
|
||||||
|
});
|
||||||
|
contextItem.setTransferSyntaxesItems(syntaxes);
|
||||||
|
contextItem.setPresentationContextID(context.id);
|
||||||
|
|
||||||
|
var abstractItem = new AbstractSyntaxItem();
|
||||||
|
abstractItem.setAbstractSyntaxName(context.abstractSyntax);
|
||||||
|
contextItem.setAbstractSyntaxItem(abstractItem);
|
||||||
|
contextItems.push(contextItem);
|
||||||
});
|
});
|
||||||
associateRQ.setPresentationContextItems(contextItems);
|
associateRQ.setPresentationContextItems(contextItems);
|
||||||
|
|
||||||
@ -123,39 +133,45 @@ CSocket.prototype.associate = function() {
|
|||||||
CSocket.prototype.getContext = function(id) {
|
CSocket.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;
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.getSyntax = function(contextId) {
|
CSocket.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;
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.getContextByUID = function(uid) {
|
CSocket.prototype.getContextByUID = function(uid) {
|
||||||
for (var k in this.negotiatedContexts) {
|
for (var k in this.negotiatedContexts) {
|
||||||
var ctx = this.negotiatedContexts[k];
|
var ctx = this.negotiatedContexts[k];
|
||||||
if (ctx.abstractSyntax == uid) {
|
if (ctx.abstractSyntax === uid) {
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.getContextId = function(contextId) {
|
CSocket.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;
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.setPresentationContexts = function(uids) {
|
CSocket.prototype.setPresentationContexts = function(uids) {
|
||||||
var contexts = [],
|
var contexts = [],
|
||||||
id = 0;
|
id = 0;
|
||||||
uids.forEach(function(uid) {
|
uids.forEach(function(uid) {
|
||||||
id++;
|
id++;
|
||||||
if (typeof uid == 'string') {
|
if (typeof uid === 'string') {
|
||||||
contexts.push({
|
contexts.push({
|
||||||
id: id,
|
id: id,
|
||||||
abstractSyntax: uid,
|
abstractSyntax: uid,
|
||||||
@ -174,7 +190,7 @@ CSocket.prototype.setPresentationContexts = function(uids) {
|
|||||||
|
|
||||||
CSocket.prototype.newMessageId = function() {
|
CSocket.prototype.newMessageId = function() {
|
||||||
return (++this.messageIdCounter) % 65536;
|
return (++this.messageIdCounter) % 65536;
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.resetReceive = function() {
|
CSocket.prototype.resetReceive = function() {
|
||||||
this.receiving = this.receiveLength = null;
|
this.receiving = this.receiveLength = null;
|
||||||
@ -197,7 +213,7 @@ CSocket.prototype.released = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CSocket.prototype.ready = function() {
|
CSocket.prototype.ready = function() {
|
||||||
console.log("Connection established");
|
console.log('Connection established');
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
this.started = time();
|
this.started = time();
|
||||||
|
|
||||||
@ -217,8 +233,6 @@ CSocket.prototype.checkIdle = function() {
|
|||||||
this.idleClose();
|
this.idleClose();
|
||||||
} else if (this.lastReceived && (current - this.lastReceived >= idl)) {
|
} else if (this.lastReceived && (current - this.lastReceived >= idl)) {
|
||||||
this.idleClose();
|
this.idleClose();
|
||||||
} else {
|
|
||||||
//console.log('keep idling')
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,7 +242,6 @@ CSocket.prototype.idleClose = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CSocket.prototype.received = function(data) {
|
CSocket.prototype.received = function(data) {
|
||||||
var i = 0;
|
|
||||||
do {
|
do {
|
||||||
data = this.process(data);
|
data = this.process(data);
|
||||||
} while (data !== null);
|
} while (data !== null);
|
||||||
@ -236,7 +249,6 @@ CSocket.prototype.received = function(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CSocket.prototype.process = function(data) {
|
CSocket.prototype.process = function(data) {
|
||||||
//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);
|
||||||
@ -263,6 +275,7 @@ CSocket.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);
|
this.interpret(new ReadStream(process), this);
|
||||||
if (remaining) {
|
if (remaining) {
|
||||||
@ -270,6 +283,7 @@ CSocket.prototype.process = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Data received');
|
||||||
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;
|
||||||
|
|
||||||
@ -281,6 +295,7 @@ CSocket.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) {
|
||||||
@ -288,6 +303,7 @@ CSocket.prototype.process = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -302,8 +318,9 @@ CSocket.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,
|
||||||
@ -350,11 +367,13 @@ CSocket.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++]);
|
||||||
@ -377,9 +396,11 @@ CSocket.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));
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.emit('response', msg);
|
listener.emit('response', msg);
|
||||||
if (msg.isFinal()) {
|
if (msg.isFinal()) {
|
||||||
if (listener) {
|
if (listener) {
|
||||||
@ -403,7 +424,7 @@ CSocket.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";
|
||||||
}
|
}
|
||||||
@ -413,7 +434,7 @@ CSocket.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];
|
||||||
@ -429,7 +450,7 @@ CSocket.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);
|
||||||
@ -447,7 +468,7 @@ CSocket.prototype.wrapToPData = function(message, context) {
|
|||||||
pdv.setMessage(message);
|
pdv.setMessage(message);
|
||||||
pdata.setPresentationDataValueItems([pdv]);
|
pdata.setPresentationDataValueItems([pdv]);
|
||||||
return pdata;
|
return pdata;
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.sendMessage = function(context, command, dataset) {
|
CSocket.prototype.sendMessage = function(context, command, dataset) {
|
||||||
var nContext = this.getContextByUID(context),
|
var nContext = this.getContextByUID(context),
|
||||||
@ -459,7 +480,7 @@ CSocket.prototype.sendMessage = function(context, command, dataset) {
|
|||||||
msgData.listener = new Envelope(command);
|
msgData.listener = new Envelope(command);
|
||||||
|
|
||||||
var o = this;
|
var o = this;
|
||||||
msgData.listener.on('cancel', function(){
|
msgData.listener.on('cancel', function() {
|
||||||
var cancelMessage = null;
|
var cancelMessage = null;
|
||||||
if (this.command.is(C.COMMAND_C_FIND_RQ) || this.command.is(C.COMMAND_C_MOVE_RQ)) {
|
if (this.command.is(C.COMMAND_C_FIND_RQ) || this.command.is(C.COMMAND_C_MOVE_RQ)) {
|
||||||
cancelMessage = new CCancelRQ();
|
cancelMessage = new CCancelRQ();
|
||||||
@ -474,20 +495,22 @@ CSocket.prototype.sendMessage = function(context, command, dataset) {
|
|||||||
command.setSyntax(C.IMPLICIT_LITTLE_ENDIAN);
|
command.setSyntax(C.IMPLICIT_LITTLE_ENDIAN);
|
||||||
command.setContextId(context);
|
command.setContextId(context);
|
||||||
command.setMessageId(messageId);
|
command.setMessageId(messageId);
|
||||||
if (dataset)
|
if (dataset) {
|
||||||
command.setDataSetPresent(C.DATA_SET_PRESENT);
|
command.setDataSetPresent(C.DATA_SET_PRESENT);
|
||||||
|
}
|
||||||
|
|
||||||
this.lastSent = command;
|
this.lastSent = command;
|
||||||
if (command.is(C.COMMAND_C_GET_RQ)) {
|
if (command.is(C.COMMAND_C_GET_RQ)) {
|
||||||
this.lastGets.push(messageId);
|
this.lastGets.push(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pdata = this.wrapToPData(command);
|
var pdata = this.wrapToPData(command);
|
||||||
|
|
||||||
msgData.command = command;
|
msgData.command = command;
|
||||||
this.messages[messageId] = msgData;
|
this.messages[messageId] = msgData;
|
||||||
console.log('Sending command ' + command.typeString());
|
console.log('Sending command ' + command.typeString());
|
||||||
this.send(pdata);
|
this.send(pdata);
|
||||||
if (dataset && typeof dataset == 'object') {
|
if (dataset && typeof dataset === 'object') {
|
||||||
dataset.setSyntax(syntax);
|
dataset.setSyntax(syntax);
|
||||||
var dsData = new PDataTF(),
|
var dsData = new PDataTF(),
|
||||||
dPdv = new PresentationDataValueItem(cid);
|
dPdv = new PresentationDataValueItem(cid);
|
||||||
@ -496,6 +519,7 @@ CSocket.prototype.sendMessage = function(context, command, dataset) {
|
|||||||
dsData.setPresentationDataValueItems([dPdv]);
|
dsData.setPresentationDataValueItems([dPdv]);
|
||||||
this.send(dsData);
|
this.send(dsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return msgData.listener;
|
return msgData.listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -520,7 +544,9 @@ CSocket.prototype.wrapMessage = function(data) {
|
|||||||
var datasetMessage = new DataSetMessage();
|
var datasetMessage = new DataSetMessage();
|
||||||
datasetMessage.setElements(data);
|
datasetMessage.setElements(data);
|
||||||
return datasetMessage;
|
return datasetMessage;
|
||||||
} else return data;
|
} else {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CSocket.prototype.find = function(params, options) {
|
CSocket.prototype.find = function(params, options) {
|
||||||
@ -540,14 +566,14 @@ CSocket.prototype.storeInstance = function(sopClassUID, sopInstanceUID, options)
|
|||||||
storeMessage.setAffectedSOPClassUID(sopClassUID);
|
storeMessage.setAffectedSOPClassUID(sopClassUID);
|
||||||
|
|
||||||
return this.sendMessage(sopClassUID, storeMessage, true);
|
return this.sendMessage(sopClassUID, storeMessage, true);
|
||||||
}
|
};
|
||||||
|
|
||||||
CSocket.prototype.moveInstances = function(destination, params, options) {
|
CSocket.prototype.moveInstances = function(destination, params, options) {
|
||||||
var sendParams = Object.assign({
|
var sendParams = Object.assign({
|
||||||
0x00080052: C.QUERY_RETRIEVE_LEVEL_IMAGE,
|
0x00080052: C.QUERY_RETRIEVE_LEVEL_IMAGE,
|
||||||
}, params);
|
}, params);
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
context : C.SOP_STUDY_ROOT_MOVE
|
context: C.SOP_STUDY_ROOT_MOVE
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
return this.move(destination, sendParams, options);
|
return this.move(destination, sendParams, options);
|
||||||
@ -556,13 +582,13 @@ CSocket.prototype.moveInstances = function(destination, params, options) {
|
|||||||
CSocket.prototype.findPatients = function(params, options) {
|
CSocket.prototype.findPatients = function(params, options) {
|
||||||
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);
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
context : C.SOP_PATIENT_ROOT_FIND
|
context: C.SOP_PATIENT_ROOT_FIND
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
return this.find(sendParams, options);
|
return this.find(sendParams, options);
|
||||||
@ -571,13 +597,13 @@ CSocket.prototype.findPatients = function(params, options) {
|
|||||||
CSocket.prototype.findStudies = function(params, options) {
|
CSocket.prototype.findStudies = function(params, options) {
|
||||||
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);
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
context : C.SOP_STUDY_ROOT_FIND
|
context: C.SOP_STUDY_ROOT_FIND
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
return this.find(sendParams, options);
|
return this.find(sendParams, options);
|
||||||
@ -586,13 +612,13 @@ CSocket.prototype.findStudies = function(params, options) {
|
|||||||
CSocket.prototype.findSeries = function(params, options) {
|
CSocket.prototype.findSeries = function(params, options) {
|
||||||
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);
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
context : C.SOP_STUDY_ROOT_FIND
|
context: C.SOP_STUDY_ROOT_FIND
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
return this.find(sendParams, options);
|
return this.find(sendParams, options);
|
||||||
@ -601,14 +627,14 @@ CSocket.prototype.findSeries = function(params, options) {
|
|||||||
CSocket.prototype.findInstances = function(params, options) {
|
CSocket.prototype.findInstances = function(params, options) {
|
||||||
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);
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
context : C.SOP_STUDY_ROOT_FIND
|
context: C.SOP_STUDY_ROOT_FIND
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
return this.find(sendParams, options);
|
return this.find(sendParams, options);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
|
// Uses NodeJS 'net'
|
||||||
|
// https://nodejs.org/api/net.html
|
||||||
var net = Npm.require('net'),
|
var net = Npm.require('net'),
|
||||||
Socket = net.Socket;
|
Socket = net.Socket;
|
||||||
|
|
||||||
var DEFAULT_MAX_PACKAGE_SIZE = 32768;
|
var DEFAULT_MAX_PACKAGE_SIZE = 32768;
|
||||||
|
|
||||||
Connection = function (options) {
|
Connection = function(options) {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
this.options = Object.assign({
|
this.options = Object.assign({
|
||||||
maxPackageSize: C.DEFAULT_MAX_PACKAGE_SIZE,
|
maxPackageSize: C.DEFAULT_MAX_PACKAGE_SIZE,
|
||||||
@ -18,21 +20,24 @@ Connection = function (options) {
|
|||||||
this.peerSockets = {};
|
this.peerSockets = {};
|
||||||
this.defaultPeer = null;
|
this.defaultPeer = null;
|
||||||
this.defaultServer = null;
|
this.defaultServer = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(Connection, EventEmitter);
|
util.inherits(Connection, EventEmitter);
|
||||||
|
|
||||||
var StoreHandle = function () {
|
var StoreHandle = function() {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(StoreHandle, EventEmitter);
|
util.inherits(StoreHandle, EventEmitter);
|
||||||
|
|
||||||
Connection.prototype.addPeer = function (options) {
|
Connection.prototype.addPeer = function(options) {
|
||||||
if (!options.aeTitle || !options.host || !options.port) {
|
if (!options.aeTitle || !options.host || !options.port) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.peers[options.aeTitle] = {
|
this.peers[options.aeTitle] = {
|
||||||
host: options.host, port: options.port
|
host: options.host,
|
||||||
|
port: options.port
|
||||||
};
|
};
|
||||||
if (options.default) {
|
if (options.default) {
|
||||||
if (options.server) {
|
if (options.server) {
|
||||||
@ -41,90 +46,103 @@ Connection.prototype.addPeer = function (options) {
|
|||||||
this.defaultPeer = options.aeTitle;
|
this.defaultPeer = options.aeTitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.server) {
|
if (options.server) {
|
||||||
//start listening
|
//start listening
|
||||||
var server = net.createServer();
|
var server = net.createServer();
|
||||||
server.listen(options.port, options.host, function () {
|
server.listen(options.port, options.host, function() {
|
||||||
console.log("listening on %j", this.address());
|
console.log('listening on %j', this.address());
|
||||||
});
|
});
|
||||||
server.on('error', function (err) {
|
server.on('error', function(err) {
|
||||||
console.log("server error %j", err);
|
console.log('server error %j', err);
|
||||||
});
|
});
|
||||||
var o = this;
|
var o = this;
|
||||||
server.on('connection', function (nativeSocket) {
|
server.on('connection', function(nativeSocket) {
|
||||||
//incoming connections
|
//incoming connections
|
||||||
var socket = new CSocket(nativeSocket, o.options);
|
var socket = new CSocket(nativeSocket, o.options);
|
||||||
o.addSocket(options.aeTitle, socket);
|
o.addSocket(options.aeTitle, socket);
|
||||||
|
|
||||||
//close server on close socket
|
//close server on close socket
|
||||||
socket.on('close', function () {
|
socket.on('close', function() {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.selectPeer = function (aeTitle) {
|
Connection.prototype.selectPeer = function(aeTitle) {
|
||||||
if (!aeTitle || !this.peers[aeTitle]) {
|
if (!aeTitle || !this.peers[aeTitle]) {
|
||||||
throw "No such peer";
|
throw 'No such peer';
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.peers[aeTitle];
|
return this.peers[aeTitle];
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype._sendFile = function (socket, sHandle, file, maxSend, metaLength, list) {
|
Connection.prototype._sendFile = function(socket, sHandle, file, maxSend, metaLength, list) {
|
||||||
var fileNameText = typeof file.file == 'string' ? file.file : 'buffer';
|
var fileNameText = typeof file.file === 'string' ? file.file : 'buffer';
|
||||||
console.log("Sending file " + fileNameText);
|
console.log('Sending file ' + fileNameText);
|
||||||
var useContext = socket.getContextByUID(file.context), self = this;
|
var useContext = socket.getContextByUID(file.context),
|
||||||
|
self = this;
|
||||||
|
|
||||||
PDU.generatePDatas(useContext.id, file.file, maxSend, null, metaLength, function (err, handle) {
|
PDU.generatePDatas(useContext.id, file.file, maxSend, null, metaLength, function(err, handle) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Error while sending file');
|
console.log('Error while sending file');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var processNext = function () {
|
|
||||||
|
var processNext = function() {
|
||||||
var next = list.shift();
|
var next = list.shift();
|
||||||
if (next)
|
if (next) {
|
||||||
self._sendFile(socket, sHandle, next, maxSend, metaLength, list);
|
self._sendFile(socket, sHandle, next, maxSend, metaLength, list);
|
||||||
else
|
} else {
|
||||||
socket.release();
|
socket.release();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var store = socket.storeInstance(useContext.abstractSyntax, file.uid);
|
var store = socket.storeInstance(useContext.abstractSyntax, file.uid);
|
||||||
handle.on('pdv', function (pdv) {
|
handle.on('pdv', function(pdv) {
|
||||||
socket.sendPData(pdv);
|
socket.sendPData(pdv);
|
||||||
});
|
});
|
||||||
handle.on('error', function (err) {
|
handle.on('error', function(err) {
|
||||||
sHandle.emit('file', err, fileNameText);
|
sHandle.emit('file', err, fileNameText);
|
||||||
processNext();
|
processNext();
|
||||||
});
|
});
|
||||||
store.on('response', function (msg) {
|
store.on('response', function(msg) {
|
||||||
var statusText = msg.getStatus().toString(16);
|
var statusText = msg.getStatus().toString(16);
|
||||||
console.log('STORE reponse with status', statusText);
|
console.log('STORE reponse with status', statusText);
|
||||||
var error = null;
|
var error = null;
|
||||||
if (msg.failure()) {
|
if (msg.failure()) {
|
||||||
error = new Error(statusText);
|
error = new Error(statusText);
|
||||||
}
|
}
|
||||||
|
|
||||||
sHandle.emit('file', error, fileNameText);
|
sHandle.emit('file', error, fileNameText);
|
||||||
processNext();
|
processNext();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.storeInstances = function (fileList) {
|
Connection.prototype.storeInstances = function(fileList) {
|
||||||
var contexts = {}, read = 0, length = fileList.length, toSend = [], self = this, handle = new StoreHandle();
|
var contexts = {},
|
||||||
|
read = 0,
|
||||||
|
length = fileList.length,
|
||||||
|
toSend = [],
|
||||||
|
self = this,
|
||||||
|
handle = new StoreHandle();
|
||||||
var lastProcessedMetaLength;
|
var lastProcessedMetaLength;
|
||||||
fileList.forEach(function (bufferOrFile) {
|
fileList.forEach(function(bufferOrFile) {
|
||||||
var fileNameText = typeof bufferOrFile == 'string' ? bufferOrFile : 'buffer';
|
var fileNameText = typeof bufferOrFile === 'string' ? bufferOrFile : 'buffer';
|
||||||
DicomMessage.readMetaHeader(bufferOrFile, function (err, metaMessage, metaLength) {
|
DicomMessage.readMetaHeader(bufferOrFile, function(err, metaMessage, metaLength) {
|
||||||
read++;
|
read++;
|
||||||
if (err) {
|
if (err) {
|
||||||
handle.emit('file', err, fileNameText);
|
handle.emit('file', err, fileNameText);
|
||||||
if (read == length && toSend.length > 0 && lastProcessedMetaLength) {
|
if (read === length && toSend.length > 0 && lastProcessedMetaLength) {
|
||||||
sendProcessedFiles(self, contexts, toSend, handle, lastProcessedMetaLength);
|
sendProcessedFiles(self, contexts, toSend, handle, lastProcessedMetaLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Dicom file ' + (typeof bufferOrFile == 'string' ? bufferOrFile : 'buffer') + ' found');
|
|
||||||
|
console.log('Dicom file ' + (typeof bufferOrFile === 'string' ? bufferOrFile : 'buffer') + ' found');
|
||||||
lastProcessedMetaLength = metaLength;
|
lastProcessedMetaLength = metaLength;
|
||||||
var syntax = metaMessage.getValue(0x00020010),
|
var syntax = metaMessage.getValue(0x00020010),
|
||||||
sopClassUID = metaMessage.getValue(0x00020002),
|
sopClassUID = metaMessage.getValue(0x00020002),
|
||||||
@ -133,12 +151,18 @@ Connection.prototype.storeInstances = function (fileList) {
|
|||||||
if (!contexts[sopClassUID]) {
|
if (!contexts[sopClassUID]) {
|
||||||
contexts[sopClassUID] = [];
|
contexts[sopClassUID] = [];
|
||||||
}
|
}
|
||||||
if (syntax && contexts[sopClassUID].indexOf(syntax) == -1) {
|
|
||||||
|
if (syntax && contexts[sopClassUID].indexOf(syntax) === -1) {
|
||||||
contexts[sopClassUID].push(syntax);
|
contexts[sopClassUID].push(syntax);
|
||||||
}
|
}
|
||||||
toSend.push({file: bufferOrFile, context: sopClassUID, uid: instanceUID});
|
|
||||||
|
|
||||||
if (read == length) {
|
toSend.push({
|
||||||
|
file: bufferOrFile,
|
||||||
|
context: sopClassUID,
|
||||||
|
uid: instanceUID
|
||||||
|
});
|
||||||
|
|
||||||
|
if (read === length) {
|
||||||
sendProcessedFiles(self, contexts, toSend, handle, metaLength);
|
sendProcessedFiles(self, contexts, toSend, handle, metaLength);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -147,27 +171,31 @@ Connection.prototype.storeInstances = function (fileList) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Starts to send dcm files
|
// Starts to send dcm files
|
||||||
sendProcessedFiles = function (self, contexts, toSend, handle, metaLength) {
|
sendProcessedFiles = function(self, contexts, toSend, handle, metaLength) {
|
||||||
var useContexts = [];
|
var useContexts = [];
|
||||||
for (var context in contexts) {
|
for (var context in contexts) {
|
||||||
var useSyntaxes = contexts[context];
|
var useSyntaxes = contexts[context];
|
||||||
if (useSyntaxes.length > 0) {
|
if (useSyntaxes.length > 0) {
|
||||||
useContexts.push({context: context, syntaxes: contexts[context]});
|
useContexts.push({
|
||||||
|
context: context,
|
||||||
|
syntaxes: contexts[context]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
throw "No syntax specified for context " + context;
|
throw 'No syntax specified for context ' + context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.associate({
|
self.associate({
|
||||||
contexts: useContexts
|
contexts: useContexts
|
||||||
}, function (ac) {
|
}, function(ac) {
|
||||||
var maxSend = ac.getMaxSize(), next = toSend.shift();
|
var maxSend = ac.getMaxSize(),
|
||||||
|
next = toSend.shift();
|
||||||
self._sendFile(this, handle, next, maxSend, metaLength, toSend);
|
self._sendFile(this, handle, next, maxSend, metaLength, toSend);
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.storeResponse = function (messageId, msg) {
|
Connection.prototype.storeResponse = function(messageId, msg) {
|
||||||
var rq = this.messages[messageId];
|
var rq = this.messages[messageId];
|
||||||
|
|
||||||
if (rq.listener[2]) {
|
if (rq.listener[2]) {
|
||||||
@ -180,12 +208,12 @@ 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.allClosed = function () {
|
Connection.prototype.allClosed = function() {
|
||||||
var allClosed = true;
|
var allClosed = true;
|
||||||
for (var i in o.peerSockets) {
|
for (var i in o.peerSockets) {
|
||||||
if (Object.keys(o.peerSockets[ae]).length > 0) {
|
if (Object.keys(o.peerSockets[ae]).length > 0) {
|
||||||
@ -193,48 +221,61 @@ Connection.prototype.allClosed = function () {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allClosed;
|
return allClosed;
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.addSocket = function (ae, socket) {
|
Connection.prototype.addSocket = function(ae, socket) {
|
||||||
if (!this.peerSockets[ae]) {
|
if (!this.peerSockets[ae]) {
|
||||||
this.peerSockets[ae] = {};
|
this.peerSockets[ae] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.peerSockets[ae][socket.id] = socket;
|
this.peerSockets[ae][socket.id] = socket;
|
||||||
|
|
||||||
var o = this;
|
var o = this;
|
||||||
socket.on("close", function () {
|
socket.on('close', function() {
|
||||||
if (o.peerSockets[ae][this.id]) {
|
if (o.peerSockets[ae][this.id]) {
|
||||||
delete o.peerSockets[ae][this.id];
|
delete o.peerSockets[ae][this.id];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.associate = function (options, callback) {
|
Connection.prototype.associate = function(options, callback) {
|
||||||
var hostAE = options.hostAE ? options.hostAE : this.defaultPeer,
|
var hostAE = options.hostAE ? options.hostAE : this.defaultPeer,
|
||||||
sourceAE = options.sourceAE ? options.sourceAE : this.defaultServer;
|
sourceAE = options.sourceAE ? options.sourceAE : this.defaultServer;
|
||||||
|
|
||||||
if (!hostAE || !sourceAE) {
|
if (!hostAE || !sourceAE) {
|
||||||
throw "Peers not provided or no defaults in settings";
|
throw 'Peers not provided or no defaults in settings';
|
||||||
}
|
}
|
||||||
|
|
||||||
var peerInfo = this.selectPeer(hostAE), nativeSocket = new Socket();
|
var peerInfo = this.selectPeer(hostAE),
|
||||||
var socket = new CSocket(nativeSocket, this.options), o = this;
|
nativeSocket = new Socket();
|
||||||
|
|
||||||
|
var socket = new CSocket(nativeSocket, this.options),
|
||||||
|
o = this;
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
socket.once('associated', callback);
|
socket.once('associated', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Starting Connection...');
|
||||||
|
|
||||||
socket.setCalledAe(hostAE);
|
socket.setCalledAe(hostAE);
|
||||||
socket.setCallingAE(sourceAE);
|
socket.setCallingAE(sourceAE);
|
||||||
|
|
||||||
|
console.log(peerInfo);
|
||||||
|
|
||||||
nativeSocket.connect({
|
nativeSocket.connect({
|
||||||
host: peerInfo.host, port: peerInfo.port
|
host: peerInfo.host,
|
||||||
}, function () {
|
port: peerInfo.port
|
||||||
|
}, function() {
|
||||||
//connected
|
//connected
|
||||||
o.addSocket(hostAE, socket);
|
o.addSocket(hostAE, socket);
|
||||||
|
|
||||||
if (options.contexts) {
|
if (options.contexts) {
|
||||||
socket.setPresentationContexts(options.contexts);
|
socket.setPresentationContexts(options.contexts);
|
||||||
} else {
|
} else {
|
||||||
throw "Contexts must be specified";
|
throw 'Contexts must be specified';
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.associate();
|
socket.associate();
|
||||||
|
|||||||
@ -56,12 +56,14 @@ var getInstanceRetrievalParams = function(studyInstanceUID, seriesInstanceUID) {
|
|||||||
|
|
||||||
Meteor.startup(function() {
|
Meteor.startup(function() {
|
||||||
if (!Meteor.settings.servers.dimse || !Meteor.settings.servers.dimse.length) {
|
if (!Meteor.settings.servers.dimse || !Meteor.settings.servers.dimse.length) {
|
||||||
return;
|
console.error('dimse-config: ' + 'No DIMSE Servers provided.');
|
||||||
|
throw new Meteor.Error('dimse-config', 'No DIMSE Servers provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: [custom-servers] use active server and check if type is DIMSE
|
// TODO: [custom-servers] use active server and check if type is DIMSE
|
||||||
var peers = Meteor.settings.servers.dimse[0].peers;
|
var peers = Meteor.settings.servers.dimse[0].peers;
|
||||||
if (!peers || !peers.length) {
|
if (!peers || !peers.length) {
|
||||||
|
console.error('dimse-config: ' + 'No DIMSE Peers provided.');
|
||||||
throw new Meteor.Error('dimse-config', 'No DIMSE Peers provided.');
|
throw new Meteor.Error('dimse-config', 'No DIMSE Peers provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ Meteor.startup(function() {
|
|||||||
conn.addPeer(peer);
|
conn.addPeer(peer);
|
||||||
});
|
});
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.warn('dimse-addPeers: ' + error);
|
console.error('dimse-addPeers: ' + error);
|
||||||
throw new Meteor.Error('dimse-addPeers', error);
|
throw new Meteor.Error('dimse-addPeers', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -82,6 +84,7 @@ DIMSE.associate = function(contexts, callback, options) {
|
|||||||
};
|
};
|
||||||
options = Object.assign(defaults, options);
|
options = Object.assign(defaults, options);
|
||||||
|
|
||||||
|
console.log('Associating...');
|
||||||
try {
|
try {
|
||||||
conn.associate(options, function(pdu) {
|
conn.associate(options, function(pdu) {
|
||||||
// associated
|
// associated
|
||||||
@ -89,7 +92,7 @@ DIMSE.associate = function(contexts, callback, options) {
|
|||||||
callback.call(this, pdu);
|
callback.call(this, pdu);
|
||||||
});
|
});
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.warn('dimse-associate: ' + error);
|
console.error('dimse-associate: ' + error);
|
||||||
throw new Meteor.Error('dimse-associate', error);
|
throw new Meteor.Error('dimse-associate', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -165,7 +168,8 @@ DIMSE.retrieveStudies = function(params, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
DIMSE._retrieveInstancesBySeries = function(conn, series, studyInstanceUID, callback, params) {
|
DIMSE._retrieveInstancesBySeries = function(conn, series, studyInstanceUID, callback, params) {
|
||||||
var aSeries = series.shift(), seriesInstanceUID = aSeries.getValue(0x0020000E),
|
var aSeries = series.shift(),
|
||||||
|
seriesInstanceUID = aSeries.getValue(0x0020000E),
|
||||||
defaultParams = getInstanceRetrievalParams(studyInstanceUID, seriesInstanceUID);
|
defaultParams = getInstanceRetrievalParams(studyInstanceUID, seriesInstanceUID);
|
||||||
|
|
||||||
var result = conn.findInstances(Object.assign(defaultParams, params)),
|
var result = conn.findInstances(Object.assign(defaultParams, params)),
|
||||||
@ -189,8 +193,9 @@ DIMSE.retrieveInstancesByStudyOnlyMulti = function(studyInstanceUID, params, opt
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var series = DIMSE.retrieveSeries(studyInstanceUID, params, options), instances = [];
|
var series = DIMSE.retrieveSeries(studyInstanceUID, params, options),
|
||||||
series.forEach(function(seriesData){
|
instances = [];
|
||||||
|
series.forEach(function(seriesData) {
|
||||||
var seriesInstanceUID = seriesData.getValue(0x0020000E);
|
var seriesInstanceUID = seriesData.getValue(0x0020000E);
|
||||||
|
|
||||||
var relatedInstances = DIMSE.retrieveInstances(studyInstanceUID, seriesInstanceUID, params, options);
|
var relatedInstances = DIMSE.retrieveInstances(studyInstanceUID, seriesInstanceUID, params, options);
|
||||||
@ -205,7 +210,7 @@ DIMSE.retrieveInstancesByStudyOnly = function(studyInstanceUID, params, options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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,
|
0x0020000D: studyInstanceUID,
|
||||||
0x00080005: '',
|
0x00080005: '',
|
||||||
@ -220,14 +225,16 @@ DIMSE.retrieveInstancesByStudyOnly = function(studyInstanceUID, params, options)
|
|||||||
0x00200011: ''
|
0x00200011: ''
|
||||||
};
|
};
|
||||||
var result = this.findSeries(Object.assign(defaultParams, params)),
|
var result = this.findSeries(Object.assign(defaultParams, params)),
|
||||||
series = [], conn = this, allInstances = [];
|
series = [],
|
||||||
|
conn = this,
|
||||||
|
allInstances = [];
|
||||||
|
|
||||||
result.on('result', function(msg) {
|
result.on('result', function(msg) {
|
||||||
series.push(msg);
|
series.push(msg);
|
||||||
});
|
});
|
||||||
result.on('end', function(){
|
result.on('end', function() {
|
||||||
if (series.length > 0) {
|
if (series.length > 0) {
|
||||||
DIMSE._retrieveInstancesBySeries(conn, series, studyInstanceUID, function(relatedInstances, isEnd){
|
DIMSE._retrieveInstancesBySeries(conn, series, studyInstanceUID, function(relatedInstances, isEnd) {
|
||||||
allInstances = allInstances.concat(relatedInstances);
|
allInstances = allInstances.concat(relatedInstances);
|
||||||
if (isEnd) {
|
if (isEnd) {
|
||||||
conn.release();
|
conn.release();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,143 +1,156 @@
|
|||||||
Field = function(type, value) {
|
Field = function(type, value) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = 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;
|
||||||
}
|
};
|
||||||
|
|
||||||
BufferField = function(buffer, start, length) {
|
BufferField = function(buffer, start, length) {
|
||||||
Field.call(this, C.TYPE_BUFFER, buffer);
|
Field.call(this, C.TYPE_BUFFER, buffer);
|
||||||
this.bufferLength = length;
|
this.bufferLength = length;
|
||||||
this.bufferStart = start;
|
this.bufferStart = start;
|
||||||
}
|
};
|
||||||
|
|
||||||
util.inherits(BufferField, Field);
|
util.inherits(BufferField, Field);
|
||||||
|
|
||||||
BufferField.prototype.length = function() {
|
BufferField.prototype.length = function() {
|
||||||
return this.bufferLength;
|
return this.bufferLength;
|
||||||
}
|
};
|
||||||
|
|
||||||
BufferField.prototype.write = function(stream) {
|
BufferField.prototype.write = function(stream) {
|
||||||
stream.writeRawBuffer(this.value, this.bufferStart, this.bufferLength);
|
stream.writeRawBuffer(this.value, this.bufferStart, this.bufferLength);
|
||||||
}
|
};
|
||||||
|
|
||||||
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;
|
||||||
if (len < this.fillLength && len >= 0) {
|
if (len < this.fillLength && len >= 0) {
|
||||||
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;
|
||||||
}
|
};
|
||||||
|
|||||||
@ -1,556 +1,590 @@
|
|||||||
DicomMessage = function(syntax) {
|
DicomMessage = function(syntax) {
|
||||||
this.syntax = syntax ? syntax : null;
|
this.syntax = syntax ? syntax : null;
|
||||||
this.type = C.DATA_TYPE_COMMAND;
|
this.type = C.DATA_TYPE_COMMAND;
|
||||||
this.messageId = C.DEFAULT_MESSAGE_ID;
|
this.messageId = C.DEFAULT_MESSAGE_ID;
|
||||||
this.elementPairs = {};
|
this.elementPairs = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
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));
|
||||||
cmds.unshift(this.newElement(0x00000700, this.priority));
|
cmds.unshift(this.newElement(0x00000700, this.priority));
|
||||||
cmds.unshift(this.newElement(0x00000110, this.messageId));
|
cmds.unshift(this.newElement(0x00000110, this.messageId));
|
||||||
cmds.unshift(this.newElement(0x00000100, this.commandType));
|
cmds.unshift(this.newElement(0x00000100, this.commandType));
|
||||||
cmds.unshift(this.newElement(0x00000002, this.contextUID));
|
|
||||||
|
|
||||||
var length = 0;
|
|
||||||
cmds.forEach(function(cmd) {
|
|
||||||
length += cmd.length(cmd.getFields());
|
|
||||||
});
|
|
||||||
|
|
||||||
cmds.unshift(this.newElement(0x00000000, length));
|
|
||||||
return 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(0x00000120, this.replyMessageId));
|
|
||||||
cmds.unshift(this.newElement(0x00000100, this.commandType));
|
|
||||||
if (this.contextUID)
|
|
||||||
cmds.unshift(this.newElement(0x00000002, this.contextUID));
|
cmds.unshift(this.newElement(0x00000002, this.contextUID));
|
||||||
|
|
||||||
var length = 0;
|
var length = 0;
|
||||||
cmds.forEach(function(cmd) {
|
cmds.forEach(function(cmd) {
|
||||||
length += cmd.length(cmd.getFields());
|
length += cmd.length(cmd.getFields());
|
||||||
});
|
});
|
||||||
|
|
||||||
cmds.unshift(this.newElement(0x00000000, length));
|
cmds.unshift(this.newElement(0x00000000, length));
|
||||||
return cmds;
|
return 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(0x00000120, this.replyMessageId));
|
||||||
|
cmds.unshift(this.newElement(0x00000100, this.commandType));
|
||||||
|
if (this.contextUID)
|
||||||
|
cmds.unshift(this.newElement(0x00000002, this.contextUID));
|
||||||
|
|
||||||
|
var length = 0;
|
||||||
|
cmds.forEach(function(cmd) {
|
||||||
|
length += cmd.length(cmd.getFields());
|
||||||
|
});
|
||||||
|
|
||||||
|
cmds.unshift(this.newElement(0x00000000, length));
|
||||||
|
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(),
|
||||||
fields.forEach(function(field){
|
o = this;
|
||||||
field.setSyntax(o.syntax);
|
fields.forEach(function(field) {
|
||||||
field.write(stream);
|
field.setSyntax(o.syntax);
|
||||||
});
|
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 {
|
||||||
|
typeName += '[' + p + ']';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (typeName[typeName.length - 1] != '\n') {
|
||||||
|
typeName += '\n';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
typeName += "[" + p + "]";
|
typeName += value + '\n';
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (typeName[typeName.length-1] != "\n") {
|
|
||||||
typeName += "\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
typeName += value + "\n";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return typeName;
|
return typeName;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.typeString = function() {
|
DicomMessage.prototype.typeString = 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return typeName;
|
|
||||||
}
|
return typeName;
|
||||||
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.toString = function() {
|
DicomMessage.prototype.toString = function() {
|
||||||
var typeName = this.typeString();
|
var typeName = this.typeString();
|
||||||
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 = {},
|
||||||
for (var tag in pairs) {
|
o = this;
|
||||||
var v = pairs[tag].getValue(), u = v;
|
for (var tag in pairs) {
|
||||||
if (v instanceof Array) {
|
var v = pairs[tag].getValue(),
|
||||||
u = [];
|
u = v;
|
||||||
v.forEach(function(a) {
|
if (v instanceof Array) {
|
||||||
if (typeof a == 'object') {
|
u = [];
|
||||||
u.push(o.walkObject(a));
|
v.forEach(function(a) {
|
||||||
} else u.push(a);
|
if (typeof a == 'object') {
|
||||||
});
|
u.push(o.walkObject(a));
|
||||||
}
|
} else u.push(a);
|
||||||
obj[tag] = u;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
obj[tag] = u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
DicomMessage.prototype.toObject = function() {
|
DicomMessage.prototype.toObject = function() {
|
||||||
return this.walkObject(this.elementPairs);
|
return this.walkObject(this.elementPairs);
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.readToPairs = function(stream, syntax, options) {
|
DicomMessage.readToPairs = function(stream, syntax, options) {
|
||||||
var pairs = {};
|
var pairs = {};
|
||||||
while (!stream.end()) {
|
while (!stream.end()) {
|
||||||
var elem = new DataElement();
|
var elem = new DataElement();
|
||||||
if (options) {
|
if (options) {
|
||||||
elem.setOptions(options);
|
elem.setOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
elem.setSyntax(syntax);
|
||||||
|
elem.readBytes(stream);
|
||||||
|
pairs[elem.tag.value] = elem;
|
||||||
}
|
}
|
||||||
elem.setSyntax(syntax);
|
|
||||||
elem.readBytes(stream);
|
return pairs;
|
||||||
pairs[elem.tag.value] = elem;
|
};
|
||||||
}
|
|
||||||
return pairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
var fileValid = function(stream) {
|
var fileValid = function(stream) {
|
||||||
return stream.readString(4, C.TYPE_ASCII) == 'DICM';
|
return stream.readString(4, C.TYPE_ASCII) == 'DICM';
|
||||||
}
|
};
|
||||||
|
|
||||||
var readMetaStream = function(stream, useSyntax, length, callback) {
|
var readMetaStream = function(stream, useSyntax, length, callback) {
|
||||||
var message = new FileMetaMessage();
|
var message = new FileMetaMessage();
|
||||||
message.setElementPairs(DicomMessage.readToPairs(stream, useSyntax));
|
message.setElementPairs(DicomMessage.readToPairs(stream, useSyntax));
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(null, message, length);
|
callback(null, message, length);
|
||||||
}
|
}
|
||||||
return message;
|
|
||||||
}
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
DicomMessage.readMetaHeader = function(bufferOrFile, callback) {
|
DicomMessage.readMetaHeader = function(bufferOrFile, callback) {
|
||||||
var useSyntax = C.EXPLICIT_LITTLE_ENDIAN;
|
var useSyntax = C.EXPLICIT_LITTLE_ENDIAN;
|
||||||
if (bufferOrFile instanceof Buffer) {
|
if (bufferOrFile instanceof Buffer) {
|
||||||
var stream = new ReadStream(bufferOrFile);
|
var stream = new ReadStream(bufferOrFile);
|
||||||
stream.reset();
|
stream.reset();
|
||||||
stream.increment(128);
|
stream.increment(128);
|
||||||
if (!fileValid(stream)) {
|
|
||||||
return quitWithError('Invalid a dicom file ', callback);
|
|
||||||
}
|
|
||||||
var el = readAElement(stream, useSyntax),
|
|
||||||
metaLength = el.value,
|
|
||||||
metaStream = stream.more(metaLength);
|
|
||||||
|
|
||||||
return readMetaStream(metaStream, useSyntax, metaLength, callback);
|
|
||||||
} else if (typeof bufferOrFile == 'string') {
|
|
||||||
fs.open(bufferOrFile, 'r', function(err, fd) {
|
|
||||||
if (err) {
|
|
||||||
//fs.closeSync(fd);
|
|
||||||
return quitWithError('Cannot open file', callback);
|
|
||||||
}
|
|
||||||
var buffer = new Buffer(16);
|
|
||||||
fs.read(fd, buffer, 0, 16, 128, function(err, bytesRead) {
|
|
||||||
if (err || bytesRead != 16) {
|
|
||||||
fs.closeSync(fd);
|
|
||||||
return quitWithError('Cannot read file', callback);
|
|
||||||
}
|
|
||||||
var stream = new ReadStream(buffer);
|
|
||||||
if (!fileValid(stream)) {
|
if (!fileValid(stream)) {
|
||||||
fs.closeSync(fd);
|
return quitWithError('Invalid a dicom file ', callback);
|
||||||
return quitWithError('Not a dicom file ' + bufferOrFile, callback);
|
}
|
||||||
}
|
|
||||||
var el = readAElement(stream, useSyntax),
|
var el = readAElement(stream, useSyntax),
|
||||||
metaLength = el.value,
|
metaLength = el.value,
|
||||||
metaBuffer = new Buffer(metaLength);
|
metaStream = stream.more(metaLength);
|
||||||
|
|
||||||
fs.read(fd, metaBuffer, 0, metaLength, 144, function(err, bytesRead) {
|
return readMetaStream(metaStream, useSyntax, metaLength, callback);
|
||||||
fs.closeSync(fd);
|
} else if (typeof bufferOrFile == 'string') {
|
||||||
if (err || bytesRead != metaLength) {
|
fs.open(bufferOrFile, 'r', function(err, fd) {
|
||||||
return quitWithError('Invalid a dicom file ' + bufferOrFile, callback);
|
if (err) {
|
||||||
}
|
//fs.closeSync(fd);
|
||||||
var metaStream = new ReadStream(metaBuffer);
|
return quitWithError('Cannot open file', callback);
|
||||||
return readMetaStream(metaStream, useSyntax, metaLength, callback);
|
}
|
||||||
|
|
||||||
|
var buffer = new Buffer(16);
|
||||||
|
fs.read(fd, buffer, 0, 16, 128, function(err, bytesRead) {
|
||||||
|
if (err || bytesRead != 16) {
|
||||||
|
fs.closeSync(fd);
|
||||||
|
return quitWithError('Cannot read file', callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
var stream = new ReadStream(buffer);
|
||||||
|
if (!fileValid(stream)) {
|
||||||
|
fs.closeSync(fd);
|
||||||
|
return quitWithError('Not a dicom file ' + bufferOrFile, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
var el = readAElement(stream, useSyntax),
|
||||||
|
metaLength = el.value,
|
||||||
|
metaBuffer = new Buffer(metaLength);
|
||||||
|
|
||||||
|
fs.read(fd, metaBuffer, 0, metaLength, 144, function(err, bytesRead) {
|
||||||
|
fs.closeSync(fd);
|
||||||
|
if (err || bytesRead != metaLength) {
|
||||||
|
return quitWithError('Invalid a dicom file ' + bufferOrFile, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
var metaStream = new ReadStream(metaBuffer);
|
||||||
|
return readMetaStream(metaStream, useSyntax, metaLength, callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
DicomMessage.read = function(stream, type, syntax, options) {
|
DicomMessage.read = function(stream, type, syntax, options) {
|
||||||
var elements = [], pairs = {}, useSyntax = type == C.DATA_TYPE_COMMAND ? C.IMPLICIT_LITTLE_ENDIAN : syntax;
|
var elements = [],
|
||||||
stream.reset();
|
pairs = {},
|
||||||
while (!stream.end()) {
|
useSyntax = type == C.DATA_TYPE_COMMAND ? C.IMPLICIT_LITTLE_ENDIAN : syntax;
|
||||||
var elem = new DataElement();
|
stream.reset();
|
||||||
if (options) {
|
while (!stream.end()) {
|
||||||
elem.setOptions(options);
|
var elem = new DataElement();
|
||||||
}
|
if (options) {
|
||||||
elem.setSyntax(useSyntax);
|
elem.setOptions(options);
|
||||||
elem.readBytes(stream);//return;
|
}
|
||||||
pairs[elem.tag.value] = elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
var message = null;
|
elem.setSyntax(useSyntax);
|
||||||
if (type == C.DATA_TYPE_COMMAND) {
|
elem.readBytes(stream);//return;
|
||||||
var cmdType = pairs[0x00000100].value;
|
pairs[elem.tag.value] = elem;
|
||||||
|
|
||||||
switch (cmdType) {
|
|
||||||
case 0x8020 : message = new CFindRSP(useSyntax); break;
|
|
||||||
case 0x8021 : message = new CMoveRSP(useSyntax); break;
|
|
||||||
case 0x8010 : message = new CGetRSP(useSyntax); break;
|
|
||||||
case 0x0001 : message = new CStoreRQ(useSyntax); break;
|
|
||||||
case 0x0020 : message = new CFindRQ(useSyntax); break;
|
|
||||||
case 0x8001 : message = new CStoreRSP(useSyntax); break;
|
|
||||||
default : throw "Unrecognized command type " + cmdType.toString(16); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message.setElementPairs(pairs);
|
var message = null;
|
||||||
message.setDataSetPresent(message.getValue(0x00000800));
|
if (type == C.DATA_TYPE_COMMAND) {
|
||||||
message.setContextId(message.getValue(0x00000002));
|
var cmdType = pairs[0x00000100].value;
|
||||||
if (!message.isResponse()) {
|
|
||||||
message.setMessageId(message.getValue(0x00000110));
|
switch (cmdType) {
|
||||||
|
case 0x8020 : message = new CFindRSP(useSyntax); break;
|
||||||
|
case 0x8021 : message = new CMoveRSP(useSyntax); break;
|
||||||
|
case 0x8010 : message = new CGetRSP(useSyntax); break;
|
||||||
|
case 0x0001 : message = new CStoreRQ(useSyntax); break;
|
||||||
|
case 0x0020 : message = new CFindRQ(useSyntax); break;
|
||||||
|
case 0x8001 : message = new CStoreRSP(useSyntax); break;
|
||||||
|
default : throw 'Unrecognized command type ' + cmdType.toString(16); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.setElementPairs(pairs);
|
||||||
|
message.setDataSetPresent(message.getValue(0x00000800));
|
||||||
|
message.setContextId(message.getValue(0x00000002));
|
||||||
|
if (!message.isResponse()) {
|
||||||
|
message.setMessageId(message.getValue(0x00000110));
|
||||||
|
} else {
|
||||||
|
message.setReplyMessageId(message.getValue(0x00000120));
|
||||||
|
}
|
||||||
|
} else if (type == C.DATA_TYPE_DATA) {
|
||||||
|
message = new DataSetMessage(useSyntax);
|
||||||
|
message.setElementPairs(pairs);
|
||||||
} else {
|
} else {
|
||||||
message.setReplyMessageId(message.getValue(0x00000120));
|
throw 'Unrecognized message type';
|
||||||
}
|
}
|
||||||
} else if (type == C.DATA_TYPE_DATA) {
|
|
||||||
message = new DataSetMessage(useSyntax);
|
|
||||||
message.setElementPairs(pairs);
|
|
||||||
} else {
|
|
||||||
throw "Unrecognized message type";
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataSetMessage = function(syntax){
|
return message;
|
||||||
DicomMessage.call(this, syntax);
|
|
||||||
this.type = C.DATA_TYPE_DATA;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DataSetMessage = function(syntax) {
|
||||||
|
DicomMessage.call(this, syntax);
|
||||||
|
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;
|
||||||
}
|
|
||||||
|
|
||||||
FileMetaMessage = function(syntax){
|
|
||||||
DicomMessage.call(this, syntax);
|
|
||||||
this.type = null
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FileMetaMessage = function(syntax) {
|
||||||
|
DicomMessage.call(this, syntax);
|
||||||
|
this.type = null;
|
||||||
|
};
|
||||||
|
|
||||||
util.inherits(FileMetaMessage, DicomMessage);
|
util.inherits(FileMetaMessage, DicomMessage);
|
||||||
|
|
||||||
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) {
|
||||||
CommandMessage.call(this, syntax);
|
CommandMessage.call(this, 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);
|
||||||
|
|
||||||
CCancelRQ = function(syntax) {
|
CCancelRQ = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
this.commandType = 0x0fff;
|
this.commandType = 0x0fff;
|
||||||
this.contextUID = null;
|
this.contextUID = null;
|
||||||
this.dataSetPresent = false;
|
this.dataSetPresent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CCancelRQ, CommandResponse);
|
util.inherits(CCancelRQ, CommandResponse);
|
||||||
|
|
||||||
CCancelMoveRQ = function(syntax) {
|
CCancelMoveRQ = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
this.commandType = 0x0fff;
|
this.commandType = 0x0fff;
|
||||||
this.contextUID = null;
|
this.contextUID = null;
|
||||||
this.dataSetPresent = false;
|
this.dataSetPresent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(CCancelMoveRQ, CommandResponse);
|
util.inherits(CCancelMoveRQ, CommandResponse);
|
||||||
|
|
||||||
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.setElement(0x00000600, dest);
|
this.setElement(0x00000600, dest);
|
||||||
}
|
};
|
||||||
|
|
||||||
CGetRQ = function(syntax) {
|
CGetRQ = function(syntax) {
|
||||||
CommandMessage.call(this, syntax);
|
CommandMessage.call(this, syntax);
|
||||||
this.commandType = 0x10;
|
this.commandType = 0x10;
|
||||||
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.getAffectedSOPInstanceUID = function() {
|
CStoreRQ.prototype.getAffectedSOPInstanceUID = function() {
|
||||||
return this.getValue(0x00001000);
|
return this.getValue(0x00001000);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRQ.prototype.setAffectedSOPInstanceUID = function(uid) {
|
CStoreRQ.prototype.setAffectedSOPInstanceUID = function(uid) {
|
||||||
this.setElement(0x00001000, uid);
|
this.setElement(0x00001000, uid);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRQ.prototype.setAffectedSOPClassUID = function(uid) {
|
CStoreRQ.prototype.setAffectedSOPClassUID = function(uid) {
|
||||||
this.setElement(0x00000002, uid);
|
this.setElement(0x00000002, uid);
|
||||||
}
|
};
|
||||||
|
|
||||||
CStoreRSP = function(syntax) {
|
CStoreRSP = function(syntax) {
|
||||||
CommandResponse.call(this, syntax);
|
CommandResponse.call(this, syntax);
|
||||||
this.commandType = 0x8001;
|
this.commandType = 0x8001;
|
||||||
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,236 +1,239 @@
|
|||||||
var isString = function(type) {
|
var isString = function(type) {
|
||||||
if (type == C.TYPE_ASCII || type == C.TYPE_HEX) {
|
if (type === C.TYPE_ASCII || type === C.TYPE_HEX) {
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
calcLength = function(type, value) {
|
calcLength = function(type, value) {
|
||||||
var size = NaN;
|
var size = NaN;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case C.TYPE_HEX : size = Buffer.byteLength(value, 'hex'); break;
|
case C.TYPE_HEX : size = Buffer.byteLength(value, 'hex'); break;
|
||||||
case C.TYPE_ASCII : size = Buffer.byteLength(value, 'ascii'); break;
|
case C.TYPE_ASCII : size = Buffer.byteLength(value, 'ascii'); break;
|
||||||
case C.TYPE_UINT8 : size = 1; break;
|
case C.TYPE_UINT8 : size = 1; break;
|
||||||
case C.TYPE_UINT16 : size = 2; break;
|
case C.TYPE_UINT16 : size = 2; break;
|
||||||
case C.TYPE_UINT32 : size = 4; break;
|
case C.TYPE_UINT32 : size = 4; break;
|
||||||
case C.TYPE_FLOAT : size = 4; break;
|
case C.TYPE_FLOAT : size = 4; break;
|
||||||
case C.TYPE_DOUBLE : size = 8; break;
|
case C.TYPE_DOUBLE : size = 8; break;
|
||||||
case C.TYPE_INT8 : size = 1; break;
|
case C.TYPE_INT8 : size = 1; break;
|
||||||
case C.TYPE_INT16 : size = 2; break;
|
case C.TYPE_INT16 : size = 2; break;
|
||||||
case C.TYPE_INT32 : size = 4; break;
|
case C.TYPE_INT32 : size = 4; break;
|
||||||
default :break;
|
default :break;
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
return size;
|
||||||
|
};
|
||||||
|
|
||||||
var RWStream = function() {
|
var RWStream = function() {
|
||||||
this.endian = C.BIG_ENDIAN;
|
this.endian = C.BIG_ENDIAN;
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
this.defaultBufferSize = 512; //512 bytes
|
this.defaultBufferSize = 512; //512 bytes
|
||||||
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);
|
||||||
|
|
||||||
WriteStream.prototype.increment = function(add) {
|
WriteStream.prototype.increment = function(add) {
|
||||||
this.offset += add;
|
this.offset += 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) {
|
||||||
// we need more size, copying old one to new buffer
|
// we need more size, copying old one to new buffer
|
||||||
var oldLength = this.rawBuffer.length,
|
var oldLength = this.rawBuffer.length,
|
||||||
newBuffer = new Buffer(oldLength + length + (oldLength / 2));
|
newBuffer = new Buffer(oldLength + length + (oldLength / 2));
|
||||||
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.writeRawBuffer = function(source, start, length) {
|
WriteStream.prototype.writeRawBuffer = function(source, start, length) {
|
||||||
if (!source) return;
|
if (!source) return;
|
||||||
this.checkSize(length);
|
this.checkSize(length);
|
||||||
source.copy(this.rawBuffer, this.offset, start, length);
|
source.copy(this.rawBuffer, this.offset, start, length);
|
||||||
this.increment(length);
|
this.increment(length);
|
||||||
}
|
};
|
||||||
|
|
||||||
WriteStream.prototype.write = function(type, value) {
|
WriteStream.prototype.write = function(type, value) {
|
||||||
if (isString(type)) {
|
if (isString(type)) {
|
||||||
this.writeString(value, type);
|
this.writeString(value, type);
|
||||||
} 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),
|
||||||
this.rawBuffer.write(string, this.offset, length, encoding);
|
length = Buffer.byteLength(string, encoding);
|
||||||
this.increment(length);
|
this.rawBuffer.write(string, this.offset, length, encoding);
|
||||||
}
|
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);
|
||||||
this.rawBuffer = buffer;
|
this.rawBuffer = buffer;
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(ReadStream, RWStream);
|
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);
|
||||||
//if (this.offset + length > this.rawBuffer.length) throw ("out of bound " + this.offset + "," + length + "," + this.rawBuffer.length);
|
//if (this.offset + length > this.rawBuffer.length) throw ("out of bound " + this.offset + "," + length + "," + this.rawBuffer.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;
|
||||||
if (isString(type)) {
|
if (isString(type)) {
|
||||||
value = this.readString(length, type);
|
value = this.readString(length, type);
|
||||||
} else {
|
} else {
|
||||||
value = this.readFromBuffer(type, calcLength(type));
|
value = this.readFromBuffer(type, calcLength(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
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,3 +0,0 @@
|
|||||||
Meteor.methods({
|
|
||||||
|
|
||||||
});
|
|
||||||
160
Packages/worklist/both/schema.js
Normal file
160
Packages/worklist/both/schema.js
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
|
|
||||||
|
export const DICOMWebRequestOptions = new SimpleSchema({
|
||||||
|
auth: {
|
||||||
|
type: String,
|
||||||
|
label: 'Username:Password Authentication String',
|
||||||
|
},
|
||||||
|
logRequests: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
label: 'Log Requests?',
|
||||||
|
},
|
||||||
|
logResponses: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: false,
|
||||||
|
label: 'Log Responses?',
|
||||||
|
},
|
||||||
|
logTiming: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
label: 'Log Timing?',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DICOMWebServer = new SimpleSchema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
label: 'Name',
|
||||||
|
max: 100
|
||||||
|
},
|
||||||
|
wadoUriRoot: {
|
||||||
|
type: String,
|
||||||
|
label: 'WADO URI Root',
|
||||||
|
max: 1000
|
||||||
|
},
|
||||||
|
qidoRoot: {
|
||||||
|
type: String,
|
||||||
|
label: 'QIDO Root',
|
||||||
|
max: 1000
|
||||||
|
},
|
||||||
|
// TODO: Remove this
|
||||||
|
wadoUriRootNOTE: {
|
||||||
|
type: String,
|
||||||
|
label: 'WADO URI Root Note',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
wadoRoot: {
|
||||||
|
type: String,
|
||||||
|
label: 'WADO Root',
|
||||||
|
max: 1000
|
||||||
|
},
|
||||||
|
qidoSupportsIncludeField: {
|
||||||
|
type: Boolean,
|
||||||
|
label: 'QIDO Supports Include Field?',
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
imageRendering: {
|
||||||
|
type: String,
|
||||||
|
label: 'Image Rendering',
|
||||||
|
defaultValue: 'wadouri'
|
||||||
|
},
|
||||||
|
requestOptions: {
|
||||||
|
type: DICOMWebRequestOptions,
|
||||||
|
label: 'Request Options'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DIMSEPeer = new SimpleSchema({
|
||||||
|
host: {
|
||||||
|
type: String,
|
||||||
|
label: 'Host URL',
|
||||||
|
},
|
||||||
|
port: {
|
||||||
|
type: Number,
|
||||||
|
label: 'Port',
|
||||||
|
min: 1,
|
||||||
|
defaultValue: 11112,
|
||||||
|
max: 65535
|
||||||
|
},
|
||||||
|
aeTitle: {
|
||||||
|
type: String,
|
||||||
|
label: 'Application Entity (AE) Title',
|
||||||
|
},
|
||||||
|
default: {
|
||||||
|
type: Boolean,
|
||||||
|
label: 'Default?',
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
type: Boolean,
|
||||||
|
label: 'Server?',
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
supportsInstanceRetrievalByStudyUid: {
|
||||||
|
type: Boolean,
|
||||||
|
label: 'Supports instance retrieval by StudyUid?',
|
||||||
|
defaultValue: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DIMSEServer = new SimpleSchema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
label: 'Name',
|
||||||
|
max: 100
|
||||||
|
},
|
||||||
|
peers: {
|
||||||
|
type: [ DIMSEPeer ],
|
||||||
|
label: 'DIMSE Peers',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const UISettings = new SimpleSchema({
|
||||||
|
studyListFunctionsEnabled: {
|
||||||
|
type: Boolean,
|
||||||
|
label: 'Study List Functions Enabled?',
|
||||||
|
defaultValue: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PublicServerConfig = new SimpleSchema({
|
||||||
|
verifyEmail: {
|
||||||
|
type: Boolean,
|
||||||
|
label: 'Verify Email',
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
ui: {
|
||||||
|
type: UISettings,
|
||||||
|
label: 'UI Settings'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const Servers = new SimpleSchema({
|
||||||
|
dicomWeb: {
|
||||||
|
type: [ DICOMWebServer ],
|
||||||
|
label: 'DICOMWeb Servers',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
dimse: {
|
||||||
|
type: [ DIMSEServer ],
|
||||||
|
label: 'DIMSE Servers',
|
||||||
|
optional: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ServerConfiguration = new SimpleSchema({
|
||||||
|
servers: {
|
||||||
|
type: Servers,
|
||||||
|
label: 'Servers'
|
||||||
|
},
|
||||||
|
defaultServiceType: {
|
||||||
|
type: String,
|
||||||
|
label: 'Default Service Type',
|
||||||
|
defaultValue: 'dicomWeb'
|
||||||
|
},
|
||||||
|
public: {
|
||||||
|
type: PublicServerConfig,
|
||||||
|
label: 'Public Server Configuration',
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -5,7 +5,7 @@ Package.describe({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function (api) {
|
||||||
api.versionsFrom('1.3.5.1');
|
api.versionsFrom('1.4');
|
||||||
|
|
||||||
api.use('ecmascript');
|
api.use('ecmascript');
|
||||||
api.use('standard-app-packages');
|
api.use('standard-app-packages');
|
||||||
@ -15,6 +15,7 @@ Package.onUse(function (api) {
|
|||||||
api.use('practicalmeteor:loglevel');
|
api.use('practicalmeteor:loglevel');
|
||||||
api.use('rwatts:uuid');
|
api.use('rwatts:uuid');
|
||||||
api.use('silentcicero:jszip');
|
api.use('silentcicero:jszip');
|
||||||
|
api.use('aldeed:simple-schema');
|
||||||
|
|
||||||
// Note: MomentJS appears to be required for Bootstrap3 Datepicker, but not a dependency for some reason
|
// Note: MomentJS appears to be required for Bootstrap3 Datepicker, but not a dependency for some reason
|
||||||
api.use('momentjs:moment');
|
api.use('momentjs:moment');
|
||||||
@ -37,6 +38,9 @@ Package.onUse(function (api) {
|
|||||||
// console for debugging purposes
|
// console for debugging purposes
|
||||||
api.addFiles('log.js');
|
api.addFiles('log.js');
|
||||||
|
|
||||||
|
api.addFiles('both/collections.js', [ 'client', 'server' ]);
|
||||||
|
api.addFiles('both/schema.js', [ 'client', 'server' ]);
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
api.addFiles('client/components/worklist.html', 'client');
|
api.addFiles('client/components/worklist.html', 'client');
|
||||||
api.addFiles('client/components/worklist.js', 'client');
|
api.addFiles('client/components/worklist.js', 'client');
|
||||||
@ -78,6 +82,7 @@ Package.onUse(function (api) {
|
|||||||
|
|
||||||
// Server-side functions
|
// Server-side functions
|
||||||
api.addFiles('server/collections.js', 'server');
|
api.addFiles('server/collections.js', 'server');
|
||||||
|
api.addFiles('server/validateServerConfiguration.js', 'server');
|
||||||
api.addFiles('server/lib/namespace.js', 'server');
|
api.addFiles('server/lib/namespace.js', 'server');
|
||||||
api.addFiles('server/lib/encodeQueryData.js', 'server');
|
api.addFiles('server/lib/encodeQueryData.js', 'server');
|
||||||
api.addFiles('server/methods/getStudyMetadata.js', 'server');
|
api.addFiles('server/methods/getStudyMetadata.js', 'server');
|
||||||
@ -99,16 +104,12 @@ Package.onUse(function (api) {
|
|||||||
api.addFiles('server/services/remote/studies.js', 'server');
|
api.addFiles('server/services/remote/studies.js', 'server');
|
||||||
api.addFiles('server/services/remote/retrieveMetadata.js', 'server');
|
api.addFiles('server/services/remote/retrieveMetadata.js', 'server');
|
||||||
|
|
||||||
api.addFiles('both/collections.js', [ 'client', 'server' ]);
|
|
||||||
|
|
||||||
api.export('Services', 'server');
|
api.export('Services', 'server');
|
||||||
|
|
||||||
// Export Worklist helper functions for usage in Routes
|
// Export Worklist helper functions for usage in Routes
|
||||||
api.export('getTimepointName', 'client');
|
|
||||||
api.export('getStudyMetadata', 'client');
|
api.export('getStudyMetadata', 'client');
|
||||||
api.export('getStudiesMetadata', 'client');
|
api.export('getStudiesMetadata', 'client');
|
||||||
api.export('openNewTab', 'client');
|
api.export('openNewTab', 'client');
|
||||||
api.export('setWorklistSubscriptions', 'client');
|
|
||||||
api.export('switchToTab', 'client');
|
api.export('switchToTab', 'client');
|
||||||
api.export('progressDialog', 'client');
|
api.export('progressDialog', 'client');
|
||||||
api.export('Worklist');
|
api.export('Worklist');
|
||||||
|
|||||||
12
Packages/worklist/server/validateServerConfiguration.js
Normal file
12
Packages/worklist/server/validateServerConfiguration.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
import { check } from 'meteor/check';
|
||||||
|
import { ServerConfiguration } from '../both/schema.js';
|
||||||
|
|
||||||
|
Meteor.startup(() => {
|
||||||
|
console.log('------ Testing Meteor Settings ------');
|
||||||
|
let config = ServerConfiguration.clean(Meteor.settings);
|
||||||
|
console.log(JSON.stringify(config, null, 2));
|
||||||
|
|
||||||
|
Meteor.settings = config;
|
||||||
|
check(config, ServerConfiguration);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user