All files / extensions/default/src/hangingprotocols/utils isNewestOfModality.ts

33.33% Statements 2/6
0% Branches 0/5
0% Functions 0/3
40% Lines 2/5

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    248x   248x                              
import { utils } from '@ohif/core';
 
const { getLatestInstanceDateTimeSortKey } = utils;
 
const sortKey = displaySet => getLatestInstanceDateTimeSortKey(displaySet.instance ?? displaySet);
 
/**
 * True when no other display set of the study with the same Modality is newer,
 * by the date/time of the instance that each display set shows. A protocol
 * gives this a weight to put the newest display set first, because display
 * sets with the same score otherwise sort by SeriesNumber.
 */
export default function isNewestOfModality(displaySet, options): boolean {
  const key = sortKey(displaySet);
  return !options?.displaySets?.some(
    other =>
      other !== displaySet && other.Modality === displaySet.Modality && sortKey(other) > key
  );
}