Skip to content

Commit

Permalink
feat: add secondary dicom server
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrokohler committed Feb 2, 2024
1 parent eb8ddc0 commit d5e7516
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function _createClientMapping ({ baseUri, settings, onError }: {
serverSettings: ServerSettings
) => void
}): { [sopClassUID: string]: DicomWebManager } {
const storageClassMapping: { [key: string]: number } = { default: 0 }
const storageClassMapping: { [key: string]: number } = { default: 0 };
const clientMapping: { [sopClassUID: string]: DicomWebManager } = {};

settings.forEach(serverSettings => {
if (serverSettings.storageClasses != null) {
serverSettings.storageClasses.forEach(sopClassUID => {
Expand All @@ -80,7 +82,12 @@ function _createClientMapping ({ baseUri, settings, onError }: {
}
})
} else {
storageClassMapping.default += 1
storageClassMapping.default += 1;
clientMapping.default = new DicomWebManager({
baseUri,
settings: [serverSettings],
onError,
});
}
})

Expand All @@ -94,6 +101,7 @@ function _createClientMapping ({ baseUri, settings, onError }: {
)
)
}

for (const key in storageClassMapping) {
if (key === 'default') {
continue
Expand All @@ -111,7 +119,6 @@ function _createClientMapping ({ baseUri, settings, onError }: {
}
}

const clientMapping: { [sopClassUID: string]: DicomWebManager } = {}
if (Object.keys(storageClassMapping).length > 1) {
settings.forEach(server => {
const client = new DicomWebManager({
Expand All @@ -125,13 +132,8 @@ function _createClientMapping ({ baseUri, settings, onError }: {
})
}
})
clientMapping.default = clientMapping[
StorageClasses.VL_WHOLE_SLIDE_MICROSCOPY_IMAGE
]
} else {
const client = new DicomWebManager({ baseUri, settings, onError })
clientMapping.default = client
}

Object.values(StorageClasses).forEach(sopClassUID => {
if (!(sopClassUID in clientMapping)) {
clientMapping[sopClassUID] = clientMapping.default
Expand Down Expand Up @@ -229,7 +231,8 @@ class App extends React.Component<AppProps, AppState> {

this.handleServerSelection = this.handleServerSelection.bind(this)

message.config({ duration: 5 })
message.config({ duration: 5 });
this.addGcpSecondaryAnnotationServer(props.config);

this.state = {
clients: _createClientMapping({
Expand All @@ -242,6 +245,33 @@ class App extends React.Component<AppProps, AppState> {
}
}

addGcpSecondaryAnnotationServer(config: AppProps['config']) {
const serverId = 'gcp_secondary_annotation_server';
const urlParams = new URLSearchParams(window.location.search);
const gcpPath = urlParams.get("gcp");
const gcpSecondaryAnnotationServer = config.servers.find(
(server) => server.id === serverId
);
if (!gcpSecondaryAnnotationServer && gcpPath) {
config.servers.push({
id: serverId,
write: true,
url: `https://healthcare.googleapis.com/v1beta1/${gcpPath}`,
storageClasses: [
StorageClasses.COMPREHENSIVE_SR,
StorageClasses.COMPREHENSIVE_3D_SR,
StorageClasses.SEGMENTATION,
StorageClasses.MICROSCOPY_BULK_SIMPLE_ANNOTATION,
StorageClasses.PARAMETRIC_MAP,
StorageClasses.ADVANCED_BLENDING_PRESENTATION_STATE,
StorageClasses.COLOR_SOFTCOPY_PRESENTATION_STATE,
StorageClasses.GRAYSCALE_SOFTCOPY_PRESENTATION_STATE,
StorageClasses.PSEUDOCOLOR_SOFTCOPY_PRESENTATION_STATE,
],
});
}
}

handleServerSelection ({ url }: { url: string }): void {
console.info('select DICOMweb server: ', url)
const tmpClient = new DicomWebManager({
Expand Down

0 comments on commit d5e7516

Please sign in to comment.