diff --git a/extensions/default/src/DicomWebDataSource/index.js b/extensions/default/src/DicomWebDataSource/index.ts similarity index 83% rename from extensions/default/src/DicomWebDataSource/index.js rename to extensions/default/src/DicomWebDataSource/index.ts index 206df45a51a..6a915c0c351 100644 --- a/extensions/default/src/DicomWebDataSource/index.js +++ b/extensions/default/src/DicomWebDataSource/index.ts @@ -27,46 +27,88 @@ const EXPLICIT_VR_LITTLE_ENDIAN = '1.2.840.10008.1.2.1'; const metadataProvider = classes.MetadataProvider; +export type DicomWebConfig = { + /** Data source name */ + name: string; + // wadoUriRoot - Legacy? (potentially unused/replaced) + /** Base URL to use for QIDO requests */ + qidoRoot?: string; + wadoRoot?: string; // - Base URL to use for WADO requests + wadoUri?: string; // - Base URL to use for WADO URI requests + qidoSupportsIncludeField?: boolean; // - Whether QIDO supports the "Include" option to request additional fields in response + imageRendering?: string; // - wadors | ? (unsure of where/how this is used) + thumbnailRendering?: string; // - wadors | ? (unsure of where/how this is used) + /** Whether the server supports reject calls (i.e. DCM4CHEE) */ + supportsReject?: boolean; + /** Request series meta async instead of blocking */ + lazyLoadStudy?: boolean; + /** indicates if the retrieves can fetch singlepart. Options are bulkdata, video, image, or true */ + singlepart?: boolean | string; + /** Transfer syntax to request from the server */ + requestTransferSyntaxUID?: string; + acceptHeader?: string[]; // - Accept header to use for requests + /** Whether to omit quotation marks for multipart requests */ + omitQuotationForMultipartRequest?: boolean; + /** Whether the server supports fuzzy matching */ + supportsFuzzyMatching?: boolean; + /** Whether the server supports wildcard matching */ + supportsWildcard?: boolean; + /** Whether the server supports the native DICOM model */ + supportsNativeDICOMModel?: boolean; + /** Whether to enable request tag */ + enableRequestTag?: boolean; + /** Whether to enable study lazy loading */ + enableStudyLazyLoad?: boolean; + /** Whether to enable bulkDataURI */ + bulkDataURI?: BulkDataURIConfig; + /** Function that is called after the configuration is initialized */ + onConfiguration: (config: DicomWebConfig, params) => DicomWebConfig; + /** Whether to use the static WADO client */ + staticWado?: boolean; + /** User authentication service */ + userAuthenticationService: Record; +}; + +export type BulkDataURIConfig = { + /** Enable bulkdata uri configuration */ + enabled?: boolean; + /** + * Remove the startsWith string. + * This is used to correct reverse proxied URLs by removing the startsWith path + */ + startsWith?: string; + /** + * Adds this prefix path. Only used if the startsWith is defined and has + * been removed. This allows replacing the base path. + */ + prefixWith?: string; + /** Transform the bulkdata path. Used to replace a portion of the path */ + transform?: (uri: string) => string; + /** + * Adds relative resolution to the path handling. + * series is the default, as the metadata retrieved is series level. + */ + relativeResolution?: 'studies' | 'series'; +}; + /** * Creates a DICOM Web API based on the provided configuration. * - * @param {object} dicomWebConfig - Configuration for the DICOM Web API - * @param {string} dicomWebConfig.name - Data source name - * @param {string} dicomWebConfig.wadoUriRoot - Legacy? (potentially unused/replaced) - * @param {string} dicomWebConfig.qidoRoot - Base URL to use for QIDO requests - * @param {string} dicomWebConfig.wadoRoot - Base URL to use for WADO requests - * @param {string} dicomWebConfig.wadoUri - Base URL to use for WADO URI requests - * @param {boolean} dicomWebConfig.qidoSupportsIncludeField - Whether QIDO supports the "Include" option to request additional fields in response - * @param {string} dicomWebConfig.imageRendering - wadors | ? (unsure of where/how this is used) - * @param {string} dicomWebConfig.thumbnailRendering - wadors | ? (unsure of where/how this is used) - * @param {boolean} dicomWebConfig.supportsReject - Whether the server supports reject calls (i.e. DCM4CHEE) - * @param {boolean} dicomWebConfig.lazyLoadStudy - "enableStudyLazyLoad"; Request series meta async instead of blocking - * @param {string|boolean} dicomWebConfig.singlepart - indicates if the retrieves can fetch singlepart. Options are bulkdata, video, image, or boolean true - * @param {string} dicomWebConfig.requestTransferSyntaxUID - Transfer syntax to request from the server - * @param {object} dicomWebConfig.acceptHeader - Accept header to use for requests - * @param {boolean} dicomWebConfig.omitQuotationForMultipartRequest - Whether to omit quotation marks for multipart requests - * @param {boolean} dicomWebConfig.supportsFuzzyMatching - Whether the server supports fuzzy matching - * @param {boolean} dicomWebConfig.supportsWildcard - Whether the server supports wildcard matching - * @param {boolean} dicomWebConfig.supportsNativeDICOMModel - Whether the server supports the native DICOM model - * @param {boolean} dicomWebConfig.enableStudyLazyLoad - Whether to enable study lazy loading - * @param {boolean} dicomWebConfig.enableRequestTag - Whether to enable request tag - * @param {boolean} dicomWebConfig.enableStudyLazyLoad - Whether to enable study lazy loading - * @param {boolean} dicomWebConfig.bulkDataURI - Whether to enable bulkDataURI - * @param {function} dicomWebConfig.onConfiguration - Function that is called after the configuration is initialized - * @param {boolean} dicomWebConfig.staticWado - Whether to use the static WADO client - * @param {object} userAuthenticationService - User authentication service - * @param {object} userAuthenticationService.getAuthorizationHeader - Function that returns the authorization header - * @returns {object} - DICOM Web API object + * @param dicomWebConfig - Configuration for the DICOM Web API + * @returns DICOM Web API object */ -function createDicomWebApi(dicomWebConfig, servicesManager) { - const { userAuthenticationService, customizationService } = servicesManager.services; +function createDicomWebApi(dicomWebConfig: DicomWebConfig, servicesManager) { + const { userAuthenticationService } = servicesManager.services; let dicomWebConfigCopy, qidoConfig, wadoConfig, qidoDicomWebClient, wadoDicomWebClient, - getAuthrorizationHeader, + getAuthorizationHeader, generateWadoHeader; + // Default to enabling bulk data retrieves, with no other customization as + // this is part of hte base standard. + dicomWebConfig.bulkDataURI ||= { enabled: true }; const implementation = { initialize: ({ params, query }) => { @@ -79,7 +121,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { dicomWebConfigCopy = JSON.parse(JSON.stringify(dicomWebConfig)); - getAuthrorizationHeader = () => { + getAuthorizationHeader = () => { const xhrRequestHeaders = {}; const authHeaders = userAuthenticationService.getAuthorizationHeader(); if (authHeaders && authHeaders.Authorization) { @@ -89,7 +131,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { }; generateWadoHeader = () => { - const authorizationHeader = getAuthrorizationHeader(); + const authorizationHeader = getAuthorizationHeader(); //Generate accept header depending on config params const formattedAcceptHeader = utils.generateAcceptHeader( dicomWebConfig.acceptHeader, @@ -133,7 +175,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { studies: { mapParams: mapParams.bind(), search: async function (origParams) { - qidoDicomWebClient.headers = getAuthrorizationHeader(); + qidoDicomWebClient.headers = getAuthorizationHeader(); const { studyInstanceUid, seriesInstanceUid, ...mappedParams } = mapParams(origParams, { supportsFuzzyMatching: dicomWebConfig.supportsFuzzyMatching, @@ -149,7 +191,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { series: { // mapParams: mapParams.bind(), search: async function (studyInstanceUid) { - qidoDicomWebClient.headers = getAuthrorizationHeader(); + qidoDicomWebClient.headers = getAuthorizationHeader(); const results = await seriesInStudy(qidoDicomWebClient, studyInstanceUid); return processSeriesResults(results); @@ -158,7 +200,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { }, instances: { search: (studyInstanceUid, queryParameters) => { - qidoDicomWebClient.headers = getAuthrorizationHeader(); + qidoDicomWebClient.headers = getAuthorizationHeader(); return qidoSearch.call( undefined, qidoDicomWebClient, @@ -200,7 +242,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { getWadoDicomWebClient: () => wadoDicomWebClient, bulkDataURI: async ({ StudyInstanceUID, BulkDataURI }) => { - qidoDicomWebClient.headers = getAuthrorizationHeader(); + qidoDicomWebClient.headers = getAuthorizationHeader(); const options = { multipart: false, BulkDataURI, @@ -248,7 +290,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) { store: { dicom: async (dataset, request, dicomDict) => { - wadoDicomWebClient.headers = getAuthrorizationHeader(); + wadoDicomWebClient.headers = getAuthorizationHeader(); if (dataset instanceof ArrayBuffer) { const options = { datasets: [dataset], diff --git a/extensions/default/src/getDataSourcesModule.js b/extensions/default/src/getDataSourcesModule.js index cc4aee56fce..85ae2391639 100644 --- a/extensions/default/src/getDataSourcesModule.js +++ b/extensions/default/src/getDataSourcesModule.js @@ -2,9 +2,9 @@ // TODO: Use constructor to create an instance of IWebClientApi // TODO: Use existing DICOMWeb configuration (previously, appConfig, to configure instance) -import { createDicomWebApi } from './DicomWebDataSource/index.js'; -import { createDicomJSONApi } from './DicomJSONDataSource/index.js'; -import { createDicomLocalApi } from './DicomLocalDataSource/index.js'; +import { createDicomWebApi } from './DicomWebDataSource/index'; +import { createDicomJSONApi } from './DicomJSONDataSource/index'; +import { createDicomLocalApi } from './DicomLocalDataSource/index'; import { createDicomWebProxyApi } from './DicomWebProxyDataSource/index'; import { createMergeDataSourceApi } from './MergeDataSource/index'; diff --git a/extensions/default/src/index.ts b/extensions/default/src/index.ts index 90976e04570..3c4577a52f7 100644 --- a/extensions/default/src/index.ts +++ b/extensions/default/src/index.ts @@ -1,16 +1,16 @@ import { Types } from '@ohif/core'; -import getDataSourcesModule from './getDataSourcesModule.js'; -import getLayoutTemplateModule from './getLayoutTemplateModule.js'; +import getDataSourcesModule from './getDataSourcesModule'; +import getLayoutTemplateModule from './getLayoutTemplateModule'; import getPanelModule from './getPanelModule'; -import getSopClassHandlerModule from './getSopClassHandlerModule.js'; +import getSopClassHandlerModule from './getSopClassHandlerModule'; import getToolbarModule from './getToolbarModule'; import getCommandsModule from './commandsModule'; import getHangingProtocolModule from './getHangingProtocolModule'; import getStudiesForPatientByMRN from './Panels/getStudiesForPatientByMRN'; import getCustomizationModule from './getCustomizationModule'; import getViewportModule from './getViewportModule'; -import { id } from './id.js'; +import { id } from './id'; import preRegistration from './init'; import { ContextMenuController, CustomizableContextMenuTypes } from './CustomizableContextMenu'; import * as dicomWebUtils from './DicomWebDataSource/utils'; diff --git a/platform/docs/docs/configuration/dataSources/dicom-web.md b/platform/docs/docs/configuration/dataSources/dicom-web.md index d6fd1ec1c21..5e516e627fb 100644 --- a/platform/docs/docs/configuration/dataSources/dicom-web.md +++ b/platform/docs/docs/configuration/dataSources/dicom-web.md @@ -194,13 +194,14 @@ See the [`singlepart`](#singlepart) data source configuration option. ### BulkDataURI -The `bulkDataURI` configuration option allows the datasource to use the -bulkdata end points for retrieving metadata if originally was not included in the +The `bulkDataURI` configuration option alters how the datasource uses the +bulkdata end points for retrieving metadata if the data was originally not included in the response from the server. This is useful for the metadata information that are big and can/should be retrieved in a separate request. In case the bulkData URI is relative (instead of absolute) the `relativeResolution` option can be used to -specify the resolution of the relative URI. The possible values are `studies`, `series` and `instances`. -Certainly the knowledge of how the server is configured is required to use this option. +specify the resolution of the relative URI. The possible values are `studies`, `series`. + +The default value is shown below (this will be added if not included in the config). ```js bulkDataURI: { @@ -209,6 +210,12 @@ bulkDataURI: { }, ``` +The other options allowed are: + +* transform - to take the string and return an updated string +* startsWith and prefixWith - to remove a standard prefix and add an optional prefix + * Used primarily for a reverse proxy or change in URL naming +* relativeResolution - used to set bulkdata paths to studies resolution for incorrect bulkdata paths ### Running DCM4CHEE diff --git a/platform/docs/docs/platform/extensions/modules/data-source.md b/platform/docs/docs/platform/extensions/modules/data-source.md index aeec72dbaa1..5f682ff9c20 100644 --- a/platform/docs/docs/platform/extensions/modules/data-source.md +++ b/platform/docs/docs/platform/extensions/modules/data-source.md @@ -36,8 +36,8 @@ Default extension provides two main data sources that are commonly used: `dicomweb` and `dicomjson` ```js -import { createDicomWebApi } from './DicomWebDataSource/index.js'; -import { createDicomJSONApi } from './DicomJSONDataSource/index.js'; +import { createDicomWebApi } from './DicomWebDataSource/index'; +import { createDicomJSONApi } from './DicomJSONDataSource/index'; function getDataSourcesModule() { return [ diff --git a/platform/docs/versioned_docs/version-3.9/platform/extensions/modules/data-source.md b/platform/docs/versioned_docs/version-3.9/platform/extensions/modules/data-source.md index 7b7a2d5060c..4bdcf37e6f4 100644 --- a/platform/docs/versioned_docs/version-3.9/platform/extensions/modules/data-source.md +++ b/platform/docs/versioned_docs/version-3.9/platform/extensions/modules/data-source.md @@ -36,8 +36,8 @@ Default extension provides two main data sources that are commonly used: `dicomweb` and `dicomjson` ```js -import { createDicomWebApi } from './DicomWebDataSource/index.js'; -import { createDicomJSONApi } from './DicomJSONDataSource/index.js'; +import { createDicomWebApi } from './DicomWebDataSource/index'; +import { createDicomJSONApi } from './DicomJSONDataSource/index'; function getDataSourcesModule() { return [