🧹🧹🧹 Don't mind me. Just moving things around

This commit is contained in:
dannyrb committed 2019-04-15 16:44:36 -04:00
1 parent 9a0d295ee6
commit 72cdebccf4
83 files changed
+479 -38

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
import React from "react";
import PropTypes from "prop-types";
import ViewerRetrieveStudyData from "../connectedComponents/ViewerRetrieveStudyData.js";
function IHEInvokeImageDisplay({ match }) {
const requestType = match.params.query.requestType;
let studyInstanceUids;
//let patientUids;
let displayStudyList = false;
if (requestType === "STUDY") {
studyInstanceUids = match.params.query.studyUID.split(';');
} else if (requestType === "STUDYBASE64") {
const uids = this.params.query.studyUID;
const decodedData = window.atob(uids);
studyInstanceUids = decodedData.split(';');
} else if (requestType === "PATIENT") {
//patientUidspatientUids = this.params.query.patientID.split(';');
displayStudyList = true
} else {
displayStudyList = true
}
if (displayStudyList) {
return ('')//<StudyList patientUids={patientUids}/>);
}
return (
<ViewerRetrieveStudyData studyInstanceUids={studyInstanceUids}/>
);
}
IHEInvokeImageDisplay.propTypes = {
match: PropTypes.shape({
params: PropTypes.shape({
query: PropTypes.shape({
requestType: PropTypes.string.isRequired,
studyUID: PropTypes.string,
patientID: PropTypes.string
})
})
})
};
export default IHEInvokeImageDisplay;
+104
View File
@@ -0,0 +1,104 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import qs from 'query-string'
import Viewer from "../connectedComponents/Viewer";
import OHIF from 'ohif-core';
const { createDisplaySets } = OHIF.utils;
class StandaloneRouting extends Component {
state = {
studies: null,
error: null
}
static propTypes = {
location: PropTypes.object,
store: PropTypes.object
};
static parseQueryAndFetchStudies(query) {
return new Promise((resolve, reject) => {
const url = query.url;
if (!url) {
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) => {
OHIF.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', () => {
// Parse the response content
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText
if (!oReq.responseText) {
OHIF.log.warn('Response was undefined');
reject(new Error('Response was undefined'));
}
OHIF.log.info(JSON.stringify(oReq.responseText, null, 2));
const data = JSON.parse(oReq.responseText);
if (data.servers && query.studyInstanceUids) {
const server = data.servers.dicomWeb[0];
server.type = 'dicomWeb';
const studyInstanceUids = query.studyInstanceUids.split(';');
const seriesInstanceUids = [];
OHIF.studies.retrieveStudiesMetadata(server, studyInstanceUids, seriesInstanceUids).then(studies => {
resolve(studies);
}, error => {
reject(error);
});
} else {
resolve(data.studies);
}
});
// 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
OHIF.log.info(`Sending Request to: ${url}`);
oReq.open('GET', url);
oReq.setRequestHeader('Accept', 'application/json')
// Fire the request to the server
oReq.send();
});
}
componentDidMount() {
const query = qs.parse(this.props.location.search);
StandaloneRouting.parseQueryAndFetchStudies(query).then(studies => {
const updatedStudies = createDisplaySets(studies);
this.setState({ studies: updatedStudies });
}, error => {
this.setState({ error });
});
}
render() {
if (this.state.error) {
return (<div>Error: {JSON.stringify(this.state.error)}</div>);
} else if (!this.state.studies) {
return (<div>Loading...</div>);
}
return (
<Viewer studies={this.state.studies}/>
);
}
}
export default StandaloneRouting;
+32
View File
@@ -0,0 +1,32 @@
import React from "react";
import PropTypes from "prop-types";
import ConnectedViewerRetrieveStudyData from "../connectedComponents/ConnectedViewerRetrieveStudyData";
function ViewerRouting({ match }) {
const { studyInstanceUids, seriesInstanceUids } = match.params;
let studyUIDs;
let seriesUIDs;
if (studyInstanceUids && !seriesInstanceUids) {
studyUIDs = studyInstanceUids.split(';');
} else if (studyInstanceUids && seriesInstanceUids) {
studyUIDs = [match.params.studyInstanceUid];
seriesUIDs = match.params.seriesInstanceUids.split(';');
}
return (
<ConnectedViewerRetrieveStudyData studyInstanceUids={studyUIDs} seriesInstanceUids={seriesUIDs}/>
);
}
ViewerRouting.propTypes = {
match: PropTypes.shape({
params: PropTypes.shape({
studyInstanceUids: PropTypes.string.isRequired,
seriesInstanceUids: PropTypes.string
})
})
};
export default ViewerRouting;
+17
View File
@@ -0,0 +1,17 @@
import IHEInvokeImageDisplay from './IHEInvokeImageDisplay.js';
import StandaloneRouting from './StandaloneRouting.js';
import ViewerRouting from './ViewerRouting.js';
export {
IHEInvokeImageDisplay,
ViewerRouting,
StandaloneRouting
};
const routes = {
IHEInvokeImageDisplay,
ViewerRouting,
StandaloneRouting
};
export default routes;