@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.
Files changed (216) hide show
  1. package/dist/ohif-extension-default.css +1 -1
  2. package/dist/ohif-extension-default.umd.js +1 -1
  3. package/package.json +14 -10
  4. package/src/Actions/createReportAsync.tsx +45 -0
  5. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  6. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  7. package/src/Components/ItemListComponent.tsx +95 -0
  8. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  9. package/src/Components/LineChartViewport/index.ts +1 -0
  10. package/src/Components/MoreDropdownMenu.tsx +112 -0
  11. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  12. package/src/Components/SidePanelWithServices.tsx +122 -0
  13. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  15. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  16. package/src/CustomizableContextMenu/index.ts +5 -0
  17. package/src/CustomizableContextMenu/types.ts +126 -0
  18. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  19. package/src/DicomJSONDataSource/index.js +326 -0
  20. package/src/DicomLocalDataSource/index.js +273 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  22. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  23. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  24. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  25. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  26. package/src/DicomWebDataSource/index.ts +808 -0
  27. package/src/DicomWebDataSource/qido.js +215 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  29. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  30. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  31. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  33. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  34. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  35. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  36. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  37. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  38. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  40. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  41. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  42. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  43. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  44. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  45. package/src/DicomWebDataSource/utils/index.ts +9 -0
  46. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  50. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  51. package/src/DicomWebProxyDataSource/index.ts +90 -0
  52. package/src/MergeDataSource/index.test.ts +212 -0
  53. package/src/MergeDataSource/index.ts +319 -0
  54. package/src/MergeDataSource/types.ts +46 -0
  55. package/src/Panels/DataSourceSelector.tsx +55 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  57. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  58. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  59. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  60. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  62. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  63. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  64. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  65. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  66. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  67. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  68. package/src/Panels/debounce.js +25 -0
  69. package/src/Panels/getImageSrcFromImageId.js +16 -0
  70. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  71. package/src/Panels/index.js +5 -0
  72. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  74. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  75. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  76. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  77. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  78. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  79. package/src/Toolbar/Toolbar.tsx +98 -0
  80. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  81. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  82. package/src/Toolbar/index.ts +7 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  84. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  85. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  86. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  87. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  88. package/src/ViewerLayout/constants/panels.ts +42 -0
  89. package/src/ViewerLayout/index.tsx +227 -0
  90. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  91. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  92. package/src/commandsModule.ts +970 -0
  93. package/src/customizations/aboutModalCustomization.tsx +42 -0
  94. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  95. package/src/customizations/contextMenuCustomization.ts +25 -0
  96. package/src/customizations/contextMenuUICustomization.ts +5 -0
  97. package/src/customizations/customRoutesCustomization.ts +6 -0
  98. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  99. package/src/customizations/datasourcesCustomization.tsx +14 -0
  100. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  101. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  102. package/src/customizations/headerRightSideCustomization.ts +19 -0
  103. package/src/customizations/helloPageCustomization.tsx +14 -0
  104. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  105. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  106. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  107. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  109. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  110. package/src/customizations/menuContentCustomization.tsx +67 -0
  111. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  112. package/src/customizations/metadataContextCustomization.ts +28 -0
  113. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  114. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  115. package/src/customizations/multimonitorCustomization.ts +63 -0
  116. package/src/customizations/notificationCustomization.ts +29 -0
  117. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  118. package/src/customizations/onboardingCustomization.ts +200 -0
  119. package/src/customizations/overlayItemCustomization.tsx +33 -0
  120. package/src/customizations/progressDropdownCustomization.ts +5 -0
  121. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  122. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  123. package/src/customizations/reportDialogCustomization.tsx +661 -0
  124. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  125. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  126. package/src/customizations/studyBrowserCustomization.ts +95 -0
  127. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  128. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  129. package/src/customizations/workListCustomization.ts +107 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  131. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  132. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  133. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  134. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  135. package/src/findViewportsByPosition.ts +102 -0
  136. package/src/getCustomizationModule.tsx +109 -0
  137. package/src/getDataSourcesModule.js +44 -0
  138. package/src/getDisplaySetMessages.ts +54 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  140. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  141. package/src/getHangingProtocolModule.js +155 -0
  142. package/src/getLayoutTemplateModule.js +28 -0
  143. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  144. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  145. package/src/getPanelModule.tsx +29 -0
  146. package/src/getSopClassHandlerModule.js +152 -0
  147. package/src/getSopClassHandlerModule.test.js +78 -0
  148. package/src/getToolbarModule.tsx +63 -0
  149. package/src/getViewportModule.tsx +12 -0
  150. package/src/hangingprotocols/hpCompare.ts +189 -0
  151. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  152. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  153. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  154. package/src/hangingprotocols/hpMammo.ts +202 -0
  155. package/src/hangingprotocols/hpScale.ts +132 -0
  156. package/src/hangingprotocols/index.ts +16 -0
  157. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  158. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  159. package/src/hangingprotocols/utils/laterality.ts +9 -0
  160. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  161. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  162. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  163. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  164. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  165. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  166. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  167. package/src/hooks/usePatientInfo.tsx +63 -0
  168. package/src/id.js +5 -0
  169. package/src/index.ts +113 -0
  170. package/src/init.ts +169 -0
  171. package/src/stores/index.ts +7 -0
  172. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  173. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  174. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  175. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  176. package/src/stores/useUIStateStore.ts +87 -0
  177. package/src/stores/useViewportGridStore.ts +89 -0
  178. package/src/stores/useViewportsByPositionStore.ts +100 -0
  179. package/src/types/AppTypes.ts +20 -0
  180. package/src/types/commandModuleTypes.tsx +6 -0
  181. package/src/utils/Toolbox.tsx +123 -0
  182. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  183. package/src/utils/addIcon.ts +6 -0
  184. package/src/utils/appendFrameQueryToImageId.js +9 -0
  185. package/src/utils/callInputDialog.tsx +126 -0
  186. package/src/utils/colorPickerDialog.css +4 -0
  187. package/src/utils/colorPickerDialog.tsx +45 -0
  188. package/src/utils/createRenderedRetrieve.js +32 -0
  189. package/src/utils/createRenderedRetrieve.test.js +46 -0
  190. package/src/utils/dicomWriter.test.ts +228 -0
  191. package/src/utils/dicomWriter.ts +110 -0
  192. package/src/utils/getBulkdataValue.js +45 -0
  193. package/src/utils/getBulkdataValue.test.js +105 -0
  194. package/src/utils/getDirectURL.test.ts +207 -0
  195. package/src/utils/getDirectURL.ts +65 -0
  196. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  197. package/src/utils/index.ts +2 -0
  198. package/src/utils/layerConfigurationUtils.ts +202 -0
  199. package/src/utils/promptLabelAnnotation.js +47 -0
  200. package/src/utils/promptSaveReport.test.ts +106 -0
  201. package/src/utils/promptSaveReport.tsx +117 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  203. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  204. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  205. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  206. package/src/utils/reuseCachedLayouts.ts +92 -0
  207. package/src/utils/secureConfigFetch.js +115 -0
  208. package/src/utils/secureConfigFetch.test.js +163 -0
  209. package/src/utils/seriesDescriptionHistory.ts +83 -0
  210. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  212. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  213. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  214. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  215. package/src/utils/validations/checkMultiframe.ts +25 -0
  216. package/src/utils/validations/checkSingleFrames.ts +36 -0
@@ -0,0 +1,104 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import HangingProtocolService from '@ohif/core/src/services/HangingProtocolService/HangingProtocolService';
4
+ import isNewestOfModality from './utils/isNewestOfModality';
5
+
6
+ const ecgFile = path.resolve(
7
+ __dirname,
8
+ '../../../../platform/app/public/customizations/hangingProtocols/ecg.jsonc'
9
+ );
10
+ // shortcut: removes whole-line comments only; use JSON5 if the file gets inline comments.
11
+ const ecgProtocol = JSON.parse(fs.readFileSync(ecgFile, 'utf8').replace(/^\s*\/\/.*$/gm, ''))
12
+ .global['hangingProtocols.@ohif/ecg'];
13
+
14
+ const current = { StudyInstanceUID: 'current' };
15
+ const prior = { StudyInstanceUID: 'prior' };
16
+ const displaySet = (study, uid: string, attributes: Record<string, unknown>) => ({
17
+ StudyInstanceUID: study.StudyInstanceUID,
18
+ SeriesInstanceUID: uid,
19
+ displaySetInstanceUID: uid,
20
+ ...attributes,
21
+ });
22
+
23
+ // `customizations` are set at global scope, and `defaults` at default scope.
24
+ function serviceWith(customizations: Record<string, unknown>, defaults = {}) {
25
+ const customizationService = {
26
+ hasCustomization: id => id in customizations,
27
+ getCustomization: id => customizations[id] ?? defaults[id],
28
+ };
29
+ return new HangingProtocolService(
30
+ { run: jest.fn() } as never,
31
+ { services: { customizationService } } as never
32
+ );
33
+ }
34
+
35
+ function hang(studies, displaySets) {
36
+ const service = serviceWith({ 'hangingProtocols.@ohif/ecg': ecgProtocol });
37
+ service.addCustomAttribute('isNewestOfModality', 'newest', isNewestOfModality);
38
+ service.setActiveProtocolIds('@ohif/ecg');
39
+ service.run({ studies, displaySets, activeStudy: studies[0] }, '@ohif/ecg', {});
40
+ const { stage, viewportMatchDetails } = service.getActiveProtocol();
41
+ const shown = [...viewportMatchDetails.values()].map(
42
+ details => details.displaySetsInfo[0]?.displaySetInstanceUID
43
+ );
44
+ return { stage: stage.id, shown };
45
+ }
46
+
47
+ describe('hangingProtocols.<id> customization', () => {
48
+ it('takes precedence over a protocol that addProtocol registered', () => {
49
+ const service = serviceWith({ 'hangingProtocols.@ohif/ecg': ecgProtocol });
50
+ service.addProtocol('@ohif/ecg', { ...ecgProtocol, name: 'registered' });
51
+ expect(service.getProtocolById('@ohif/ecg').name).toBe('ECG');
52
+ });
53
+
54
+ it('does not replace a registered protocol when the customization is only a default', () => {
55
+ const service = serviceWith({}, { 'hangingProtocols.@ohif/ecg': ecgProtocol });
56
+ expect(service.getProtocolById('@ohif/ecg').name).toBe('ECG');
57
+
58
+ service.addProtocol('@ohif/ecg', { ...ecgProtocol, name: 'registered' });
59
+ expect(service.getProtocolById('@ohif/ecg').name).toBe('registered');
60
+ });
61
+ });
62
+
63
+ describe('the hangingProtocols/ecg customization', () => {
64
+ const ct = displaySet(current, 'ct', { Modality: 'CT', numImageFrames: 100 });
65
+
66
+ it('shows the ECG of a study with one ECG in one viewport', () => {
67
+ const ecg = displaySet(current, 'ecg', { Modality: 'ECG', numImageFrames: 0 });
68
+
69
+ expect(hang([current], [ct, ecg])).toEqual({ stage: 'ecg', shown: ['ecg'] });
70
+ });
71
+
72
+ it('opens one empty viewport for a study with no ECG', () => {
73
+ expect(hang([current], [ct])).toEqual({ stage: 'ecg', shown: [undefined] });
74
+ });
75
+
76
+ it('shows the newest of two ECGs above the older one', () => {
77
+ const older = displaySet(current, 'older', {
78
+ Modality: 'ECG',
79
+ SeriesNumber: 1,
80
+ SeriesDate: '20250101',
81
+ });
82
+ const newer = displaySet(current, 'newer', {
83
+ Modality: 'ECG',
84
+ SeriesNumber: 2,
85
+ SeriesDate: '20260101',
86
+ });
87
+
88
+ expect(hang([current], [older, newer])).toEqual({
89
+ stage: 'ecgTwo',
90
+ shown: ['newer', 'older'],
91
+ });
92
+ });
93
+
94
+ it('shows the current ECG above the prior ECG first, and a PDF with Modality ECG is an ECG', () => {
95
+ const ecgPdf = displaySet(current, 'ecgPdf', { Modality: 'ECG', numImageFrames: 0 });
96
+ const otherEcg = displaySet(current, 'otherEcg', { Modality: 'ECG', numImageFrames: 0 });
97
+ const priorEcg = displaySet(prior, 'priorEcg', { Modality: 'ECG', numImageFrames: 0 });
98
+
99
+ const { stage, shown } = hang([current, prior], [ct, ecgPdf, otherEcg, priorEcg]);
100
+ expect(stage).toBe('ecgPrior');
101
+ expect(shown[1]).toBe('priorEcg');
102
+ expect(['ecgPdf', 'otherEcg']).toContain(shown[0]);
103
+ });
104
+ });
@@ -0,0 +1,120 @@
1
+ import HangingProtocolService from '@ohif/core/src/services/HangingProtocolService/HangingProtocolService';
2
+ import { hpMN } from './hpMNGrid';
3
+
4
+ const study = { StudyInstanceUID: 'study' };
5
+ const displaySet = (displaySetInstanceUID: string, attributes: Record<string, unknown>) => ({
6
+ ...study,
7
+ SeriesInstanceUID: displaySetInstanceUID,
8
+ displaySetInstanceUID,
9
+ ...attributes,
10
+ });
11
+
12
+ // Runs mnGrid with no stage, as the URL route does without a stageid.
13
+ function run(displaySets: Record<string, unknown>[]) {
14
+ const service = new HangingProtocolService(
15
+ { run: jest.fn() } as never,
16
+ {
17
+ services: {
18
+ customizationService: { hasCustomization: () => false, getCustomization: () => undefined },
19
+ displaySetService: {
20
+ getDisplaySetByUID: uid => displaySets.find(it => it.displaySetInstanceUID === uid),
21
+ },
22
+ },
23
+ } as never
24
+ );
25
+ service.addProtocol(hpMN.id, hpMN);
26
+ service.setActiveProtocolIds(hpMN.id);
27
+ service.run({ studies: [study], displaySets, activeStudy: study }, hpMN.id, {
28
+ stageIndex: undefined,
29
+ });
30
+ return service;
31
+ }
32
+
33
+ function hang(displaySets: Record<string, unknown>[]) {
34
+ const { stage, viewportMatchDetails } = run(displaySets).getActiveProtocol();
35
+ const shown = [...viewportMatchDetails.values()].map(
36
+ details => details.displaySetsInfo[0]?.displaySetInstanceUID
37
+ );
38
+ return { stage: stage.name, shown };
39
+ }
40
+
41
+ const ecg = displaySet('ecg', { Modality: 'ECG', numImageFrames: 0 });
42
+
43
+ describe('hpMN', () => {
44
+ it('shows an ECG, whole slide or PDF study in one viewport', () => {
45
+ const slide = displaySet('slide', { Modality: 'SM', numImageFrames: 0 });
46
+ const pdf = displaySet('pdf', { Modality: 'OT', numImageFrames: 0 });
47
+
48
+ expect(hang([ecg])).toEqual({ stage: '1x1', shown: ['ecg'] });
49
+ expect(hang([slide])).toEqual({ stage: '1x1', shown: ['slide'] });
50
+ expect(hang([pdf])).toEqual({ stage: '1x1', shown: ['pdf'] });
51
+ });
52
+
53
+ it('opens the first applicable stage when a command gives no stage, and disables the image-only stages', () => {
54
+ const service = run([ecg]);
55
+ // As setHangingProtocol does for a protocol with no stored or given stage
56
+ service.setProtocol(hpMN.id, { stageIndex: service.getStageIndex(hpMN.id, {}) });
57
+
58
+ const { stage, protocol } = service.getActiveProtocol();
59
+ expect(stage.name).toBe('1x1');
60
+ expect(protocol.stages.map(it => it.status)).toEqual([
61
+ 'disabled',
62
+ 'disabled',
63
+ 'passive',
64
+ 'enabled',
65
+ ]);
66
+ });
67
+
68
+ it('opens the first applicable stage when the URL gives a stage that is disabled', () => {
69
+ const service = run([ecg]);
70
+ // As the URL route does for &stageid=2x2
71
+ service.setProtocol(hpMN.id, {
72
+ stageIndex: service.getStageIndex(hpMN.id, { stageId: '2x2' }),
73
+ });
74
+
75
+ expect(service.getActiveProtocol().stage.id).toBe('1x1');
76
+ });
77
+
78
+ it('keeps the display set that the user chose in 3x1 when the stage changes to 2x1', () => {
79
+ const images = ['ct1', 'ct2', 'ct3'].map(id =>
80
+ displaySet(id, { Modality: 'CT', numImageFrames: 100 })
81
+ );
82
+ const service = run(images);
83
+ // reuseCachedLayouts stores the user's ct3 in viewport 0 of the 3x1 under this key
84
+ const [viewport0] = service.getActiveProtocol().stage.viewports;
85
+ const key = service.getDisplaySetSelectorMapKey('study', viewport0.displaySets[0]);
86
+
87
+ service.setProtocol(hpMN.id, { stageId: '2x1', displaySetSelectorMap: { [key]: ['ct3'] } });
88
+
89
+ const { stage, viewportMatchDetails } = service.getActiveProtocol();
90
+ expect(stage.id).toBe('2x1');
91
+ expect(
92
+ viewportMatchDetails.get(stage.viewports[0].viewportOptions.viewportId)?.displaySetsInfo[0]
93
+ .displaySetInstanceUID
94
+ ).toBe('ct3');
95
+ });
96
+
97
+ it('shows a single-frame image', () => {
98
+ const cr = displaySet('cr', { Modality: 'CR', numImageFrames: 1 });
99
+
100
+ expect(hang([cr])).toEqual({ stage: '1x1', shown: ['cr'] });
101
+ });
102
+
103
+ it('fills the 2x1 with the image first and then the ECG, and never a SEG, PR or SR', () => {
104
+ const ct = displaySet('ct', { Modality: 'CT', numImageFrames: 100 });
105
+ // A segmentation that the viewer creates has numImageFrames.
106
+ const seg = displaySet('seg', { Modality: 'SEG', numImageFrames: 100 });
107
+ const pr = displaySet('pr', { Modality: 'PR' });
108
+ const sr = displaySet('sr', { Modality: 'SR' });
109
+
110
+ expect(hang([seg, pr, ecg, sr, ct])).toEqual({ stage: '2x1', shown: ['ct', 'ecg'] });
111
+ });
112
+
113
+ it('does not show the ECG when the images fill the 3x1', () => {
114
+ const images = ['ct1', 'ct2', 'ct3'].map(id =>
115
+ displaySet(id, { Modality: 'CT', numImageFrames: 100 })
116
+ );
117
+
118
+ expect(hang([ecg, ...images])).toEqual({ stage: '3x1', shown: ['ct1', 'ct2', 'ct3'] });
119
+ });
120
+ });
@@ -0,0 +1,419 @@
1
+ import { Types } from '@ohif/core';
2
+ import { studyWithImages } from './utils/studySelectors';
3
+ import { seriesViewable, seriesWithImages } from './utils/seriesSelectors';
4
+ import { viewportOptions } from './utils/viewportOptions';
5
+
6
+ /**
7
+ * Sync group configuration for hydrating segmentations across viewports
8
+ * that share the same frame of reference
9
+ * @type {Types.HangingProtocol.SyncGroup}
10
+ */
11
+ export const HYDRATE_SEG_SYNC_GROUP = {
12
+ type: 'hydrateseg',
13
+ id: 'sameFORId',
14
+ source: true,
15
+ target: true,
16
+ options: {
17
+ matchingRules: ['sameFOR'],
18
+ },
19
+ } as const;
20
+
21
+ /**
22
+ * This hanging protocol can be activated on the primary mode by directly
23
+ * referencing it in a URL or by directly including it within a mode, e.g.:
24
+ * `&hangingProtocolId=@ohif/mnGrid` added to the viewer URL
25
+ * It is not included in the viewer mode by default.
26
+ */
27
+ export const hpMN: Types.HangingProtocol.Protocol = {
28
+ id: '@ohif/mnGrid',
29
+ description: 'Has various hanging protocol grid layouts',
30
+ name: '2x2',
31
+ protocolMatchingRules: studyWithImages,
32
+ toolGroupIds: ['default'],
33
+ displaySetSelectors: {
34
+ defaultDisplaySetId: {
35
+ allowUnmatchedView: true,
36
+ seriesMatchingRules: seriesWithImages,
37
+ },
38
+ // The 2x1 and 1x1 stages also take an ECG, SM or PDF display set
39
+ viewableDisplaySetId: {
40
+ allowUnmatchedView: true,
41
+ // Keeps the user's choice when the stage changes between 3x1 and 2x1
42
+ selectorMapId: 'defaultDisplaySetId',
43
+ seriesMatchingRules: seriesViewable,
44
+ },
45
+ },
46
+ defaultViewport: {
47
+ viewportOptions: {
48
+ viewportType: 'stack',
49
+ toolGroupId: 'default',
50
+ syncGroups: [HYDRATE_SEG_SYNC_GROUP],
51
+ },
52
+ displaySets: [
53
+ {
54
+ id: 'defaultDisplaySetId',
55
+ matchedDisplaySetsIndex: -1,
56
+ },
57
+ ],
58
+ },
59
+ stages: [
60
+ {
61
+ id: '2x2',
62
+ name: '2x2',
63
+ stageActivation: {
64
+ enabled: {
65
+ minViewportsMatched: 4,
66
+ },
67
+ // Disabled with no image, so an ECG, SM or PDF study skips the stage
68
+ passive: {
69
+ minViewportsMatched: 1,
70
+ },
71
+ },
72
+ viewportStructure: {
73
+ layoutType: 'grid',
74
+ properties: {
75
+ rows: 2,
76
+ columns: 2,
77
+ },
78
+ },
79
+ viewports: [
80
+ {
81
+ viewportOptions,
82
+ displaySets: [
83
+ {
84
+ id: 'defaultDisplaySetId',
85
+ },
86
+ ],
87
+ },
88
+ {
89
+ viewportOptions,
90
+ displaySets: [
91
+ {
92
+ matchedDisplaySetsIndex: 1,
93
+ id: 'defaultDisplaySetId',
94
+ },
95
+ ],
96
+ },
97
+ {
98
+ viewportOptions,
99
+ displaySets: [
100
+ {
101
+ matchedDisplaySetsIndex: 2,
102
+ id: 'defaultDisplaySetId',
103
+ },
104
+ ],
105
+ },
106
+ {
107
+ viewportOptions,
108
+ displaySets: [
109
+ {
110
+ matchedDisplaySetsIndex: 3,
111
+ id: 'defaultDisplaySetId',
112
+ },
113
+ ],
114
+ },
115
+ ],
116
+ },
117
+
118
+ // 3x1 stage
119
+ {
120
+ id: '3x1',
121
+ name: '3x1',
122
+ stageActivation: {
123
+ enabled: {
124
+ minViewportsMatched: 3,
125
+ },
126
+ passive: {
127
+ minViewportsMatched: 1,
128
+ },
129
+ },
130
+ viewportStructure: {
131
+ layoutType: 'grid',
132
+ properties: {
133
+ rows: 1,
134
+ columns: 3,
135
+ },
136
+ },
137
+ viewports: [
138
+ {
139
+ viewportOptions,
140
+ displaySets: [
141
+ {
142
+ id: 'defaultDisplaySetId',
143
+ },
144
+ ],
145
+ },
146
+ {
147
+ viewportOptions,
148
+ displaySets: [
149
+ {
150
+ id: 'defaultDisplaySetId',
151
+ matchedDisplaySetsIndex: 1,
152
+ },
153
+ ],
154
+ },
155
+ {
156
+ viewportOptions,
157
+ displaySets: [
158
+ {
159
+ id: 'defaultDisplaySetId',
160
+ matchedDisplaySetsIndex: 2,
161
+ },
162
+ ],
163
+ },
164
+ ],
165
+ },
166
+
167
+ // A 2x1 stage
168
+ {
169
+ id: '2x1',
170
+ name: '2x1',
171
+ stageActivation: {
172
+ enabled: {
173
+ minViewportsMatched: 2,
174
+ },
175
+ },
176
+ viewportStructure: {
177
+ layoutType: 'grid',
178
+ properties: {
179
+ rows: 1,
180
+ columns: 2,
181
+ },
182
+ },
183
+ viewports: [
184
+ {
185
+ viewportOptions,
186
+ displaySets: [
187
+ {
188
+ id: 'viewableDisplaySetId',
189
+ },
190
+ ],
191
+ },
192
+ {
193
+ viewportOptions,
194
+ displaySets: [
195
+ {
196
+ matchedDisplaySetsIndex: 1,
197
+ id: 'viewableDisplaySetId',
198
+ },
199
+ ],
200
+ },
201
+ ],
202
+ },
203
+
204
+ // A 1x1 stage - should be automatically activated if there is only 1 viewable instance
205
+ {
206
+ id: '1x1',
207
+ name: '1x1',
208
+ stageActivation: {
209
+ enabled: {
210
+ minViewportsMatched: 1,
211
+ },
212
+ },
213
+ viewportStructure: {
214
+ layoutType: 'grid',
215
+ properties: {
216
+ rows: 1,
217
+ columns: 1,
218
+ },
219
+ },
220
+ viewports: [
221
+ {
222
+ viewportOptions,
223
+ displaySets: [
224
+ {
225
+ id: 'viewableDisplaySetId',
226
+ },
227
+ ],
228
+ },
229
+ ],
230
+ },
231
+ ],
232
+ numberOfPriorsReferenced: -1,
233
+ };
234
+
235
+ /**
236
+ * This hanging protocol can be activated on the primary mode by directly
237
+ * referencing it in a URL or by directly including it within a mode, e.g.:
238
+ * `&hangingProtocolId=@ohif/mnGrid8` added to the viewer URL
239
+ * It is not included in the viewer mode by default.
240
+ */
241
+ export const hpMN8: Types.HangingProtocol.Protocol = {
242
+ ...hpMN,
243
+ id: '@ohif/mnGrid8',
244
+ description: 'Has various hanging protocol grid layouts up to 4x2',
245
+ name: '4x2',
246
+ stages: [
247
+ {
248
+ id: '4x2',
249
+ name: '4x2',
250
+ stageActivation: {
251
+ enabled: {
252
+ minViewportsMatched: 7,
253
+ },
254
+ passive: {
255
+ minViewportsMatched: 1,
256
+ },
257
+ },
258
+ viewportStructure: {
259
+ layoutType: 'grid',
260
+ properties: {
261
+ rows: 2,
262
+ columns: 4,
263
+ },
264
+ },
265
+ viewports: [
266
+ {
267
+ viewportOptions,
268
+ displaySets: [
269
+ {
270
+ id: 'defaultDisplaySetId',
271
+ },
272
+ ],
273
+ },
274
+ {
275
+ viewportOptions,
276
+ displaySets: [
277
+ {
278
+ matchedDisplaySetsIndex: 1,
279
+ id: 'defaultDisplaySetId',
280
+ },
281
+ ],
282
+ },
283
+ {
284
+ viewportOptions,
285
+ displaySets: [
286
+ {
287
+ matchedDisplaySetsIndex: 2,
288
+ id: 'defaultDisplaySetId',
289
+ },
290
+ ],
291
+ },
292
+ {
293
+ viewportOptions,
294
+ displaySets: [
295
+ {
296
+ matchedDisplaySetsIndex: 3,
297
+ id: 'defaultDisplaySetId',
298
+ },
299
+ ],
300
+ },
301
+ {
302
+ viewportOptions,
303
+ displaySets: [
304
+ {
305
+ matchedDisplaySetsIndex: 4,
306
+ id: 'defaultDisplaySetId',
307
+ },
308
+ ],
309
+ },
310
+ {
311
+ viewportOptions,
312
+ displaySets: [
313
+ {
314
+ matchedDisplaySetsIndex: 5,
315
+ id: 'defaultDisplaySetId',
316
+ },
317
+ ],
318
+ },
319
+ {
320
+ viewportOptions,
321
+ displaySets: [
322
+ {
323
+ matchedDisplaySetsIndex: 6,
324
+ id: 'defaultDisplaySetId',
325
+ },
326
+ ],
327
+ },
328
+ {
329
+ viewportOptions,
330
+ displaySets: [
331
+ {
332
+ matchedDisplaySetsIndex: 7,
333
+ id: 'defaultDisplaySetId',
334
+ },
335
+ ],
336
+ },
337
+ ],
338
+ },
339
+
340
+ {
341
+ id: '3x2',
342
+ name: '3x2',
343
+ stageActivation: {
344
+ enabled: {
345
+ minViewportsMatched: 5,
346
+ },
347
+ passive: {
348
+ minViewportsMatched: 1,
349
+ },
350
+ },
351
+ viewportStructure: {
352
+ layoutType: 'grid',
353
+ properties: {
354
+ rows: 2,
355
+ columns: 3,
356
+ },
357
+ },
358
+ viewports: [
359
+ {
360
+ viewportOptions,
361
+ displaySets: [
362
+ {
363
+ id: 'defaultDisplaySetId',
364
+ },
365
+ ],
366
+ },
367
+ {
368
+ viewportOptions,
369
+ displaySets: [
370
+ {
371
+ matchedDisplaySetsIndex: 1,
372
+ id: 'defaultDisplaySetId',
373
+ },
374
+ ],
375
+ },
376
+ {
377
+ viewportOptions,
378
+ displaySets: [
379
+ {
380
+ matchedDisplaySetsIndex: 2,
381
+ id: 'defaultDisplaySetId',
382
+ },
383
+ ],
384
+ },
385
+ {
386
+ viewportOptions,
387
+ displaySets: [
388
+ {
389
+ matchedDisplaySetsIndex: 3,
390
+ id: 'defaultDisplaySetId',
391
+ },
392
+ ],
393
+ },
394
+ {
395
+ viewportOptions,
396
+ displaySets: [
397
+ {
398
+ matchedDisplaySetsIndex: 4,
399
+ id: 'defaultDisplaySetId',
400
+ },
401
+ ],
402
+ },
403
+ {
404
+ viewportOptions,
405
+ displaySets: [
406
+ {
407
+ matchedDisplaySetsIndex: 5,
408
+ id: 'defaultDisplaySetId',
409
+ },
410
+ ],
411
+ },
412
+ ],
413
+ },
414
+
415
+ ...hpMN.stages,
416
+ ],
417
+ };
418
+
419
+ export default hpMN;