2017-01-16 18:30:54 +01:00
|
|
|
import { OHIFError } from './classes/OHIFError';
|
|
|
|
|
|
2015-11-16 17:49:35 +01:00
|
|
|
/**
|
|
|
|
|
* Sorts the series and instances inside a study instance by their series
|
|
|
|
|
* and instance numbers in ascending order.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} study The study instance
|
|
|
|
|
*/
|
2017-01-16 18:30:54 +01:00
|
|
|
export function sortStudy(study) {
|
2016-07-23 15:56:36 +02:00
|
|
|
if (!study || !study.seriesList) {
|
2017-01-16 18:30:54 +01:00
|
|
|
throw new OHIFError('Insufficient study data was provided to sortStudy');
|
2015-10-13 14:14:50 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-16 18:30:54 +01:00
|
|
|
study.seriesList.sort((a, b) => a.seriesNumber - b.seriesNumber);
|
|
|
|
|
|
|
|
|
|
study.seriesList.forEach(series => {
|
|
|
|
|
series.instances.sort((a, b) => a.instanceNumber - b.instanceNumber);
|
2015-10-13 14:14:50 +02:00
|
|
|
});
|
2017-01-16 18:30:54 +01:00
|
|
|
}
|