Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 10611x 116564x 2354070x 2354070x 2354070x 2354070x 2354070x 2354070x 2354070x 91147x 2262923x 2262923x 29108x 105953x 105953x 105953x 29108x 29108x 2233815x 10647x 10647x 10647x 2223168x 11389x 2223168x 2518203x 2223168x | /**
* Delivers metadata from a standard DICOMweb Metadata instance to a listener
*/
import { dictionaryLookup, mapTagInfo } from '../Tags';
export class MetaDataIterator {
public metadata;
constructor(metadata) {
this.metadata = metadata;
}
public syncIterator(listener, object = this.metadata) {
for (const [key, value] of Object.entries<MetadataValue>(object)) {
Iif (key === '_vrMap' || value === undefined) {
continue;
}
Iif (value === null) {
listener.addTag(key, { length: 0 });
listener.pop();
continue;
}
const vr = value.vr;
const tagData = mapTagInfo.get(key);
const dictEntry = !tagData ? dictionaryLookup(key) : undefined;
const hasBulk =
!value.Value &&
((value as MetadataValue).BulkDataURI ??
(value as MetadataValue).InlineBinary);
if (!value.Value && !hasBulk) {
continue;
}
listener.addTag(key, {
vr,
name: tagData?.name || dictEntry?.name,
vm: tagData?.vm ?? dictEntry?.vm,
});
if (vr === 'SQ') {
for (const v of value.Value) {
listener.startObject();
this.syncIterator(listener, v);
listener.pop();
}
listener.pop();
continue;
}
if (hasBulk) {
listener.value({
BulkDataURI: (value as MetadataValue).BulkDataURI,
InlineBinary: (value as MetadataValue).InlineBinary,
});
listener.pop();
continue;
}
if (
value.vr === 'CS' &&
value.Value.length === 1 &&
String(value.Value[0]).indexOf('\\') !== -1
) {
// Fix static dicomweb CS values not split
value.Value = String(value.Value[0]).split('\\');
}
for (const v of value.Value) {
listener.value(v);
}
listener.pop();
}
}
}
export type MetadataValue = {
Value?: unknown[];
vr: string;
BulkDataURI?: string;
InlineBinary?: string;
};
|