ohif-viewer/Packages/ohif-measurements/client/lib/hangingProtocolCustomizations.js
2017-03-21 10:16:46 -03:00

35 lines
1.0 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { Viewerbase } from 'meteor/ohif:viewerbase';
import { OHIF } from 'meteor/ohif:core';
const { InstanceMetadata, StudySummary } = Viewerbase.metadata;
// 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
*/
const getTimepointType = study => {
const { timepointApi } = OHIF.viewer;
if (!timepointApi || !(study instanceof InstanceMetadata || study instanceof StudySummary)) {
return;
}
const timepoint = timepointApi.study(study.getStudyInstanceUID());
if (!timepoint || !(timepoint instanceof Array) || timepoint.length < 1) {
return;
}
return timepoint[0].timepointType;
};
Meteor.startup(() => {
HP = HP || false;
if (HP) {
HP.addCustomAttribute('timepointType', 'Timepoint Type', getTimepointType);
}
});