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

55.55% Statements 5/9
25% Branches 1/4
100% Functions 1/1
55.55% Lines 5/9

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                345x       345x       345x       345x 345x          
/**
 * Returns the Alphabetic version of a PN
 *
 * @param element - The group/element of the element (e.g. '00200013')
 * @param [defaultValue] - The default value to return if the element is not found
 * @returns {*}
 */
export default function getName(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 the Alphabetic component group
  if (element.Value[0].Alphabetic) {
    return element.Value[0].Alphabetic;
  }
  // Orthanc does not return PN properly so this is a temporary workaround
  return element.Value[0];
}