diff --git a/extensions/default/src/DicomWebDataSource/index.js b/extensions/default/src/DicomWebDataSource/index.js index 5f232a8c5..c6fa9dca8 100644 --- a/extensions/default/src/DicomWebDataSource/index.js +++ b/extensions/default/src/DicomWebDataSource/index.js @@ -6,7 +6,7 @@ import { processResults, processSeriesResults, } from './qido.js'; -import { dicomMetadataStore, IWebApiDataSource, utils } from '@ohif/core'; +import { DicomMetadataStore, IWebApiDataSource, utils } from '@ohif/core'; import getImageId from './utils/getImageId'; import * as dcmjs from 'dcmjs'; @@ -89,7 +89,7 @@ function createDicomWebApi(dicomWebConfig) { series: { // TODO: change queryParams to `StudyInstanceUID` for now? // Conduct query, return a promise like others - // Await this call and add to dicomMetadataStore after receiving result + // Await this call and add to DicomMetadataStore after receiving result metadata: (queryParams, callback) => { let { StudyInstanceUIDs } = urlUtil.parse(queryParams, true); @@ -104,7 +104,7 @@ function createDicomWebApi(dicomWebConfig) { const storeInstances = instances => { const naturalizedInstances = instances.map(naturalizeDataset); - dicomMetadataStore.addInstances(naturalizedInstances); + DicomMetadataStore.addInstances(naturalizedInstances); callback(naturalizedInstances); }; @@ -146,7 +146,7 @@ function createDicomWebApi(dicomWebConfig) { function storeInstances(instances) { const naturalizedInstances = instances.map(naturalizeDataset); - dicomMetadataStore.addInstances(naturalizedInstances); + DicomMetadataStore.addInstances(naturalizedInstances); } seriesPromises.forEach(async seriesPromise => { diff --git a/extensions/default/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js b/extensions/default/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js index 194efc1d7..8e103850d 100644 --- a/extensions/default/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +++ b/extensions/default/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js @@ -1,10 +1,6 @@ import RetrieveMetadataLoader from './retrieveMetadataLoader'; //import { sortStudySeries, sortingCriteria } from '../../sortStudy'; import getSeriesInfo from './utils/getSeriesInfo'; -// import { -// createStudyFromSOPInstanceList, -// addInstancesToStudy, -// } from './studyInstanceHelpers'; /** * Map seriesList to an array of seriesInstanceUid @@ -15,19 +11,6 @@ function mapStudySeries(seriesList) { return seriesList.map(series => getSeriesInfo(series).seriesInstanceUid); } -// function attachSeriesLoader(server, study, seriesLoader) { -// study.seriesLoader = Object.freeze({ -// hasNext() { -// return seriesLoader.hasNext(); -// }, -// async next() { -// const series = await seriesLoader.next(); -// await addInstancesToStudy(server, study, series.sopInstances); -// return study.seriesMap[series.seriesInstanceUID]; -// }, -// }); -// } - /** * Creates an immutable series loader object which loads each series sequentially using the iterator interface * @param {DICOMWebClient} dicomWebClient The DICOMWebClient instance to be used for series load diff --git a/extensions/default/src/Panels/PanelStudyBrowser.jsx b/extensions/default/src/Panels/PanelStudyBrowser.jsx index 54e6eda4e..80248f4e5 100644 --- a/extensions/default/src/Panels/PanelStudyBrowser.jsx +++ b/extensions/default/src/Panels/PanelStudyBrowser.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useCallback } from 'react'; import PropTypes from 'prop-types'; // import { StudyBrowser, useImageViewer } from '@ohif/ui'; -import { dicomMetadataStore } from '@ohif/core'; +import { DicomMetadataStore } from '@ohif/core'; // This has to import from somewhere else... function PanelStudyBrowser({ @@ -46,8 +46,10 @@ function PanelStudyBrowser({ } StudyInstanceUIDs.forEach(sid => fetchStudiesForPatient(sid)); - }, [StudyInstanceUIDs, getStudiesForPatientByStudyInstanceUID]); - + }, [ + StudyInstanceUIDs, + getStudiesForPatientByStudyInstanceUID, + ]); const updateThumbnailMap = (displaySetInstanceUID, imageSrc) => { setThumbnailImageSrcMap( diff --git a/extensions/default/src/Panels/getStudiesForPatientByStudyInstanceUID.js b/extensions/default/src/Panels/getStudiesForPatientByStudyInstanceUID.js index e9084a8f1..9327383ee 100644 --- a/extensions/default/src/Panels/getStudiesForPatientByStudyInstanceUID.js +++ b/extensions/default/src/Panels/getStudiesForPatientByStudyInstanceUID.js @@ -2,7 +2,7 @@ async function getStudiesForPatientByStudyInstanceUID( dataSource, StudyInstanceUID ) { - // TODO: The `dicomMetadataStore` should short-circuit both of these requests + // TODO: The `DicomMetadataStore` should short-circuit both of these requests // Data _could_ be here from route query, or if using JSON data source // We could also force this to "await" these values being available in the DICOMStore? // Kind of like promise fulfillment in cornerstone-wado-image-loader when there are multiple @@ -18,6 +18,6 @@ async function getStudiesForPatientByStudyInstanceUID( patientId: getStudyResult[0].mrn, }); } -}; +} export default getStudiesForPatientByStudyInstanceUID; diff --git a/extensions/default/src/ViewerLayout/index.jsx b/extensions/default/src/ViewerLayout/index.jsx index 21f89d91e..caff0abfc 100644 --- a/extensions/default/src/ViewerLayout/index.jsx +++ b/extensions/default/src/ViewerLayout/index.jsx @@ -77,7 +77,6 @@ function ViewerLayout({ label: tool.label, type: 'setToolActive', onClick: () => { - debugger; commandsManager.runCommand(tool.commandName, commandOptions); }, }); @@ -104,8 +103,6 @@ function ViewerLayout({ // } }); - debugger; - setToolBarLayout(toolBarLayout); }; @@ -134,7 +131,7 @@ function ViewerLayout({ moreTools={toolBarLayout[0].moreTools} />
{/* LEFT SIDEPANELS */} @@ -145,10 +142,10 @@ function ViewerLayout({ /> {/* TOOLBAR + GRID */}
-
+
-
+
Add instances //_addInstance(input) // arraybuffer, or other stuff -export { dicomMetadataStore }; -export default dicomMetadataStore; +export { DicomMetadataStore }; +export default DicomMetadataStore; diff --git a/platform/core/src/services/DicomMetadataStore/EVENTS.js b/platform/core/src/services/DicomMetadataStore/EVENTS.js new file mode 100644 index 000000000..6b964f703 --- /dev/null +++ b/platform/core/src/services/DicomMetadataStore/EVENTS.js @@ -0,0 +1,6 @@ +const EVENTS = { + DISPLAY_SETS_ADDED: 'event::displaySetService:displaySetsAdded', + DISPLAY_SETS_CHANGED: 'event::displaySetService:displaySetsChanged', +}; + +export default EVENTS; diff --git a/platform/core/src/services/DicomMetadataStore/SeriesMetadata.js b/platform/core/src/services/DicomMetadataStore/SeriesMetadata.js new file mode 100644 index 000000000..bc6fca4d4 --- /dev/null +++ b/platform/core/src/services/DicomMetadataStore/SeriesMetadata.js @@ -0,0 +1,9 @@ +class SeriesMetadata { + constructor(instances) { + const { SeriesInstanceUID } = instances[0]; + this.SeriesInstanceUID = SeriesInstanceUID; + this.instances = instances; + } +} + +export default SeriesMetadata; diff --git a/platform/core/src/services/DicomMetadataStore/StudyMetadata.js b/platform/core/src/services/DicomMetadataStore/StudyMetadata.js new file mode 100644 index 000000000..bf3ca5b0f --- /dev/null +++ b/platform/core/src/services/DicomMetadataStore/StudyMetadata.js @@ -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; diff --git a/platform/core/src/services/DicomMetadataStore/index.js b/platform/core/src/services/DicomMetadataStore/index.js new file mode 100644 index 000000000..e41b2e59d --- /dev/null +++ b/platform/core/src/services/DicomMetadataStore/index.js @@ -0,0 +1,4 @@ +import DicomMetadataStore from './DicomMetadataStore'; + +export { DicomMetadataStore }; +export default DicomMetadataStore; diff --git a/platform/core/src/services/DisplaySetService/DisplaySetService.js b/platform/core/src/services/DisplaySetService/DisplaySetService.js index e31f1c43b..b09aa8c03 100644 --- a/platform/core/src/services/DisplaySetService/DisplaySetService.js +++ b/platform/core/src/services/DisplaySetService/DisplaySetService.js @@ -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); } }; diff --git a/platform/core/src/services/DisplaySetService/EVENTS.js b/platform/core/src/services/DisplaySetService/EVENTS.js new file mode 100644 index 000000000..6b964f703 --- /dev/null +++ b/platform/core/src/services/DisplaySetService/EVENTS.js @@ -0,0 +1,6 @@ +const EVENTS = { + DISPLAY_SETS_ADDED: 'event::displaySetService:displaySetsAdded', + DISPLAY_SETS_CHANGED: 'event::displaySetService:displaySetsChanged', +}; + +export default EVENTS; diff --git a/platform/core/src/services/MeasurementService/MeasurementService.js b/platform/core/src/services/MeasurementService/MeasurementService.js index 0f0ea6aed..9028758a6 100644 --- a/platform/core/src/services/MeasurementService/MeasurementService.js +++ b/platform/core/src/services/MeasurementService/MeasurementService.js @@ -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 diff --git a/platform/core/src/services/ToolBarService/ToolBarService.js b/platform/core/src/services/ToolBarService/ToolBarService.js index 0eb0056ef..1c3757c9e 100644 --- a/platform/core/src/services/ToolBarService/ToolBarService.js +++ b/platform/core/src/services/ToolBarService/ToolBarService.js @@ -1,4 +1,4 @@ -import pubSubServiceInterface from '../pubSubServiceInterface'; +import pubSubServiceInterface from '../_shared/pubSubServiceInterface'; const EVENTS = { TOOL_BAR_MODIFIED: 'event::toolBarService:toolBarModified', diff --git a/platform/core/src/services/_shared/index.js b/platform/core/src/services/_shared/index.js new file mode 100644 index 000000000..3ae9a1496 --- /dev/null +++ b/platform/core/src/services/_shared/index.js @@ -0,0 +1,3 @@ +import pubSubServiceInterface from './pubSubServiceInterface'; + +export { pubSubServiceInterface }; diff --git a/platform/core/src/services/pubSubServiceInterface/index.js b/platform/core/src/services/_shared/pubSubServiceInterface.js similarity index 72% rename from platform/core/src/services/pubSubServiceInterface/index.js rename to platform/core/src/services/_shared/pubSubServiceInterface.js index b7c42eca7..1719be1ca 100644 --- a/platform/core/src/services/pubSubServiceInterface/index.js +++ b/platform/core/src/services/_shared/pubSubServiceInterface.js @@ -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); + }); + } +} diff --git a/platform/core/src/services/index.js b/platform/core/src/services/index.js index 70eadd0d7..96ecfb4d5 100644 --- a/platform/core/src/services/index.js +++ b/platform/core/src/services/index.js @@ -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, }; diff --git a/platform/viewer/src/routes/DataSourceWrapper.jsx b/platform/viewer/src/routes/DataSourceWrapper.jsx index 9011e59e1..d89831440 100644 --- a/platform/viewer/src/routes/DataSourceWrapper.jsx +++ b/platform/viewer/src/routes/DataSourceWrapper.jsx @@ -38,6 +38,7 @@ 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 @@ -48,7 +49,6 @@ function DataSourceWrapper(props) { // Or no data fetching here, and just hand down my source const [data, setData] = useState(); useEffect(() => { - // 204: no content async function getData() { const searchResults = await dataSource.query.studies.search( @@ -61,7 +61,6 @@ function DataSourceWrapper(props) { getData(); } catch (ex) { console.warn(ex); - } console.log('DataSourceWrapper: useEffect'); // eslint-disable-next-line react-hooks/exhaustive-deps