@ohif/extension-default 3.14.0-beta.10 → 3.14.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohif-extension-default.css +1 -1
- package/dist/ohif-extension-default.umd.js +1 -1
- package/package.json +14 -10
- package/src/Actions/createReportAsync.tsx +45 -0
- package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
- package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
- package/src/Components/ItemListComponent.tsx +95 -0
- package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
- package/src/Components/LineChartViewport/index.ts +1 -0
- package/src/Components/MoreDropdownMenu.tsx +112 -0
- package/src/Components/ProgressDropdownWithService.tsx +101 -0
- package/src/Components/SidePanelWithServices.tsx +122 -0
- package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
- package/src/CustomizableContextMenu/index.ts +5 -0
- package/src/CustomizableContextMenu/types.ts +126 -0
- package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
- package/src/DicomJSONDataSource/index.js +326 -0
- package/src/DicomLocalDataSource/index.js +273 -0
- package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
- package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
- package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
- package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
- package/src/DicomWebDataSource/exampleInstances.js +280 -0
- package/src/DicomWebDataSource/index.ts +808 -0
- package/src/DicomWebDataSource/qido.js +215 -0
- package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
- package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
- package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
- package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
- package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
- package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
- package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
- package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
- package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
- package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
- package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
- package/src/DicomWebDataSource/utils/getImageId.js +54 -0
- package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
- package/src/DicomWebDataSource/utils/index.ts +9 -0
- package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
- package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
- package/src/DicomWebProxyDataSource/index.ts +90 -0
- package/src/MergeDataSource/index.test.ts +212 -0
- package/src/MergeDataSource/index.ts +319 -0
- package/src/MergeDataSource/types.ts +46 -0
- package/src/Panels/DataSourceSelector.tsx +55 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
- package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
- package/src/Panels/StudyBrowser/constants/index.ts +4 -0
- package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
- package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
- package/src/Panels/StudyBrowser/types/index.ts +4 -0
- package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
- package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
- package/src/Panels/createReportDialogPrompt.tsx +128 -0
- package/src/Panels/debounce.js +25 -0
- package/src/Panels/getImageSrcFromImageId.js +16 -0
- package/src/Panels/getStudiesForPatientByMRN.js +19 -0
- package/src/Panels/index.js +5 -0
- package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
- package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
- package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
- package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
- package/src/Toolbar/ToolRowWrapper.tsx +41 -0
- package/src/Toolbar/Toolbar.tsx +98 -0
- package/src/Toolbar/ToolbarDivider.tsx +5 -0
- package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
- package/src/Toolbar/index.ts +7 -0
- package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
- package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
- package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
- package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
- package/src/ViewerLayout/ViewerHeader.tsx +124 -0
- package/src/ViewerLayout/constants/panels.ts +42 -0
- package/src/ViewerLayout/index.tsx +227 -0
- package/src/ViewerLayout/useUndoRedoState.ts +75 -0
- package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
- package/src/commandsModule.ts +970 -0
- package/src/customizations/aboutModalCustomization.tsx +42 -0
- package/src/customizations/appearanceModalCustomization.tsx +143 -0
- package/src/customizations/contextMenuCustomization.ts +25 -0
- package/src/customizations/contextMenuUICustomization.ts +5 -0
- package/src/customizations/customRoutesCustomization.ts +6 -0
- package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
- package/src/customizations/datasourcesCustomization.tsx +14 -0
- package/src/customizations/defaultContextMenuCustomization.ts +22 -0
- package/src/customizations/hangingProtocolsCustomization.ts +15 -0
- package/src/customizations/headerRightSideCustomization.ts +19 -0
- package/src/customizations/helloPageCustomization.tsx +14 -0
- package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
- package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
- package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
- package/src/customizations/labellingFlowCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
- package/src/customizations/menuContentCustomization.tsx +67 -0
- package/src/customizations/metadataContextCustomization.test.ts +22 -0
- package/src/customizations/metadataContextCustomization.ts +28 -0
- package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
- package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
- package/src/customizations/multimonitorCustomization.ts +63 -0
- package/src/customizations/notificationCustomization.ts +29 -0
- package/src/customizations/onDropHandlerCustomization.ts +5 -0
- package/src/customizations/onboardingCustomization.ts +200 -0
- package/src/customizations/overlayItemCustomization.tsx +33 -0
- package/src/customizations/progressDropdownCustomization.ts +5 -0
- package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
- package/src/customizations/reportDialogCustomization.test.ts +701 -0
- package/src/customizations/reportDialogCustomization.tsx +661 -0
- package/src/customizations/sortingCriteriaCustomization.ts +14 -0
- package/src/customizations/studyBrowserCustomization.test.ts +69 -0
- package/src/customizations/studyBrowserCustomization.ts +95 -0
- package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
- package/src/customizations/userPreferencesCustomization.tsx +342 -0
- package/src/customizations/workListCustomization.ts +107 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
- package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
- package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
- package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
- package/src/findViewportsByPosition.ts +102 -0
- package/src/getCustomizationModule.tsx +109 -0
- package/src/getDataSourcesModule.js +44 -0
- package/src/getDisplaySetMessages.ts +54 -0
- package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
- package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
- package/src/getHangingProtocolModule.js +155 -0
- package/src/getLayoutTemplateModule.js +28 -0
- package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
- package/src/getPTImageIdInstanceMetadata.ts +124 -0
- package/src/getPanelModule.tsx +29 -0
- package/src/getSopClassHandlerModule.js +152 -0
- package/src/getSopClassHandlerModule.test.js +78 -0
- package/src/getToolbarModule.tsx +63 -0
- package/src/getViewportModule.tsx +12 -0
- package/src/hangingprotocols/hpCompare.ts +189 -0
- package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
- package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
- package/src/hangingprotocols/hpMNGrid.ts +419 -0
- package/src/hangingprotocols/hpMammo.ts +202 -0
- package/src/hangingprotocols/hpScale.ts +132 -0
- package/src/hangingprotocols/index.ts +16 -0
- package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
- package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
- package/src/hangingprotocols/utils/laterality.ts +9 -0
- package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
- package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
- package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
- package/src/hangingprotocols/utils/studySelectors.ts +14 -0
- package/src/hangingprotocols/utils/viewCode.test.js +25 -0
- package/src/hangingprotocols/utils/viewCode.ts +17 -0
- package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
- package/src/hooks/usePatientInfo.tsx +63 -0
- package/src/id.js +5 -0
- package/src/index.ts +113 -0
- package/src/init.ts +169 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/useDisplaySetSelectorStore.ts +83 -0
- package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
- package/src/stores/useToggleHangingProtocolStore.ts +76 -0
- package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
- package/src/stores/useUIStateStore.ts +87 -0
- package/src/stores/useViewportGridStore.ts +89 -0
- package/src/stores/useViewportsByPositionStore.ts +100 -0
- package/src/types/AppTypes.ts +20 -0
- package/src/types/commandModuleTypes.tsx +6 -0
- package/src/utils/Toolbox.tsx +123 -0
- package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
- package/src/utils/addIcon.ts +6 -0
- package/src/utils/appendFrameQueryToImageId.js +9 -0
- package/src/utils/callInputDialog.tsx +126 -0
- package/src/utils/colorPickerDialog.css +4 -0
- package/src/utils/colorPickerDialog.tsx +45 -0
- package/src/utils/createRenderedRetrieve.js +32 -0
- package/src/utils/createRenderedRetrieve.test.js +46 -0
- package/src/utils/dicomWriter.test.ts +228 -0
- package/src/utils/dicomWriter.ts +110 -0
- package/src/utils/getBulkdataValue.js +45 -0
- package/src/utils/getBulkdataValue.test.js +105 -0
- package/src/utils/getDirectURL.test.ts +207 -0
- package/src/utils/getDirectURL.ts +65 -0
- package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/layerConfigurationUtils.ts +202 -0
- package/src/utils/promptLabelAnnotation.js +47 -0
- package/src/utils/promptSaveReport.test.ts +106 -0
- package/src/utils/promptSaveReport.tsx +117 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
- package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
- package/src/utils/registerStoredInstanceImageId.ts +66 -0
- package/src/utils/reuseCachedLayouts.ts +92 -0
- package/src/utils/secureConfigFetch.js +115 -0
- package/src/utils/secureConfigFetch.test.js +163 -0
- package/src/utils/seriesDescriptionHistory.ts +83 -0
- package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
- package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
- package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
- package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
- package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
- package/src/utils/validations/checkMultiframe.ts +25 -0
- package/src/utils/validations/checkSingleFrames.ts +36 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QIDO - Query based on ID for DICOM Objects
|
|
3
|
+
* search for studies, series and instances by patient ID, and receive their
|
|
4
|
+
* unique identifiers for further usage.
|
|
5
|
+
*
|
|
6
|
+
* Quick: https://www.dicomstandard.org/dicomweb/query-qido-rs/
|
|
7
|
+
* Standard: http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6
|
|
8
|
+
*
|
|
9
|
+
* Routes:
|
|
10
|
+
* ==========
|
|
11
|
+
* /studies?
|
|
12
|
+
* /studies/{studyInstanceUid}/series?
|
|
13
|
+
* /studies/{studyInstanceUid}/series/{seriesInstanceUid}/instances?
|
|
14
|
+
*
|
|
15
|
+
* Query Parameters:
|
|
16
|
+
* ================
|
|
17
|
+
* | KEY | VALUE |
|
|
18
|
+
* |------------------|--------------------|
|
|
19
|
+
* | {attributeId} | {value} |
|
|
20
|
+
* | includeField | {attribute} or all |
|
|
21
|
+
* | fuzzymatching | true OR false |
|
|
22
|
+
* | limit | {number} |
|
|
23
|
+
* | offset | {number} |
|
|
24
|
+
*/
|
|
25
|
+
import { DICOMWeb, utils } from '@ohif/core';
|
|
26
|
+
import { sortStudySeries } from '@ohif/core/src/utils/sortStudy';
|
|
27
|
+
|
|
28
|
+
const { getString, getName, getModalities } = DICOMWeb;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parses resulting data from a QIDO call into a set of Study MetaData
|
|
32
|
+
*
|
|
33
|
+
* @param {Array} qidoStudies - An array of study objects. Each object contains a keys for DICOM tags.
|
|
34
|
+
* @param {object} qidoStudies[0].qidoStudy - An object where each key is the DICOM Tag group+element
|
|
35
|
+
* @param {object} qidoStudies[0].qidoStudy[dicomTag] - Optional object that represents DICOM Tag
|
|
36
|
+
* @param {string} qidoStudies[0].qidoStudy[dicomTag].vr - Value Representation
|
|
37
|
+
* @param {string[]} qidoStudies[0].qidoStudy[dicomTag].Value - Optional string array representation of the DICOM Tag's value
|
|
38
|
+
* @returns {Array} An array of Study MetaData objects
|
|
39
|
+
*/
|
|
40
|
+
function processResults(qidoStudies) {
|
|
41
|
+
if (!qidoStudies || !qidoStudies.length) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const studies = [];
|
|
46
|
+
|
|
47
|
+
qidoStudies.forEach(qidoStudy =>
|
|
48
|
+
studies.push({
|
|
49
|
+
studyInstanceUid: getString(qidoStudy['0020000D']),
|
|
50
|
+
date: getString(qidoStudy['00080020']), // YYYYMMDD
|
|
51
|
+
time: getString(qidoStudy['00080030']), // HHmmss.SSS (24-hour, minutes, seconds, fractional seconds)
|
|
52
|
+
accession: getString(qidoStudy['00080050']) || '', // short string, probably a number?
|
|
53
|
+
mrn: getString(qidoStudy['00100020']) || '', // medicalRecordNumber
|
|
54
|
+
patientName: utils.formatPN(getName(qidoStudy['00100010'])) || '',
|
|
55
|
+
patientBirthDate: getString(qidoStudy['00100030']) || '', // YYYYMMDD
|
|
56
|
+
instances: Number(getString(qidoStudy['00201208'])) || 0, // number
|
|
57
|
+
description: getString(qidoStudy['00081030']) || '',
|
|
58
|
+
modalities: getString(getModalities(qidoStudy['00080060'], qidoStudy['00080061'])) || '',
|
|
59
|
+
referringPhysicianName: utils.formatPN(getName(qidoStudy['00080090'])) || '', // Referring Physician's Name
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return studies;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Parses resulting data from a QIDO call into a set of Study MetaData
|
|
68
|
+
*
|
|
69
|
+
* @param {Array} qidoSeries - An array of study objects. Each object contains a keys for DICOM tags.
|
|
70
|
+
* @param {object} qidoSeries[0].qidoSeries - An object where each key is the DICOM Tag group+element
|
|
71
|
+
* @param {object} qidoSeries[0].qidoSeries[dicomTag] - Optional object that represents DICOM Tag
|
|
72
|
+
* @param {string} qidoSeries[0].qidoSeries[dicomTag].vr - Value Representation
|
|
73
|
+
* @param {string[]} qidoSeries[0].qidoSeries[dicomTag].Value - Optional string array representation of the DICOM Tag's value
|
|
74
|
+
* @returns {Array} An array of Study MetaData objects
|
|
75
|
+
*/
|
|
76
|
+
export function processSeriesResults(qidoSeries) {
|
|
77
|
+
const series = [];
|
|
78
|
+
|
|
79
|
+
if (qidoSeries && qidoSeries.length) {
|
|
80
|
+
qidoSeries.forEach(qidoSeries =>
|
|
81
|
+
series.push({
|
|
82
|
+
studyInstanceUid: getString(qidoSeries['0020000D']),
|
|
83
|
+
seriesInstanceUid: getString(qidoSeries['0020000E']),
|
|
84
|
+
modality: getString(qidoSeries['00080060']),
|
|
85
|
+
seriesNumber: getString(qidoSeries['00200011']),
|
|
86
|
+
// The raw DICOM DA value: `sortStudySeries` orders by it and cannot
|
|
87
|
+
// read a date already formatted for display, so it is formatted below,
|
|
88
|
+
// once the order is settled.
|
|
89
|
+
seriesDate: getString(qidoSeries['00080021']),
|
|
90
|
+
numSeriesInstances: Number(getString(qidoSeries['00201209'])),
|
|
91
|
+
description: getString(qidoSeries['0008103E']),
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
sortStudySeries(series);
|
|
97
|
+
|
|
98
|
+
return series.map(result => ({
|
|
99
|
+
...result,
|
|
100
|
+
seriesDate: utils.formatDate(result.seriesDate),
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @param {object} dicomWebClient - Client similar to what's provided by `dicomweb-client` library
|
|
107
|
+
* @param {function} dicomWebClient.searchForStudies -
|
|
108
|
+
* @param {string} [studyInstanceUid]
|
|
109
|
+
* @param {string} [seriesInstanceUid]
|
|
110
|
+
* @param {string} [queryParamaters]
|
|
111
|
+
* @returns {Promise<results>} - Promise that resolves results
|
|
112
|
+
*/
|
|
113
|
+
async function search(dicomWebClient, studyInstanceUid, seriesInstanceUid, queryParameters) {
|
|
114
|
+
let searchResult = await dicomWebClient.searchForStudies({
|
|
115
|
+
studyInstanceUid: undefined,
|
|
116
|
+
queryParams: queryParameters,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return searchResult;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @param {string} studyInstanceUID - ID of study to return a list of series for
|
|
125
|
+
* @returns {Promise} - Resolves SeriesMetadata[] in study
|
|
126
|
+
*/
|
|
127
|
+
export function seriesInStudy(dicomWebClient, studyInstanceUID) {
|
|
128
|
+
// Series Description
|
|
129
|
+
// Already included?
|
|
130
|
+
const commaSeparatedFields = ['0008103E', '00080021'].join(',');
|
|
131
|
+
const queryParams = {
|
|
132
|
+
includefield: commaSeparatedFields,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return dicomWebClient.searchForSeries({ studyInstanceUID, queryParams });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Maps study list search filter items to study-level QIDO query parameters.
|
|
140
|
+
*
|
|
141
|
+
* @param {object} params - Search filter items, for example `patientName` and `startDate`
|
|
142
|
+
* @param {object} [options] - Data source options: `supportsWildcard`, `supportsFuzzyMatching`
|
|
143
|
+
* @returns {object} The query parameters, without undefined or empty values
|
|
144
|
+
*/
|
|
145
|
+
function mapParams(params, options = {}) {
|
|
146
|
+
if (!params) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const commaSeparatedFields = [
|
|
150
|
+
'00081030', // Study Description
|
|
151
|
+
'00080061', // Modalities In Study
|
|
152
|
+
'00080090', // Referring Physician's Name
|
|
153
|
+
'00100030', // Patient's Birth Date
|
|
154
|
+
// Add more fields here if you want them in the result
|
|
155
|
+
].join(',');
|
|
156
|
+
|
|
157
|
+
const useWildcard =
|
|
158
|
+
params?.disableWildcard !== undefined ? !params.disableWildcard : options.supportsWildcard;
|
|
159
|
+
|
|
160
|
+
const withWildcard = value => {
|
|
161
|
+
return useWildcard && value ? `*${value}*` : value;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const parameters = {
|
|
165
|
+
// Named
|
|
166
|
+
PatientName: withWildcard(params.patientName),
|
|
167
|
+
//PatientID: withWildcard(params.patientId),
|
|
168
|
+
'00100020': withWildcard(params.patientId), // Temporarily to make the tests pass with dicomweb-server.. Apparently it's broken?
|
|
169
|
+
AccessionNumber: withWildcard(params.accessionNumber),
|
|
170
|
+
StudyDescription: withWildcard(params.studyDescription),
|
|
171
|
+
ModalitiesInStudy: params.modalitiesInStudy,
|
|
172
|
+
// Other
|
|
173
|
+
limit: params.limit || 101,
|
|
174
|
+
offset: params.offset || 0,
|
|
175
|
+
fuzzymatching: options.supportsFuzzyMatching === true,
|
|
176
|
+
includefield: commaSeparatedFields,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// build the StudyDate range parameter
|
|
180
|
+
if (params.startDate && params.endDate) {
|
|
181
|
+
parameters.StudyDate = `${params.startDate}-${params.endDate}`;
|
|
182
|
+
} else if (params.startDate) {
|
|
183
|
+
const today = new Date();
|
|
184
|
+
const DD = String(today.getDate()).padStart(2, '0');
|
|
185
|
+
const MM = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
|
|
186
|
+
const YYYY = today.getFullYear();
|
|
187
|
+
const todayStr = `${YYYY}${MM}${DD}`;
|
|
188
|
+
|
|
189
|
+
parameters.StudyDate = `${params.startDate}-${todayStr}`;
|
|
190
|
+
} else if (params.endDate) {
|
|
191
|
+
const oldDateStr = `19700102`;
|
|
192
|
+
|
|
193
|
+
parameters.StudyDate = `${oldDateStr}-${params.endDate}`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Build the StudyInstanceUID parameter
|
|
197
|
+
if (params.studyInstanceUid) {
|
|
198
|
+
let studyUids = params.studyInstanceUid;
|
|
199
|
+
studyUids = Array.isArray(studyUids) ? studyUids.join() : studyUids;
|
|
200
|
+
studyUids = studyUids.replace(/[^0-9.]+/g, '\\');
|
|
201
|
+
parameters.StudyInstanceUID = studyUids;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Clean query params of undefined values.
|
|
205
|
+
const final = {};
|
|
206
|
+
Object.keys(parameters).forEach(key => {
|
|
207
|
+
if (parameters[key] !== undefined && parameters[key] !== '') {
|
|
208
|
+
final[key] = parameters[key];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return final;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export { mapParams, search, processResults };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import retrieveBulkData from './retrieveBulkData';
|
|
2
|
+
|
|
3
|
+
describe('retrieveBulkData', () => {
|
|
4
|
+
it('returns and caches a single-part ArrayBuffer response', async () => {
|
|
5
|
+
const buffer = new Uint8Array([1]).buffer;
|
|
6
|
+
const client = {
|
|
7
|
+
retrieveBulkData: jest.fn().mockResolvedValue(buffer),
|
|
8
|
+
};
|
|
9
|
+
const value: { BulkDataURI: string; Value?: ArrayBuffer } = {
|
|
10
|
+
BulkDataURI: 'https://example.com/bulk/70531000',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
await expect(retrieveBulkData.call(client, value)).resolves.toBe(buffer);
|
|
14
|
+
expect(value.Value).toBe(buffer);
|
|
15
|
+
expect(client.retrieveBulkData).toHaveBeenCalledWith(
|
|
16
|
+
expect.objectContaining({
|
|
17
|
+
multipart: false,
|
|
18
|
+
BulkDataURI: value.BulkDataURI,
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('still selects the non-empty buffer from a multipart response', async () => {
|
|
24
|
+
const buffer = new Uint8Array([2]).buffer;
|
|
25
|
+
const client = {
|
|
26
|
+
retrieveBulkData: jest.fn().mockResolvedValue([new ArrayBuffer(0), buffer]),
|
|
27
|
+
};
|
|
28
|
+
const value: { BulkDataURI: string; Value?: ArrayBuffer } = {
|
|
29
|
+
BulkDataURI: 'https://example.com/bulk/70531009',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
await expect(retrieveBulkData.call(client, value)).resolves.toBe(buffer);
|
|
33
|
+
expect(value.Value).toBe(buffer);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bindable function that retrieves bulkdata against `this` DICOMweb client
|
|
3
|
+
* and caches the resolved buffer on the given value element.
|
|
4
|
+
*
|
|
5
|
+
* @param value - A bound value that stores the retrieved buffer.
|
|
6
|
+
* @param options - Options such as the requested content type.
|
|
7
|
+
*/
|
|
8
|
+
export default function retrieveBulkData(value, options = {}) {
|
|
9
|
+
const { mediaType } = options;
|
|
10
|
+
const useOptions = {
|
|
11
|
+
// The bulkdata fetches work with either multipart or singlepart, so set
|
|
12
|
+
// multipart to false to let the server decide which type to respond with.
|
|
13
|
+
multipart: false,
|
|
14
|
+
BulkDataURI: value.BulkDataURI,
|
|
15
|
+
mediaTypes: mediaType ? [{ mediaType }, { mediaType: 'application/octet-stream' }] : undefined,
|
|
16
|
+
...options,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return this.retrieveBulkData(useOptions).then(val => {
|
|
20
|
+
// Single-part clients return a bare ArrayBuffer. Multipart clients return
|
|
21
|
+
// an array; DICOM PDF/video payloads may occupy different positions, so
|
|
22
|
+
// select the first non-empty part in that response shape.
|
|
23
|
+
const ret = Array.isArray(val)
|
|
24
|
+
? val.find(arrayBuffer => arrayBuffer?.byteLength)
|
|
25
|
+
: val?.byteLength
|
|
26
|
+
? val
|
|
27
|
+
: undefined;
|
|
28
|
+
value.Value = ret;
|
|
29
|
+
return ret;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { fetchRenderedURL, getRenderedURL, isTrustedWadoURL } from './retrieveRendered';
|
|
2
|
+
|
|
3
|
+
describe('retrieveRendered', () => {
|
|
4
|
+
const originalFetch = global.fetch;
|
|
5
|
+
const originalCreateObjectURL = URL.createObjectURL;
|
|
6
|
+
const originalRevokeObjectURL = URL.revokeObjectURL;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
global.fetch = jest.fn();
|
|
10
|
+
URL.createObjectURL = jest.fn(() => 'blob:rendered') as jest.Mock;
|
|
11
|
+
URL.revokeObjectURL = jest.fn() as jest.Mock;
|
|
12
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
jest.restoreAllMocks();
|
|
17
|
+
global.fetch = originalFetch;
|
|
18
|
+
URL.createObjectURL = originalCreateObjectURL;
|
|
19
|
+
URL.revokeObjectURL = originalRevokeObjectURL;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns null when there is no resolved URL', async () => {
|
|
23
|
+
const result = await fetchRenderedURL({
|
|
24
|
+
url: undefined,
|
|
25
|
+
wadoRoot: 'https://example.com/dicomweb',
|
|
26
|
+
headers: { Authorization: 'Bearer token' },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(result).toEqual({ url: null });
|
|
30
|
+
expect(global.fetch).not.toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('returns the direct URL without fetching when there is no authorization header', async () => {
|
|
34
|
+
const result = await fetchRenderedURL({
|
|
35
|
+
url: 'https://example.com/dicomweb/rendered',
|
|
36
|
+
wadoRoot: 'https://example.com/dicomweb',
|
|
37
|
+
headers: {},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(result).toEqual({ url: 'https://example.com/dicomweb/rendered' });
|
|
41
|
+
expect(global.fetch).not.toHaveBeenCalled();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('does not attach auth headers to untrusted absolute URLs', async () => {
|
|
45
|
+
const result = await fetchRenderedURL({
|
|
46
|
+
url: 'https://untrusted.example.com/rendered',
|
|
47
|
+
wadoRoot: 'https://example.com/dicomweb',
|
|
48
|
+
headers: { Authorization: 'Bearer token' },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(result).toEqual({ url: 'https://untrusted.example.com/rendered' });
|
|
52
|
+
expect(global.fetch).not.toHaveBeenCalled();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('fetches trusted URLs with auth and returns a revocable object URL', async () => {
|
|
56
|
+
(global.fetch as jest.Mock).mockResolvedValueOnce({
|
|
57
|
+
ok: true,
|
|
58
|
+
blob: jest.fn().mockResolvedValueOnce(new Blob(['pdf'], { type: 'application/pdf' })),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const result = await fetchRenderedURL({
|
|
62
|
+
url: 'https://example.com/dicomweb/studies/1/rendered',
|
|
63
|
+
wadoRoot: 'https://example.com/dicomweb',
|
|
64
|
+
headers: { Authorization: 'Bearer token' },
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
68
|
+
'https://example.com/dicomweb/studies/1/rendered',
|
|
69
|
+
expect.objectContaining({
|
|
70
|
+
method: 'GET',
|
|
71
|
+
headers: { Authorization: 'Bearer token' },
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
expect(result.url).toBe('blob:rendered');
|
|
75
|
+
|
|
76
|
+
result.revoke?.();
|
|
77
|
+
result.revoke?.();
|
|
78
|
+
|
|
79
|
+
expect(URL.revokeObjectURL).toHaveBeenCalledTimes(1);
|
|
80
|
+
expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:rendered');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('returns null and triggers unauthenticated handling on 401/403 responses', async () => {
|
|
84
|
+
const handleUnauthenticated = jest.fn();
|
|
85
|
+
(global.fetch as jest.Mock).mockResolvedValueOnce({
|
|
86
|
+
ok: false,
|
|
87
|
+
status: 401,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const result = await fetchRenderedURL({
|
|
91
|
+
url: 'https://example.com/dicomweb/studies/1/rendered',
|
|
92
|
+
wadoRoot: 'https://example.com/dicomweb',
|
|
93
|
+
headers: { Authorization: 'Bearer token' },
|
|
94
|
+
userAuthenticationService: { handleUnauthenticated },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
expect(result).toEqual({ url: null });
|
|
98
|
+
expect(handleUnauthenticated).toHaveBeenCalledTimes(1);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('revokes an object URL created after the request was aborted', async () => {
|
|
102
|
+
const abortController = new AbortController();
|
|
103
|
+
(global.fetch as jest.Mock).mockResolvedValueOnce({
|
|
104
|
+
ok: true,
|
|
105
|
+
blob: jest.fn().mockImplementationOnce(async () => {
|
|
106
|
+
abortController.abort();
|
|
107
|
+
return new Blob(['pdf'], { type: 'application/pdf' });
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const result = await fetchRenderedURL({
|
|
112
|
+
url: 'https://example.com/dicomweb/studies/1/rendered',
|
|
113
|
+
wadoRoot: 'https://example.com/dicomweb',
|
|
114
|
+
headers: { Authorization: 'Bearer token' },
|
|
115
|
+
signal: abortController.signal,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(result).toEqual({ url: null });
|
|
119
|
+
expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:rendered');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('resolves directURL through the datasource retrieve API', async () => {
|
|
123
|
+
const renderedURL = getRenderedURL({
|
|
124
|
+
config: { wadoRoot: 'https://example.com/dicomweb' },
|
|
125
|
+
getAuthorizationHeader: () => ({}),
|
|
126
|
+
retrieve: {
|
|
127
|
+
directURL: jest.fn().mockResolvedValueOnce('https://example.com/dicomweb/rendered'),
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await expect(renderedURL({ instance: {} })).resolves.toEqual({
|
|
132
|
+
url: 'https://example.com/dicomweb/rendered',
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('trusts URLs that share the configured WADO origin', () => {
|
|
137
|
+
expect(
|
|
138
|
+
isTrustedWadoURL('/dicomweb/studies/1/rendered', `${window.location.origin}/dicomweb`)
|
|
139
|
+
).toBe(true);
|
|
140
|
+
expect(
|
|
141
|
+
isTrustedWadoURL(
|
|
142
|
+
'https://other.example.com/dicomweb/studies/1/rendered',
|
|
143
|
+
'https://example.com/dicomweb'
|
|
144
|
+
)
|
|
145
|
+
).toBe(false);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { HeadersInterface } from '@ohif/core/src/types/RequestHeaders';
|
|
2
|
+
|
|
3
|
+
type RetrieveApi = {
|
|
4
|
+
directURL: (params: unknown) => unknown;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type RenderedURLConfig = {
|
|
8
|
+
wadoRoot?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type UserAuthenticationService = {
|
|
12
|
+
handleUnauthenticated?: () => unknown;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type GetRenderedURLDeps = {
|
|
16
|
+
config: RenderedURLConfig;
|
|
17
|
+
getAuthorizationHeader: () => HeadersInterface;
|
|
18
|
+
retrieve: RetrieveApi;
|
|
19
|
+
userAuthenticationService?: UserAuthenticationService;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type RenderedURLOptions = {
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type FetchRenderedURLOptions = RenderedURLOptions & {
|
|
27
|
+
url?: string | null;
|
|
28
|
+
wadoRoot?: string;
|
|
29
|
+
headers?: HeadersInterface;
|
|
30
|
+
userAuthenticationService?: UserAuthenticationService;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type RenderedURLResult = {
|
|
34
|
+
url: string | null;
|
|
35
|
+
revoke?: () => void;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function getRenderedURL({
|
|
39
|
+
config,
|
|
40
|
+
getAuthorizationHeader,
|
|
41
|
+
retrieve,
|
|
42
|
+
userAuthenticationService,
|
|
43
|
+
}: GetRenderedURLDeps) {
|
|
44
|
+
return async function renderedURL(
|
|
45
|
+
params: unknown,
|
|
46
|
+
options: RenderedURLOptions = {}
|
|
47
|
+
): Promise<RenderedURLResult> {
|
|
48
|
+
const resolvedUrl = (await retrieve.directURL(params)) as string | undefined | null;
|
|
49
|
+
|
|
50
|
+
return fetchRenderedURL({
|
|
51
|
+
url: resolvedUrl,
|
|
52
|
+
wadoRoot: config.wadoRoot,
|
|
53
|
+
headers: getAuthorizationHeader(),
|
|
54
|
+
signal: options.signal,
|
|
55
|
+
userAuthenticationService,
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function fetchRenderedURL({
|
|
61
|
+
url,
|
|
62
|
+
wadoRoot,
|
|
63
|
+
headers,
|
|
64
|
+
signal,
|
|
65
|
+
userAuthenticationService,
|
|
66
|
+
}: FetchRenderedURLOptions): Promise<RenderedURLResult> {
|
|
67
|
+
if (!url || signal?.aborted) {
|
|
68
|
+
return { url: null };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!headers?.Authorization || !isTrustedWadoURL(url, wadoRoot)) {
|
|
72
|
+
return { url };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const response = await fetch(url, {
|
|
77
|
+
method: 'GET',
|
|
78
|
+
headers: headers as Record<string, string>,
|
|
79
|
+
signal,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
if (response.status === 401 || response.status === 403) {
|
|
84
|
+
userAuthenticationService?.handleUnauthenticated?.();
|
|
85
|
+
}
|
|
86
|
+
console.warn(`rendered media fetch failed with status ${response.status}`);
|
|
87
|
+
return { url: null };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const blob = await response.blob();
|
|
91
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
92
|
+
|
|
93
|
+
if (signal?.aborted) {
|
|
94
|
+
URL.revokeObjectURL(objectUrl);
|
|
95
|
+
return { url: null };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
url: objectUrl,
|
|
100
|
+
revoke: createRevokeOnce(objectUrl),
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if ((error as { name?: string })?.name === 'AbortError') {
|
|
104
|
+
return { url: null };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.warn('rendered media fetch failed', error);
|
|
108
|
+
return { url: null };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function isTrustedWadoURL(url: string, wadoRoot?: string): boolean {
|
|
113
|
+
if (!wadoRoot) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
const parsedUrl = new URL(url, window.location.href);
|
|
119
|
+
const parsedWadoRoot = new URL(wadoRoot, window.location.href);
|
|
120
|
+
const isHttpUrl = parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:';
|
|
121
|
+
const isHttpWadoRoot =
|
|
122
|
+
parsedWadoRoot.protocol === 'http:' || parsedWadoRoot.protocol === 'https:';
|
|
123
|
+
|
|
124
|
+
return isHttpUrl && isHttpWadoRoot && parsedUrl.origin === parsedWadoRoot.origin;
|
|
125
|
+
} catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function createRevokeOnce(objectUrl: string) {
|
|
131
|
+
let revoked = false;
|
|
132
|
+
|
|
133
|
+
return () => {
|
|
134
|
+
if (revoked) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
URL.revokeObjectURL(objectUrl);
|
|
139
|
+
revoked = true;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import retrieveMetadataFiltered from './utils/retrieveMetadataFiltered.js';
|
|
2
|
+
import RetrieveMetadata from './wado/retrieveMetadata.js';
|
|
3
|
+
|
|
4
|
+
const moduleName = 'RetrieveStudyMetadata';
|
|
5
|
+
// Cache for promises. Prevents unnecessary subsequent calls to the server
|
|
6
|
+
const StudyMetaDataPromises = new Map();
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves study metadata.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} dicomWebClient The DICOMWebClient instance to be used for series load
|
|
12
|
+
* @param {string} StudyInstanceUID The UID of the Study to be retrieved
|
|
13
|
+
* @param {boolean} enableStudyLazyLoad Whether the study metadata should be loaded asynchronously.
|
|
14
|
+
* @param {Object} [filters] Object containing filters to be applied on retrieve metadata process
|
|
15
|
+
* @param {string} [filters.seriesInstanceUID] Series instance uid to filter results against
|
|
16
|
+
* @param {function} [sortCriteria] Sort criteria function
|
|
17
|
+
* @param {function} [sortFunction] Sort function
|
|
18
|
+
*
|
|
19
|
+
* @returns {Promise} that will be resolved with the metadata or rejected with the error
|
|
20
|
+
*/
|
|
21
|
+
export function retrieveStudyMetadata(
|
|
22
|
+
dicomWebClient,
|
|
23
|
+
StudyInstanceUID,
|
|
24
|
+
enableStudyLazyLoad,
|
|
25
|
+
filters,
|
|
26
|
+
sortCriteria,
|
|
27
|
+
sortFunction,
|
|
28
|
+
dicomWebConfig = {}
|
|
29
|
+
) {
|
|
30
|
+
// @TODO: Whenever a study metadata request has failed, its related promise will be rejected once and for all
|
|
31
|
+
// and further requests for that metadata will always fail. On failure, we probably need to remove the
|
|
32
|
+
// corresponding promise from the "StudyMetaDataPromises" map...
|
|
33
|
+
|
|
34
|
+
if (!dicomWebClient) {
|
|
35
|
+
throw new Error(`${moduleName}: Required 'dicomWebClient' parameter not provided.`);
|
|
36
|
+
}
|
|
37
|
+
if (!StudyInstanceUID) {
|
|
38
|
+
throw new Error(`${moduleName}: Required 'StudyInstanceUID' parameter not provided.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const promiseId = `${dicomWebConfig.name}:${StudyInstanceUID}`;
|
|
42
|
+
|
|
43
|
+
// Already waiting on result? Return cached promise
|
|
44
|
+
if (StudyMetaDataPromises.has(promiseId)) {
|
|
45
|
+
return StudyMetaDataPromises.get(promiseId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let promise;
|
|
49
|
+
|
|
50
|
+
if (filters && filters.seriesInstanceUID && Array.isArray(filters.seriesInstanceUID)) {
|
|
51
|
+
promise = retrieveMetadataFiltered(
|
|
52
|
+
dicomWebClient,
|
|
53
|
+
StudyInstanceUID,
|
|
54
|
+
enableStudyLazyLoad,
|
|
55
|
+
filters,
|
|
56
|
+
sortCriteria,
|
|
57
|
+
sortFunction
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
// Create a promise to handle the data retrieval
|
|
61
|
+
promise = new Promise((resolve, reject) => {
|
|
62
|
+
RetrieveMetadata(
|
|
63
|
+
dicomWebClient,
|
|
64
|
+
StudyInstanceUID,
|
|
65
|
+
enableStudyLazyLoad,
|
|
66
|
+
filters,
|
|
67
|
+
sortCriteria,
|
|
68
|
+
sortFunction
|
|
69
|
+
).then(function (data) {
|
|
70
|
+
resolve(data);
|
|
71
|
+
}, reject);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Store the promise in cache
|
|
76
|
+
StudyMetaDataPromises.set(promiseId, promise);
|
|
77
|
+
|
|
78
|
+
return promise;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Delete the cached study metadata retrieval promise to ensure that the browser will
|
|
83
|
+
* re-retrieve the study metadata when it is next requested.
|
|
84
|
+
*
|
|
85
|
+
* Callers know only the study, so this matches every
|
|
86
|
+
* `<data source name>:<StudyInstanceUID>` key rather than looking the bare UID
|
|
87
|
+
* up as one.
|
|
88
|
+
*
|
|
89
|
+
* @param {String} StudyInstanceUID The UID of the Study to be removed from cache
|
|
90
|
+
*/
|
|
91
|
+
export function deleteStudyMetadataPromise(StudyInstanceUID) {
|
|
92
|
+
if (!StudyInstanceUID) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const suffix = `:${StudyInstanceUID}`;
|
|
97
|
+
|
|
98
|
+
for (const promiseId of [...StudyMetaDataPromises.keys()]) {
|
|
99
|
+
if (promiseId === StudyInstanceUID || promiseId.endsWith(suffix)) {
|
|
100
|
+
StudyMetaDataPromises.delete(promiseId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Test seam: the cached promises, so a test can assert what invalidation removed. */
|
|
106
|
+
export function _getStudyMetadataPromiseCache() {
|
|
107
|
+
return StudyMetaDataPromises;
|
|
108
|
+
}
|