@ohif/extension-default 3.14.0-beta.97 → 3.14.0-beta.99

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.
Files changed (215) hide show
  1. package/dist/ohif-extension-default.umd.js +1 -1
  2. package/package.json +9 -6
  3. package/src/Actions/createReportAsync.tsx +45 -0
  4. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  5. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  6. package/src/Components/ItemListComponent.tsx +95 -0
  7. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  8. package/src/Components/LineChartViewport/index.ts +1 -0
  9. package/src/Components/MoreDropdownMenu.tsx +112 -0
  10. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  11. package/src/Components/SidePanelWithServices.tsx +122 -0
  12. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  13. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  15. package/src/CustomizableContextMenu/index.ts +5 -0
  16. package/src/CustomizableContextMenu/types.ts +126 -0
  17. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  18. package/src/DicomJSONDataSource/index.js +326 -0
  19. package/src/DicomLocalDataSource/index.js +273 -0
  20. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  22. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  23. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  24. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  25. package/src/DicomWebDataSource/index.ts +808 -0
  26. package/src/DicomWebDataSource/qido.js +215 -0
  27. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  29. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  30. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  31. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  33. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  34. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  35. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  36. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  37. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  38. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  40. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  41. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  42. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  43. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  44. package/src/DicomWebDataSource/utils/index.ts +9 -0
  45. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  46. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  50. package/src/DicomWebProxyDataSource/index.ts +90 -0
  51. package/src/MergeDataSource/index.test.ts +212 -0
  52. package/src/MergeDataSource/index.ts +319 -0
  53. package/src/MergeDataSource/types.ts +46 -0
  54. package/src/Panels/DataSourceSelector.tsx +55 -0
  55. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  57. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  58. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  59. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  60. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  62. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  63. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  64. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  65. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  66. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  67. package/src/Panels/debounce.js +25 -0
  68. package/src/Panels/getImageSrcFromImageId.js +16 -0
  69. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  70. package/src/Panels/index.js +5 -0
  71. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  72. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  74. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  75. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  76. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  77. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  78. package/src/Toolbar/Toolbar.tsx +98 -0
  79. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  80. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  81. package/src/Toolbar/index.ts +7 -0
  82. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  84. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  85. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  86. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  87. package/src/ViewerLayout/constants/panels.ts +42 -0
  88. package/src/ViewerLayout/index.tsx +227 -0
  89. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  90. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  91. package/src/commandsModule.ts +970 -0
  92. package/src/customizations/aboutModalCustomization.tsx +42 -0
  93. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  94. package/src/customizations/contextMenuCustomization.ts +25 -0
  95. package/src/customizations/contextMenuUICustomization.ts +5 -0
  96. package/src/customizations/customRoutesCustomization.ts +6 -0
  97. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  98. package/src/customizations/datasourcesCustomization.tsx +14 -0
  99. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  100. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  101. package/src/customizations/headerRightSideCustomization.ts +19 -0
  102. package/src/customizations/helloPageCustomization.tsx +14 -0
  103. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  104. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  105. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  106. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  107. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  109. package/src/customizations/menuContentCustomization.tsx +67 -0
  110. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  111. package/src/customizations/metadataContextCustomization.ts +28 -0
  112. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  113. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  114. package/src/customizations/multimonitorCustomization.ts +63 -0
  115. package/src/customizations/notificationCustomization.ts +29 -0
  116. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  117. package/src/customizations/onboardingCustomization.ts +200 -0
  118. package/src/customizations/overlayItemCustomization.tsx +33 -0
  119. package/src/customizations/progressDropdownCustomization.ts +5 -0
  120. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  121. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  122. package/src/customizations/reportDialogCustomization.tsx +661 -0
  123. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  124. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  125. package/src/customizations/studyBrowserCustomization.ts +95 -0
  126. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  127. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  128. package/src/customizations/workListCustomization.ts +107 -0
  129. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  131. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  132. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  133. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  134. package/src/findViewportsByPosition.ts +102 -0
  135. package/src/getCustomizationModule.tsx +109 -0
  136. package/src/getDataSourcesModule.js +44 -0
  137. package/src/getDisplaySetMessages.ts +54 -0
  138. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  140. package/src/getHangingProtocolModule.js +155 -0
  141. package/src/getLayoutTemplateModule.js +28 -0
  142. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  143. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  144. package/src/getPanelModule.tsx +29 -0
  145. package/src/getSopClassHandlerModule.js +152 -0
  146. package/src/getSopClassHandlerModule.test.js +78 -0
  147. package/src/getToolbarModule.tsx +63 -0
  148. package/src/getViewportModule.tsx +12 -0
  149. package/src/hangingprotocols/hpCompare.ts +189 -0
  150. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  151. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  152. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  153. package/src/hangingprotocols/hpMammo.ts +202 -0
  154. package/src/hangingprotocols/hpScale.ts +132 -0
  155. package/src/hangingprotocols/index.ts +16 -0
  156. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  157. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  158. package/src/hangingprotocols/utils/laterality.ts +9 -0
  159. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  160. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  161. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  162. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  163. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  164. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  165. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  166. package/src/hooks/usePatientInfo.tsx +63 -0
  167. package/src/id.js +5 -0
  168. package/src/index.ts +113 -0
  169. package/src/init.ts +169 -0
  170. package/src/stores/index.ts +7 -0
  171. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  172. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  173. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  174. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  175. package/src/stores/useUIStateStore.ts +87 -0
  176. package/src/stores/useViewportGridStore.ts +89 -0
  177. package/src/stores/useViewportsByPositionStore.ts +100 -0
  178. package/src/types/AppTypes.ts +20 -0
  179. package/src/types/commandModuleTypes.tsx +6 -0
  180. package/src/utils/Toolbox.tsx +123 -0
  181. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  182. package/src/utils/addIcon.ts +6 -0
  183. package/src/utils/appendFrameQueryToImageId.js +9 -0
  184. package/src/utils/callInputDialog.tsx +126 -0
  185. package/src/utils/colorPickerDialog.css +4 -0
  186. package/src/utils/colorPickerDialog.tsx +45 -0
  187. package/src/utils/createRenderedRetrieve.js +32 -0
  188. package/src/utils/createRenderedRetrieve.test.js +46 -0
  189. package/src/utils/dicomWriter.test.ts +228 -0
  190. package/src/utils/dicomWriter.ts +110 -0
  191. package/src/utils/getBulkdataValue.js +45 -0
  192. package/src/utils/getBulkdataValue.test.js +105 -0
  193. package/src/utils/getDirectURL.test.ts +207 -0
  194. package/src/utils/getDirectURL.ts +65 -0
  195. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  196. package/src/utils/index.ts +2 -0
  197. package/src/utils/layerConfigurationUtils.ts +202 -0
  198. package/src/utils/promptLabelAnnotation.js +47 -0
  199. package/src/utils/promptSaveReport.test.ts +106 -0
  200. package/src/utils/promptSaveReport.tsx +117 -0
  201. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  203. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  204. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  205. package/src/utils/reuseCachedLayouts.ts +92 -0
  206. package/src/utils/secureConfigFetch.js +115 -0
  207. package/src/utils/secureConfigFetch.test.js +163 -0
  208. package/src/utils/seriesDescriptionHistory.ts +83 -0
  209. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  210. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  212. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  213. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  214. package/src/utils/validations/checkMultiframe.ts +25 -0
  215. package/src/utils/validations/checkSingleFrames.ts +36 -0
@@ -0,0 +1,12 @@
1
+ import type { actionIcon } from '../types/actionsIcon';
2
+
3
+ const defaultActionIcons = [
4
+ {
5
+ id: 'settings',
6
+ iconName: 'Settings',
7
+ label: 'Sort and filter series',
8
+ value: false,
9
+ },
10
+ ] as actionIcon[];
11
+
12
+ export { defaultActionIcons };
@@ -0,0 +1,4 @@
1
+ import { defaultActionIcons } from './actionIcons';
2
+ import { defaultViewPresets } from './viewPresets';
3
+
4
+ export { defaultActionIcons, defaultViewPresets };
@@ -0,0 +1,16 @@
1
+ import type { viewPreset } from '../types/viewPreset';
2
+
3
+ const defaultViewPresets = [
4
+ {
5
+ id: 'list',
6
+ iconName: 'ListView',
7
+ selected: false,
8
+ },
9
+ {
10
+ id: 'thumbnails',
11
+ iconName: 'ThumbnailView',
12
+ selected: true,
13
+ },
14
+ ] as viewPreset[];
15
+
16
+ export { defaultViewPresets };
@@ -0,0 +1,197 @@
1
+ import { utils } from '@ohif/core';
2
+ import { resolveThumbnailDetails } from './resolveThumbnailDetails';
3
+ import thumbnailDetailsCustomization, {
4
+ thumbnailDetailSources,
5
+ thumbnailDetailTests,
6
+ } from '../../customizations/thumbnailDetailsCustomization';
7
+
8
+ const { formatDate, formatTime } = utils;
9
+
10
+ const defaultItems = thumbnailDetailsCustomization['studyBrowser.thumbnailDetails'];
11
+
12
+ const resolve = (items, displaySet) =>
13
+ resolveThumbnailDetails({
14
+ items,
15
+ displaySet,
16
+ sources: thumbnailDetailSources,
17
+ tests: thumbnailDetailTests,
18
+ formatters: { formatDate, formatTime },
19
+ });
20
+
21
+ const displaySet = (overrides = {}) => ({
22
+ displaySetInstanceUID: 'ds1',
23
+ SeriesNumber: 5,
24
+ SeriesDate: '20260817',
25
+ SeriesTime: '090000',
26
+ instances: [{}, {}, {}],
27
+ instance: { SeriesDate: '20260817', SeriesTime: '090000' },
28
+ ...overrides,
29
+ });
30
+
31
+ describe('resolveThumbnailDetails', () => {
32
+ // The thumbnails have always shown the series number and the instance count,
33
+ // so that is what the default items have to come to.
34
+ it('defaults to the series number and the instance count', () => {
35
+ expect(resolve(defaultItems, displaySet())).toEqual([
36
+ { id: 'SeriesNumber', label: 'S:', title: '', value: '5', iconName: undefined },
37
+ { id: 'InstanceCount', label: '', title: '', value: '3', iconName: 'InfoSeries' },
38
+ ]);
39
+ });
40
+
41
+ it('uses the display set count icon when it has one', () => {
42
+ const [, count] = resolve(defaultItems, displaySet({ countIcon: 'icon-mpr' }));
43
+
44
+ expect(count.iconName).toBe('icon-mpr');
45
+ });
46
+
47
+ it('counts a multiframe display set by its frames', () => {
48
+ const [, count] = resolve(defaultItems, displaySet({ numImageFrames: 60 }));
49
+
50
+ expect(count.value).toBe('60');
51
+ });
52
+
53
+ it('takes a value from a named source', () => {
54
+ const items = [{ id: 'SeriesDate', label: '', source: 'seriesDate' }];
55
+
56
+ expect(resolve(items, displaySet())[0].value).toBe(formatDate('20260817'));
57
+ });
58
+
59
+ it('takes a value from a source function', () => {
60
+ const items = [{ id: 'Modality', contentF: ({ displaySet }) => displaySet.Modality }];
61
+
62
+ expect(resolve(items, displaySet({ Modality: 'SEG' }))[0].value).toBe('SEG');
63
+ });
64
+
65
+ it('takes a value from an attribute of the instance the display set shows', () => {
66
+ const items = [{ id: 'SOPInstanceUID', attribute: 'SOPInstanceUID' }];
67
+ const ds = displaySet({ instance: { SOPInstanceUID: '1.2.3.4' } });
68
+
69
+ expect(resolve(items, ds)[0].value).toBe('1.2.3.4');
70
+ });
71
+
72
+ // With no items at all - no customization was resolved - the thumbnail has to
73
+ // be left showing the default detail line it stands alone with, which an
74
+ // empty array would replace with an empty line.
75
+ it('resolves to nothing when there are no items to resolve', () => {
76
+ expect(resolve(undefined, displaySet())).toBeUndefined();
77
+ expect(resolve([], displaySet())).toEqual([]);
78
+ });
79
+
80
+ it('leaves out an item with no value', () => {
81
+ const items = [{ id: 'SeriesDate', source: 'seriesDate' }];
82
+
83
+ expect(resolve(items, displaySet({ SeriesDate: undefined, instance: {} }))).toEqual([]);
84
+ });
85
+
86
+ // A `studyBrowser.thumbnailDetailSources` override written with `$set` rather
87
+ // than `$merge` takes the sources the default items name away with it. That
88
+ // must not blank the series number and instance count on every thumbnail, so
89
+ // a line left empty only by names that could not be resolved is not honoured
90
+ // as an empty line - the thumbnail keeps the default one it stands alone with.
91
+ it('resolves to nothing when nothing was left after an unresolved name', () => {
92
+ jest.spyOn(console, 'warn').mockImplementation(() => {});
93
+
94
+ expect(
95
+ resolveThumbnailDetails({
96
+ items: defaultItems,
97
+ displaySet: displaySet(),
98
+ sources: { somethingElse: () => 'x' },
99
+ tests: thumbnailDetailTests,
100
+ formatters: { formatDate, formatTime },
101
+ })
102
+ ).toBeUndefined();
103
+ expect(console.warn).toHaveBeenCalled();
104
+ });
105
+
106
+ // The same broken customization is resolved for every item of every
107
+ // thumbnail, and again on every re-map, so a report on each of them buries
108
+ // the console under thousands of identical lines while a study loads.
109
+ it('reports an unresolved name once', () => {
110
+ const items = [{ id: 'ReportedOnce', source: 'noSuchSourceReportedOnce' }];
111
+ jest.spyOn(console, 'warn').mockImplementation(() => {});
112
+ (console.warn as jest.Mock).mockClear();
113
+
114
+ resolve(items, displaySet());
115
+ resolve(items, displaySet());
116
+ resolve(items, displaySet({ displaySetInstanceUID: 'ds2' }));
117
+
118
+ expect(console.warn).toHaveBeenCalledTimes(1);
119
+ });
120
+
121
+ describe('condition', () => {
122
+ const items = [
123
+ { id: 'InstanceDateTime', source: 'instanceDateTime', condition: 'isDerivedDisplaySet' },
124
+ ];
125
+
126
+ it('includes the item when a named test passes', () => {
127
+ const ds = displaySet({ isDerivedDisplaySet: true });
128
+
129
+ expect(resolve(items, ds).map(detail => detail.id)).toEqual(['InstanceDateTime']);
130
+ });
131
+
132
+ it('leaves the item out when a named test fails', () => {
133
+ expect(resolve(items, displaySet({ isDerivedDisplaySet: false }))).toEqual([]);
134
+ });
135
+
136
+ it('leaves the item out when it names a test that is not registered', () => {
137
+ const unknown = [
138
+ { id: 'X', source: 'seriesNumber', condition: 'noSuchTest' },
139
+ { id: 'SeriesDate', source: 'seriesDate' },
140
+ ];
141
+ jest.spyOn(console, 'warn').mockImplementation(() => {});
142
+
143
+ expect(resolve(unknown, displaySet()).map(detail => detail.id)).toEqual(['SeriesDate']);
144
+ expect(console.warn).toHaveBeenCalled();
145
+ });
146
+
147
+ it('accepts a test function', () => {
148
+ const withFunction = [
149
+ {
150
+ id: 'X',
151
+ source: 'seriesNumber',
152
+ condition: ({ displaySet }) => displaySet.SeriesNumber > 9,
153
+ },
154
+ ];
155
+
156
+ expect(resolve(withFunction, displaySet({ SeriesNumber: 10 }))).toHaveLength(1);
157
+ expect(resolve(withFunction, displaySet({ SeriesNumber: 5 }))).toHaveLength(0);
158
+ });
159
+ });
160
+
161
+ describe('instanceDateTime source', () => {
162
+ const items = [{ id: 'InstanceDateTime', source: 'instanceDateTime' }];
163
+
164
+ // A report saved into an existing series keeps that series' date and time,
165
+ // so the date shown has to be the one of the instance the display set shows
166
+ // - which is also the one the series list is sorted by.
167
+ it('reports the creation date/time of the instance, not the series one', () => {
168
+ const ds = displaySet({
169
+ instance: {
170
+ SeriesDate: '20260817',
171
+ SeriesTime: '090000',
172
+ ContentDate: '20260819',
173
+ ContentTime: '143012',
174
+ },
175
+ });
176
+
177
+ expect(resolve(items, ds)[0].value).toBe(`${formatDate('20260819')} 14:30`);
178
+ });
179
+
180
+ // Nothing below minutes: the second a report was written is noise.
181
+ it('shows no seconds', () => {
182
+ expect(resolve(items, displaySet())[0].value).toBe(`${formatDate('20260817')} 09:00`);
183
+ });
184
+
185
+ it('shows the date alone when the instance has no time', () => {
186
+ const ds = displaySet({ instance: { SeriesDate: '20260817' } });
187
+
188
+ expect(resolve(items, ds)[0].value).toBe(formatDate('20260817'));
189
+ });
190
+
191
+ it('falls back to the display set when it has no instance', () => {
192
+ const ds = displaySet({ instance: undefined });
193
+
194
+ expect(resolve(items, ds)[0].value).toBe(`${formatDate('20260817')} 09:00`);
195
+ });
196
+ });
197
+ });
@@ -0,0 +1,132 @@
1
+ import { utils } from '@ohif/core';
2
+
3
+ const { formatValue } = utils;
4
+
5
+ export type ThumbnailDetail = {
6
+ id: string;
7
+ label: string;
8
+ title: string;
9
+ value: string;
10
+ iconName?: string;
11
+ };
12
+
13
+ type ResolveOptions = {
14
+ /** `studyBrowser.thumbnailDetails` - the items to include. */
15
+ items;
16
+ displaySet;
17
+ /** `studyBrowser.thumbnailDetailSources` - named value sources. */
18
+ sources?: Record<string, (props) => unknown>;
19
+ /** `studyBrowser.thumbnailDetailTests` - named `condition` tests. */
20
+ tests?: Record<string, (props) => boolean>;
21
+ formatters;
22
+ };
23
+
24
+ /**
25
+ * The `<kind> "<value>"` names already reported by {@link resolveThumbnailDetails}.
26
+ *
27
+ * A broken customization is broken for every item of every thumbnail, and the
28
+ * details are re-resolved on each re-map, so the same name would otherwise be
29
+ * reported thousands of times while a large study loads. One report per name
30
+ * says everything the developer needs, so the rest are dropped.
31
+ */
32
+ const reportedNames = new Set<string>();
33
+
34
+ /**
35
+ * Builds the detail line of a study browser thumbnail from the
36
+ * `studyBrowser.thumbnailDetails` items, in the order they are declared.
37
+ *
38
+ * Each item contributes its value, taken from its own `contentF`, from a named
39
+ * `source`, or from an `attribute` of the instance the display set shows - the
40
+ * same three ways the viewport overlay items get theirs. An item whose
41
+ * `condition` says no, or which has no value to show, is left out.
42
+ *
43
+ * Returns `undefined` when there are no items to resolve at all, which leaves
44
+ * the thumbnail showing the default detail line it stands alone with. An empty
45
+ * `items` is a customization asking for an empty line, and is honoured as one.
46
+ *
47
+ * A line that came out empty only because the names it used could not be
48
+ * resolved is a broken customization rather than a request for an empty line -
49
+ * an override of `studyBrowser.thumbnailDetailSources` written with `$set`
50
+ * removes the sources the default items name - so that too is returned as
51
+ * `undefined`, leaving every thumbnail its default detail line instead of
52
+ * blanking the series number and instance count on all of them.
53
+ */
54
+ export function resolveThumbnailDetails({
55
+ items,
56
+ displaySet,
57
+ sources,
58
+ tests,
59
+ formatters,
60
+ }: ResolveOptions): ThumbnailDetail[] | undefined {
61
+ if (!Array.isArray(items)) {
62
+ return undefined;
63
+ }
64
+
65
+ const props = { displaySet, instance: displaySet?.instance, formatters };
66
+ const details: ThumbnailDetail[] = [];
67
+ let hasUnresolvedName = false;
68
+
69
+ /** A `condition` / `source` that is a name resolves against a registry. */
70
+ const resolveNamed = (value, registry, kind: string, id: string) => {
71
+ if (typeof value !== 'string') {
72
+ return value;
73
+ }
74
+ const named = registry?.[value];
75
+ if (!named) {
76
+ const reportKey = `${id}|${kind}|${value}`;
77
+ if (!reportedNames.has(reportKey)) {
78
+ reportedNames.add(reportKey);
79
+ console.warn(`Thumbnail detail item "${id}" names an unknown ${kind} "${value}"`);
80
+ }
81
+ hasUnresolvedName = true;
82
+ }
83
+ return named;
84
+ };
85
+
86
+ for (const item of items) {
87
+ if (!item) {
88
+ continue;
89
+ }
90
+ const { id, condition, contentF, source, attribute, iconName } = item;
91
+
92
+ if (condition !== undefined) {
93
+ const test = resolveNamed(condition, tests, 'condition', id);
94
+ if (typeof test !== 'function' || !test(props)) {
95
+ continue;
96
+ }
97
+ }
98
+
99
+ let value;
100
+ if (typeof contentF === 'function') {
101
+ value = contentF(props);
102
+ } else if (source !== undefined) {
103
+ const sourceF = resolveNamed(source, sources, 'source', id);
104
+ value = typeof sourceF === 'function' ? sourceF(props) : undefined;
105
+ } else if (attribute) {
106
+ value = props.instance?.[attribute];
107
+ }
108
+
109
+ const displayValue = formatValue(value);
110
+ if (!displayValue) {
111
+ continue;
112
+ }
113
+
114
+ const icon = typeof iconName === 'function' ? iconName(props) : iconName;
115
+
116
+ details.push({
117
+ id,
118
+ label: item.label ?? '',
119
+ title: item.title ?? '',
120
+ value: displayValue,
121
+ iconName: icon || undefined,
122
+ });
123
+ }
124
+
125
+ if (!details.length && hasUnresolvedName) {
126
+ return undefined;
127
+ }
128
+
129
+ return details;
130
+ }
131
+
132
+ export default resolveThumbnailDetails;
@@ -0,0 +1,9 @@
1
+ type actionIcon = {
2
+ id: string;
3
+ iconName: string;
4
+ value: boolean;
5
+ /** StudyBrowser translation key shown as the icon's tooltip. */
6
+ label?: string;
7
+ };
8
+
9
+ export type { actionIcon };
@@ -0,0 +1,4 @@
1
+ import type { actionIcon } from './actionIcon';
2
+ import type { viewPreset } from './viewPreset';
3
+
4
+ export type { actionIcon, viewPreset };
@@ -0,0 +1,7 @@
1
+ type viewPreset = {
2
+ id: string;
3
+ iconName: string;
4
+ selected: boolean;
5
+ };
6
+
7
+ export type { viewPreset };
@@ -0,0 +1,61 @@
1
+ import PanelStudyBrowser from './StudyBrowser/PanelStudyBrowser';
2
+ import getImageSrcFromImageId from './getImageSrcFromImageId';
3
+ import getStudiesForPatientByMRN from './getStudiesForPatientByMRN';
4
+ import requestDisplaySetCreationForStudy from './requestDisplaySetCreationForStudy';
5
+ import { useSystem } from '@ohif/core';
6
+
7
+ /**
8
+ * Wraps the PanelStudyBrowser and provides features afforded by managers/services
9
+ *
10
+ * @param {object} params
11
+ * @param {object} commandsManager
12
+ * @param {object} extensionManager
13
+ */
14
+ function WrappedPanelStudyBrowser() {
15
+ const { extensionManager } = useSystem();
16
+ // TODO: This should be made available a different way; route should have
17
+ // already determined our datasource
18
+ const [dataSource] = extensionManager.getActiveDataSource();
19
+ const _getStudiesForPatientByMRN = getStudiesForPatientByMRN.bind(null, dataSource);
20
+ // Plain call: the React Compiler caches this keyed on extensionManager (a
21
+ // stable service), so it runs once and keeps a stable identity — what the
22
+ // old useCallback(fn(), []) wanted, but analyzable and correctly keyed.
23
+ const _getImageSrcFromImageId = _createGetImageSrcFromImageIdFn(extensionManager);
24
+ const _requestDisplaySetCreationForStudy = requestDisplaySetCreationForStudy.bind(
25
+ null,
26
+ dataSource
27
+ );
28
+
29
+ return (
30
+ <PanelStudyBrowser
31
+ dataSource={dataSource}
32
+ getImageSrc={_getImageSrcFromImageId}
33
+ getStudiesForPatientByMRN={_getStudiesForPatientByMRN}
34
+ requestDisplaySetCreationForStudy={_requestDisplaySetCreationForStudy}
35
+ />
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Grabs cornerstone library reference using a dependent command from
41
+ * the @ohif/extension-cornerstone extension. Then creates a helper function
42
+ * that can take an imageId and return an image src.
43
+ *
44
+ * @param {func} getCommand - CommandManager's getCommand method
45
+ * @returns {func} getImageSrcFromImageId - A utility function powered by
46
+ * cornerstone
47
+ */
48
+ function _createGetImageSrcFromImageIdFn(extensionManager) {
49
+ const utilities = extensionManager.getModuleEntry(
50
+ '@ohif/extension-cornerstone.utilityModule.common'
51
+ );
52
+
53
+ try {
54
+ const { cornerstone } = utilities.exports.getCornerstoneLibraries();
55
+ return getImageSrcFromImageId.bind(null, cornerstone);
56
+ } catch (ex) {
57
+ throw new Error('Required command not found');
58
+ }
59
+ }
60
+
61
+ export default WrappedPanelStudyBrowser;
@@ -0,0 +1,128 @@
1
+ import PROMPT_RESPONSES from '../utils/_shared/PROMPT_RESPONSES';
2
+
3
+ /**
4
+ * Creates and shows a report dialog prompt.
5
+ * The input for this is:
6
+ * - `title` shown in the dialog
7
+ * - `modality` being stored, used to query existing series
8
+ * - `minSeriesNumber` is the start of new series of this modality type.
9
+ * Will get set to 4000 if not determined by the modality
10
+ * - predecessorImageId is the image id that this series was currently loaded
11
+ * from. That is the series the dialog offers to extend, and it defaults to
12
+ * extending it instead of creating a new series. Without one, the dialog
13
+ * only offers to create a new series.
14
+ * - `itemName` is the name the user chose, such as the segmentation name. A
15
+ * new series offers it first. A generated name belongs in
16
+ * `defaultSeriesDescription` instead.
17
+ * - `defaultSeriesDescription` is the name for an item with no chosen name,
18
+ * such as 'Contours' or 'Measurements'. A new series offers it last.
19
+ * - `itemType` is the type of item being stored, used as the key that the
20
+ * series descriptions used before are remembered under. Defaults to the
21
+ * modality, so that segmentations, contours and reports are remembered
22
+ * separately.
23
+ * - `rememberedDescriptionCount` is how many previously used series
24
+ * descriptions to remember and offer for this type of item, 0 to remember
25
+ * none of them.
26
+ *
27
+ * The dialog offers three destinations - `Save to current`, `Save as new` and
28
+ * `Replace existing` - and says which one is in effect. Each destination stores
29
+ * all of the current data as one object, and the dialog merges nothing. The
30
+ * behaviour doc describes the destinations, the series that the dialog offers,
31
+ * and the names for a new series:
32
+ * `platform/docs/docs/behaviours/report-dialog-save-destinations.md`.
33
+ *
34
+ * The response is:
35
+ * - `value`, the series description of the object/series being created. When
36
+ * extending an existing series this is that series' existing description,
37
+ * as an existing series description is not editable.
38
+ * - `dataSourceName`, where to store the object to
39
+ * - `series`, is the series to store do, as referenced by a predecessorImageId value.
40
+ * This is falsy for a new series.
41
+ * - `seriesNumber` is the series number to store the object as, which is the
42
+ * value shown (and possibly edited) in the dialog.
43
+ * - `priorSeriesNumber` is one less than `seriesNumber`, for callers that
44
+ * compute the series number to store as `1 + priorSeriesNumber`.
45
+ *
46
+ * The `series` value should be provided to the DICOM encoder, which will get the
47
+ * predecessor sequence from the metaData provider so that the saved instance
48
+ * goes into the same series, superseding the existing instance there.
49
+ */
50
+ export default function CreateReportDialogPrompt({
51
+ title = 'Save Measurements',
52
+ modality = 'SR',
53
+ minSeriesNumber = 0,
54
+ predecessorImageId,
55
+ itemName = '',
56
+ defaultSeriesDescription = '',
57
+ itemType,
58
+ rememberedDescriptionCount = 5,
59
+ extensionManager,
60
+ servicesManager,
61
+ enableDownload = false,
62
+ }): Promise<{
63
+ value: string;
64
+ dataSourceName: string;
65
+ seriesNumber?: number;
66
+ priorSeriesNumber?: number;
67
+ series: string;
68
+ action: (typeof PROMPT_RESPONSES)[keyof typeof PROMPT_RESPONSES];
69
+ }> {
70
+ const { uiDialogService, customizationService } = servicesManager.services;
71
+ const dataSources = extensionManager.getDataSourcesForUI();
72
+ const ReportDialog = customizationService.getCustomization('ohif.createReportDialog');
73
+
74
+ const allowMultipleDataSources = window.config.allowMultiSelectExport;
75
+
76
+ minSeriesNumber ||=
77
+ (modality === 'SR' && 3000) ||
78
+ (modality === 'SEG' && 3100) ||
79
+ (modality === 'RTSTRUCT' && 3200) ||
80
+ 4000;
81
+
82
+ return new Promise(function (resolve) {
83
+ uiDialogService.show({
84
+ id: 'report-dialog',
85
+ title,
86
+ // The default dialog width (max-w-md) is narrower than the destination
87
+ // control, which would otherwise stick out past the dialog's edge.
88
+ containerClassName: 'max-w-lg',
89
+ content: ReportDialog,
90
+ contentProps: {
91
+ dataSources: allowMultipleDataSources ? dataSources : undefined,
92
+ predecessorImageId,
93
+ minSeriesNumber,
94
+ itemName,
95
+ defaultSeriesDescription,
96
+ itemType,
97
+ rememberedDescriptionCount,
98
+ modality,
99
+ enableDownload,
100
+ onSave: async ({
101
+ reportName,
102
+ dataSource: selectedDataSource,
103
+ series,
104
+ seriesNumber,
105
+ priorSeriesNumber,
106
+ }) => {
107
+ resolve({
108
+ value: reportName,
109
+ dataSourceName: selectedDataSource,
110
+ series,
111
+ seriesNumber,
112
+ priorSeriesNumber,
113
+ action: PROMPT_RESPONSES.CREATE_REPORT,
114
+ });
115
+ },
116
+ onCancel: () => {
117
+ resolve({
118
+ action: PROMPT_RESPONSES.CANCEL,
119
+ value: undefined,
120
+ series: undefined,
121
+ dataSourceName: undefined,
122
+ });
123
+ },
124
+ defaultValue: title,
125
+ },
126
+ });
127
+ });
128
+ }
@@ -0,0 +1,25 @@
1
+ // Returns a function, that, as long as it continues to be invoked, will not
2
+ // be triggered. The function will be called after it stops being called for
3
+ // N milliseconds. If `immediate` is passed, trigger the function on the
4
+ // leading edge, instead of the trailing.
5
+ function debounce(func, wait, immediate) {
6
+ var timeout;
7
+ return function () {
8
+ var context = this,
9
+ args = arguments;
10
+ var later = function () {
11
+ timeout = null;
12
+ if (!immediate) {
13
+ func.apply(context, args);
14
+ }
15
+ };
16
+ var callNow = immediate && !timeout;
17
+ clearTimeout(timeout);
18
+ timeout = setTimeout(later, wait);
19
+ if (callNow) {
20
+ func.apply(context, args);
21
+ }
22
+ };
23
+ }
24
+
25
+ export default debounce;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @param {*} cornerstone
3
+ * @param {*} imageId
4
+ */
5
+ function getImageSrcFromImageId(cornerstone, imageId) {
6
+ return new Promise((resolve, reject) => {
7
+ const canvas = document.createElement('canvas');
8
+ cornerstone.utilities
9
+ .loadImageToCanvas({ canvas, imageId, thumbnail: true })
10
+ .then(imageId => {
11
+ resolve(canvas.toDataURL());
12
+ })
13
+ .catch(reject);
14
+ });
15
+ }
16
+ export default getImageSrcFromImageId;
@@ -0,0 +1,19 @@
1
+ async function getStudiesForPatientByMRN(dataSource, qidoForStudyUID) {
2
+ if (!qidoForStudyUID?.length) {
3
+ return [];
4
+ }
5
+
6
+ const mrn = qidoForStudyUID[0].mrn;
7
+
8
+ // if not defined or empty, return the original qidoForStudyUID
9
+ if (!mrn) {
10
+ return qidoForStudyUID;
11
+ }
12
+
13
+ return dataSource.query.studies.search({
14
+ patientId: mrn,
15
+ disableWildcard: true,
16
+ });
17
+ }
18
+
19
+ export default getStudiesForPatientByMRN;
@@ -0,0 +1,5 @@
1
+ import PanelStudyBrowser from './StudyBrowser/PanelStudyBrowser';
2
+ import WrappedPanelStudyBrowser from './WrappedPanelStudyBrowser';
3
+ import createReportDialogPrompt from './createReportDialogPrompt';
4
+
5
+ export { PanelStudyBrowser, WrappedPanelStudyBrowser, createReportDialogPrompt };
@@ -0,0 +1,19 @@
1
+ function requestDisplaySetCreationForStudy(
2
+ dataSource,
3
+ displaySetService,
4
+ StudyInstanceUID,
5
+ madeInClient
6
+ ) {
7
+ // TODO: is this already short-circuited by the map of Retrieve promises?
8
+ if (
9
+ displaySetService.activeDisplaySets.some(
10
+ displaySet => displaySet.StudyInstanceUID === StudyInstanceUID
11
+ )
12
+ ) {
13
+ return;
14
+ }
15
+
16
+ return dataSource.retrieve.series.metadata({ StudyInstanceUID, madeInClient });
17
+ }
18
+
19
+ export default requestDisplaySetCreationForStudy;