basic pub/sub refresh for tabs from displaysets from dicommetadata
This commit is contained in:
1 parent
1892ec2a2a
commit
f87d18936e
9 files changed
+191
-158
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import pubSubServiceInterface from '../_shared/pubSubServiceInterface';
|
||||
import StudyMetadata from './StudyMetadata';
|
||||
import createStudyMetadata from './createStudyMetadata';
|
||||
import EVENTS from './EVENTS';
|
||||
|
||||
const _model = {
|
||||
@@ -57,20 +57,26 @@ function _getInstance(StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID) {
|
||||
const BaseImplementation = {
|
||||
EVENTS,
|
||||
listeners: {},
|
||||
// TODO: The assumption is that this is called per Study per Series
|
||||
// We should do more to verify/clarify that
|
||||
addInstances(instances) {
|
||||
const { StudyInstanceUID } = instances[0];
|
||||
const { StudyInstanceUID, SeriesInstanceUID } = instances[0];
|
||||
|
||||
let study = _model.studies.find(
|
||||
study => study.StudyInstanceUID === StudyInstanceUID
|
||||
);
|
||||
|
||||
if (!study) {
|
||||
_model.studies.push(new StudyMetadata(StudyInstanceUID));
|
||||
_model.studies.push(createStudyMetadata(StudyInstanceUID));
|
||||
|
||||
study = _model.studies[_model.studies.length - 1];
|
||||
}
|
||||
|
||||
study.addSeries(instances);
|
||||
this._broadcastEvent(EVENTS.INSTANCES_ADDED, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
});
|
||||
},
|
||||
addStudy(study) {
|
||||
const { StudyInstanceUID } = study;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const EVENTS = {
|
||||
DISPLAY_SETS_ADDED: 'event::displaySetService:displaySetsAdded',
|
||||
DISPLAY_SETS_CHANGED: 'event::displaySetService:displaySetsChanged',
|
||||
INSTANCES_ADDED: 'event::dicomMetadataStore:instancesAdded',
|
||||
};
|
||||
|
||||
export default EVENTS;
|
||||
@@ -1,9 +0,0 @@
|
||||
class SeriesMetadata {
|
||||
constructor(instances) {
|
||||
const { SeriesInstanceUID } = instances[0];
|
||||
this.SeriesInstanceUID = SeriesInstanceUID;
|
||||
this.instances = instances;
|
||||
}
|
||||
}
|
||||
|
||||
export default SeriesMetadata;
|
||||
@@ -1,14 +0,0 @@
|
||||
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,10 @@
|
||||
function createSeriesMetadata(instances) {
|
||||
const { SeriesInstanceUID } = instances[0];
|
||||
|
||||
return {
|
||||
SeriesInstanceUID,
|
||||
instances,
|
||||
};
|
||||
}
|
||||
|
||||
export default createSeriesMetadata;
|
||||
@@ -0,0 +1,14 @@
|
||||
import createSeriesMetadata from './createSeriesMetadata';
|
||||
|
||||
function createStudyMetadata(StudyInstanceUID) {
|
||||
return {
|
||||
StudyInstanceUID,
|
||||
series: [],
|
||||
addSeries: function(instances) {
|
||||
const series = createSeriesMetadata(instances);
|
||||
this.series.push(series);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default createStudyMetadata;
|
||||
@@ -38,7 +38,6 @@ function DataSourceWrapper(props) {
|
||||
const firstAppConfigDataSource = appConfig.dataSources[0];
|
||||
const dataSourceConfig = firstAppConfigDataSource.configuration;
|
||||
const firstWebApiDataSource = webApiDataSources[0];
|
||||
debugger;
|
||||
const dataSource = firstWebApiDataSource.createDataSource(dataSourceConfig);
|
||||
|
||||
// Route props --> studies.mapParams
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { useParams } from 'react-router';
|
||||
import PropTypes from 'prop-types';
|
||||
//
|
||||
import { ToolBarManager } from '@ohif/core';
|
||||
// TODO: DicomMetadataStore should be injected?
|
||||
import { DicomMetadataStore, ToolBarManager } from '@ohif/core';
|
||||
import { DragAndDropProvider, ImageViewerProvider } from '@ohif/ui';
|
||||
//
|
||||
import { useQuery } from '@hooks';
|
||||
@@ -91,10 +91,31 @@ export default function ModeRoute({
|
||||
console.log('queryParams: ', queryParams);
|
||||
|
||||
// Call the data source to start building the view model?
|
||||
dataSource.retrieve.series.metadata(
|
||||
queryParams,
|
||||
DisplaySetService.makeDisplaySets
|
||||
// TODO: This should be called on subscription to DicomMetadataStore?
|
||||
// dataSource.retrieve.series.metadata(
|
||||
// queryParams,
|
||||
// DisplaySetService.makeDisplaySets
|
||||
// );
|
||||
|
||||
// TODO: This should be baked into core, not manuel?
|
||||
// DisplaySetService would wire this up?
|
||||
DicomMetadataStore.subscribe(
|
||||
DicomMetadataStore.EVENTS.INSTANCES_ADDED,
|
||||
({ StudyInstanceUID, SeriesInstanceUID }) => {
|
||||
console.warn(`INSTANCES_ADDED::\nStudy:${StudyInstanceUID}\nSeries:${SeriesInstanceUID}`);
|
||||
|
||||
const seriesMetadata = DicomMetadataStore.getSeries(
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID
|
||||
);
|
||||
|
||||
DisplaySetService.makeDisplaySets(seriesMetadata.instances);
|
||||
}
|
||||
);
|
||||
|
||||
StudyInstanceUIDsAsArray.forEach(StudyInstanceUID => {
|
||||
dataSource.retrieveSeriesMetadata({ StudyInstanceUID });
|
||||
});
|
||||
}, [
|
||||
mode,
|
||||
dataSourceName,
|
||||
@@ -102,7 +123,8 @@ export default function ModeRoute({
|
||||
DisplaySetService,
|
||||
extensionManager,
|
||||
sopClassHandlers,
|
||||
dataSource.retrieve.series,
|
||||
StudyInstanceUIDsAsArray,
|
||||
dataSource,
|
||||
]);
|
||||
|
||||
const reducer = (state, action) => {
|
||||
|
||||
Reference in new issue
Block a user