createStacks --> studyMetadata.createDisplaySets(sopClassHandlerModules)
This commit is contained in:
parent
89b1ce4a4e
commit
29853429c7
@ -1,9 +1,13 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import { metadata, studies, utils } from 'ohif-core';
|
||||||
import OHIF from 'ohif-core';
|
|
||||||
import ConnectedViewer from './ConnectedViewer.js';
|
|
||||||
|
|
||||||
const { createDisplaySets } = OHIF.utils;
|
import ConnectedViewer from './ConnectedViewer.js';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { extensionManager } from './../App.js';
|
||||||
|
|
||||||
|
const { OHIFStudyMetadata } = metadata;
|
||||||
|
const { retrieveStudiesMetadata } = studies;
|
||||||
|
const { studyMetadataManager, updateMetaDataManager } = utils;
|
||||||
|
|
||||||
class ViewerRetrieveStudyData extends Component {
|
class ViewerRetrieveStudyData extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -17,32 +21,55 @@ class ViewerRetrieveStudyData extends Component {
|
|||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
async componentDidMount() {
|
||||||
// TODO: Avoid using timepoints here
|
// TODO: Avoid using timepoints here
|
||||||
//const params = { studyInstanceUids, seriesInstanceUids, timepointId, timepointsFilter={} };
|
//const params = { studyInstanceUids, seriesInstanceUids, timepointId, timepointsFilter={} };
|
||||||
const { studyInstanceUids, seriesInstanceUids, server } = this.props;
|
const { studyInstanceUids, seriesInstanceUids, server } = this.props;
|
||||||
const promise = OHIF.studies.retrieveStudiesMetadata(
|
|
||||||
|
try {
|
||||||
|
const studies = await retrieveStudiesMetadata(
|
||||||
server,
|
server,
|
||||||
studyInstanceUids,
|
studyInstanceUids,
|
||||||
seriesInstanceUids
|
seriesInstanceUids
|
||||||
);
|
);
|
||||||
|
|
||||||
// Render the viewer when the data is ready
|
// Render the viewer when the data is ready
|
||||||
promise
|
// TODO: CLEAR THIS SOMEWHERE ELSE
|
||||||
.then(studies => {
|
studyMetadataManager.purge();
|
||||||
const updatedStudies = createDisplaySets(studies);
|
|
||||||
|
// Map studies to new format, update metadata manager?
|
||||||
|
const updatedStudies = studies.map(study => {
|
||||||
|
const studyMetadata = new OHIFStudyMetadata(
|
||||||
|
study,
|
||||||
|
study.studyInstanceUid
|
||||||
|
);
|
||||||
|
const sopClassHandlerModules =
|
||||||
|
extensionManager.modules['sopClassHandlerModule'];
|
||||||
|
|
||||||
|
study.displaySets =
|
||||||
|
study.displaySets ||
|
||||||
|
studyMetadata.createDisplaySets(sopClassHandlerModules);
|
||||||
|
studyMetadata.setDisplaySets(study.displaySets);
|
||||||
|
|
||||||
|
// Updates WADO-RS metaDataManager
|
||||||
|
updateMetaDataManager(study);
|
||||||
|
|
||||||
|
studyMetadataManager.add(studyMetadata);
|
||||||
|
|
||||||
|
return study;
|
||||||
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
studies: updatedStudies,
|
studies: updatedStudies,
|
||||||
});
|
});
|
||||||
})
|
} catch (err) {
|
||||||
.catch(error => {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true,
|
error: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
throw new Error(error);
|
// TODO: Handle gracefully instead of throwing?
|
||||||
});
|
throw new Error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { OHIF } from 'ohif-core';
|
import { measurements, utils } from 'ohif-core';
|
||||||
|
|
||||||
|
const { MeasurementApi } = measurements;
|
||||||
|
const { studyMetadataManager } = utils;
|
||||||
|
|
||||||
// TODO: Move this function to OHIF itself so we can use it on the OHIF measurment table (when it is finished)
|
// TODO: Move this function to OHIF itself so we can use it on the OHIF measurment table (when it is finished)
|
||||||
|
|
||||||
@ -47,9 +50,7 @@ export default function jumpToRowItem(
|
|||||||
|
|
||||||
let measurement = dataAtThisTimepoint;
|
let measurement = dataAtThisTimepoint;
|
||||||
|
|
||||||
const { tool } = OHIF.measurements.MeasurementApi.getToolConfiguration(
|
const { tool } = MeasurementApi.getToolConfiguration(toolType);
|
||||||
toolType
|
|
||||||
);
|
|
||||||
if (options.childToolKey) {
|
if (options.childToolKey) {
|
||||||
measurement = dataAtThisTimepoint[options.childToolKey];
|
measurement = dataAtThisTimepoint[options.childToolKey];
|
||||||
} else if (Array.isArray(tool.childTools)) {
|
} else if (Array.isArray(tool.childTools)) {
|
||||||
@ -79,7 +80,7 @@ export default function jumpToRowItem(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const study = OHIF.utils.studyMetadataManager.get(data.studyInstanceUid);
|
const study = studyMetadataManager.get(data.studyInstanceUid);
|
||||||
if (!study) {
|
if (!study) {
|
||||||
throw new Error('Study not found.');
|
throw new Error('Study not found.');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import { log, metadata, studies, utils } from 'ohif-core';
|
||||||
import qs from 'querystring';
|
|
||||||
import Viewer from '../connectedComponents/Viewer';
|
|
||||||
import OHIF from 'ohif-core';
|
|
||||||
|
|
||||||
const { createDisplaySets } = OHIF.utils;
|
import PropTypes from 'prop-types';
|
||||||
|
import Viewer from '../connectedComponents/Viewer';
|
||||||
|
import { extensionManager } from './../App.js';
|
||||||
|
import qs from 'querystring';
|
||||||
|
|
||||||
|
const { OHIFStudyMetadata } = metadata;
|
||||||
|
const { retrieveStudiesMetadata } = studies;
|
||||||
|
const { studyMetadataManager, updateMetaDataManager } = utils;
|
||||||
|
|
||||||
class StandaloneRouting extends Component {
|
class StandaloneRouting extends Component {
|
||||||
state = {
|
state = {
|
||||||
@ -31,7 +35,7 @@ class StandaloneRouting extends Component {
|
|||||||
|
|
||||||
// Add event listeners for request failure
|
// Add event listeners for request failure
|
||||||
oReq.addEventListener('error', error => {
|
oReq.addEventListener('error', error => {
|
||||||
OHIF.log.warn('An error occurred while retrieving the JSON data');
|
log.warn('An error occurred while retrieving the JSON data');
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,11 +45,11 @@ class StandaloneRouting extends Component {
|
|||||||
// Parse the response content
|
// Parse the response content
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText
|
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText
|
||||||
if (!oReq.responseText) {
|
if (!oReq.responseText) {
|
||||||
OHIF.log.warn('Response was undefined');
|
log.warn('Response was undefined');
|
||||||
reject(new Error('Response was undefined'));
|
reject(new Error('Response was undefined'));
|
||||||
}
|
}
|
||||||
|
|
||||||
OHIF.log.info(JSON.stringify(oReq.responseText, null, 2));
|
log.info(JSON.stringify(oReq.responseText, null, 2));
|
||||||
|
|
||||||
const data = JSON.parse(oReq.responseText);
|
const data = JSON.parse(oReq.responseText);
|
||||||
if (data.servers && query.studyInstanceUids) {
|
if (data.servers && query.studyInstanceUids) {
|
||||||
@ -55,13 +59,11 @@ class StandaloneRouting extends Component {
|
|||||||
const studyInstanceUids = query.studyInstanceUids.split(';');
|
const studyInstanceUids = query.studyInstanceUids.split(';');
|
||||||
const seriesInstanceUids = [];
|
const seriesInstanceUids = [];
|
||||||
|
|
||||||
OHIF.studies
|
retrieveStudiesMetadata(
|
||||||
.retrieveStudiesMetadata(
|
|
||||||
server,
|
server,
|
||||||
studyInstanceUids,
|
studyInstanceUids,
|
||||||
seriesInstanceUids
|
seriesInstanceUids
|
||||||
)
|
).then(
|
||||||
.then(
|
|
||||||
studies => {
|
studies => {
|
||||||
resolve(studies);
|
resolve(studies);
|
||||||
},
|
},
|
||||||
@ -77,7 +79,7 @@ class StandaloneRouting extends Component {
|
|||||||
// Open the Request to the server for the JSON data
|
// Open the Request to the server for the JSON data
|
||||||
// In this case we have a server-side route called /api/
|
// In this case we have a server-side route called /api/
|
||||||
// which responds to GET requests with the study data
|
// which responds to GET requests with the study data
|
||||||
OHIF.log.info(`Sending Request to: ${url}`);
|
log.info(`Sending Request to: ${url}`);
|
||||||
oReq.open('GET', url);
|
oReq.open('GET', url);
|
||||||
oReq.setRequestHeader('Accept', 'application/json');
|
oReq.setRequestHeader('Accept', 'application/json');
|
||||||
|
|
||||||
@ -86,18 +88,39 @@ class StandaloneRouting extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
async componentDidMount() {
|
||||||
|
try {
|
||||||
const query = qs.parse(this.props.location.search);
|
const query = qs.parse(this.props.location.search);
|
||||||
StandaloneRouting.parseQueryAndFetchStudies(query).then(
|
const studies = await StandaloneRouting.parseQueryAndFetchStudies(query);
|
||||||
studies => {
|
|
||||||
const updatedStudies = createDisplaySets(studies);
|
studyMetadataManager.purge();
|
||||||
|
|
||||||
|
// Map studies to new format, update metadata manager?
|
||||||
|
const updatedStudies = studies.map(study => {
|
||||||
|
const studyMetadata = new OHIFStudyMetadata(
|
||||||
|
study,
|
||||||
|
study.studyInstanceUid
|
||||||
|
);
|
||||||
|
const sopClassHandlerModules =
|
||||||
|
extensionManager.modules['sopClassHandlerModule'];
|
||||||
|
|
||||||
|
study.displaySets =
|
||||||
|
study.displaySets ||
|
||||||
|
studyMetadata.createDisplaySets(sopClassHandlerModules);
|
||||||
|
studyMetadata.setDisplaySets(study.displaySets);
|
||||||
|
|
||||||
|
// Updates WADO-RS metaDataManager
|
||||||
|
updateMetaDataManager(study);
|
||||||
|
|
||||||
|
studyMetadataManager.add(studyMetadata);
|
||||||
|
|
||||||
|
return study;
|
||||||
|
});
|
||||||
|
|
||||||
this.setState({ studies: updatedStudies });
|
this.setState({ studies: updatedStudies });
|
||||||
},
|
} catch (error) {
|
||||||
error => {
|
|
||||||
this.setState({ error });
|
this.setState({ error });
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user