fix: Inconsistencies and update the style setting on load for embedded styles from codingValues (#4599)

This commit is contained in:
Bill Wallace 2025-01-09 09:28:02 -05:00 committed by GitHub
parent 3c848c6d34
commit e0088ec918
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 58 additions and 5 deletions

View File

@ -208,7 +208,11 @@ export default function hydrateStructuredReport(
annotation.data.label = getLabelFromDCMJSImportedToolData(toolData);
annotation.data.finding = convertCode(codingValues, toolData.finding?.[0]);
annotation.data.findingSites = convertSites(codingValues, toolData.findingSites);
annotation.data.site = annotation.data.findingSites?.[0];
annotation.data.findingSites?.forEach(site => {
if (site.type) {
annotation.data[site.type] = site;
}
});
const matchingMapping = mappings.find(m => m.annotationType === annotationType);
@ -220,6 +224,11 @@ export default function hydrateStructuredReport(
dataSource
);
commandsManager.runCommand('updateMeasurement', {
uid: newAnnotationUID,
code: annotation.data.finding,
});
if (disableEditing) {
const addedAnnotation = annotationManager.getAnnotation(newAnnotationUID);
locking.setAnnotationLocked(addedAnnotation, true);

View File

@ -11,6 +11,7 @@ import {
Enums,
utilities as cstUtils,
ReferenceLinesTool,
annotation,
} from '@cornerstonejs/tools';
import { Types as OhifTypes } from '@ohif/core';
@ -30,6 +31,7 @@ import { getFirstAnnotationSelected } from './utils/measurementServiceMappings/u
import getActiveViewportEnabledElement from './utils/getActiveViewportEnabledElement';
import toggleVOISliceSync from './utils/toggleVOISliceSync';
import { usePositionPresentationStore, useSegmentationPresentationStore } from './stores';
import { toolNames } from './initCornerstoneTools';
const toggleSyncFunctions = {
imageSlice: toggleImageSliceSync,
@ -218,6 +220,8 @@ function commandsModule({
* * CodingSchemeDesignator - the issue of the code value
* * CodeMeaning - the text value shown to the user
* * ref - a string reference in the form `<designator>:<codeValue>`
* * type - defaulting to 'finding'. Will replace other codes of same type
* * style - a styling object to use
* * Other fields
* Note it is a valid option to remove the finding or site values by
* supplying null for the code.
@ -233,7 +237,12 @@ function commandsModule({
*/
updateMeasurement: props => {
const { code, uid, textLabel, label } = props;
let { style } = props;
const measurement = measurementService.getMeasurement(uid);
if (!measurement) {
console.warn('No measurement found to update', uid);
return;
}
const updatedMeasurement = {
...measurement,
};
@ -252,7 +261,6 @@ function commandsModule({
code.CodingSchemeDesignator = code.ref.substring(0, split);
}
updatedMeasurement[measurementKey] = code;
// TODO - remove this line once the measurements table customizations are in
if (measurementKey !== 'finding') {
if (updatedMeasurement.findingSites) {
updatedMeasurement.findingSites = updatedMeasurement.findingSites.filter(
@ -264,6 +272,26 @@ function commandsModule({
}
}
}
style ||= updatedMeasurement.finding?.style;
style ||= updatedMeasurement.findingSites?.find(site => site?.style)?.style;
if (style) {
// Reset the selected values to preserve appearance on selection
style.lineDashSelected ||= style.lineDash;
annotation.config.style.setAnnotationStyles(measurement.uid, style);
// this is a bit ugly, but given the underlying behavior, this is how it needs to work.
switch (measurement.toolName) {
case toolNames.PlanarFreehandROI: {
const targetAnnotation = annotation.state.getAnnotation(measurement.uid);
targetAnnotation.data.isOpenUShapeContour = !!style.isOpenUShapeContour;
break;
}
default:
break;
}
}
measurementService.update(updatedMeasurement.uid, updatedMeasurement, true);
},

View File

@ -23,28 +23,44 @@ const codingValues = {
'SCT:69536005': {
text: 'Head',
type: 'site',
style: {
color: 'red',
},
},
'SCT:45048000': {
text: 'Neck',
type: 'site',
style: {
color: 'blue',
},
},
'SCT:818981001': {
text: 'Abdomen',
type: 'site',
style: {
color: 'orange',
},
},
'SCT:816092008': {
text: 'Pelvis',
type: 'site',
style: {
color: 'cyan',
},
},
// Findings
'SCT:371861004': {
text: 'Mild intimal coronary irregularities',
color: 'green',
style: {
color: 'green',
},
},
'SCT:194983005': {
text: 'Aortic insufficiency',
color: 'darkred',
style: {
color: 'darkred',
},
},
'SCT:399232001': {
text: '2-chamber',

View File

@ -13,7 +13,7 @@ const codeMenuItem = {
...this,
codeRef,
code: { ref: codeRef, ...code },
label: code.text,
label: this.label || code.text || codeRef,
commands: [
{
commandName: 'updateMeasurement',