Fix/hp validate match offset 2 (#3279)

* fix: Validate provided display sets other than 0

* Build fix
This commit is contained in:
Bill Wallace 2023-03-28 11:18:33 -04:00 committed by GitHub
parent ed7ded05db
commit b2128976a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 104 additions and 21 deletions

View File

@ -2,7 +2,8 @@
<!-- markdownlint-disable --> <!-- markdownlint-disable -->
<div align="center"> <div align="center">
<h1>OHIF Medical Imaging Viewer</h1> <h1>OHIF Medical Imaging Viewer</h1>
<p><strong>The OHIF Viewer</strong> is a zero-footprint medical image viewer provided by the <a href="https://ohif.org/">Open Health Imaging Foundation (OHIF)</a>. It is a configurable and extensible progressive web application with out-of-the-box support for image archives which support <a href="https://www.dicomstandard.org/dicomweb/">DICOMweb</a>.</p> <p><strong>The OHIF Viewer</strong> is a zero-footprint medical image viewer
provided by the <a href="https://ohif.org/">Open Health Imaging Foundation (OHIF)</a>. It is a configurable and extensible progressive web application with out-of-the-box support for image archives which support <a href="https://www.dicomstandard.org/dicomweb/">DICOMweb</a>.</p>
</div> </div>

View File

@ -98,7 +98,7 @@ const defaultProtocol = {
viewportStructure: { viewportStructure: {
layoutType: 'grid', layoutType: 'grid',
properties: { properties: {
rows: 1, rows: 2,
columns: 2, columns: 2,
}, },
}, },
@ -137,13 +137,7 @@ const defaultProtocol = {
], ],
}, },
{ {
viewportOptions: { viewportOptions: {},
toolGroupId: 'default',
// initialImageOptions: {
// index: 180,
// preset: 'middle', // 'first', 'last', 'middle'
// },
},
displaySets: [ displaySets: [
{ {
id: 'defaultDisplaySetId', id: 'defaultDisplaySetId',
@ -154,10 +148,61 @@ const defaultProtocol = {
], ],
}, },
{
name: '3x1',
// Indicate that the number of viewports needed is 2 filled viewports,
// but that 4 viewports are preferred.
stageActivation: {
enabled: {
minViewportsMatched: 3,
},
},
viewportStructure: {
layoutType: 'grid',
properties: {
rows: 1,
columns: 3,
},
},
viewports: [
{
viewportOptions: {
toolGroupId: 'default',
},
displaySets: [
{
id: 'defaultDisplaySetId',
matchedDisplaySetsIndex: 2,
},
],
},
{
viewportOptions: {
toolGroupId: 'default',
},
displaySets: [
{
id: 'defaultDisplaySetId',
matchedDisplaySetsIndex: 1,
},
],
},
{
viewportOptions: {},
displaySets: [
{
id: 'defaultDisplaySetId',
},
],
},
],
},
// This is an example of a layout with more than one element in it // This is an example of a layout with more than one element in it
// It can be navigated to using , and . (prev/next stage) // It can be navigated to using , and . (prev/next stage)
{ {
name: '1x2', name: '2x1',
// Indicate that the number of viewports needed is 1 filled viewport, // Indicate that the number of viewports needed is 1 filled viewport,
// but that 2 viewports are preferred. // but that 2 viewports are preferred.
stageActivation: { stageActivation: {
@ -185,17 +230,42 @@ const defaultProtocol = {
displaySets: [ displaySets: [
{ {
id: 'defaultDisplaySetId', id: 'defaultDisplaySetId',
// Shows the second index of this image set
matchedDisplaySetsIndex: 1,
}, },
], ],
}, },
{ {
viewportOptions: { viewportOptions: {},
toolGroupId: 'default', displaySets: [
// initialImageOptions: { {
// index: 180, id: 'defaultDisplaySetId',
// preset: 'middle', // 'first', 'last', 'middle' },
// }, ],
}, },
],
},
{
name: '2x1',
// Indicate that the number of viewports needed is 1 filled viewport,
// but that 2 viewports are preferred.
stageActivation: {
enabled: {
minViewportsMatched: 3,
},
},
viewportStructure: {
layoutType: 'grid',
properties: {
rows: 2,
columns: 1,
},
},
viewports: [
{
viewportOptions: {},
displaySets: [ displaySets: [
{ {
id: 'defaultDisplaySetId', id: 'defaultDisplaySetId',
@ -204,8 +274,15 @@ const defaultProtocol = {
}, },
], ],
}, },
{
viewportOptions: {},
displaySets: [
{
id: 'defaultDisplaySetId',
},
],
},
], ],
createdDate: '2021-02-23T18:32:42.850Z',
}, },
], ],
}; };

View File

@ -1011,6 +1011,7 @@ export default class HangingProtocolService extends PubSubService {
): HangingProtocol.DisplaySetMatchDetails { ): HangingProtocol.DisplaySetMatchDetails {
if (!matchDetails) return; if (!matchDetails) return;
if (offset === 0) return matchDetails; if (offset === 0) return matchDetails;
const { matchingScores = [] } = matchDetails;
if (offset === -1) { if (offset === -1) {
const { inDisplay } = options; const { inDisplay } = options;
if (!inDisplay) return matchDetails; if (!inDisplay) return matchDetails;
@ -1022,13 +1023,14 @@ export default class HangingProtocolService extends PubSubService {
) { ) {
const match = matchDetails.matchingScores[i]; const match = matchDetails.matchingScores[i];
return match.matchingScore > 0 return match.matchingScore > 0
? matchDetails.matchingScores[i] ? { matchingScores, ...matchDetails.matchingScores[i] }
: null; : null;
} }
} }
return; return;
} }
return matchDetails.matchingScores[offset]; const matchFound = matchingScores[offset];
return matchFound ? { ...matchFound, matchingScores } : undefined;
} }
protected validateDisplaySetSelectMatch( protected validateDisplaySetSelectMatch(
@ -1037,6 +1039,9 @@ export default class HangingProtocolService extends PubSubService {
displaySetUID: string displaySetUID: string
): void { ): void {
if (match.displaySetInstanceUID === displaySetUID) return; if (match.displaySetInstanceUID === displaySetUID) return;
if (!match.matchingScores) {
throw new Error('No matchingScores found in ' + match);
}
for (const subMatch of match.matchingScores) { for (const subMatch of match.matchingScores) {
if (subMatch.displaySetInstanceUID === displaySetUID) return; if (subMatch.displaySetInstanceUID === displaySetUID) return;
} }
@ -1085,7 +1090,7 @@ export default class HangingProtocolService extends PubSubService {
const reuseDisplaySetUID = const reuseDisplaySetUID =
id && id &&
displaySetSelectorMap[ displaySetSelectorMap[
`${activeStudyUID}:${id}:${matchedDisplaySetsIndex || 0}` `${activeStudyUID}:${id}:${matchedDisplaySetsIndex || 0}`
]; ];
const viewportDisplaySetMain = this.displaySetMatchDetails.get(id); const viewportDisplaySetMain = this.displaySetMatchDetails.get(id);