From 9116d0895963d8644311fb88527b15bff4f10ef6 Mon Sep 17 00:00:00 2001 From: David Wire Date: Tue, 11 Jun 2019 11:56:18 -0600 Subject: [PATCH] fix(IHEInvokeImageDisplay): Fix the props to access query parameters per API spec I encountered this bug trying to use the IHEInvokeImageDisplay API in order to render multiple DICOM studies in the viewer. Unfortunately, the component was no longer working and required some changes in order to access the query parameters used in the API. These changes update the component to use react router to access the query parameters and pass them to ConnectedViewerRetrieveStudyData as appropriate. The move from ViewerRetrieveStudyData to ConnectedViewerRetrieveStudyData was necessary in order to access the active server from the redux store. I also made a change from a series of if clauses to a switch statement as it seemed a little more appropriate given the nature of the code paths. Happy to change that back if needed. The PATIENT and default paths were not fixed as a part of this work because we'll need a way to pass the filter in to the StudyList component. --- src/routes/IHEInvokeImageDisplay.js | 80 ++++++++++++++++++----------- 1 file changed, 49 insertions(+), 31 deletions(-) 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);