All files / extensions/default/src/DicomWebDataSource/wado retrieveMetadataLoaderSync.js

0% Statements 0/16
0% Branches 0/3
0% Functions 0/4
0% Lines 0/16

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 54 55 56 57 58 59                                                                                                                     
// import { api } from 'dicomweb-client';
// import DICOMWeb from '../../../DICOMWeb/';
import RetrieveMetadataLoader from './retrieveMetadataLoader';
 
/**
 * Class for sync load of study metadata.
 * It inherits from RetrieveMetadataLoader
 *
 * A list of loaders (getLoaders) can be created so, it will be applied a fallback load strategy.
 * I.e Retrieve metadata using all loaders possibilities.
 */
export default class RetrieveMetadataLoaderSync extends RetrieveMetadataLoader {
  getOptions() {
    const { studyInstanceUID, filters } = this;
 
    const options = {
      studyInstanceUID,
    };
 
    const { seriesInstanceUID } = filters;
    Iif (seriesInstanceUID) {
      options['seriesInstanceUID'] = seriesInstanceUID;
    }
 
    return options;
  }
 
  /**
   * @returns {Array} Array of loaders. To be consumed as queue
   */
  *getLoaders() {
    const loaders = [];
    const { studyInstanceUID, filters: { seriesInstanceUID } = {}, client } = this;
 
    Iif (seriesInstanceUID) {
      loaders.push(
        client.retrieveSeriesMetadata.bind(client, {
          studyInstanceUID,
          seriesInstanceUID,
        })
      );
    }
 
    loaders.push(client.retrieveStudyMetadata.bind(client, { studyInstanceUID }));
 
    yield* loaders;
  }
 
  async load(preLoadData) {
    const loaders = this.getLoaders();
    const result = this.runLoaders(loaders);
    return result;
  }
 
  async posLoad(loadData) {
    return loadData;
  }
}