2020-06-25 18:13:31 +02:00
|
|
|
import SUPPORTED_TOOLS from './constants/supportedTools';
|
|
|
|
|
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
2020-08-05 14:56:02 +02:00
|
|
|
import getHandlesFromPoints from './utils/getHandlesFromPoints';
|
2020-06-25 18:13:31 +02:00
|
|
|
|
|
|
|
|
const Bidirectional = {
|
2020-08-05 14:56:02 +02:00
|
|
|
toAnnotation: (measurement, definition) => {},
|
2020-07-22 19:40:40 +02:00
|
|
|
toMeasurement: (
|
|
|
|
|
csToolsAnnotation,
|
|
|
|
|
DisplaySetService,
|
|
|
|
|
getValueTypeFromToolType
|
|
|
|
|
) => {
|
2020-06-25 18:13:31 +02:00
|
|
|
const { element, measurementData } = csToolsAnnotation;
|
|
|
|
|
const tool =
|
|
|
|
|
csToolsAnnotation.toolType ||
|
|
|
|
|
csToolsAnnotation.toolName ||
|
|
|
|
|
measurementData.toolType;
|
|
|
|
|
|
|
|
|
|
const validToolType = toolName => SUPPORTED_TOOLS.includes(toolName);
|
|
|
|
|
|
|
|
|
|
if (!validToolType(tool)) {
|
|
|
|
|
throw new Error('Tool not supported');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
SOPInstanceUID,
|
|
|
|
|
FrameOfReferenceUID,
|
|
|
|
|
SeriesInstanceUID,
|
|
|
|
|
StudyInstanceUID,
|
|
|
|
|
} = getSOPInstanceAttributes(element);
|
|
|
|
|
|
2020-07-22 19:40:40 +02:00
|
|
|
const displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
|
|
|
|
|
SOPInstanceUID,
|
|
|
|
|
SeriesInstanceUID
|
|
|
|
|
);
|
|
|
|
|
|
2020-06-25 18:13:31 +02:00
|
|
|
const { handles } = measurementData;
|
|
|
|
|
|
|
|
|
|
const longAxis = [handles.start, handles.end];
|
|
|
|
|
const shortAxis = [handles.perpendicularStart, handles.perpendicularEnd];
|
|
|
|
|
|
|
|
|
|
return {
|
2020-07-01 11:08:56 +02:00
|
|
|
id: measurementData.id,
|
2020-08-05 14:56:02 +02:00
|
|
|
SOPInstanceUID,
|
2020-06-25 18:13:31 +02:00
|
|
|
FrameOfReferenceUID,
|
|
|
|
|
referenceSeriesUID: SeriesInstanceUID,
|
|
|
|
|
referenceStudyUID: StudyInstanceUID,
|
2020-07-22 19:40:40 +02:00
|
|
|
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
2020-08-05 14:56:02 +02:00
|
|
|
label: measurementData.label,
|
2020-06-25 18:13:31 +02:00
|
|
|
description: measurementData.description,
|
|
|
|
|
unit: measurementData.unit,
|
|
|
|
|
shortestDiameter: measurementData.shortestDiameter,
|
|
|
|
|
longestDiameter: measurementData.longestDiameter,
|
|
|
|
|
type: getValueTypeFromToolType(tool),
|
|
|
|
|
points: { longAxis, shortAxis },
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Bidirectional;
|