2024-11-06 13:15:27 +01:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2025-01-10 04:01:42 +01:00
|
|
|
import { DicomMetadataStore, utils } from '@ohif/core';
|
2025-01-08 20:23:34 +01:00
|
|
|
import { useViewportGrid } from '@ohif/ui-next';
|
2024-11-06 13:15:27 +01:00
|
|
|
import { Button, Icons } from '@ohif/ui-next';
|
2025-01-10 04:01:42 +01:00
|
|
|
import { PanelMeasurement, StudySummaryFromMetadata } from '@ohif/extension-cornerstone';
|
2024-11-06 13:15:27 +01:00
|
|
|
import { useTrackedMeasurements } from '../getContextModule';
|
|
|
|
|
|
2025-01-23 20:24:13 +01:00
|
|
|
const { filterAnd, filterPlanarMeasurement, filterMeasurementsBySeriesUID } =
|
2025-01-10 04:01:42 +01:00
|
|
|
utils.MeasurementFilters;
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
function PanelMeasurementTableTracking({
|
|
|
|
|
servicesManager,
|
|
|
|
|
extensionManager,
|
|
|
|
|
commandsManager,
|
|
|
|
|
}: withAppTypes) {
|
|
|
|
|
const [viewportGrid] = useViewportGrid();
|
2025-01-10 04:01:42 +01:00
|
|
|
const { customizationService } = servicesManager.services;
|
2024-11-06 13:15:27 +01:00
|
|
|
const [trackedMeasurements, sendTrackedMeasurementsEvent] = useTrackedMeasurements();
|
|
|
|
|
const { trackedStudy, trackedSeries } = trackedMeasurements.context;
|
2025-01-10 04:01:42 +01:00
|
|
|
const measurementFilter = trackedStudy
|
|
|
|
|
? filterAnd(filterPlanarMeasurement, filterMeasurementsBySeriesUID(trackedSeries))
|
|
|
|
|
: filterPlanarMeasurement;
|
2024-11-06 13:15:27 +01:00
|
|
|
|
2025-01-23 20:24:13 +01:00
|
|
|
const disableEditing = customizationService.getCustomization('panelMeasurement.disableEditing');
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2025-01-10 04:01:42 +01:00
|
|
|
<StudySummaryFromMetadata StudyInstanceUID={trackedStudy} />
|
2024-11-06 13:15:27 +01:00
|
|
|
<PanelMeasurement
|
|
|
|
|
servicesManager={servicesManager}
|
|
|
|
|
extensionManager={extensionManager}
|
|
|
|
|
commandsManager={commandsManager}
|
2025-01-10 04:01:42 +01:00
|
|
|
measurementFilter={measurementFilter}
|
2024-11-06 13:15:27 +01:00
|
|
|
customHeader={({ additionalFindings, measurements }) => {
|
|
|
|
|
const disabled = additionalFindings.length === 0 && measurements.length === 0;
|
|
|
|
|
|
|
|
|
|
if (disableEditing || disabled) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="bg-background flex h-9 w-full items-center rounded pr-0.5">
|
|
|
|
|
<div className="flex space-x-1">
|
|
|
|
|
<Button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
className="pl-1.5"
|
|
|
|
|
onClick={() => {
|
2025-01-10 04:01:42 +01:00
|
|
|
commandsManager.runCommand('downloadCSVMeasurementsReport', {
|
|
|
|
|
measurementFilter,
|
|
|
|
|
});
|
2024-11-06 13:15:27 +01:00
|
|
|
}}
|
|
|
|
|
>
|
2024-11-12 19:14:47 +01:00
|
|
|
<Icons.Download className="h-5 w-5" />
|
2024-11-06 13:15:27 +01:00
|
|
|
<span className="pl-1">CSV</span>
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
className="pl-0.5"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
sendTrackedMeasurementsEvent('SAVE_REPORT', {
|
|
|
|
|
viewportId: viewportGrid.activeViewportId,
|
|
|
|
|
isBackupSave: true,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Icons.Add />
|
2024-11-12 19:14:47 +01:00
|
|
|
Create SR
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
className="pl-0.5"
|
|
|
|
|
onClick={() => {
|
2025-01-10 04:01:42 +01:00
|
|
|
commandsManager.runCommand('clearMeasurements', { measurementFilter });
|
2024-11-12 19:14:47 +01:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Icons.Delete />
|
|
|
|
|
Delete All
|
2024-11-06 13:15:27 +01:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
></PanelMeasurement>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PanelMeasurementTableTracking;
|