diff --git a/src/routes/IHEInvokeImageDisplay.js b/src/routes/IHEInvokeImageDisplay.js index 450030157..bd1c13d80 100644 --- a/src/routes/IHEInvokeImageDisplay.js +++ b/src/routes/IHEInvokeImageDisplay.js @@ -1,43 +1,61 @@ import React from 'react'; import PropTypes from 'prop-types'; -import ViewerRetrieveStudyData from '../connectedComponents/ViewerRetrieveStudyData.js'; +import { withRouter } from 'react-router-dom'; +import queryString from 'query-string'; +import ConnectedViewerRetrieveStudyData from '../connectedComponents/ConnectedViewerRetrieveStudyData.js'; -function IHEInvokeImageDisplay({ match }) { - const requestType = match.params.query.requestType; - let studyInstanceUids; - //let patientUids; - let displayStudyList = false; +function decodeStudyUids(studyUids) { + const decodedData = window.atob(studyUids); - 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; + return decodedData.split(';'); +} + +function getQueryParameters(location) { + if (location) { + return queryString.parse(location.search); } - if (displayStudyList) { - return ''; //); - } + return {}; +} - return ; +function IHEInvokeImageDisplay({ location }) { + const { + // patientID, + requestType, + studyUID, + } = getQueryParameters(location); + + switch (requestType) { + case 'STUDY': + return ( + + ); + + case 'STUDYBASE64': + return ( + + ); + + case 'PATIENT': + // TODO: connect this to the StudyList when we have the filter parameters set up + // return ; + return ''; + + default: + // TODO: Figure out what to do here, this won't work because StudyList expects studies + // return ; + return ''; + } } IHEInvokeImageDisplay.propTypes = { - match: PropTypes.shape({ - params: PropTypes.shape({ - query: PropTypes.shape({ - requestType: PropTypes.string.isRequired, - studyUID: PropTypes.string, - patientID: PropTypes.string, - }), - }), - }), + location: PropTypes.shape({ + search: PropTypes.string, + }).isRequired, }; -export default IHEInvokeImageDisplay; +export default withRouter(IHEInvokeImageDisplay);