All files / platform/app/src/routes/Local filesToStudies.js

9.09% Statements 1/11
100% Branches 0/0
0% Functions 0/2
9.09% Lines 1/11

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      34x                                      
import FileLoaderService from './fileLoaderService';
import { DicomMetadataStore } from '@ohif/core';
 
const processFile = async file => {
  try {
    const fileLoaderService = new FileLoaderService(file);
    const imageId = fileLoaderService.addFile(file);
    const image = await fileLoaderService.loadFile(file, imageId);
    const dicomJSONDataset = await fileLoaderService.getDataset(image, imageId);
 
    DicomMetadataStore.addInstance(dicomJSONDataset);
  } catch (error) {
    console.log(error.name, ':Error when trying to load and process local files:', error.message);
  }
};
 
export default async function filesToStudies(files) {
  const processFilesPromises = files.map(processFile);
  await Promise.all(processFilesPromises);
 
  return DicomMetadataStore.getStudyInstanceUIDs();
}