-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat hp search recover from incomplete or missing series/stages #3538
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,12 +382,30 @@ export default class HangingProtocolService extends PubSubService { | |
return; | ||
} | ||
|
||
const matchedProtocol = this.protocolEngine.run({ | ||
let matchedProtocol = this.protocolEngine.run({ | ||
studies: this.studies, | ||
activeStudy, | ||
displaySets, | ||
}); | ||
this._setProtocol(matchedProtocol); | ||
let nthBestMatch = 1; | ||
const matchedProtocolSize = this.protocolEngine.getMatchedProtocolsSize(); | ||
let done = false; | ||
while (!done && nthBestMatch <= matchedProtocolSize) { | ||
try { | ||
this._setProtocol(matchedProtocol); | ||
done = true; | ||
} catch (e) { | ||
// something went wrong while setting current matchedProtocol, so we rollback and | ||
// try again with next nth best matched protocol | ||
nthBestMatch++; | ||
matchedProtocol = this.protocolEngine.run({ | ||
studies: this.studies, | ||
activeStudy, | ||
displaySets, | ||
nthBest: nthBestMatch | ||
}); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -856,26 +874,39 @@ export default class HangingProtocolService extends PubSubService { | |
options = null as HangingProtocol.SetProtocolOptions | ||
) { | ||
const stages = this.protocol.stages; | ||
let failureCounter = 0; | ||
for (let i = 0; i < stages.length; i++) { | ||
const stage = stages[i]; | ||
try { | ||
const stage = stages[i]; | ||
|
||
const { matchedViewports } = this._matchAllViewports( | ||
stage, | ||
options, | ||
new Map() | ||
); | ||
const activation = stage.stageActivation || {}; | ||
if (this.matchActivation(matchedViewports, activation.passive, 0)) { | ||
if (this.matchActivation(matchedViewports, activation.enabled, 1)) { | ||
stage.status = 'enabled'; | ||
const { matchedViewports } = this._matchAllViewports( | ||
stage, | ||
options, | ||
new Map() | ||
) || {}; | ||
const activation = stage.stageActivation || {}; | ||
|
||
if (this.matchActivation(matchedViewports, activation.passive, 0)) { | ||
if (this.matchActivation(matchedViewports, activation.enabled, 1)) { | ||
stage.status = 'enabled'; | ||
} else { | ||
stage.status = 'passive'; | ||
} | ||
} else { | ||
stage.status = 'passive'; | ||
stage.status = 'disabled'; | ||
} | ||
} else { | ||
stage.status = 'disabled'; | ||
} catch (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should avoid touching this code here. |
||
stages[i].status = 'passive'; | ||
failureCounter++; | ||
console.warn(`The hanging protocol viewport is requesting to display the matching displaysets for ${stages[i]} but something went wrong and it could not be matched.`); | ||
} | ||
} | ||
|
||
// it means there is no valid stage | ||
if (failureCounter === stages.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you can just iterate over the stages and see if there is a passive or enabled one, rather than throwing. |
||
throw new Error(); | ||
} | ||
|
||
this._broadcastEvent(this.EVENTS.STAGE_ACTIVATION, { | ||
protocol: this.protocol, | ||
stages: this.protocol.stages, | ||
|
@@ -1284,6 +1315,14 @@ export default class HangingProtocolService extends PubSubService { | |
); | ||
} | ||
}); | ||
|
||
// there is no displayset found for given protocol | ||
if (!displaySetsInfo.length) { | ||
throw new Error( | ||
`Can't find a displaySet match for any viewport` | ||
); | ||
} | ||
|
||
return { | ||
viewportOptions, | ||
displaySetsInfo, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should just throw the exception if a specific protocol is specified