feat: 🎸 Filter/promote multiple series instances (#1533)
improve filter/promote to be applied on multiple series instances
✅ Closes: 1532
Co-authored-by: Rodolfo Ladeira <rodolfo_radical@hotmail.com>
This commit is contained in:
parent
71b6b454a3
commit
5fdace1432
@ -14,23 +14,25 @@ const { OHIFStudyMetadata, OHIFSeriesMetadata } = metadata;
|
|||||||
const { retrieveStudiesMetadata, deleteStudyMetadataPromise } = studies;
|
const { retrieveStudiesMetadata, deleteStudyMetadataPromise } = studies;
|
||||||
const { studyMetadataManager, makeCancelable } = utils;
|
const { studyMetadataManager, makeCancelable } = utils;
|
||||||
|
|
||||||
const _promoteToFront = (list, value, searchMethod) => {
|
const _promoteToFront = (list, values, searchMethod) => {
|
||||||
let response = [...list];
|
let listCopy = [...list];
|
||||||
let promoted = false;
|
let response = [];
|
||||||
const index = response.findIndex(searchMethod.bind(undefined, value));
|
let promotedCount = 0;
|
||||||
|
|
||||||
if (index > 0) {
|
const arrayValues = values.split(',');
|
||||||
const first = response.splice(index, 1);
|
arrayValues.forEach(value => {
|
||||||
response = [...first, ...response];
|
const index = listCopy.findIndex(searchMethod.bind(undefined, value));
|
||||||
}
|
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
promoted = true;
|
const [itemToPromote] = listCopy.splice(index, 1);
|
||||||
|
response[promotedCount] = itemToPromote;
|
||||||
|
promotedCount++;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
promoted,
|
promoted: promotedCount === arrayValues.length,
|
||||||
data: response,
|
data: [...response, ...listCopy],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,12 +92,48 @@ const _isQueryParamApplied = (study, filters = {}, isFilterStrategy) => {
|
|||||||
if (!seriesInstanceUID) {
|
if (!seriesInstanceUID) {
|
||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
|
const seriesInstanceUIDs = seriesInstanceUID.split(',');
|
||||||
|
|
||||||
|
let validateFilterApplied = () => {
|
||||||
|
const sameSize = arrayToInspect.length === seriesInstanceUIDs.length;
|
||||||
|
if (!sameSize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return arrayToInspect.every(item =>
|
||||||
|
seriesInstanceUIDs.some(
|
||||||
|
seriesInstanceUIDStr => seriesInstanceUIDStr === item.SeriesInstanceUID
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
let validatePromoteApplied = () => {
|
||||||
|
let isValid = true;
|
||||||
|
for (let index = 0; index < seriesInstanceUIDs.length; index++) {
|
||||||
|
const seriesInstanceUIDStr = seriesInstanceUIDs[index];
|
||||||
|
const resultSeries = arrayToInspect[index];
|
||||||
|
|
||||||
|
if (
|
||||||
|
!resultSeries ||
|
||||||
|
resultSeries.SeriesInstanceUID !== seriesInstanceUIDStr
|
||||||
|
) {
|
||||||
|
isValid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isValid;
|
||||||
|
};
|
||||||
|
|
||||||
const { series = [], displaySets = [] } = study;
|
const { series = [], displaySets = [] } = study;
|
||||||
const firstSeries = isFilterStrategy ? series[0] : displaySets[0];
|
const arrayToInspect = isFilterStrategy ? series : displaySets;
|
||||||
|
const validateMethod = isFilterStrategy
|
||||||
|
? validateFilterApplied
|
||||||
|
: validatePromoteApplied;
|
||||||
|
|
||||||
if (!firstSeries || firstSeries.SeriesInstanceUID !== seriesInstanceUID) {
|
if (!arrayToInspect) {
|
||||||
applied = false;
|
applied = false;
|
||||||
|
} else {
|
||||||
|
applied = validateMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
return applied;
|
return applied;
|
||||||
@ -221,7 +259,7 @@ function ViewerRetrieveStudyData({
|
|||||||
// Show message in case not promoted neither filtered but should to
|
// Show message in case not promoted neither filtered but should to
|
||||||
_showUserMessage(
|
_showUserMessage(
|
||||||
isQueryParamApplied,
|
isQueryParamApplied,
|
||||||
'Query parameters were not applied. Using original series list for given study.',
|
'Query parameters were not totally applied. It might be using original series list for given study.',
|
||||||
snackbarContext
|
snackbarContext
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -233,7 +271,7 @@ function ViewerRetrieveStudyData({
|
|||||||
* Method to process studies. It will update displaySet, studyMetadata, load remaining series, ...
|
* Method to process studies. It will update displaySet, studyMetadata, load remaining series, ...
|
||||||
* @param {Array} studiesData Array of studies retrieved from server
|
* @param {Array} studiesData Array of studies retrieved from server
|
||||||
* @param {Object} [filters] - Object containing filters to be applied
|
* @param {Object} [filters] - Object containing filters to be applied
|
||||||
* @param {string} [filter.seriesInstanceUID] - series instance uid to filter results against
|
* @param {string} [filters.seriesInstanceUID] - series instance uid to filter results against
|
||||||
*/
|
*/
|
||||||
const processStudies = (studiesData, filters) => {
|
const processStudies = (studiesData, filters) => {
|
||||||
if (Array.isArray(studiesData) && studiesData.length > 0) {
|
if (Array.isArray(studiesData) && studiesData.length > 0) {
|
||||||
@ -299,7 +337,6 @@ function ViewerRetrieveStudyData({
|
|||||||
const filters = {};
|
const filters = {};
|
||||||
// Use the first, discard others
|
// Use the first, discard others
|
||||||
const seriesInstanceUID = seriesInstanceUIDs && seriesInstanceUIDs[0];
|
const seriesInstanceUID = seriesInstanceUIDs && seriesInstanceUIDs[0];
|
||||||
|
|
||||||
const retrieveParams = [server, studyInstanceUIDs];
|
const retrieveParams = [server, studyInstanceUIDs];
|
||||||
|
|
||||||
if (seriesInstanceUID) {
|
if (seriesInstanceUID) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user