Files
ohif-viewer/platform/core/src/DataSources/IWebApiDataSource.js
T

83 lines
2.1 KiB
JavaScript
Raw Normal View History

import { DicomMetadataStore } from '../services/DicomMetadataStore';
2020-05-21 16:24:35 -04:00
// TODO: Use above to inject so dependent datasources don't need to import or
// depend on @ohif/core?
2020-05-11 18:56:46 +02:00
2020-05-07 10:56:26 -03:00
/**
* 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.
*/
2020-05-21 16:24:35 -04:00
function create({
query,
retrieve,
store,
reject,
initialize,
2020-06-30 16:10:27 +02:00
deleteStudyMetadataPromise,
2020-05-21 16:24:35 -04:00
getImageIdsForDisplaySet,
getImageIdsForInstance,
getConfig,
2020-05-21 16:24:35 -04:00
}) {
2020-05-07 10:56:26 -03:00
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,
2022-02-08 13:17:37 +00:00
requestResults: () => {},
2020-05-07 10:56:26 -03:00
processResults: results => results,
},
series: {},
instances: {},
};
2020-05-11 18:56:46 +02:00
const defaultRetrieve = {
series: {},
};
2020-05-07 10:56:26 -03:00
const defaultStore = {
dicom: async naturalizedDataset => {
throw new Error(
'store.dicom(naturalizedDicom, StudyInstanceUID) not implemented for dataSource.'
);
},
};
const defaultReject = {};
const defaultGetConfig = () => {
return { dicomUploadEnabled: false };
};
2020-05-07 10:56:26 -03:00
return {
query: query || defaultQuery,
retrieve: retrieve || defaultRetrieve,
reject: reject || defaultReject,
store: store || defaultStore,
initialize,
2020-06-30 16:10:27 +02:00
deleteStudyMetadataPromise,
getImageIdsForDisplaySet,
getImageIdsForInstance,
getConfig: getConfig || defaultGetConfig,
2020-05-07 10:56:26 -03:00
};
}
2020-05-08 00:29:57 -04:00
const IWebApiDataSource = {
create,
};
export default IWebApiDataSource;