2018-12-14 15:23:48 +01:00
|
|
|
import React, {Component} from "react";
|
|
|
|
|
import PropTypes from "prop-types";
|
2018-12-17 17:23:03 +01:00
|
|
|
import OHIF from 'ohif-core';
|
2018-12-17 22:50:58 +01:00
|
|
|
import Viewer from "./viewer/viewer.js";
|
|
|
|
|
import createDisplaySets from './lib/createDisplaySets.js';
|
2018-12-14 15:23:48 +01:00
|
|
|
|
|
|
|
|
class ViewerFromStudyData extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
studies: null,
|
|
|
|
|
error: null
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
// TODO: Avoid using timepoints here
|
|
|
|
|
//const params = { studyInstanceUids, seriesInstanceUids, timepointId, timepointsFilter={} };
|
2018-12-17 17:23:03 +01:00
|
|
|
const { studyInstanceUids, seriesInstanceUids, server } = this.props;
|
|
|
|
|
const promise = OHIF.studies.retrieveStudiesMetadata(server, studyInstanceUids, seriesInstanceUids)
|
2018-12-14 15:23:48 +01:00
|
|
|
|
|
|
|
|
// Render the viewer when the data is ready
|
2018-12-17 17:23:03 +01:00
|
|
|
promise.then(studies => {
|
2018-12-14 15:23:48 +01:00
|
|
|
const updatedStudies = createDisplaySets(studies);
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
studies: updatedStudies,
|
|
|
|
|
});
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
this.setState({
|
2018-12-17 17:23:03 +01:00
|
|
|
error: true,
|
2018-12-14 15:23:48 +01:00
|
|
|
});
|
2018-12-17 17:23:03 +01:00
|
|
|
|
|
|
|
|
console.error(error);
|
2018-12-14 15:23:48 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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}/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ViewerFromStudyData.propTypes = {
|
|
|
|
|
studyInstanceUids: PropTypes.array.isRequired,
|
2018-12-17 17:23:03 +01:00
|
|
|
seriesInstanceUids: PropTypes.array,
|
|
|
|
|
server: PropTypes.object
|
2018-12-14 15:23:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ViewerFromStudyData;
|