2017-02-22 14:15:33 +01:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2016-09-22 20:58:29 +02:00
|
|
|
import { Template } from 'meteor/templating';
|
2017-02-10 22:13:30 +01:00
|
|
|
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
2016-09-22 20:58:29 +02:00
|
|
|
|
2017-02-23 17:23:17 +01:00
|
|
|
const { InstanceMetadata, StudySummary } = Viewerbase.metadata;
|
|
|
|
|
|
2017-02-10 22:13:30 +01:00
|
|
|
// TODO: [LT-refactor] move this to ohif:hanging-protocols package
|
|
|
|
|
/**
|
|
|
|
|
* Get a timepoint type for a given study metadata
|
|
|
|
|
* @param {StudyMetadata} study StudyMetadata instance
|
|
|
|
|
* @return {String|undefined} Timepoint type if found or undefined if not found or any error/missing information
|
|
|
|
|
*/
|
2016-09-22 20:58:29 +02:00
|
|
|
const getTimepointType = study => {
|
2017-02-23 17:23:17 +01:00
|
|
|
const timepointApi = OHIF.viewer.timepointApi;
|
2017-02-10 22:13:30 +01:00
|
|
|
|
2017-02-23 17:23:17 +01:00
|
|
|
if (!timepointApi || !(study instanceof InstanceMetadata || study instanceof StudySummary) ) {
|
2016-08-15 15:34:36 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 17:23:17 +01:00
|
|
|
const timepoint = timepointApi.study(study.getStudyInstanceUID());
|
|
|
|
|
if (!timepoint || !(timepoint instanceof Array) || timepoint.length < 1) {
|
2016-08-15 15:34:36 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 17:23:17 +01:00
|
|
|
return timepoint[0].timepointType;
|
2016-08-15 15:34:36 +02:00
|
|
|
};
|
|
|
|
|
|
2017-02-22 14:15:33 +01:00
|
|
|
Meteor.startup(() => {
|
|
|
|
|
HP = HP || false;
|
2016-08-15 15:34:36 +02:00
|
|
|
|
2017-02-22 14:15:33 +01:00
|
|
|
if (HP) {
|
|
|
|
|
HP.addCustomAttribute('timepointType', 'Timepoint Type', getTimepointType);
|
|
|
|
|
}
|
|
|
|
|
});
|