lint(curly): consistent use of curly brackets in codebase (#3584)
This commit is contained in:
1 parent
9ae3d9f769
commit
5d435424e2
113 files changed
+1501
-1056
No files matched your search
@@ -134,7 +134,7 @@ function checkHpsBestMatch(hps) {
|
||||
displaySetOptions: {
|
||||
id: 'displaySetSelector',
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -192,6 +192,6 @@ describe('HangingProtocolService', () => {
|
||||
it('matches best image match', () => {
|
||||
checkHpsBestMatch(hangingProtocolService);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -86,7 +86,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
metadata.ModalitiesInStudy ??
|
||||
(metadata.series || []).reduce((prev, curr) => {
|
||||
const { Modality } = curr;
|
||||
if (Modality && prev.indexOf(Modality) == -1) prev.push(Modality);
|
||||
if (Modality && prev.indexOf(Modality) == -1) {
|
||||
prev.push(Modality);
|
||||
}
|
||||
return prev;
|
||||
}, []),
|
||||
},
|
||||
@@ -200,7 +202,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
* protocolId, stageIndex, stageId and activeStudyUID
|
||||
*/
|
||||
public getState(): HangingProtocol.HPInfo {
|
||||
if (!this.protocol) return;
|
||||
if (!this.protocol) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
protocolId: this.protocol.id,
|
||||
stageIndex: this.stageIndex,
|
||||
@@ -257,8 +261,12 @@ export default class HangingProtocolService extends PubSubService {
|
||||
* @returns protocol - the protocol with the given id
|
||||
*/
|
||||
public getProtocolById(protocolId: string): HangingProtocol.Protocol {
|
||||
if (!protocolId) return;
|
||||
if (protocolId === this.protocol?.id) return this.protocol;
|
||||
if (!protocolId) {
|
||||
return;
|
||||
}
|
||||
if (protocolId === this.protocol?.id) {
|
||||
return this.protocol;
|
||||
}
|
||||
const protocol = this.protocols.get(protocolId);
|
||||
if (!protocol) {
|
||||
throw new Error(`No protocol ${protocolId} found`);
|
||||
@@ -697,7 +705,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const { id } = displaySet;
|
||||
const displaySetMatchDetail = displaySetMatchDetails.get(id);
|
||||
|
||||
const { displaySetInstanceUID: oldDisplaySetInstanceUID } = displaySetMatchDetail;
|
||||
const {
|
||||
displaySetInstanceUID: oldDisplaySetInstanceUID,
|
||||
} = displaySetMatchDetail;
|
||||
|
||||
const displaySetInstanceUID =
|
||||
displaySet.id === displaySetSelectorId
|
||||
@@ -730,8 +740,12 @@ export default class HangingProtocolService extends PubSubService {
|
||||
);
|
||||
}
|
||||
|
||||
if (options === null) return options;
|
||||
if (typeof options !== 'object') return options;
|
||||
if (options === null) {
|
||||
return options;
|
||||
}
|
||||
if (typeof options !== 'object') {
|
||||
return options;
|
||||
}
|
||||
|
||||
// If options is an object with a custom attribute, compute a new options object
|
||||
if (options.custom) {
|
||||
@@ -892,7 +906,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
if (stageId) {
|
||||
for (let i = 0; i < stages.length; i++) {
|
||||
const stage = stages[i];
|
||||
if (stage.id === stageId && stage.status !== 'disabled') return i;
|
||||
if (stage.id === stageId && stage.status !== 'disabled') {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -905,7 +921,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
let firstNotDisabled: number;
|
||||
|
||||
for (let i = 0; i < stages.length; i++) {
|
||||
if (stages[i].status === 'enabled') return i;
|
||||
if (stages[i].status === 'enabled') {
|
||||
return i;
|
||||
}
|
||||
if (firstNotDisabled === undefined && stages[i].status !== 'disabled') {
|
||||
firstNotDisabled = i;
|
||||
}
|
||||
@@ -979,7 +997,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
if (stageId !== undefined) {
|
||||
return protocol.stages.findIndex(it => it.id === stageId);
|
||||
}
|
||||
if (stageIndex !== undefined) return stageIndex;
|
||||
if (stageIndex !== undefined) {
|
||||
return stageIndex;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1050,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const protocol = this.protocol;
|
||||
const stage = protocol.stages[stageIdx];
|
||||
const defaultViewport = stage.defaultViewport || protocol.defaultViewport;
|
||||
if (!defaultViewport) return;
|
||||
if (!defaultViewport) {
|
||||
return;
|
||||
}
|
||||
|
||||
const useViewport = { ...defaultViewport };
|
||||
return this._matchViewport(useViewport, options);
|
||||
@@ -1152,12 +1174,18 @@ export default class HangingProtocolService extends PubSubService {
|
||||
offset: number,
|
||||
options: HangingProtocol.SetProtocolOptions = {}
|
||||
): HangingProtocol.DisplaySetMatchDetails {
|
||||
if (!matchDetails) return;
|
||||
if (offset === 0) return matchDetails;
|
||||
if (!matchDetails) {
|
||||
return;
|
||||
}
|
||||
if (offset === 0) {
|
||||
return matchDetails;
|
||||
}
|
||||
const { matchingScores = [] } = matchDetails;
|
||||
if (offset === -1) {
|
||||
const { inDisplay } = options;
|
||||
if (!inDisplay) return matchDetails;
|
||||
if (!inDisplay) {
|
||||
return matchDetails;
|
||||
}
|
||||
for (let i = 0; i < matchDetails.matchingScores.length; i++) {
|
||||
if (
|
||||
inDisplay.indexOf(
|
||||
@@ -1184,12 +1212,16 @@ export default class HangingProtocolService extends PubSubService {
|
||||
id: string,
|
||||
displaySetUID: string
|
||||
): 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) {
|
||||
if (subMatch.displaySetInstanceUID === displaySetUID) return;
|
||||
if (subMatch.displaySetInstanceUID === displaySetUID) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`Reused viewport details ${id} with ds ${displaySetUID} not valid`
|
||||
@@ -1391,21 +1423,23 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const matchActiveOnly = this.protocol.numberOfPriorsReferenced === -1;
|
||||
this.studies.forEach(study => {
|
||||
// Skip non-active if active only
|
||||
if (matchActiveOnly && this.activeStudy !== study) return;
|
||||
if (matchActiveOnly && this.activeStudy !== study) {
|
||||
return;
|
||||
}
|
||||
|
||||
const studyDisplaySets = this.displaySets.filter(
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
);
|
||||
|
||||
const studyMatchDetails = this.protocolEngine.findMatch(
|
||||
study,
|
||||
studyMatchingRules,
|
||||
{
|
||||
studies: this.studies,
|
||||
displaySets: studyDisplaySets,
|
||||
allDisplaySets: this.displaySets,
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
}
|
||||
study,
|
||||
studyMatchingRules,
|
||||
{
|
||||
studies: this.studies,
|
||||
displaySets: studyDisplaySets,
|
||||
allDisplaySets: this.displaySets,
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
@@ -1414,10 +1448,10 @@ export default class HangingProtocolService extends PubSubService {
|
||||
}
|
||||
|
||||
this.debug(
|
||||
'study',
|
||||
study.StudyInstanceUID,
|
||||
'display sets #',
|
||||
studyDisplaySets.length
|
||||
'study',
|
||||
study.StudyInstanceUID,
|
||||
'display sets #',
|
||||
studyDisplaySets.length
|
||||
);
|
||||
studyDisplaySets.forEach(displaySet => {
|
||||
const {
|
||||
@@ -1426,15 +1460,15 @@ export default class HangingProtocolService extends PubSubService {
|
||||
displaySetInstanceUID,
|
||||
} = displaySet;
|
||||
const seriesMatchDetails = this.protocolEngine.findMatch(
|
||||
displaySet,
|
||||
seriesMatchingRules,
|
||||
// Todo: why we have images here since the matching type does not have it
|
||||
{
|
||||
studies: this.studies,
|
||||
instance: displaySet.images?.[0],
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
displaySets: studyDisplaySets,
|
||||
}
|
||||
displaySet,
|
||||
seriesMatchingRules,
|
||||
// Todo: why we have images here since the matching type does not have it
|
||||
{
|
||||
studies: this.studies,
|
||||
instance: displaySet.images?.[0],
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
displaySets: studyDisplaySets,
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
|
||||
+9
-3
@@ -13,7 +13,9 @@ const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
params
|
||||
);
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid', params);
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) return false;
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) {
|
||||
return false;
|
||||
}
|
||||
const isSeriesMatch =
|
||||
!initialSeriesInstanceUID ||
|
||||
initialSeriesInstanceUID.some(
|
||||
@@ -32,9 +34,13 @@ const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
*/
|
||||
function sopInstanceLocation(displaySets) {
|
||||
const displaySet = displaySets?.[0];
|
||||
if (!displaySet) return;
|
||||
if (!displaySet) {
|
||||
return;
|
||||
}
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid');
|
||||
if (!initialSOPInstanceUID) return;
|
||||
if (!initialSOPInstanceUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = displaySet.instances.findIndex(instance =>
|
||||
initialSOPInstanceUID.includes(instance.SOPInstanceUID)
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
export default (study, extraData) => {
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames>0)?.length;
|
||||
console.log("number of display sets with images", ret);
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames > 0)
|
||||
?.length;
|
||||
console.log('number of display sets with images', ret);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
export default (study, extraData) => extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
export default (study, extraData) =>
|
||||
extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
@@ -111,10 +111,12 @@ validate.validators.includes = function(value, options, key) {
|
||||
const includedValues = testValue.filter(el => dicomArrayValue.includes(el));
|
||||
if (includedValues.length === 0) {
|
||||
return `${key} must include at least one of the following values: ${testValue.join(
|
||||
', '
|
||||
', '
|
||||
)}`;
|
||||
}
|
||||
} else return `${key} ${testValue} must be an array`;
|
||||
} else {
|
||||
return `${key} ${testValue} must be an array`;
|
||||
}
|
||||
// else if (!value.includes(testValue)) {
|
||||
// return `${key} ${value} must include ${testValue}`;
|
||||
// }
|
||||
@@ -151,7 +153,9 @@ validate.validators.doesNotInclude = function(value, options, key) {
|
||||
if (includedValues.length > 0) {
|
||||
return `${key} must not include the following value: ${includedValues}`;
|
||||
}
|
||||
} else return `${key} ${testValue} must be an array`;
|
||||
} else {
|
||||
return `${key} ${testValue} must be an array`;
|
||||
}
|
||||
};
|
||||
// Ignore case contains.
|
||||
// options testValue MUST be in lower case already, otherwise it won't match
|
||||
@@ -175,31 +179,31 @@ validate.validators.containsI = function(value, options, key) {
|
||||
const testValue = getTestValue(options);
|
||||
if (Array.isArray(value)) {
|
||||
if (
|
||||
value.some(
|
||||
item => !validate.validators.containsI(item.toLowerCase(), options, key)
|
||||
)
|
||||
value.some(
|
||||
item => !validate.validators.containsI(item.toLowerCase(), options, key)
|
||||
)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return `No item of ${value.join(',')} contains ${JSON.stringify(
|
||||
testValue
|
||||
testValue
|
||||
)}`;
|
||||
}
|
||||
if (Array.isArray(testValue)) {
|
||||
if (
|
||||
testValue.some(
|
||||
subTest =>
|
||||
!validate.validators.containsI(value, subTest.toLowerCase(), key)
|
||||
)
|
||||
testValue.some(
|
||||
subTest =>
|
||||
!validate.validators.containsI(value, subTest.toLowerCase(), key)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return `${key} must contain at least one of ${testValue.join(',')}`;
|
||||
}
|
||||
if (
|
||||
testValue &&
|
||||
value.indexOf &&
|
||||
value.toLowerCase().indexOf(testValue.toLowerCase()) === -1
|
||||
testValue &&
|
||||
value.indexOf &&
|
||||
value.toLowerCase().indexOf(testValue.toLowerCase()) === -1
|
||||
) {
|
||||
return key + 'must contain any case of' + testValue;
|
||||
}
|
||||
@@ -227,14 +231,14 @@ validate.validators.contains = function(value, options, key) {
|
||||
return undefined;
|
||||
}
|
||||
return `No item of ${value.join(',')} contains ${JSON.stringify(
|
||||
testValue
|
||||
testValue
|
||||
)}`;
|
||||
}
|
||||
if (Array.isArray(testValue)) {
|
||||
if (
|
||||
testValue.some(
|
||||
subTest => !validate.validators.contains(value, subTest, key)
|
||||
)
|
||||
testValue.some(
|
||||
subTest => !validate.validators.contains(value, subTest, key)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -454,11 +458,13 @@ validate.validators.range = function(value, options, key) {
|
||||
if (value === undefined || value < min || value > max) {
|
||||
return `${key} with value ${value} must be between ${min} and ${max}`;
|
||||
}
|
||||
} else return `${key} must be an array of length 2`;
|
||||
} else {
|
||||
return `${key} must be an array of length 2`;
|
||||
}
|
||||
};
|
||||
|
||||
validate.validators.notNull = value =>
|
||||
value === null || value === undefined ? 'Value is null' : undefined;
|
||||
value === null || value === undefined ? 'Value is null' : undefined;
|
||||
const getTestValue = options => {
|
||||
if (Array.isArray(options)) {
|
||||
return options.map(option => option?.value ?? option);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user