OHIF-135: providing all data required by cornerstoneWADOImageLoader to wadors instances

This commit is contained in:
Leonardo Campos committed 2017-03-15 15:48:35 -03:00
1 parent 3d99821117
commit 9ad0b670b3
7 files changed
+194 -106

No files matched your search

@@ -0,0 +1,48 @@
export class WadoRsMetaDataBuilder {
constructor() {
this.tags = {};
}
addTag(tag, value, multi) {
this.tags[tag] = {
tag,
value,
multi
};
return this;
}
toJSON() {
const json = {};
const keys = Object.keys(this.tags);
keys.forEach(key => {
if (!this.tags.hasOwnProperty(key)) {
return;
}
const tag = this.tags[key];
const multi = !!tag.multi;
let value = tag.value;
if ((value == null) || ((value.length === 1) && (value[0] == null))) {
return;
}
if ((typeof value === 'string') && multi) {
value = value.split('\\');
}
if (!_.isArray(value)) {
value = [value];
}
json[key] = {
Value: value
};
});
return json;
}
}