Adapting OHIFStudySummary to translate OHIF Viewers specific property names to standard DICOM keywords.

This commit is contained in:
Emanuel F. Oliveira 2017-02-10 18:37:32 -02:00 committed by Eloízio Salgado
parent 4df18233c4
commit 72bfbf69c7
3 changed files with 43 additions and 6 deletions

View File

@ -1,12 +1,52 @@
import { OHIF } from 'meteor/ohif:core';
import 'meteor/ohif:viewerbase';
/**
* Constants
*/
const STRING = 'string';
const propertyReplacementMap = {
modalities: 'ModalitiesInStudy',
patientBirthdate: 'PatientBirthDate'
};
/**
* OHIF Viewers specialized version of StudySummary class
*/
export class OHIFStudySummary extends OHIF.viewerbase.metadata.StudySummary {
// @Override
addTags(tagMap) {
// @TODO: Map OHIF tag names to standard DICOM tag names
super.addTags(tagMap);
const _hasOwn = Object.prototype.hasOwnProperty;
const _tagMap = Object.create(null);
for (let property in tagMap) {
if (_hasOwn.call(tagMap, property)) {
let standardProperty = OHIFStudySummary.getStandardPropertyName(property);
if (standardProperty) {
_tagMap[standardProperty] = tagMap[property];
}
}
}
super.addTags(_tagMap);
}
/**
* Turns a non-standard, OHIF specific, DICOM property name into a standard one.
* @param {string} property A string representing a non-conforming keyword.
* @returns {string|undefined} Returns a standard-conforming property name.
*/
static getStandardPropertyName(property) {
let standardProperty;
if (typeof property === STRING && property.charAt(0) !== '_') {
if (property in propertyReplacementMap) {
standardProperty = propertyReplacementMap[propertyReplacementMap];
} else {
standardProperty = property.replace(/^sop/, 'SOP').replace(/Uid$/, 'UID').replace(/Id$/, 'ID');
standardProperty = standardProperty.charAt(0).toUpperCase() + standardProperty.substr(1);
}
}
return standardProperty;
}
}

View File

@ -40,9 +40,6 @@ const getStudyPriors = study => {
const summary = new OHIFStudySummary();
summary.addTags(study);
priorStudies.push(summary);
console.log('@StudyListStudies');
console.log(study);
console.log(study);
});
return priorStudies;

View File

@ -1,6 +1,6 @@
import { DICOMTagDescriptions } from '../../DICOMTagDescriptions';
const StudyInstanceUID = 'x0020000D';
const StudyInstanceUID = 'x0020000d';
export class StudySummary {