Fix/hp validate match offset 2 (#3279)

* fix: Validate provided display sets other than 0

* Build fix
This commit is contained in:
Bill Wallace authored and GitHub committed 2023-03-28 11:18:33 -04:00
1 parent ed7ded05db
commit b2128976a3
3 files changed
+104 -21

No files matched your search

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