Fixing Hardcoded Data to use Tag IDs instead of non-standard-conforming attribute names + Preparing Hanging Protocols for Demoing

This commit is contained in:
Emanuel F. Oliveira 2017-02-14 10:55:14 -02:00 committed by Eloízio Salgado
parent d8e5609089
commit e10453b919
2 changed files with 56 additions and 39 deletions

View File

@ -11,20 +11,21 @@ HP.displaySettings = {
} }
}; };
// @TODO Fix abstractPriorValue comparison
HP.studyAttributes = [{ HP.studyAttributes = [{
id: 'patientId', id: 'x00100020',
text: '(x00100020) Patient ID' text: '(x00100020) Patient ID'
}, { }, {
id: 'studyInstanceUid', id: 'x0020000d',
text: '(x0020000d) Study Instance UID' text: '(x0020000d) Study Instance UID'
}, { }, {
id: 'studyDate', id: 'x00080020',
text: '(x00080020) Study Date' text: '(x00080020) Study Date'
}, { }, {
id: 'studyTime', id: 'x00080030',
text: '(x00080030) Study Time' text: '(x00080030) Study Time'
}, { }, {
id: 'studyDescription', id: 'x00081030',
text: '(x00081030) Study Description' text: '(x00081030) Study Description'
}, { }, {
id: 'abstractPriorValue', id: 'abstractPriorValue',
@ -32,19 +33,19 @@ HP.studyAttributes = [{
}]; }];
HP.protocolAttributes = [{ HP.protocolAttributes = [{
id: 'patientId', id: 'x00100020',
text: '(x00100020) Patient ID' text: '(x00100020) Patient ID'
}, { }, {
id: 'studyInstanceUid', id: 'x0020000d',
text: '(x0020000d) Study Instance UID' text: '(x0020000d) Study Instance UID'
}, { }, {
id: 'studyDate', id: 'x00080020',
text: '(x00080020) Study Date' text: '(x00080020) Study Date'
}, { }, {
id: 'studyTime', id: 'x00080030',
text: '(x00080030) Study Time' text: '(x00080030) Study Time'
}, { }, {
id: 'studyDescription', id: 'x00081030',
text: '(x00081030) Study Description' text: '(x00081030) Study Description'
}, { }, {
id: 'anatomicRegion', id: 'anatomicRegion',
@ -52,16 +53,16 @@ HP.protocolAttributes = [{
}]; }];
HP.seriesAttributes = [{ HP.seriesAttributes = [{
id: 'seriesInstanceUid', id: 'x0020000e',
text: '(x0020000e) Series Instance UID' text: '(x0020000e) Series Instance UID'
}, { }, {
id: 'modality', id: 'x00080060',
text: '(x00080060) Modality' text: '(x00080060) Modality'
}, { }, {
id: 'seriesNumber', id: 'x00200011',
text: '(x00080060) Series Number' text: '(x00200011) Series Number'
}, { }, {
id: 'seriesDescription', id: 'x0008103e',
text: '(x0008103e) Series Description' text: '(x0008103e) Series Description'
}, { }, {
id: 'numImages', id: 'numImages',
@ -69,33 +70,33 @@ HP.seriesAttributes = [{
}]; }];
HP.instanceAttributes = [{ HP.instanceAttributes = [{
id: 'sopClassUid', id: 'x00080016',
text: 'SOP Class UID' text: '(x00080016) SOP Class UID'
}, { }, {
id: 'sopInstanceUid', id: 'x00080018',
text: 'SOP Instance UID' text: '(x00080018) SOP Instance UID'
}, { }, {
id: 'viewPosition', id: 'x00185101',
text: 'View Position' text: '(x00185101) View Position'
}, { }, {
id: 'instanceNumber', id: 'x00200013',
text: 'Instance Number' text: '(x00200013) Instance Number'
}, { }, {
id: 'imageType', id: 'x00080008',
text: 'Image Type' text: '(x00080008) Image Type'
}, { }, {
id: 'frameTime', id: 'x00181063',
text: 'Frame Time' text: '(x00181063) Frame Time'
}, { }, {
id: 'laterality', id: 'x00200060',
text: 'Laterality' text: '(x00200060) Laterality'
}, { }, {
id: 'index', id: 'x00541330',
text: 'Image Index' text: '(x00541330) Image Index'
}, { }, {
id: 'photometricInterpretation', id: 'x00280004',
text: 'Photometric Interpretation' text: '(x00280004) Photometric Interpretation'
}, { }, {
id: 'sliceThickness', id: 'x00180050',
text: 'Slice Thickness' text: '(x00180050) Slice Thickness'
}]; }];

View File

@ -9,7 +9,7 @@ import 'meteor/ohif:viewerbase';
*/ */
const { OHIFError } = OHIF.viewerbase; const { OHIFError } = OHIF.viewerbase;
const { StudyMetadata, StudySummary } = OHIF.viewerbase.metadata; const { StudyMetadata, SeriesMetadata, InstanceMetadata, StudySummary } = OHIF.viewerbase.metadata;
// Define a global variable that will be used to refer to the Protocol Engine // Define a global variable that will be used to refer to the Protocol Engine
@ -98,6 +98,11 @@ Meteor.startup(function() {
* @return {Object} Matching Object with score and details (which rule passed or failed) * @return {Object} Matching Object with score and details (which rule passed or failed)
*/ */
HP.match = function(metadataInstance, rules) { HP.match = function(metadataInstance, rules) {
if (!(metadataInstance instanceof StudyMetadata || metadataInstance instanceof SeriesMetadata || metadataInstance instanceof InstanceMetadata)) {
throw new OHIFError('HP::match metadataInstance must be an instance of StudyMetadata, SeriesMetadata or InstanceMetadata');
}
const options = { const options = {
format: 'grouped' format: 'grouped'
}; };
@ -109,17 +114,27 @@ HP.match = function(metadataInstance, rules) {
let requiredFailed = false; let requiredFailed = false;
let score = 0; let score = 0;
let instance;
if (metadataInstance instanceof StudyMetadata) {
instance = metadataInstance.getFirstInstance();
} else if (metadataInstance instanceof SeriesMetadata) {
instance = metadataInstance.getInstanceByIndex(0);
} else {
instance = metadataInstance;
}
rules.forEach(rule => { rules.forEach(rule => {
const attribute = rule.attribute; const attribute = rule.attribute;
let customAttributeExists = metadataInstance.customAttributeExists(attribute);
// If the metadataInstance we are testing (e.g. study, series, or instance MetadataInstance) do // If the metadataInstance we are testing (e.g. study, series, or instance MetadataInstance) do
// not contain the attribute specified in the rule, check whether or not they have been // not contain the attribute specified in the rule, check whether or not they have been
// defined in the CustomAttributeRetrievalCallbacks Object. // defined in the CustomAttributeRetrievalCallbacks Object.
if (!metadataInstance.customAttributeExists(attribute) && if (!customAttributeExists && HP.CustomAttributeRetrievalCallbacks.hasOwnProperty(attribute)) {
HP.CustomAttributeRetrievalCallbacks.hasOwnProperty(attribute)) {
const customAttribute = HP.CustomAttributeRetrievalCallbacks[attribute]; const customAttribute = HP.CustomAttributeRetrievalCallbacks[attribute];
metadataInstance.setCustomAttribute(attribute, customAttribute.callback(metadataInstance)); metadataInstance.setCustomAttribute(attribute, customAttribute.callback(metadataInstance));
customAttributeExists = true;
} }
// Format the constraint as required by Validate.js // Format the constraint as required by Validate.js
@ -129,8 +144,9 @@ HP.match = function(metadataInstance, rules) {
// Create a single attribute object to be validated, since metadataInstance is an // Create a single attribute object to be validated, since metadataInstance is an
// instance of Metadata (StudyMetadata, SeriesMetadata or InstanceMetadata) // instance of Metadata (StudyMetadata, SeriesMetadata or InstanceMetadata)
const attributeValue = customAttributeExists ? metadataInstance.getCustomAttribute(attribute) : instance.getRawValue(attribute);
const attributeMap = { const attributeMap = {
[attribute]: metadataInstance.getCustomAttribute(attribute) [attribute]: attributeValue + ''
}; };
// Use Validate.js to evaluate the constraints on the specified metadataInstance // Use Validate.js to evaluate the constraints on the specified metadataInstance