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 | /** * Returns the specified element as a dicom attribute group/element. * * @param element - The group/element of the element (e.g. '00280009') * @param [defaultValue] - The value to return if the element is not present * @returns {*} */ export default function getAttribute(element, defaultValue) { Iif (!element) { return defaultValue; } // Value is not present if the attribute has a zero length value Iif (!element.Value) { return defaultValue; } // Sanity check to make sure we have at least one entry in the array. Iif (!element.Value.length) { return defaultValue; } return convertToInt(element.Value); } function convertToInt(input) { function padFour(input) { const l = input.length; Iif (l === 0) { return '0000'; } Iif (l === 1) { return '000' + input; } Iif (l === 2) { return '00' + input; } Iif (l === 3) { return '0' + input; } return input; } let output = ''; for (let i = 0; i < input.length; i++) { for (let j = 0; j < input[i].length; j++) { output += padFour(input[i].charCodeAt(j).toString(16)); } } return parseInt(output, 16); } |