Move files around to confuse James and Erik
This commit is contained in:
1 parent
b5070dd518
commit
715377c565
21 files changed
+122
-101
No files matched your search
@@ -0,0 +1,111 @@
|
||||
import pubSubServiceInterface from '../_shared/pubSubServiceInterface';
|
||||
import StudyMetadata from './StudyMetadata';
|
||||
import EVENTS from './EVENTS';
|
||||
|
||||
const _model = {
|
||||
studies: [],
|
||||
// studies: [{
|
||||
// seriesLists: [
|
||||
// {
|
||||
// // Series in study from dicom web server 1 (or different backend 1)
|
||||
// series: [{
|
||||
// instances: [{
|
||||
// ...instanceMetadata // Naturalized DICOM.
|
||||
// }],
|
||||
// ...seriesMetadata
|
||||
// }],
|
||||
// clientName
|
||||
// },
|
||||
// {
|
||||
// // Series in study from dicom web server 2 (or different backend 2)
|
||||
// },
|
||||
// ],
|
||||
// ...studyMetadata,
|
||||
// }]
|
||||
};
|
||||
|
||||
function _getStudy(StudyInstanceUID) {
|
||||
return _model.studies.find(
|
||||
aStudy => aStudy.StudyInstanceUID === StudyInstanceUID
|
||||
);
|
||||
}
|
||||
|
||||
function _getSeries(StudyInstanceUID, SeriesInstanceUID) {
|
||||
const study = _getStudy(StudyInstanceUID);
|
||||
|
||||
if (!study) {
|
||||
return;
|
||||
}
|
||||
|
||||
return study.series.find(
|
||||
aSeries => aSeries.SeriesInstanceUID === SeriesInstanceUID
|
||||
);
|
||||
}
|
||||
|
||||
function _getInstance(StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID) {
|
||||
const series = _getSeries(StudyInstanceUID, SeriesInstanceUID);
|
||||
|
||||
if (!series) {
|
||||
return;
|
||||
}
|
||||
|
||||
return series.instances.find(
|
||||
instance => instance.SOPInstanceUID === SOPInstanceUID
|
||||
);
|
||||
}
|
||||
|
||||
const BaseImplementation = {
|
||||
EVENTS,
|
||||
listeners: {},
|
||||
addInstances(instances) {
|
||||
const { StudyInstanceUID } = instances[0];
|
||||
|
||||
let study = _model.studies.find(
|
||||
study => study.StudyInstanceUID === StudyInstanceUID
|
||||
);
|
||||
|
||||
if (!study) {
|
||||
_model.studies.push(new StudyMetadata(StudyInstanceUID));
|
||||
|
||||
study = _model.studies[_model.studies.length - 1];
|
||||
}
|
||||
|
||||
study.addSeries(instances);
|
||||
},
|
||||
addStudy(study) {
|
||||
const { StudyInstanceUID } = study;
|
||||
|
||||
let existingStudy = _model.studies.find(
|
||||
study => study.StudyInstanceUID === StudyInstanceUID
|
||||
);
|
||||
|
||||
if (!existingStudy) {
|
||||
const newStudy = new StudyMetadata(StudyInstanceUID);
|
||||
|
||||
newStudy.PatientID = study.PatientID;
|
||||
newStudy.PatientName = study.PatientName;
|
||||
newStudy.StudyDate = study.StudyDate;
|
||||
newStudy.ModalitiesInStudy = study.ModalitiesInStudy;
|
||||
newStudy.StudyDescription = study.StudyDescription;
|
||||
newStudy.AccessionNumber = study.AccessionNumber;
|
||||
newStudy.NumInstances = study.NumInstances; // todo: Correct naming?
|
||||
|
||||
_model.studies.push(newStudy);
|
||||
}
|
||||
},
|
||||
getStudy: _getStudy,
|
||||
getSeries: _getSeries,
|
||||
getInstance: _getInstance,
|
||||
};
|
||||
|
||||
const DicomMetadataStore = Object.assign(
|
||||
{},
|
||||
BaseImplementation,
|
||||
pubSubServiceInterface
|
||||
);
|
||||
|
||||
// TODO => Add instances
|
||||
//_addInstance(input) // arraybuffer, or other stuff
|
||||
|
||||
export { DicomMetadataStore };
|
||||
export default DicomMetadataStore;
|
||||
@@ -0,0 +1,6 @@
|
||||
const EVENTS = {
|
||||
DISPLAY_SETS_ADDED: 'event::displaySetService:displaySetsAdded',
|
||||
DISPLAY_SETS_CHANGED: 'event::displaySetService:displaySetsChanged',
|
||||
};
|
||||
|
||||
export default EVENTS;
|
||||
@@ -0,0 +1,9 @@
|
||||
class SeriesMetadata {
|
||||
constructor(instances) {
|
||||
const { SeriesInstanceUID } = instances[0];
|
||||
this.SeriesInstanceUID = SeriesInstanceUID;
|
||||
this.instances = instances;
|
||||
}
|
||||
}
|
||||
|
||||
export default SeriesMetadata;
|
||||
@@ -0,0 +1,14 @@
|
||||
import SeriesMetadata from './SeriesMetadata';
|
||||
|
||||
class StudyMetadata {
|
||||
constructor(StudyInstanceUID) {
|
||||
this.StudyInstanceUID = StudyInstanceUID;
|
||||
this.series = [];
|
||||
}
|
||||
|
||||
addSeries(instances) {
|
||||
this.series.push(new SeriesMetadata(instances));
|
||||
}
|
||||
}
|
||||
|
||||
export default StudyMetadata;
|
||||
@@ -0,0 +1,4 @@
|
||||
import DicomMetadataStore from './DicomMetadataStore';
|
||||
|
||||
export { DicomMetadataStore };
|
||||
export default DicomMetadataStore;
|
||||
@@ -1,17 +1,13 @@
|
||||
import pubSubServiceInterface from '../pubSubServiceInterface';
|
||||
|
||||
const EVENTS = {
|
||||
DISPLAY_SETS_ADDED: 'event::displaySetService:displaySetsAdded',
|
||||
DISPLAY_SETS_CHANGED: 'event::displaySetService:displaySetsChanged',
|
||||
};
|
||||
import pubSubServiceInterface from '../_shared/pubSubServiceInterface';
|
||||
import EVENTS from './EVENTS';
|
||||
|
||||
const displaySetCache = [];
|
||||
|
||||
export default class DisplaySetService {
|
||||
constructor() {
|
||||
this.displaySets = {};
|
||||
this.EVENTS = EVENTS;
|
||||
this.listeners = {};
|
||||
this.EVENTS = EVENTS;
|
||||
|
||||
Object.assign(this, pubSubServiceInterface);
|
||||
}
|
||||
@@ -50,27 +46,11 @@ export default class DisplaySetService {
|
||||
* @param {string} displaySetInstanceUID
|
||||
* @returns {object} displaySet
|
||||
*/
|
||||
getDisplaySetByUID = displaySetInstanceUid => displaySetCache.find(
|
||||
getDisplaySetByUID = displaySetInstanceUid =>
|
||||
displaySetCache.find(
|
||||
displaySet => displaySet.displaySetInstanceUID === displaySetInstanceUid
|
||||
);
|
||||
|
||||
/**
|
||||
* Broadcasts displaySetService changes.
|
||||
*
|
||||
* @param {string} eventName The event name
|
||||
* @return void
|
||||
*/
|
||||
_broadcastChange = (eventName, callbackProps) => {
|
||||
const hasListeners = Object.keys(this.listeners).length > 0;
|
||||
const hasCallbacks = Array.isArray(this.listeners[eventName]);
|
||||
|
||||
if (hasListeners && hasCallbacks) {
|
||||
this.listeners[eventName].forEach(listener => {
|
||||
listener.callback(callbackProps);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
makeDisplaySets = (input, batch = false) => {
|
||||
if (!input || !input.length) {
|
||||
throw new Error('No instances were provided.');
|
||||
@@ -98,12 +78,9 @@ export default class DisplaySetService {
|
||||
}
|
||||
|
||||
if (displaySetsAdded && displaySetsAdded.length) {
|
||||
this._broadcastChange(EVENTS.DISPLAY_SETS_ADDED, displaySetsAdded);
|
||||
this._broadcastEvent(EVENTS.DISPLAY_SETS_ADDED, displaySetsAdded);
|
||||
|
||||
this._broadcastChange(
|
||||
EVENTS.DISPLAY_SETS_CHANGED,
|
||||
this.activeDisplaySets
|
||||
);
|
||||
this._broadcastEvent(EVENTS.DISPLAY_SETS_CHANGED, this.activeDisplaySets);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
const EVENTS = {
|
||||
DISPLAY_SETS_ADDED: 'event::displaySetService:displaySetsAdded',
|
||||
DISPLAY_SETS_CHANGED: 'event::displaySetService:displaySetsChanged',
|
||||
};
|
||||
|
||||
export default EVENTS;
|
||||
@@ -1,6 +1,6 @@
|
||||
import log from '../../log';
|
||||
import guid from '../../utils/guid';
|
||||
import pubSubServiceInterface from '../pubSubServiceInterface';
|
||||
import pubSubServiceInterface from '../_shared/pubSubServiceInterface';
|
||||
|
||||
/**
|
||||
* Measurement source schema
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import pubSubServiceInterface from '../pubSubServiceInterface';
|
||||
import pubSubServiceInterface from '../_shared/pubSubServiceInterface';
|
||||
|
||||
const EVENTS = {
|
||||
TOOL_BAR_MODIFIED: 'event::toolBarService:toolBarModified',
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pubSubServiceInterface from './pubSubServiceInterface';
|
||||
|
||||
export { pubSubServiceInterface };
|
||||
+24
@@ -1,7 +1,13 @@
|
||||
import guid from '../../utils/guid';
|
||||
|
||||
/**
|
||||
* Consumer must implement:
|
||||
* this.listeners = {}
|
||||
* this.EVENTS = { "EVENT_KEY": "EVENT_VALUE" }
|
||||
*/
|
||||
export default {
|
||||
subscribe,
|
||||
_broadcastEvent,
|
||||
_unsubscribe,
|
||||
_isValidEvent,
|
||||
};
|
||||
@@ -62,3 +68,21 @@ function _unsubscribe(eventName, listenerId) {
|
||||
function _isValidEvent(eventName) {
|
||||
return Object.values(this.EVENTS).includes(eventName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts displaySetService changes.
|
||||
*
|
||||
* @param {string} eventName - The event name
|
||||
* @param {func} callbackProps - Properties to pass callback
|
||||
* @return void
|
||||
*/
|
||||
function _broadcastEvent(eventName, callbackProps) {
|
||||
const hasListeners = Object.keys(this.listeners).length > 0;
|
||||
const hasCallbacks = Array.isArray(this.listeners[eventName]);
|
||||
|
||||
if (hasListeners && hasCallbacks) {
|
||||
this.listeners[eventName].forEach(listener => {
|
||||
listener.callback(callbackProps);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import UIDialogService from './UIDialogService';
|
||||
import UIModalService from './UIModalService';
|
||||
import UINotificationService from './UINotificationService';
|
||||
import UIViewportDialogService from './UIViewportDialogService';
|
||||
import DicomMetadataStore from './DicomMetadataStore';
|
||||
import DisplaySetService from './DisplaySetService';
|
||||
import ToolBarSerivce from './ToolBarService';
|
||||
|
||||
@@ -14,6 +15,7 @@ export {
|
||||
UIModalService,
|
||||
UINotificationService,
|
||||
UIViewportDialogService,
|
||||
DicomMetadataStore,
|
||||
DisplaySetService,
|
||||
ToolBarSerivce,
|
||||
};
|
||||
Reference in new issue
Block a user