Hydrate our first data source
This commit is contained in:
parent
c3ee59c60e
commit
20dd83e702
@ -1,6 +1,6 @@
|
||||
import { api } from 'dicomweb-client';
|
||||
import { mapParams, search, processResults } from './qido.js';
|
||||
import IWebApi from '@ohif/core';
|
||||
import { IWebApiDataSource } from '@ohif/core';
|
||||
|
||||
/**
|
||||
*
|
||||
@ -22,7 +22,7 @@ function createDicomWebApi(dicomWebConfig) {
|
||||
|
||||
const dicomWebClient = new api.DICOMwebClient(config);
|
||||
|
||||
return IWebApi({
|
||||
return IWebApiDataSource.create({
|
||||
query: {
|
||||
studies: {
|
||||
mapParams: mapParams.bind(),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { api } from 'dicomweb-client';
|
||||
import { mapParams, search, processResults } from './qido.js';
|
||||
import IWebApi from './IWebApi.js';
|
||||
import IWebApiDataSource from './IWebApiDataSource.js';
|
||||
|
||||
/**
|
||||
*
|
||||
@ -22,7 +22,7 @@ function createDicomWebApi(dicomWebConfig) {
|
||||
|
||||
const dicomWebClient = new api.DICOMwebClient(config);
|
||||
|
||||
return IWebApi({
|
||||
return IWebApiDataSource.create({
|
||||
query: {
|
||||
studies: {
|
||||
mapParams: mapParams.bind(),
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
import {dicomMetadataStore} from '@ohif/core';
|
||||
|
||||
/**
|
||||
* Factory function that creates a new "Web API" data source.
|
||||
* A "Web API" data source is any source that fetches data over
|
||||
* HTTP. This function serves as an "adapter" to wrap those calls
|
||||
* so that all "Web API" data sources have the same interface and can
|
||||
* be used interchangeably.
|
||||
*
|
||||
* It's worth noting that a single implementation of this interface
|
||||
* can define different underlying sources for "read" and "write" operations.
|
||||
*/
|
||||
function createWebApiDataSource({ query, retrieve, retrieveMetadata }) {
|
||||
const defaultQuery = {
|
||||
studies: {
|
||||
/**
|
||||
* @param {string} params.patientName
|
||||
* @param {string} params.mrn
|
||||
* @param {object} params.studyDate
|
||||
* @param {string} params.description
|
||||
* @param {string} params.modality
|
||||
* @param {string} params.accession
|
||||
* @param {string} params.sortBy
|
||||
* @param {string} params.sortDirection -
|
||||
* @param {number} params.page
|
||||
* @param {number} params.resultsPerPage
|
||||
*/
|
||||
mapParams: params => params,
|
||||
requestResults: () => {},
|
||||
processResults: results => results,
|
||||
},
|
||||
series: {},
|
||||
instances: {},
|
||||
};
|
||||
|
||||
const defaultRetrieve = {};
|
||||
|
||||
return {
|
||||
query,
|
||||
retrieve: {},
|
||||
retrieveMetadata: retrieveMetadata.bind(null, dicomMetadataStore);
|
||||
// then go get all series level metadata.
|
||||
// Store this in the DICOM MetadataStore.
|
||||
};
|
||||
}
|
||||
|
||||
export { createWebApiDataSource };
|
||||
@ -8,7 +8,7 @@
|
||||
* It's worth noting that a single implementation of this interface
|
||||
* can define different underlying sources for "read" and "write" operations.
|
||||
*/
|
||||
function createWebApiDataSource({ query, retrieve }) {
|
||||
function create({ query, retrieve, retrieveMetadata }) {
|
||||
const defaultQuery = {
|
||||
studies: {
|
||||
/**
|
||||
@ -36,7 +36,14 @@ function createWebApiDataSource({ query, retrieve }) {
|
||||
return {
|
||||
query,
|
||||
retrieve: {},
|
||||
// retrieveMetadata: retrieveMetadata.bind(null, dicomMetadataStore);
|
||||
// then go get all series level metadata.
|
||||
// Store this in the DICOM MetadataStore.
|
||||
};
|
||||
}
|
||||
|
||||
export { createWebApiDataSource };
|
||||
const IWebApiDataSource = {
|
||||
create,
|
||||
};
|
||||
|
||||
export default IWebApiDataSource;
|
||||
|
||||
@ -29,7 +29,7 @@ import {
|
||||
UIViewportDialogService,
|
||||
} from './services';
|
||||
|
||||
import * as IWebApiDataSource from './DataSources/IWebApiDataSource';
|
||||
import IWebApiDataSource from './DataSources/IWebApiDataSource';
|
||||
|
||||
const OHIF = {
|
||||
MODULE_TYPES,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
/* eslint-disable react/jsx-props-no-spreading */
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { MODULE_TYPES } from '@ohif/core';
|
||||
//
|
||||
import { extensionManager } from '../App.js';
|
||||
import { appConfig, extensionManager } from '../App.js';
|
||||
|
||||
/**
|
||||
* Uses route properties to determine the data source that should be passed
|
||||
@ -14,8 +15,39 @@ import { extensionManager } from '../App.js';
|
||||
*/
|
||||
function DataSourceWrapper(props) {
|
||||
const { children: LayoutTemplate, ...rest } = props;
|
||||
console.log('data source wrapper', props);
|
||||
console.log(extensionManager);
|
||||
// TODO: Fetch by type, name, etc?
|
||||
const dataSourceModules = extensionManager.modules[MODULE_TYPES.DATA_SOURCE];
|
||||
// TODO: Good usecase for flatmap?
|
||||
const webApiDataSources = dataSourceModules.reduce((acc, curr) => {
|
||||
const mods = [];
|
||||
curr.module.forEach(mod => {
|
||||
if (mod.type === 'webApi') {
|
||||
mods.push(mod);
|
||||
}
|
||||
});
|
||||
return acc.concat(mods);
|
||||
}, []);
|
||||
|
||||
// Grabbing first for now. This isn't hydrated yet, but we should
|
||||
// hydrate it somewhere based on config...
|
||||
// ~ default.js
|
||||
const firstAppConfigDataSource = appConfig.dataSources[0];
|
||||
const dataSourceConfig = firstAppConfigDataSource.configuration;
|
||||
const firstWebApiDataSource = webApiDataSources[0];
|
||||
const dataSource = firstWebApiDataSource.createDataSource(dataSourceConfig);
|
||||
|
||||
console.log(dataSource, 'dsm');
|
||||
|
||||
// Route props --> studies.mapParams
|
||||
// mapParams --> studies.search
|
||||
// studies.search --> studies.processResults
|
||||
// studies.processResults --> <LayoutTemplate studies={} />
|
||||
// But only for LayoutTemplate type of 'list'?
|
||||
// Or no data fetching here, and just hand down my source
|
||||
|
||||
// const studies = dataSource.query.studies.search();
|
||||
|
||||
// console.log(studies);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user