2022-12-29 10:13:06 -05:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {*} servicesManager
|
|
|
|
|
*/
|
2024-05-08 12:12:49 -04:00
|
|
|
async function createReportAsync({
|
|
|
|
|
servicesManager,
|
|
|
|
|
getReport,
|
2026-03-17 08:59:47 -04:00
|
|
|
reportType = 'Measurements',
|
|
|
|
|
successMessage,
|
2024-05-08 12:12:49 -04:00
|
|
|
}: withAppTypes) {
|
2023-09-01 16:19:39 -04:00
|
|
|
const { displaySetService, uiNotificationService, uiDialogService } = servicesManager.services;
|
2022-12-29 10:13:06 -05:00
|
|
|
|
|
|
|
|
try {
|
2023-09-22 10:23:44 -04:00
|
|
|
const naturalizedReport = await getReport();
|
2022-12-29 10:13:06 -05:00
|
|
|
|
2025-02-28 15:17:55 -05:00
|
|
|
if (!naturalizedReport) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-10-17 15:49:53 +02:00
|
|
|
|
2026-03-17 08:59:47 -04:00
|
|
|
// addInstances is called by the store command (storeMeasurements/storeSegmentation),
|
|
|
|
|
// so the display set should already exist at this point.
|
2023-09-22 10:23:44 -04:00
|
|
|
const displaySet = displaySetService.getMostRecentDisplaySet();
|
|
|
|
|
|
|
|
|
|
const displaySetInstanceUID = displaySet.displaySetInstanceUID;
|
2022-12-29 10:13:06 -05:00
|
|
|
|
2023-02-10 16:46:09 -05:00
|
|
|
uiNotificationService.show({
|
2022-12-29 10:13:06 -05:00
|
|
|
title: 'Create Report',
|
2026-03-17 08:59:47 -04:00
|
|
|
message: successMessage ?? `${reportType} saved successfully`,
|
2022-12-29 10:13:06 -05:00
|
|
|
type: 'success',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return [displaySetInstanceUID];
|
|
|
|
|
} catch (error) {
|
2023-02-10 16:46:09 -05:00
|
|
|
uiNotificationService.show({
|
2022-12-29 10:13:06 -05:00
|
|
|
title: 'Create Report',
|
2023-09-22 10:23:44 -04:00
|
|
|
message: error.message || `Failed to store ${reportType}`,
|
2022-12-29 10:13:06 -05:00
|
|
|
type: 'error',
|
|
|
|
|
});
|
2024-05-06 14:55:32 -04:00
|
|
|
throw new Error(`Failed to store ${reportType}. Error: ${error.message || 'Unknown error'}`);
|
2022-12-29 10:13:06 -05:00
|
|
|
} finally {
|
2025-02-28 15:17:55 -05:00
|
|
|
uiDialogService.hide('loading-dialog');
|
2022-12-29 10:13:06 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default createReportAsync;
|