All files / platform/core/src/DICOMWeb getString.js

85.71% Statements 6/7
66.66% Branches 2/3
100% Functions 1/1
85.71% Lines 6/7

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                2760x 10x     2750x 252x     2498x         2498x    
/**
 * Returns the specified element as a string.  Multi-valued elements will be separated by a backslash
 *
 * @param element - The group/element of the element (e.g. '00200013')
 * @param [defaultValue] - The value to return if the element is not present
 * @returns {*}
 */
export default function getString(element, defaultValue) {
  if (!element) {
    return defaultValue;
  }
  // Value is not present if the attribute has a zero length value
  if (!element.Value) {
    return defaultValue;
  }
  // Sanity check to make sure we have at least one entry in the array.
  Iif (!element.Value.length) {
    return defaultValue;
  }
  // Join the array together separated by backslash
  // NOTE: Orthanc does not correctly split values into an array so the join is a no-op
  return element.Value.join('\\');
}