2024-11-06 13:15:27 +01:00
|
|
|
import PROMPT_RESPONSES from '../utils/_shared/PROMPT_RESPONSES';
|
2022-12-29 16:13:06 +01:00
|
|
|
|
2025-11-21 19:07:26 +01:00
|
|
|
/**
|
|
|
|
|
* Creates and shows a report dialog prompt.
|
|
|
|
|
* The input for this is:
|
|
|
|
|
* - `title` shown in the dialog
|
|
|
|
|
* - `modality` being stored, used to query existing series
|
|
|
|
|
* - `minSeriesNumber` is the start of new series of this modality type.
|
|
|
|
|
* Will get set to 4000 if not determined by the modality
|
|
|
|
|
* - predecessorImageId is the image id that this series was currently loaded
|
|
|
|
|
* from. That allows defaulting the dialog to show the specified series instead
|
|
|
|
|
* of always creating a new series.
|
|
|
|
|
*
|
|
|
|
|
* The response is:
|
|
|
|
|
* - `value`, the default name of the object/series being created
|
|
|
|
|
* - `dataSourceName`, where to store the object to
|
|
|
|
|
* - `series`, is the series to store do, as referenced by a predecessorImageId value.
|
|
|
|
|
* - `priorSeriesNumber` is the previously lowest series number at least minSeriesNumber
|
|
|
|
|
* of all the seris of the given modality type.
|
|
|
|
|
*
|
|
|
|
|
* This should be provided to the DICOM encoder, which will get the predecessor
|
|
|
|
|
* sequence from the metaData provider so that the saved series will replace
|
|
|
|
|
* the existing instance in the same series.
|
|
|
|
|
* This will be falsy for a new series.
|
|
|
|
|
*/
|
2025-02-28 21:17:55 +01:00
|
|
|
export default function CreateReportDialogPrompt({
|
|
|
|
|
title = 'Create Report',
|
2025-11-21 19:07:26 +01:00
|
|
|
modality = 'SR',
|
|
|
|
|
minSeriesNumber = 0,
|
|
|
|
|
predecessorImageId,
|
2025-02-28 21:17:55 +01:00
|
|
|
extensionManager,
|
|
|
|
|
servicesManager,
|
2026-03-17 13:59:47 +01:00
|
|
|
enableDownload = false,
|
2025-02-28 21:17:55 +01:00
|
|
|
}): Promise<{
|
|
|
|
|
value: string;
|
|
|
|
|
dataSourceName: string;
|
2025-11-21 19:07:26 +01:00
|
|
|
priorSeriesNumber?: number;
|
2025-04-07 16:05:22 +02:00
|
|
|
series: string;
|
2025-02-28 21:17:55 +01:00
|
|
|
action: (typeof PROMPT_RESPONSES)[keyof typeof PROMPT_RESPONSES];
|
|
|
|
|
}> {
|
|
|
|
|
const { uiDialogService, customizationService } = servicesManager.services;
|
|
|
|
|
const dataSources = extensionManager.getDataSourcesForUI();
|
|
|
|
|
const ReportDialog = customizationService.getCustomization('ohif.createReportDialog');
|
2022-12-29 16:13:06 +01:00
|
|
|
|
2025-02-28 21:17:55 +01:00
|
|
|
const allowMultipleDataSources = window.config.allowMultiSelectExport;
|
2022-12-29 16:13:06 +01:00
|
|
|
|
2025-11-21 19:07:26 +01:00
|
|
|
minSeriesNumber ||=
|
|
|
|
|
(modality === 'SR' && 3000) ||
|
|
|
|
|
(modality === 'SEG' && 3100) ||
|
|
|
|
|
(modality === 'RTSTRUCT' && 3200) ||
|
|
|
|
|
4000;
|
|
|
|
|
|
|
|
|
|
return new Promise(function (resolve) {
|
2025-02-28 21:17:55 +01:00
|
|
|
uiDialogService.show({
|
|
|
|
|
id: 'report-dialog',
|
|
|
|
|
title,
|
|
|
|
|
content: ReportDialog,
|
|
|
|
|
contentProps: {
|
|
|
|
|
dataSources: allowMultipleDataSources ? dataSources : undefined,
|
2025-11-21 19:07:26 +01:00
|
|
|
predecessorImageId,
|
|
|
|
|
minSeriesNumber,
|
|
|
|
|
modality,
|
2026-03-17 13:59:47 +01:00
|
|
|
enableDownload,
|
2025-11-21 19:07:26 +01:00
|
|
|
onSave: async ({
|
|
|
|
|
reportName,
|
|
|
|
|
dataSource: selectedDataSource,
|
|
|
|
|
series,
|
|
|
|
|
priorSeriesNumber,
|
|
|
|
|
}) => {
|
2022-12-29 16:13:06 +01:00
|
|
|
resolve({
|
2025-02-28 21:17:55 +01:00
|
|
|
value: reportName,
|
|
|
|
|
dataSourceName: selectedDataSource,
|
2025-04-07 16:05:22 +02:00
|
|
|
series,
|
2025-11-21 19:07:26 +01:00
|
|
|
priorSeriesNumber,
|
2024-11-06 13:15:27 +01:00
|
|
|
action: PROMPT_RESPONSES.CREATE_REPORT,
|
2022-12-29 16:13:06 +01:00
|
|
|
});
|
2025-02-28 21:17:55 +01:00
|
|
|
},
|
|
|
|
|
onCancel: () => {
|
2022-12-29 16:13:06 +01:00
|
|
|
resolve({
|
2024-11-06 13:15:27 +01:00
|
|
|
action: PROMPT_RESPONSES.CANCEL,
|
2022-12-29 16:13:06 +01:00
|
|
|
value: undefined,
|
2025-04-07 16:05:22 +02:00
|
|
|
series: undefined,
|
2022-12-29 16:13:06 +01:00
|
|
|
dataSourceName: undefined,
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-03-20 14:22:45 +01:00
|
|
|
defaultValue: title,
|
2022-12-29 16:13:06 +01:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|