ohif-viewer/extensions/default/src/Actions/createReportAsync.tsx
Bill Wallace 8af0362d12
fix(typescript): rename services to fix typescript (#3165)
* fix: Rename services to lower camel case, hp, measure

* fix: Rename DisplaySetService instances to displaySetService

* fix: Rename CornerstoneViewportService to lower camel case

* fix: Added lower case segmentationService rename

* rename other services (#3166)

* rename uiDialogService

* rename toolGroupService

* rename uiNotificationService

* rename viewportGridService

* rename syncGroupService

* rename CornerstoneCacheService

* Fix a syntax error in hotkeys

* Fix a couple of rename issues that were missed

---------

Co-authored-by: Alireza <ar.sedghi@gmail.com>
2023-02-10 16:46:09 -05:00

74 lines
1.8 KiB
TypeScript

import React from 'react';
import { DicomMetadataStore } from '@ohif/core';
/**
*
* @param {*} servicesManager
* @param {*} dataSource
* @param {*} measurements
* @param {*} options
* @returns {string[]} displaySetInstanceUIDs
*/
async function createReportAsync(
servicesManager,
commandsManager,
dataSource,
measurements,
options
) {
const {
displaySetService,
uiNotificationService,
uiDialogService,
} = servicesManager.services;
const loadingDialogId = uiDialogService.create({
showOverlay: true,
isDraggable: false,
centralize: true,
// TODO: Create a loading indicator component + zeplin design?
content: Loading,
});
try {
const naturalizedReport = await commandsManager.runCommand(
'storeMeasurements',
{
measurementData: measurements,
dataSource,
additionalFindingTypes: ['ArrowAnnotate'],
options,
},
'CORNERSTONE_STRUCTURED_REPORT'
);
// The "Mode" route listens for DicomMetadataStore changes
// When a new instance is added, it listens and
// automatically calls makeDisplaySets
DicomMetadataStore.addInstances([naturalizedReport], true);
const displaySetInstanceUID = displaySetService.getMostRecentDisplaySet();
uiNotificationService.show({
title: 'Create Report',
message: 'Measurements saved successfully',
type: 'success',
});
return [displaySetInstanceUID];
} catch (error) {
uiNotificationService.show({
title: 'Create Report',
message: error.message || 'Failed to store measurements',
type: 'error',
});
} finally {
uiDialogService.dismiss({ id: loadingDialogId });
}
}
function Loading() {
return <div className="text-primary-active">Loading...</div>;
}
export default createReportAsync;