All files / extensions/cornerstone-dicom-sr/src/utils getLabelFromDCMJSImportedToolData.js

75% Statements 6/8
20% Branches 1/5
100% Functions 2/2
75% Lines 6/8

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    34x                     2x   2x 2x     2x 2x              
import { adaptersSR } from '@cornerstonejs/adapters';
 
const { CodeScheme: Cornerstone3DCodeScheme } = adaptersSR.Cornerstone3D;
 
/**
 * Extracts the label from the toolData imported from dcmjs. We need to do this
 * as dcmjs does not depeend on OHIF/the measurementService, it just produces data for cornestoneTools.
 * This optional data is available for the consumer to process if they wish to.
 * @param {object} toolData The tooldata relating to the
 *
 * @returns {string} The extracted label.
 */
export default function getLabelFromDCMJSImportedToolData(toolData) {
  const { findingSites = [], finding } = toolData;
 
  let freeTextLabel = findingSites.find(
    fs => fs.CodeValue === Cornerstone3DCodeScheme.codeValues.CORNERSTONEFREETEXT
  );
 
  if (freeTextLabel) {
    return freeTextLabel.CodeMeaning;
  }
 
  Iif (finding && finding.CodeValue === Cornerstone3DCodeScheme.codeValues.CORNERSTONEFREETEXT) {
    return finding.CodeMeaning;
  }
}