Remove unused files
This commit is contained in:
parent
10930cda68
commit
96bf56b8c1
@ -1,48 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { withRouter } from 'react-router-dom';
|
|
||||||
import ConnectedViewerRetrieveStudyData from '../connectedComponents/ConnectedViewerRetrieveStudyData.js';
|
|
||||||
import OHIF from '@ohif/core';
|
|
||||||
const { urlUtil: UrlUtil } = OHIF.utils;
|
|
||||||
|
|
||||||
function IHEInvokeImageDisplay({ location }) {
|
|
||||||
const {
|
|
||||||
// patientID,
|
|
||||||
requestType,
|
|
||||||
studyUID,
|
|
||||||
} = UrlUtil.parse(location.search);
|
|
||||||
|
|
||||||
switch (requestType) {
|
|
||||||
case 'STUDY':
|
|
||||||
return (
|
|
||||||
<ConnectedViewerRetrieveStudyData
|
|
||||||
studyInstanceUIDs={studyUID.split(';')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
case 'STUDYBASE64':
|
|
||||||
return (
|
|
||||||
<ConnectedViewerRetrieveStudyData
|
|
||||||
studyInstanceUIDs={UrlUtil.paramString.parseParam(studyUID)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
case 'PATIENT':
|
|
||||||
// TODO: connect this to the StudyList when we have the filter parameters set up
|
|
||||||
// return <StudyList patientUIDs={patientID.split(';')} />;
|
|
||||||
return '';
|
|
||||||
|
|
||||||
default:
|
|
||||||
// TODO: Figure out what to do here, this won't work because StudyList expects studies
|
|
||||||
// return <StudyList />;
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IHEInvokeImageDisplay.propTypes = {
|
|
||||||
location: PropTypes.shape({
|
|
||||||
search: PropTypes.string,
|
|
||||||
}).isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withRouter(IHEInvokeImageDisplay);
|
|
||||||
@ -1,211 +0,0 @@
|
|||||||
import React, { Component } from 'react';
|
|
||||||
import OHIF from '@ohif/core';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import qs from 'querystring';
|
|
||||||
|
|
||||||
import { extensionManager } from './../App.js';
|
|
||||||
import ConnectedViewer from '../connectedComponents/ConnectedViewer';
|
|
||||||
import ConnectedViewerRetrieveStudyData from '../connectedComponents/ConnectedViewerRetrieveStudyData';
|
|
||||||
import NotFound from '../routes/NotFound';
|
|
||||||
|
|
||||||
const { log, metadata, utils } = OHIF;
|
|
||||||
const { studyMetadataManager } = utils;
|
|
||||||
const { OHIFStudyMetadata } = metadata;
|
|
||||||
|
|
||||||
class StandaloneRouting extends Component {
|
|
||||||
state = {
|
|
||||||
studies: null,
|
|
||||||
server: null,
|
|
||||||
studyInstanceUIDs: null,
|
|
||||||
seriesInstanceUIDs: null,
|
|
||||||
error: null,
|
|
||||||
loading: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
location: PropTypes.object,
|
|
||||||
store: PropTypes.object,
|
|
||||||
setServers: PropTypes.func,
|
|
||||||
};
|
|
||||||
|
|
||||||
parseQueryAndRetrieveDICOMWebData(query) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const url = query.url;
|
|
||||||
|
|
||||||
if (!url) {
|
|
||||||
return reject(new Error('No URL was specified. Use ?url=$yourURL'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define a request to the server to retrieve the study data
|
|
||||||
// as JSON, given a URL that was in the Route
|
|
||||||
const oReq = new XMLHttpRequest();
|
|
||||||
|
|
||||||
// Add event listeners for request failure
|
|
||||||
oReq.addEventListener('error', error => {
|
|
||||||
log.warn('An error occurred while retrieving the JSON data');
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
// When the JSON has been returned, parse it into a JavaScript Object
|
|
||||||
// and render the OHIF Viewer with this data
|
|
||||||
oReq.addEventListener('load', event => {
|
|
||||||
if (event.target.status === 404) {
|
|
||||||
reject(new Error('No JSON data found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the response content
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText
|
|
||||||
if (!oReq.responseText) {
|
|
||||||
log.warn('Response was undefined');
|
|
||||||
reject(new Error('Response was undefined'));
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info(JSON.stringify(oReq.responseText, null, 2));
|
|
||||||
|
|
||||||
const data = JSON.parse(oReq.responseText);
|
|
||||||
if (data.servers) {
|
|
||||||
if (!query.studyInstanceUIDs) {
|
|
||||||
log.warn('No study instance uids specified');
|
|
||||||
reject(new Error('No study instance uids specified'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const server = data.servers.dicomWeb[0];
|
|
||||||
server.type = 'dicomWeb';
|
|
||||||
|
|
||||||
log.warn('Activating server', server);
|
|
||||||
this.props.activateServer(server);
|
|
||||||
|
|
||||||
const studyInstanceUIDs = query.studyInstanceUIDs.split(';');
|
|
||||||
const seriesInstanceUIDs = query.seriesInstanceUIDs
|
|
||||||
? query.seriesInstanceUIDs.split(';')
|
|
||||||
: [];
|
|
||||||
|
|
||||||
resolve({ server, studyInstanceUIDs, seriesInstanceUIDs });
|
|
||||||
} else {
|
|
||||||
// Parse data here and add to metadata provider.
|
|
||||||
const metadataProvider = OHIF.cornerstone.metadataProvider;
|
|
||||||
|
|
||||||
let StudyInstanceUID;
|
|
||||||
let SeriesInstanceUID;
|
|
||||||
|
|
||||||
data.studies.forEach(study => {
|
|
||||||
StudyInstanceUID = study.StudyInstanceUID;
|
|
||||||
|
|
||||||
study.series.forEach(series => {
|
|
||||||
SeriesInstanceUID = series.SeriesInstanceUID;
|
|
||||||
|
|
||||||
series.instances.forEach(instance => {
|
|
||||||
const { url: imageId, metadata: naturalizedDicom } = instance;
|
|
||||||
|
|
||||||
// Add instance to metadata provider.
|
|
||||||
metadataProvider.addInstance(naturalizedDicom);
|
|
||||||
// Add imageId specific mapping to this data as the URL isn't necessarliy WADO-URI.
|
|
||||||
metadataProvider.addImageIdToUIDs(imageId, {
|
|
||||||
StudyInstanceUID,
|
|
||||||
SeriesInstanceUID,
|
|
||||||
SOPInstanceUID: naturalizedDicom.SOPInstanceUID,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
resolve({ studies: data.studies, studyInstanceUIDs: [] });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Open the Request to the server for the JSON data
|
|
||||||
// In this case we have a server-side route called /api/
|
|
||||||
// which responds to GET requests with the study data
|
|
||||||
log.info(`Sending Request to: ${url}`);
|
|
||||||
oReq.open('GET', url);
|
|
||||||
oReq.setRequestHeader('Accept', 'application/json');
|
|
||||||
|
|
||||||
// Fire the request to the server
|
|
||||||
oReq.send();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
try {
|
|
||||||
let { search } = this.props.location;
|
|
||||||
|
|
||||||
// Remove ? prefix which is included for some reason
|
|
||||||
search = search.slice(1, search.length);
|
|
||||||
const query = qs.parse(search);
|
|
||||||
|
|
||||||
let {
|
|
||||||
server,
|
|
||||||
studies,
|
|
||||||
studyInstanceUIDs,
|
|
||||||
seriesInstanceUIDs,
|
|
||||||
} = await this.parseQueryAndRetrieveDICOMWebData(query);
|
|
||||||
|
|
||||||
if (studies) {
|
|
||||||
const {
|
|
||||||
studies: updatedStudies,
|
|
||||||
studyInstanceUIDs: updatedStudiesInstanceUIDs,
|
|
||||||
} = _mapStudiesToNewFormat(studies);
|
|
||||||
studies = updatedStudies;
|
|
||||||
studyInstanceUIDs = updatedStudiesInstanceUIDs;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
studies,
|
|
||||||
server,
|
|
||||||
studyInstanceUIDs,
|
|
||||||
seriesInstanceUIDs,
|
|
||||||
loading: false,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
this.setState({ error: error.message, loading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const message = this.state.error
|
|
||||||
? `Error: ${JSON.stringify(this.state.error)}`
|
|
||||||
: 'Loading...';
|
|
||||||
if (this.state.error || this.state.loading) {
|
|
||||||
return <NotFound message={message} showGoBackButton={this.state.error} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.state.studies ? (
|
|
||||||
<ConnectedViewer studies={this.state.studies} />
|
|
||||||
) : (
|
|
||||||
<ConnectedViewerRetrieveStudyData
|
|
||||||
studyInstanceUIDs={this.state.studyInstanceUIDs}
|
|
||||||
seriesInstanceUIDs={this.state.seriesInstanceUIDs}
|
|
||||||
server={this.state.server}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _mapStudiesToNewFormat = studies => {
|
|
||||||
studyMetadataManager.purge();
|
|
||||||
|
|
||||||
/* Map studies to new format, update metadata manager? */
|
|
||||||
const uniqueStudyUIDs = new Set();
|
|
||||||
const updatedStudies = studies.map(study => {
|
|
||||||
const studyMetadata = new OHIFStudyMetadata(study, study.StudyInstanceUID);
|
|
||||||
|
|
||||||
const sopClassHandlerModules =
|
|
||||||
extensionManager.modules['sopClassHandlerModule'];
|
|
||||||
study.displaySets =
|
|
||||||
study.displaySets ||
|
|
||||||
studyMetadata.createDisplaySets(sopClassHandlerModules);
|
|
||||||
studyMetadata.setDisplaySets(study.displaySets);
|
|
||||||
|
|
||||||
studyMetadataManager.add(studyMetadata);
|
|
||||||
uniqueStudyUIDs.add(study.StudyInstanceUID);
|
|
||||||
|
|
||||||
return study;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
studies: updatedStudies,
|
|
||||||
studyInstanceUIDs: Array.from(uniqueStudyUIDs),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default StandaloneRouting;
|
|
||||||
@ -1,74 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { utils, user } from '@ohif/core';
|
|
||||||
//
|
|
||||||
import ConnectedViewerRetrieveStudyData from '../connectedComponents/ConnectedViewerRetrieveStudyData';
|
|
||||||
import useServer from '../customHooks/useServer';
|
|
||||||
import useQuery from '../customHooks/useQuery';
|
|
||||||
const { urlUtil: UrlUtil } = utils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get array of seriesUIDs from param or from queryString
|
|
||||||
* @param {*} seriesInstanceUIDs
|
|
||||||
* @param {*} location
|
|
||||||
*/
|
|
||||||
const getSeriesInstanceUIDs = (seriesInstanceUIDs, routeLocation) => {
|
|
||||||
const queryFilters = UrlUtil.queryString.getQueryFilters(routeLocation);
|
|
||||||
const querySeriesUIDs = queryFilters && queryFilters['seriesInstanceUID'];
|
|
||||||
const _seriesInstanceUIDs = seriesInstanceUIDs || querySeriesUIDs;
|
|
||||||
|
|
||||||
return UrlUtil.paramString.parseParam(_seriesInstanceUIDs);
|
|
||||||
};
|
|
||||||
|
|
||||||
function ViewerRouting({ match: routeMatch, location: routeLocation }) {
|
|
||||||
const {
|
|
||||||
project,
|
|
||||||
location,
|
|
||||||
dataset,
|
|
||||||
dicomStore,
|
|
||||||
studyInstanceUIDs,
|
|
||||||
seriesInstanceUIDs,
|
|
||||||
} = routeMatch.params;
|
|
||||||
|
|
||||||
// Set the user's default authToken for outbound DICOMWeb requests.
|
|
||||||
// Is only applied if target server does not set `requestOptions` property.
|
|
||||||
//
|
|
||||||
// See: `getAuthorizationHeaders.js`
|
|
||||||
let query = useQuery();
|
|
||||||
const authToken = query.get('token');
|
|
||||||
|
|
||||||
if (authToken) {
|
|
||||||
user.getAccessToken = () => authToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
const server = useServer({ project, location, dataset, dicomStore });
|
|
||||||
const studyUIDs = UrlUtil.paramString.parseParam(studyInstanceUIDs);
|
|
||||||
const seriesUIDs = getSeriesInstanceUIDs(seriesInstanceUIDs, routeLocation);
|
|
||||||
|
|
||||||
if (server && studyUIDs) {
|
|
||||||
return (
|
|
||||||
<ConnectedViewerRetrieveStudyData
|
|
||||||
studyInstanceUIDs={studyUIDs}
|
|
||||||
seriesInstanceUIDs={seriesUIDs}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewerRouting.propTypes = {
|
|
||||||
match: PropTypes.shape({
|
|
||||||
params: PropTypes.shape({
|
|
||||||
studyInstanceUIDs: PropTypes.string.isRequired,
|
|
||||||
seriesInstanceUIDs: PropTypes.string,
|
|
||||||
dataset: PropTypes.string,
|
|
||||||
dicomStore: PropTypes.string,
|
|
||||||
location: PropTypes.string,
|
|
||||||
project: PropTypes.string,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
location: PropTypes.any,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ViewerRouting;
|
|
||||||
@ -1,135 +0,0 @@
|
|||||||
import asyncComponent from '../components/AsyncComponent.js';
|
|
||||||
|
|
||||||
import OHIF from '@ohif/core';
|
|
||||||
const { urlUtil: UrlUtil } = OHIF.utils;
|
|
||||||
|
|
||||||
// Dynamic Import Routes (CodeSplitting)
|
|
||||||
const IHEInvokeImageDisplay = asyncComponent(() =>
|
|
||||||
import(
|
|
||||||
/* webpackChunkName: "IHEInvokeImageDisplay" */ './IHEInvokeImageDisplay.js'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const ViewerRouting = asyncComponent(() =>
|
|
||||||
import(/* webpackChunkName: "ViewerRouting" */ './ViewerRouting.js')
|
|
||||||
);
|
|
||||||
|
|
||||||
const StudyListRouting = asyncComponent(() =>
|
|
||||||
import(
|
|
||||||
/* webpackChunkName: "StudyListRouting" */ '../studylist/StudyListRouting.js'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const StandaloneRouting = asyncComponent(() =>
|
|
||||||
import(
|
|
||||||
/* webpackChunkName: "ConnectedStandaloneRouting" */ '../connectedComponents/ConnectedStandaloneRouting.js'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const ViewerLocalFileData = asyncComponent(() =>
|
|
||||||
import(
|
|
||||||
/* webpackChunkName: "ViewerLocalFileData" */ '../connectedComponents/ViewerLocalFileData.js'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const reload = () => window.location.reload();
|
|
||||||
|
|
||||||
const ROUTES_DEF = {
|
|
||||||
default: {
|
|
||||||
viewer: {
|
|
||||||
path: '/viewer/:studyInstanceUIDs',
|
|
||||||
component: ViewerRouting,
|
|
||||||
},
|
|
||||||
standaloneViewer: {
|
|
||||||
path: '/viewer',
|
|
||||||
component: StandaloneRouting,
|
|
||||||
},
|
|
||||||
list: {
|
|
||||||
path: ['/studylist', '/'],
|
|
||||||
component: StudyListRouting,
|
|
||||||
condition: appConfig => {
|
|
||||||
return appConfig.showStudyList;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
local: {
|
|
||||||
path: '/local',
|
|
||||||
component: ViewerLocalFileData,
|
|
||||||
},
|
|
||||||
IHEInvokeImageDisplay: {
|
|
||||||
path: '/IHEInvokeImageDisplay',
|
|
||||||
component: IHEInvokeImageDisplay,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
gcloud: {
|
|
||||||
viewer: {
|
|
||||||
path:
|
|
||||||
'/projects/:project/locations/:location/datasets/:dataset/dicomStores/:dicomStore/study/:studyInstanceUIDs',
|
|
||||||
component: ViewerRouting,
|
|
||||||
condition: appConfig => {
|
|
||||||
return !!appConfig.enableGoogleCloudAdapter;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
list: {
|
|
||||||
path:
|
|
||||||
'/projects/:project/locations/:location/datasets/:dataset/dicomStores/:dicomStore',
|
|
||||||
component: StudyListRouting,
|
|
||||||
condition: appConfig => {
|
|
||||||
const showList = appConfig.showStudyList;
|
|
||||||
|
|
||||||
return showList && !!appConfig.enableGoogleCloudAdapter;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const getRoutes = appConfig => {
|
|
||||||
const routes = [];
|
|
||||||
for (let keyConfig in ROUTES_DEF) {
|
|
||||||
const routesConfig = ROUTES_DEF[keyConfig];
|
|
||||||
|
|
||||||
for (let routeKey in routesConfig) {
|
|
||||||
const route = routesConfig[routeKey];
|
|
||||||
const validRoute =
|
|
||||||
typeof route.condition === 'function'
|
|
||||||
? route.condition(appConfig)
|
|
||||||
: true;
|
|
||||||
|
|
||||||
if (validRoute) {
|
|
||||||
routes.push({
|
|
||||||
path: route.path,
|
|
||||||
Component: route.component,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return routes;
|
|
||||||
};
|
|
||||||
|
|
||||||
const parsePath = (path, server, params) => {
|
|
||||||
let _path = path;
|
|
||||||
const _paramsCopy = Object.assign({}, server, params);
|
|
||||||
|
|
||||||
for (let key in _paramsCopy) {
|
|
||||||
_path = UrlUtil.paramString.replaceParam(_path, key, _paramsCopy[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _path;
|
|
||||||
};
|
|
||||||
|
|
||||||
const parseViewerPath = (appConfig = {}, server = {}, params) => {
|
|
||||||
let viewerPath = ROUTES_DEF.default.viewer.path;
|
|
||||||
if (appConfig.enableGoogleCloudAdapter) {
|
|
||||||
viewerPath = ROUTES_DEF.gcloud.viewer.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parsePath(viewerPath, server, params);
|
|
||||||
};
|
|
||||||
|
|
||||||
const parseStudyListPath = (appConfig = {}, server = {}, params) => {
|
|
||||||
let studyListPath = ROUTES_DEF.default.list.path;
|
|
||||||
if (appConfig.enableGoogleCloudAdapter) {
|
|
||||||
studyListPath = ROUTES_DEF.gcloud.list.path || studyListPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parsePath(studyListPath, server, params);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { getRoutes, parseViewerPath, parseStudyListPath, reload };
|
|
||||||
Loading…
Reference in New Issue
Block a user