Co-authored-by: James Petts <jamesapetts@gmail.com>
This commit is contained in:
parent
2d827c2a49
commit
62a2cd5ff3
@ -2,6 +2,7 @@ import OHIF from '@ohif/core';
|
||||
import {
|
||||
save,
|
||||
getDicomWebClientFromContext,
|
||||
getStudyInstanceUIDFromStudies,
|
||||
getSOPInstanceReferenceFromActiveViewport,
|
||||
getSOPInstanceReferencesFromViewports,
|
||||
} from './utils';
|
||||
@ -41,6 +42,14 @@ export function getCommands(context) {
|
||||
listOfUIDs
|
||||
);
|
||||
},
|
||||
downloadAndZipStudy({ servers, studies, progress }) {
|
||||
const dicomWebClient = getDicomWebClientFromContext(context, servers);
|
||||
const listOfUIDs = getStudyInstanceUIDFromStudies(studies);
|
||||
return save(
|
||||
_downloadAndZip(dicomWebClient, listOfUIDs, { progress }),
|
||||
listOfUIDs
|
||||
);
|
||||
},
|
||||
downloadAndZipSeriesOnViewports({ servers, viewports, progress }) {
|
||||
const dicomWebClient = getDicomWebClientFromContext(context, servers);
|
||||
const listOfUIDs = getSOPInstanceReferencesFromViewports(viewports);
|
||||
@ -64,6 +73,11 @@ export function getCommands(context) {
|
||||
commandFn: queue.bindSafe(actions.downloadAndZip, error),
|
||||
storeContexts: ['servers'],
|
||||
},
|
||||
downloadAndZipStudy: {
|
||||
commandFn: queue.bindSafe(actions.downloadAndZipStudy, error),
|
||||
storeContexts: ['servers', 'studies'],
|
||||
options: { progress },
|
||||
},
|
||||
downloadAndZipSeriesOnViewports: {
|
||||
commandFn: queue.bindSafe(actions.downloadAndZipSeriesOnViewports, error),
|
||||
storeContexts: ['servers', 'viewports'],
|
||||
|
||||
@ -100,11 +100,16 @@ function save(promise, listOfUIDs) {
|
||||
});
|
||||
}
|
||||
|
||||
function getStudyInstanceUIDFromStudies(studies) {
|
||||
return Object.keys(Object(Object(studies).studyData)).slice(0, 1);
|
||||
}
|
||||
|
||||
export {
|
||||
save,
|
||||
validDicomUid,
|
||||
getDicomWebClientFromConfig,
|
||||
getDicomWebClientFromContext,
|
||||
getStudyInstanceUIDFromStudies,
|
||||
getSOPInstanceReferenceFromActiveViewport,
|
||||
getSOPInstanceReferencesFromViewports,
|
||||
};
|
||||
|
||||
@ -13,7 +13,7 @@ const findMostRecentStructuredReport = studies => {
|
||||
// Skip series that may not have instances yet
|
||||
// This can happen if we have retrieved just the initial
|
||||
// details about the series via QIDO-RS, but not the full metadata
|
||||
if (!series.instances.length) {
|
||||
if (!series.instances || !series.instances.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -6,11 +6,12 @@ const defaultState = {
|
||||
|
||||
const servers = (state = defaultState, action) => {
|
||||
switch (action.type) {
|
||||
case 'SET_STUDY_DATA':
|
||||
const updatedStudyData = cloneDeep(state).studyData;
|
||||
updatedStudyData[action.StudyInstanceUID] = action.data;
|
||||
case 'SET_STUDY_DATA': {
|
||||
const updatedStudyData = cloneDeep(state.studyData);
|
||||
updatedStudyData[action.StudyInstanceUID] = cloneDeep(action.data);
|
||||
|
||||
return Object.assign({}, state, { studyData: updatedStudyData });
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||
import ViewerRetrieveStudyData from './ViewerRetrieveStudyData.js';
|
||||
import OHIF from '@ohif/core';
|
||||
|
||||
const { clearViewportSpecificData } = OHIF.redux.actions;
|
||||
const { clearViewportSpecificData, setStudyData } = OHIF.redux.actions;
|
||||
const isActive = a => a.active === true;
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
@ -14,6 +14,9 @@ const mapStateToProps = (state, ownProps) => {
|
||||
};
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
setStudyData: (StudyInstanceUID, data) => {
|
||||
dispatch(setStudyData(StudyInstanceUID, data));
|
||||
},
|
||||
clearViewportSpecificData: () => {
|
||||
dispatch(clearViewportSpecificData());
|
||||
},
|
||||
|
||||
@ -154,11 +154,21 @@ const _sortStudyDisplaySet = (study, studyMetadata) => {
|
||||
studyMetadata.sortDisplaySets(study.displaySets);
|
||||
};
|
||||
|
||||
const _thinStudyData = study => {
|
||||
return {
|
||||
StudyInstanceUID: study.StudyInstanceUID,
|
||||
series: study.series.map(item => ({
|
||||
SeriesInstanceUID: item.SeriesInstanceUID
|
||||
})),
|
||||
}
|
||||
};
|
||||
|
||||
function ViewerRetrieveStudyData({
|
||||
server,
|
||||
studyInstanceUIDs,
|
||||
seriesInstanceUIDs,
|
||||
clearViewportSpecificData,
|
||||
setStudyData,
|
||||
}) {
|
||||
// hooks
|
||||
const [error, setError] = useState(false);
|
||||
@ -220,6 +230,7 @@ function ViewerRetrieveStudyData({
|
||||
if (Array.isArray(studiesData) && studiesData.length > 0) {
|
||||
// Map studies to new format, update metadata manager?
|
||||
const studies = studiesData.map(study => {
|
||||
setStudyData(study.StudyInstanceUID, _thinStudyData(study));
|
||||
const studyMetadata = new OHIFStudyMetadata(
|
||||
study,
|
||||
study.StudyInstanceUID
|
||||
@ -369,6 +380,7 @@ ViewerRetrieveStudyData.propTypes = {
|
||||
seriesInstanceUIDs: PropTypes.array,
|
||||
server: PropTypes.object,
|
||||
clearViewportSpecificData: PropTypes.func.isRequired,
|
||||
setStudyData: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default ViewerRetrieveStudyData;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user