feat(react-measurements): Integrate Timepoint API and Measurement API from ohif-core package - WIP
This commit is contained in:
parent
84e2f86a76
commit
13c8599f06
@ -18,6 +18,7 @@ import {
|
|||||||
createUserManager,
|
createUserManager,
|
||||||
reducer as oidcReducer
|
reducer as oidcReducer
|
||||||
} from 'redux-oidc';
|
} from 'redux-oidc';
|
||||||
|
import timepointManager from './redux/timepointManager';
|
||||||
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ const Icons = '/icons.svg';
|
|||||||
const { reducers, localStorage } = OHIF.redux;
|
const { reducers, localStorage } = OHIF.redux;
|
||||||
reducers.ui = ui;
|
reducers.ui = ui;
|
||||||
reducers.oidc = oidcReducer;
|
reducers.oidc = oidcReducer;
|
||||||
|
reducers.timepointManager = timepointManager;
|
||||||
|
|
||||||
const combined = combineReducers(reducers);
|
const combined = combineReducers(reducers);
|
||||||
const store = createStore(combined, localStorage.loadState());
|
const store = createStore(combined, localStorage.loadState());
|
||||||
|
|||||||
@ -33,9 +33,9 @@ function convertMeasurementsToTableData(measurements) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const { timepoints, measurements } = state;
|
const { timepoints, measurements } = state.timepointManager;
|
||||||
return {
|
return {
|
||||||
timepoints: convertTimepointsToTableData(timepoints.timepoints),
|
timepoints: convertTimepointsToTableData(timepoints),
|
||||||
measurementCollection: convertMeasurementsToTableData(measurements)
|
measurementCollection: convertMeasurementsToTableData(measurements)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import Viewer from './Viewer.js';
|
||||||
|
import actions from '../redux/actions.js';
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
onTimepointsUpdated: timepoints => {
|
||||||
|
dispatch(actions.setTimepoints(timepoints));
|
||||||
|
},
|
||||||
|
onMeasurementsUpdated: measurements => {
|
||||||
|
dispatch(actions.setMeasurements(measurements));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConnectedViewer = connect(
|
||||||
|
null,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(Viewer);
|
||||||
|
|
||||||
|
export default ConnectedViewer;
|
||||||
@ -76,7 +76,7 @@ class FlexboxLayout extends Component {
|
|||||||
mainContentClassName += ' sidebar-right-open';
|
mainContentClassName += ' sidebar-right-open';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO[react]: Add measurementLightTable
|
// TODO[react]: Make ConnectedMeasurementTable extension with state.timepointManager
|
||||||
return (
|
return (
|
||||||
<div className="FlexboxLayout">
|
<div className="FlexboxLayout">
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -51,111 +51,120 @@ OHIF.viewer.functionList = {
|
|||||||
|
|
||||||
class Viewer extends Component {
|
class Viewer extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
studies: PropTypes.array
|
studies: PropTypes.array,
|
||||||
|
onTimepointsUpdated: PropTypes.func,
|
||||||
|
onMeasurementsUpdated: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const retrieveMeasurements = (patientId, timepointIds) => {
|
|
||||||
OHIF.log.info('retrieveMeasurements');
|
|
||||||
// TODO: Retrieve the measurements from the latest available SR
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const storeMeasurements = (measurementData, timepointIds) => {
|
|
||||||
OHIF.log.info('storeMeasurements');
|
|
||||||
// TODO: Store the measurements into a new SR sent to the active server
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const retrieveTimepoints = filter => {
|
|
||||||
OHIF.log.info('retrieveTimepoints');
|
|
||||||
|
|
||||||
// Get the earliest and latest study date
|
|
||||||
let earliestDate = new Date().toISOString();
|
|
||||||
let latestDate = new Date().toISOString();
|
|
||||||
if (props.studies) {
|
|
||||||
latestDate = new Date('1000-01-01').toISOString();
|
|
||||||
props.studies.forEach(study => {
|
|
||||||
const studyDate = moment(study.studyDate, 'YYYYMMDD').toISOString();
|
|
||||||
if (studyDate < earliestDate) {
|
|
||||||
earliestDate = studyDate;
|
|
||||||
}
|
|
||||||
if (studyDate > latestDate) {
|
|
||||||
latestDate = studyDate;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a generic timepoint
|
|
||||||
return Promise.resolve([
|
|
||||||
{
|
|
||||||
timepointType: 'baseline',
|
|
||||||
timepointId: 'TimepointId',
|
|
||||||
studyInstanceUids: props.studyInstanceUids,
|
|
||||||
patientId: filter.patientId,
|
|
||||||
earliestDate,
|
|
||||||
latestDate,
|
|
||||||
isLocked: false
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const storeTimepoints = timepointData => {
|
|
||||||
OHIF.log.info('storeTimepoints');
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateTimepoint = (timepointData, query) => {
|
|
||||||
OHIF.log.info('updateTimepoint');
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeTimepoint = timepointId => {
|
|
||||||
OHIF.log.info('removeTimepoint');
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const disassociateStudy = (timepointIds, studyInstanceUid) => {
|
|
||||||
OHIF.log.info('disassociateStudy');
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
OHIF.measurements.MeasurementApi.setConfiguration({
|
OHIF.measurements.MeasurementApi.setConfiguration({
|
||||||
measurementTools,
|
measurementTools,
|
||||||
dataExchange: {
|
dataExchange: {
|
||||||
retrieve: retrieveMeasurements,
|
retrieve: this.retrieveMeasurements,
|
||||||
store: storeMeasurements
|
store: this.storeMeasurements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OHIF.measurements.TimepointApi.setConfiguration({
|
OHIF.measurements.TimepointApi.setConfiguration({
|
||||||
dataExchange: {
|
dataExchange: {
|
||||||
retrieve: retrieveTimepoints,
|
retrieve: this.retrieveTimepoints,
|
||||||
store: storeTimepoints,
|
store: this.storeTimepoints,
|
||||||
remove: removeTimepoint,
|
remove: this.removeTimepoint,
|
||||||
update: updateTimepoint,
|
update: this.updateTimepoint,
|
||||||
disassociate: disassociateStudy
|
disassociate: this.disassociateStudy
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retrieveMeasurements = (patientId, timepointIds) => {
|
||||||
|
OHIF.log.info('retrieveMeasurements');
|
||||||
|
// TODO: Retrieve the measurements from the latest available SR
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
storeMeasurements = (measurementData, timepointIds) => {
|
||||||
|
OHIF.log.info('storeMeasurements');
|
||||||
|
// TODO: Store the measurements into a new SR sent to the active server
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
retrieveTimepoints = filter => {
|
||||||
|
OHIF.log.info('retrieveTimepoints');
|
||||||
|
|
||||||
|
// Get the earliest and latest study date
|
||||||
|
let earliestDate = new Date().toISOString();
|
||||||
|
let latestDate = new Date().toISOString();
|
||||||
|
if (this.props.studies) {
|
||||||
|
latestDate = new Date('1000-01-01').toISOString();
|
||||||
|
this.props.studies.forEach(study => {
|
||||||
|
const studyDate = moment(study.studyDate, 'YYYYMMDD').toISOString();
|
||||||
|
if (studyDate < earliestDate) {
|
||||||
|
earliestDate = studyDate;
|
||||||
|
}
|
||||||
|
if (studyDate > latestDate) {
|
||||||
|
latestDate = studyDate;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a generic timepoint
|
||||||
|
return Promise.resolve([
|
||||||
|
{
|
||||||
|
timepointType: 'baseline',
|
||||||
|
timepointId: 'TimepointId',
|
||||||
|
studyInstanceUids: this.props.studyInstanceUids,
|
||||||
|
patientId: filter.patientId,
|
||||||
|
earliestDate,
|
||||||
|
latestDate,
|
||||||
|
isLocked: false
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
storeTimepoints = timepointData => {
|
||||||
|
OHIF.log.info('storeTimepoints');
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
updateTimepoint = (timepointData, query) => {
|
||||||
|
OHIF.log.info('updateTimepoint');
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
removeTimepoint = timepointId => {
|
||||||
|
OHIF.log.info('removeTimepoint');
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
disassociateStudy = (timepointIds, studyInstanceUid) => {
|
||||||
|
OHIF.log.info('disassociateStudy');
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
onTimepointsUpdated = timepoints => {
|
||||||
|
if (this.props.onTimepointsUpdated) {
|
||||||
|
this.props.onTimepointsUpdated(timepoints);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMeasurementsUpdated = measurements => {
|
||||||
|
if (this.props.onMeasurementsUpdated) {
|
||||||
|
this.props.onMeasurementsUpdated(measurements);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { studies } = this.props;
|
const { studies } = this.props;
|
||||||
const { TimepointApi, MeasurementApi } = OHIF.measurements;
|
const { TimepointApi, MeasurementApi } = OHIF.measurements;
|
||||||
|
|
||||||
// TODO: Get the Redux store from somewhere else
|
const timepointApi = new TimepointApi('TimepointId', {
|
||||||
const { store } = window;
|
onTimepointsUpdated: this.onTimepointsUpdated
|
||||||
|
});
|
||||||
const timepointApi = new TimepointApi(store, 'TimepointId');
|
const measurementApi = new MeasurementApi(timepointApi, {
|
||||||
const measurementApi = new MeasurementApi(store, timepointApi);
|
onMeasurementsUpdated: this.onMeasurementsUpdated
|
||||||
const apis = {
|
});
|
||||||
timepointApi,
|
|
||||||
measurementApi
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.assign(OHIF.viewer, apis);
|
|
||||||
|
|
||||||
const patientId = studies[0] && studies[0].patientId;
|
const patientId = studies[0] && studies[0].patientId;
|
||||||
timepointApi.retrieveTimepoints({ patientId });
|
timepointApi.retrieveTimepoints({ patientId });
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import OHIF from 'ohif-core';
|
import OHIF from 'ohif-core';
|
||||||
import Viewer from './Viewer.js';
|
import ConnectedViewer from './ConnectedViewer.js';
|
||||||
|
|
||||||
const { createDisplaySets } = OHIF.utils;
|
const { createDisplaySets } = OHIF.utils;
|
||||||
|
|
||||||
@ -18,6 +18,8 @@ class ViewerRetrieveStudyData extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
// TODO: Avoid using timepoints here
|
||||||
|
//const params = { studyInstanceUids, seriesInstanceUids, timepointId, timepointsFilter={} };
|
||||||
const { studyInstanceUids, seriesInstanceUids, server } = this.props;
|
const { studyInstanceUids, seriesInstanceUids, server } = this.props;
|
||||||
const promise = OHIF.studies.retrieveStudiesMetadata(
|
const promise = OHIF.studies.retrieveStudiesMetadata(
|
||||||
server,
|
server,
|
||||||
@ -50,7 +52,7 @@ class ViewerRetrieveStudyData extends Component {
|
|||||||
return <div>Loading...</div>;
|
return <div>Loading...</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Viewer studies={this.state.studies} />;
|
return <ConnectedViewer studies={this.state.studies} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,22 @@ export const setUserPreferencesModalOpen = state => ({
|
|||||||
state
|
state
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const setTimepoints = state => ({
|
||||||
|
type: 'SET_TIMEPOINTS',
|
||||||
|
state
|
||||||
|
});
|
||||||
|
|
||||||
|
export const setMeasurements = state => ({
|
||||||
|
type: 'SET_MEASUREMENTS',
|
||||||
|
state
|
||||||
|
});
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
setLeftSidebarOpen,
|
setLeftSidebarOpen,
|
||||||
setRightSidebarOpen,
|
setRightSidebarOpen,
|
||||||
setUserPreferencesModalOpen
|
setUserPreferencesModalOpen,
|
||||||
|
setTimepoints,
|
||||||
|
setMeasurements
|
||||||
};
|
};
|
||||||
|
|
||||||
export default actions;
|
export default actions;
|
||||||
|
|||||||
17
Packages-react/ohif-viewer/src/redux/timepointManager.js
Normal file
17
Packages-react/ohif-viewer/src/redux/timepointManager.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const defaultState = {
|
||||||
|
timepoints: [],
|
||||||
|
measurements: []
|
||||||
|
};
|
||||||
|
|
||||||
|
const timepointManager = (state = defaultState, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'SET_TIMEPOINTS':
|
||||||
|
return Object.assign({}, state, { timepoints: action.state });
|
||||||
|
case 'SET_MEASUREMENTS':
|
||||||
|
return Object.assign({}, state, { measurements: action.state });
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default timepointManager;
|
||||||
Loading…
Reference in New Issue
Block a user