fix(hanging-protocols): Fail rule matching if a required rule fails
This commit is contained in:
parent
b6eecf8c8f
commit
b64c9878af
@ -103,7 +103,8 @@ const match = (metadataInstance, rules) => {
|
||||
|
||||
return {
|
||||
score,
|
||||
details
|
||||
details,
|
||||
requiredFailed
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -274,8 +274,6 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
|
||||
let highestStudyMatchingScore = 0;
|
||||
let highestSeriesMatchingScore = 0;
|
||||
let highestImageMatchingScore = 0;
|
||||
let bestMatch;
|
||||
|
||||
// Set custom attribute for study metadata and it's first instance
|
||||
currentStudy.setCustomAttribute(ABSTRACT_PRIOR_VALUE, 0);
|
||||
@ -349,8 +347,9 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
|
||||
this.studies.forEach(study => {
|
||||
const studyMatchDetails = HPMatcher.match(study.getFirstInstance(), studyMatchingRules);
|
||||
if ((studyMatchingRules.length && !studyMatchDetails.score) ||
|
||||
studyMatchDetails.score < highestStudyMatchingScore) {
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
if (studyMatchDetails.requiredFailed === true || studyMatchDetails.score < highestStudyMatchingScore) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -358,8 +357,9 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
|
||||
study.forEachSeries(series => {
|
||||
const seriesMatchDetails = HPMatcher.match(series.getFirstInstance(), seriesMatchingRules);
|
||||
if ((seriesMatchingRules.length && !seriesMatchDetails.score) ||
|
||||
seriesMatchDetails.score < highestSeriesMatchingScore) {
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
if (seriesMatchDetails.requiredFailed === true || seriesMatchDetails.score < highestSeriesMatchingScore) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -377,6 +377,11 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
|
||||
const instanceMatchDetails = HPMatcher.match(instance, instanceMatchingRules);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
if (instanceMatchDetails.requiredFailed === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const matchDetails = {
|
||||
passed: [],
|
||||
failed: []
|
||||
@ -417,11 +422,6 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
imageDetails.imageId = instance.getImageId();
|
||||
}
|
||||
|
||||
if ((totalMatchScore > highestImageMatchingScore) || !bestMatch) {
|
||||
highestImageMatchingScore = totalMatchScore;
|
||||
bestMatch = imageDetails;
|
||||
}
|
||||
|
||||
matchingScores.push(imageDetails);
|
||||
});
|
||||
});
|
||||
@ -441,6 +441,8 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
});
|
||||
matchingScores.sort((a, b) => sortingFunction(a.sortingInfo, b.sortingInfo));
|
||||
|
||||
const bestMatch = matchingScores[0];
|
||||
|
||||
OHIF.log.info('ProtocolEngine::matchImages bestMatch', bestMatch);
|
||||
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user