fix(HangingProtocolService): Add callback property & update description (#3349)

The description for the numberOfDisplaySetsWithImages property was corrected. The update also involves adding a callback property that returns several objects (matchedViewports, viewportMatchDetails, displaySetMatchDetails) and returning them from the method 'findViewportProtocols'. The refactored code also has better readability.
This commit is contained in:
Alireza 2023-05-02 13:31:51 -04:00 committed by GitHub
parent 0f85b1a681
commit ef24d89930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,8 +102,8 @@ export default class HangingProtocolService extends PubSubService {
}, },
numberOfDisplaySetsWithImages: { numberOfDisplaySetsWithImages: {
name: 'numberOfDisplaySetsWithImages', name: 'numberOfDisplaySetsWithImages',
desription: 'Number of displays sets with images', description: 'Number of displays sets with images',
numberOfDisplaySetsWithImages, callback: numberOfDisplaySetsWithImages,
}, },
}; };
listeners = {}; listeners = {};
@ -1058,7 +1058,11 @@ export default class HangingProtocolService extends PubSubService {
viewportMatchDetails.set(viewportIndex, matchDetails); viewportMatchDetails.set(viewportIndex, matchDetails);
} }
}); });
return { matchedViewports, viewportMatchDetails, displaySetMatchDetails }; return {
matchedViewports,
viewportMatchDetails,
displaySetMatchDetails,
};
} }
protected findDeduplicatedMatchDetails( protected findDeduplicatedMatchDetails(
@ -1080,7 +1084,10 @@ export default class HangingProtocolService extends PubSubService {
) { ) {
const match = matchDetails.matchingScores[i]; const match = matchDetails.matchingScores[i];
return match.matchingScore > 0 return match.matchingScore > 0
? { matchingScores, ...matchDetails.matchingScores[i] } ? {
matchingScores,
...matchDetails.matchingScores[i],
}
: null; : null;
} }
} }
@ -1309,11 +1316,11 @@ export default class HangingProtocolService extends PubSubService {
const studyMatchDetails = this.protocolEngine.findMatch( const studyMatchDetails = this.protocolEngine.findMatch(
study, study,
studyMatchingRules, studyMatchingRules,
{ {
studies: this.studies, studies: this.studies,
displaySets: studyDisplaySets, displaySets: studyDisplaySets,
displaySetMatchDetails: this.displaySetMatchDetails, displaySetMatchDetails: this.displaySetMatchDetails,
} }
); );
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed // Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
@ -1337,12 +1344,12 @@ export default class HangingProtocolService extends PubSubService {
displaySet, displaySet,
seriesMatchingRules, seriesMatchingRules,
// Todo: why we have images here since the matching type does not have it // Todo: why we have images here since the matching type does not have it
{ {
studies: this.studies, studies: this.studies,
instance: displaySet.images?.[0], instance: displaySet.images?.[0],
displaySetMatchDetails: this.displaySetMatchDetails, displaySetMatchDetails: this.displaySetMatchDetails,
displaySets: studyDisplaySets, displaySets: studyDisplaySets,
} }
); );
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed // Prevent bestMatch from being updated if the matchDetails' required attribute check has failed