import { DicomMetadataStore } from '@ohif/core'; /** * * @param {*} servicesManager */ async function createReportAsync({ servicesManager, getReport, reportType = 'measurement', }: withAppTypes) { const { displaySetService, uiNotificationService, uiDialogService } = servicesManager.services; try { const naturalizedReport = await getReport(); if (!naturalizedReport) { return; } // The "Mode" route listens for DicomMetadataStore changes // When a new instance is added, it listens and // automatically calls makeDisplaySets DicomMetadataStore.addInstances([naturalizedReport], true); const displaySet = displaySetService.getMostRecentDisplaySet(); const displaySetInstanceUID = displaySet.displaySetInstanceUID; uiNotificationService.show({ title: 'Create Report', message: `${reportType} saved successfully`, type: 'success', }); return [displaySetInstanceUID]; } catch (error) { uiNotificationService.show({ title: 'Create Report', message: error.message || `Failed to store ${reportType}`, type: 'error', }); throw new Error(`Failed to store ${reportType}. Error: ${error.message || 'Unknown error'}`); } finally { uiDialogService.hide('loading-dialog'); } } export default createReportAsync;