Creating ohif:metadata package with metadata classes and adding it to the viewers
This commit is contained in:
1 parent
30a50c7ade
commit
660b828f4b
24 files changed
+242
-28
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
|
||||
const InstanceMetadata = Viewerbase.metadata.InstanceMetadata;
|
||||
|
||||
export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
|
||||
/**
|
||||
* @param {Object} Instance object.
|
||||
*/
|
||||
constructor(data) {
|
||||
super(data);
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const data = this.getData();
|
||||
// set protected property...
|
||||
this._sopInstanceUID = data.sopInstanceUid;
|
||||
}
|
||||
|
||||
// Override
|
||||
getRawValue(tagOrProperty, defaultValue) {
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
|
||||
const data = this.getData();
|
||||
const rawValue = data[propertyName];
|
||||
|
||||
return rawValue !== void 0 ? rawValue : defaultValue;
|
||||
}
|
||||
|
||||
// Override
|
||||
tagExists(tagOrProperty) {
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
|
||||
const data = this.getData();
|
||||
|
||||
return (propertyName in data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static methods
|
||||
*/
|
||||
|
||||
static getPropertyName(tagOrProperty) {
|
||||
const tagInfo = InstanceMetadata.getTagInfo(tagOrProperty);
|
||||
|
||||
if(tagInfo.propertyName === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
let propertyName = tagInfo.propertyName.charAt(0).toLowerCase() + tagInfo.propertyName.substr(1);
|
||||
// TODO: Improve this: change retriveMetadata to use dicom standard names (see dicomTagDescriptions.js)
|
||||
propertyName = propertyName.replace(/^sop/, 'SOP');
|
||||
propertyName = propertyName.replace(/uid$/i, 'UID');
|
||||
|
||||
return propertyName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
import { OHIFInstanceMetadata } from './OHIFInstanceMetadata';
|
||||
|
||||
export class OHIFSeriesMetadata extends Viewerbase.metadata.SeriesMetadata {
|
||||
|
||||
/**
|
||||
* @param {Object} Series object.
|
||||
*/
|
||||
constructor(data) {
|
||||
super(data);
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const data = this.getData();
|
||||
|
||||
// set protected property...
|
||||
this._seriesInstanceUID = data.seriesInstanceUid;
|
||||
// populate internal list of instances...
|
||||
data.instances.forEach(instance => {
|
||||
this.addInstance(new OHIFInstanceMetadata(instance));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
import { OHIFSeriesMetadata } from './OHIFSeriesMetadata';
|
||||
|
||||
export class OHIFStudyMetadata extends Viewerbase.metadata.StudyMetadata {
|
||||
|
||||
/**
|
||||
* @param {Object} Study object.
|
||||
*/
|
||||
constructor(data) {
|
||||
super(data);
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const data = this.getData();
|
||||
|
||||
// set protected property...
|
||||
this._studyInstanceUID = data.studyInstanceUid;
|
||||
// populate internal list of series...
|
||||
data.seriesList.forEach(series => {
|
||||
this.addSeries(new OHIFSeriesMetadata(series));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Metadata } from '../namespace';
|
||||
|
||||
// OHIFStudyMetadata, OHIFSeriesMetadata, OHIFInstanceMetadata
|
||||
import { OHIFStudyMetadata } from './OHIFStudyMetadata';
|
||||
import { OHIFSeriesMetadata } from './OHIFSeriesMetadata';
|
||||
import { OHIFInstanceMetadata } from './OHIFInstanceMetadata';
|
||||
|
||||
Metadata.StudyMetadata = OHIFStudyMetadata;
|
||||
Metadata.SeriesMetadata = OHIFSeriesMetadata;
|
||||
Metadata.InstanceMetadata = OHIFInstanceMetadata;
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Import namespace...
|
||||
*/
|
||||
|
||||
import { OHIF, Metadata } from './namespace.js';
|
||||
|
||||
/**
|
||||
* Import scripts that will populate the Metadata namespace as a side effect only import. This is effectively the public API...
|
||||
*/
|
||||
|
||||
import './client/'; // which is actually: import './client/index.js';
|
||||
|
||||
/**
|
||||
* Export relevant objects...
|
||||
*
|
||||
* With the following export it becomes possible to import "OHIF" from "ohif:core" and "Metadata"
|
||||
* from "ohif:metadata" using a single import (a shorthand), like this:
|
||||
*
|
||||
* import { OHIF } from 'meteor/ohif:metadata';
|
||||
*
|
||||
* Which is equivalent to:
|
||||
*
|
||||
* import { OHIF } from 'meteor/ohif:core';
|
||||
* import 'meteor/ohif:metadata';
|
||||
*
|
||||
* The second (extended) format should be used when other OHIF packages are also to be used within
|
||||
* the current module. This makes it explicit that the following imports will populate their
|
||||
* respective namespaces within the to "OHIF" namespace. Example:
|
||||
*
|
||||
* import { OHIF } from 'meteor/ohif:core';
|
||||
* import 'meteor/ohif:metadata';
|
||||
* import 'meteor/ohif:hanging-protocols';
|
||||
* [ ... ]
|
||||
* OHIF.metadata.setActiveViewport(...);
|
||||
* OHIF.hangingprotocols.doSomething(...);
|
||||
*
|
||||
*/
|
||||
|
||||
export { OHIF, Metadata };
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Import main dependency...
|
||||
*/
|
||||
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Create Metadata namespace...
|
||||
*/
|
||||
|
||||
const Metadata = {};
|
||||
|
||||
/**
|
||||
* Append Metadata namespace to OHIF namespace...
|
||||
*/
|
||||
|
||||
OHIF.metadata = Metadata;
|
||||
|
||||
/**
|
||||
* Export relevant objects...
|
||||
*/
|
||||
|
||||
export { OHIF, Metadata };
|
||||
@@ -0,0 +1,16 @@
|
||||
Package.describe({
|
||||
name: 'ohif:metadata',
|
||||
summary: 'OHIF Metadata classes',
|
||||
version: '0.0.1'
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
api.versionsFrom('1.4');
|
||||
|
||||
api.use('ecmascript');
|
||||
|
||||
api.use('ohif:core');
|
||||
api.use('ohif:viewerbase');
|
||||
|
||||
api.mainModule('main.js', 'client');
|
||||
});
|
||||
Reference in new issue
Block a user