hanging protocols first commit
This commit is contained in:
parent
edc9ecf69c
commit
f7d03c5c11
17
Packages/hangingprotocols/package.js
Executable file
17
Packages/hangingprotocols/package.js
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
Package.describe({
|
||||||
|
name: "weiwei:hangingprotocols",
|
||||||
|
summary: "DICOM Haning Protocols",
|
||||||
|
version: '0.0.1'
|
||||||
|
});
|
||||||
|
|
||||||
|
Package.onUse(function (api) {
|
||||||
|
api.use("weiwei:dicomservices");
|
||||||
|
|
||||||
|
api.addFiles('server/namespace.js', 'server');
|
||||||
|
|
||||||
|
api.export("DICOMHP", 'server');
|
||||||
|
});
|
||||||
|
|
||||||
|
Package.onTest(function (api){
|
||||||
|
api.use(["weiwei:hangingprotocols"]);
|
||||||
|
});
|
||||||
20
Packages/hangingprotocols/server/imageset.js
Executable file
20
Packages/hangingprotocols/server/imageset.js
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
DICOMHP.imageSet = function(setNumber, category) {
|
||||||
|
this.setNumber = setNumber;
|
||||||
|
this.category = category;
|
||||||
|
};
|
||||||
|
|
||||||
|
DICOMHP.imageSet.prototype.setRelativeTime = function(time) {
|
||||||
|
this.relativeTime = time;
|
||||||
|
};
|
||||||
|
|
||||||
|
DICOMHP.imageSet.prototype.setTimeUnits = function(units) {
|
||||||
|
this.timeUnits = units;
|
||||||
|
};
|
||||||
|
|
||||||
|
DICOMHP.imageSet.prototype.setPriorValue = function(priorValue) {
|
||||||
|
this.priorValue = priorValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
DICOMHP.imageSet.prototype.retrieve = function(studyInstanceId) {
|
||||||
|
|
||||||
|
};
|
||||||
46
Packages/hangingprotocols/server/match.js
Executable file
46
Packages/hangingprotocols/server/match.js
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
DICOMHP.match = function(studyInstanceUID) {
|
||||||
|
var metadata = DICOMService.retrieveMetadata(studyInstanceUID);
|
||||||
|
if (!metadata) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var params = {"00080016" : "1.2.840.10008.5.1.4.38.1"}, modalities = metadata["00080061"].Value[0],
|
||||||
|
modalityMatch = null;
|
||||||
|
|
||||||
|
if (modalities) {
|
||||||
|
modalityMatch = [];
|
||||||
|
modalities.split('\\').forEach(function(modality){
|
||||||
|
if (modality && modality != 'SC') {
|
||||||
|
modalityMatch.push(modality);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var firstInstance = DICOMService.retrieveMetadata(studyInstanceUID, null, null, {limit : 1}),
|
||||||
|
lateralityMatch = null;
|
||||||
|
|
||||||
|
if (firstInstance.length > 0) {
|
||||||
|
lateralityMatch = firstInstance[0]["00200060"].Value[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// since orthanc doesn't support sequence matching
|
||||||
|
var allProtocols = DICOMService.searchForInstances(null, null, params);
|
||||||
|
if (allProtocols.length < 1) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var matchedPrtocols = [];
|
||||||
|
allProtocols.forEach(function(protocol) {
|
||||||
|
var definitionSequence = protocol["0072000C"].Value;
|
||||||
|
definitionSequence.forEach(function(definition){
|
||||||
|
var defModality = definition["00080060"].Value[0];
|
||||||
|
if (defModality && modalityMatch && modalityMatch.indexOf(defModality) != -1) {
|
||||||
|
matchedPrtocols.push(protocol);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var defLaterality = definition["00200060"].Value[0];
|
||||||
|
if (defLaterality && (defLaterality == lateralityMatch)) {
|
||||||
|
matchedPrtocols.push(protocol);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return matchedPrtocols;
|
||||||
|
};
|
||||||
1
Packages/hangingprotocols/server/namespace.js
Executable file
1
Packages/hangingprotocols/server/namespace.js
Executable file
@ -0,0 +1 @@
|
|||||||
|
DICOMHP = {};
|
||||||
77
Packages/hangingprotocols/server/select.js
Executable file
77
Packages/hangingprotocols/server/select.js
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
DICOMHP.select = function(hpInstance) {
|
||||||
|
var imageSetsSequence = hpInstance["00720020"].Value;
|
||||||
|
if (!imageSetsSequence) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var matchedImageSets = [];
|
||||||
|
imageSetsSequence.forEach(function(imageSet) {
|
||||||
|
var selectorSequence = imageSet["00720022"].Value;
|
||||||
|
selectorSequence.forEach(function(selector){
|
||||||
|
var usageFlag = selector["00720024"].Value[0],
|
||||||
|
selectorAttribute = selector["00720026"].Value[0],
|
||||||
|
selectorAttributeVR = selector["00720050"].Value[0],
|
||||||
|
selectorAttributeValue = null;
|
||||||
|
|
||||||
|
if (selectorAttributeVR == 'SQ') {
|
||||||
|
return;
|
||||||
|
} else if (selectorAttributeVR == 'AT') {
|
||||||
|
selectorAttributeValue = selector["00720060"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'CS') {
|
||||||
|
selectorAttributeValue = selector["00720062"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'IS') {
|
||||||
|
selectorAttributeValue = selector["00720064"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'LO') {
|
||||||
|
selectorAttributeValue = selector["00720066"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'LT') {
|
||||||
|
selectorAttributeValue = selector["00720068"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'PN') {
|
||||||
|
selectorAttributeValue = selector["0072006A"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'SH') {
|
||||||
|
selectorAttributeValue = selector["0072006C"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'ST') {
|
||||||
|
selectorAttributeValue = selector["0072006E"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'UT') {
|
||||||
|
selectorAttributeValue = selector["00720070"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'DS') {
|
||||||
|
selectorAttributeValue = selector["00720072"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'FD') {
|
||||||
|
selectorAttributeValue = selector["00720074"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'FL') {
|
||||||
|
selectorAttributeValue = selector["00720076"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'UL') {
|
||||||
|
selectorAttributeValue = selector["00720078"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'US') {
|
||||||
|
selectorAttributeValue = selector["0072007A"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'SL') {
|
||||||
|
selectorAttributeValue = selector["0072007C"].Value[0];
|
||||||
|
} else if (selectorAttributeVR == 'SS') {
|
||||||
|
selectorAttributeValue = selector["0072007E"].Value[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectorAttributeValue !== null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var timeBasedImageSetsSequence = imageSet["00720030"].Value;
|
||||||
|
timeBasedImageSetsSequence.forEach(function(timeImageSet){
|
||||||
|
var setNumber = timeImageSet["00720032"].Value[0], selectorCategory = timeImageSet["00720034"].Value[0];
|
||||||
|
|
||||||
|
var mImageSet = new DICOMHP.imageSet(setNumber, selectorCategory);
|
||||||
|
if (selectorCategory == 'RELATIVE_TIME') {
|
||||||
|
var relativeTime = timeImageSet["00720038"].Value[0], timeUnits = timeImageSet["0072003A"].Value[0];
|
||||||
|
|
||||||
|
mImageSet.setRelativeTime(relativeTime);
|
||||||
|
mImageSet.setTimeUnits(timeUnits);
|
||||||
|
} else if (selectorCategory == 'ABSTRACT_PRIOR') {
|
||||||
|
var priorValue = timeImageSet["0072003C"].Value[0];
|
||||||
|
|
||||||
|
mImageSet.setPriorValue(priorValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
matchedImageSets.push(mImageSet);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return matchedImageSets;
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user