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.
This commit is contained in:
parent
1d5c1cb83f
commit
9116d08959
@ -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 ''; //<StudyList patientUids={patientUids}/>);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
return <ViewerRetrieveStudyData studyInstanceUids={studyInstanceUids} />;
|
||||
function IHEInvokeImageDisplay({ location }) {
|
||||
const {
|
||||
// patientID,
|
||||
requestType,
|
||||
studyUID,
|
||||
} = getQueryParameters(location);
|
||||
|
||||
switch (requestType) {
|
||||
case 'STUDY':
|
||||
return (
|
||||
<ConnectedViewerRetrieveStudyData
|
||||
studyInstanceUids={studyUID.split(';')}
|
||||
/>
|
||||
);
|
||||
|
||||
case 'STUDYBASE64':
|
||||
return (
|
||||
<ConnectedViewerRetrieveStudyData
|
||||
studyInstanceUids={decodeStudyUids(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 = {
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user