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

View File

@ -11,6 +11,7 @@ import {
Enums, Enums,
utilities as cstUtils, utilities as cstUtils,
ReferenceLinesTool, ReferenceLinesTool,
annotation,
} from '@cornerstonejs/tools'; } from '@cornerstonejs/tools';
import { Types as OhifTypes } from '@ohif/core'; import { Types as OhifTypes } from '@ohif/core';
@ -30,6 +31,7 @@ import { getFirstAnnotationSelected } from './utils/measurementServiceMappings/u
import getActiveViewportEnabledElement from './utils/getActiveViewportEnabledElement'; import getActiveViewportEnabledElement from './utils/getActiveViewportEnabledElement';
import toggleVOISliceSync from './utils/toggleVOISliceSync'; import toggleVOISliceSync from './utils/toggleVOISliceSync';
import { usePositionPresentationStore, useSegmentationPresentationStore } from './stores'; import { usePositionPresentationStore, useSegmentationPresentationStore } from './stores';
import { toolNames } from './initCornerstoneTools';
const toggleSyncFunctions = { const toggleSyncFunctions = {
imageSlice: toggleImageSliceSync, imageSlice: toggleImageSliceSync,
@ -218,6 +220,8 @@ function commandsModule({
* * CodingSchemeDesignator - the issue of the code value * * CodingSchemeDesignator - the issue of the code value
* * CodeMeaning - the text value shown to the user * * CodeMeaning - the text value shown to the user
* * ref - a string reference in the form `<designator>:<codeValue>` * * 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 * * Other fields
* Note it is a valid option to remove the finding or site values by * Note it is a valid option to remove the finding or site values by
* supplying null for the code. * supplying null for the code.
@ -233,7 +237,12 @@ function commandsModule({
*/ */
updateMeasurement: props => { updateMeasurement: props => {
const { code, uid, textLabel, label } = props; const { code, uid, textLabel, label } = props;
let { style } = props;
const measurement = measurementService.getMeasurement(uid); const measurement = measurementService.getMeasurement(uid);
if (!measurement) {
console.warn('No measurement found to update', uid);
return;
}
const updatedMeasurement = { const updatedMeasurement = {
...measurement, ...measurement,
}; };
@ -252,7 +261,6 @@ function commandsModule({
code.CodingSchemeDesignator = code.ref.substring(0, split); code.CodingSchemeDesignator = code.ref.substring(0, split);
} }
updatedMeasurement[measurementKey] = code; updatedMeasurement[measurementKey] = code;
// TODO - remove this line once the measurements table customizations are in
if (measurementKey !== 'finding') { if (measurementKey !== 'finding') {
if (updatedMeasurement.findingSites) { if (updatedMeasurement.findingSites) {
updatedMeasurement.findingSites = updatedMeasurement.findingSites.filter( 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); measurementService.update(updatedMeasurement.uid, updatedMeasurement, true);
}, },

View File

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

View File

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