@@ -179,15 +179,15 @@ const getBigQueryRows = async (studyuids, seriesuid, access_token) => {
179179
180180const filesFromStudyInstanceUID = async ( { bucketName, prefix, studyuids, headers} ) => {
181181 const studyMetadata = studyuids . map ( async ( studyuid ) => {
182- const folderPath = `${ prefix } /${ studyuid } /` ;
182+ const folderPath = `${ prefix } /studies/ ${ studyuid } /series /` ;
183183 const delimiter = '/'
184184 const apiUrl = `https://storage.googleapis.com/storage/v1/b/${ bucketName } /o?prefix=${ folderPath } &delimiter=${ delimiter } ` ;
185185 const response = await fetch ( apiUrl , { headers } ) ;
186186 const res = await response . json ( )
187187 const files = res . items || [ ] ;
188188 const folders = res . prefixes || [ ] ;
189189 const series = folders . map ( async ( folderPath ) => {
190- const objectName = `${ folderPath } metadata.json.gz ` ;
190+ const objectName = `${ folderPath } metadata` ;
191191 const apiUrl = `https://storage.googleapis.com/storage/v1/b/${ bucketName } /o/${ encodeURIComponent ( objectName ) } ?alt=media` ;
192192 const response = await fetch ( apiUrl , { headers } ) ;
193193 return response . json ( )
@@ -241,7 +241,9 @@ const storeDicomSeg = async (naturalizedReport, headers) => {
241241 } = naturalizedReport ;
242242
243243 const params = new URLSearchParams ( window . location . search ) ;
244- const bucket = params . get ( 'bucket' ) || 'gradient-health-search-viewer-links' ;
244+ const buckets = params . getAll ( 'bucket' ) ;
245+ const bucket =
246+ buckets [ 1 ] || buckets [ 0 ] || 'gradient-health-search-viewer-links' ;
245247 const prefix = params . get ( 'bucket-prefix' ) || 'dicomweb' ;
246248 const segBucket = params . get ( 'seg-bucket' ) || bucket
247249 const segPrefix = params . get ( 'seg-prefix' ) || prefix
@@ -275,7 +277,7 @@ const storeDicomSeg = async (naturalizedReport, headers) => {
275277 const compressedFile = pako . gzip ( JSON . stringify ( segSeries ) ) ;
276278
277279 return fetch (
278- `https://storage.googleapis.com/upload/storage/v1/b/${ segBucket } /o?uploadType=media&name=${ segPrefix } /${ StudyInstanceUID } /${ SeriesInstanceUID } /metadata.json.gz &contentEncoding=gzip` ,
280+ `https://storage.googleapis.com/upload/storage/v1/b/${ segBucket } /o?uploadType=media&name=${ segPrefix } /studies/ ${ StudyInstanceUID } /series/ ${ SeriesInstanceUID } /metadata&contentEncoding=gzip` ,
279281 {
280282 method : 'POST' ,
281283 headers : {
@@ -320,6 +322,10 @@ function createDicomJSONApi(dicomJsonConfig, servicesManager) {
320322 } ,
321323 initialize : async ( { params, query, url } ) => {
322324 if ( ! url ) url = query . get ( 'url' ) ;
325+ if ( ! url ) {
326+ url = query . toString ( ) ;
327+ query . set ( 'url' , url ) ;
328+ }
323329 let metaData = getMetaDataByURL ( url ) ;
324330
325331 // if we have already cached the data from this specific url
@@ -331,19 +337,29 @@ function createDicomJSONApi(dicomJsonConfig, servicesManager) {
331337 } ) ;
332338 }
333339
340+ const buckets = query . getAll ( 'bucket' ) ;
341+ if ( buckets . length === 0 )
342+ buckets . push ( 'gradient-health-search-viewer-links' ) ;
343+
334344 const { UserAuthenticationService } = servicesManager . services ;
335- const studyMetadata = await filesFromStudyInstanceUID ( {
336- bucketName : query . get ( 'bucket' ) || 'gradient-health-search-viewer-links' ,
337- prefix : query . get ( 'bucket-prefix' ) || 'dicomweb' ,
338- studyuids : query . getAll ( 'StudyInstanceUID' ) ,
339- headers : UserAuthenticationService . getAuthorizationHeader ( )
340- } ) ;
345+
346+ const studyMetadata = [ ] ;
347+ for ( let i = 0 ; i < buckets . length ; i ++ ) {
348+ const metadataPerBucket = await filesFromStudyInstanceUID ( {
349+ bucketName : buckets [ i ] ,
350+ prefix : query . get ( 'bucket-prefix' ) || 'dicomweb' ,
351+ studyuids : query . getAll ( 'StudyInstanceUIDs' ) ,
352+ headers : UserAuthenticationService . getAuthorizationHeader ( ) ,
353+ } ) ;
354+
355+ studyMetadata . push ( ...metadataPerBucket ) ;
356+ }
341357
342358 const data = getMetadataFromRows (
343- _ . flatten ( studyMetadata ) ,
344- query . get ( 'prefix' ) ,
359+ _ . flatten ( studyMetadata ) ,
360+ query . get ( 'prefix' ) ,
345361 query . getAll ( 'SeriesInstanceUID' )
346- ) ;
362+ ) ;
347363
348364 let StudyInstanceUID ;
349365 let SeriesInstanceUID ;
@@ -422,8 +438,9 @@ function createDicomJSONApi(dicomJsonConfig, servicesManager) {
422438 console . debug ( 'Not implemented' , params )
423439 } ,
424440 series : {
425- metadata : ( {
441+ metadata : async ( {
426442 StudyInstanceUID,
443+ buckets,
427444 madeInClient = false ,
428445 customSort,
429446 } = { } ) => {
@@ -433,7 +450,20 @@ function createDicomJSONApi(dicomJsonConfig, servicesManager) {
433450 ) ;
434451 }
435452
436- const study = findStudies ( 'StudyInstanceUID' , StudyInstanceUID ) [ 0 ] ;
453+ let study = findStudies ( 'StudyInstanceUID' , StudyInstanceUID ) [ 0 ] ;
454+
455+ if ( ! study && buckets ) {
456+ const params = new URLSearchParams ( window . location . search ) ;
457+ params . set ( 'StudyInstanceUIDs' , StudyInstanceUID ) ;
458+ params . delete ( 'bucket' ) ;
459+ buckets . forEach ( ( bucket ) => {
460+ params . append ( 'bucket' , bucket ) ;
461+ } ) ;
462+ await implementation . initialize ( { query : params } ) ;
463+
464+ study = findStudies ( 'StudyInstanceUID' , StudyInstanceUID ) [ 0 ] ;
465+ }
466+
437467 let series ;
438468
439469 if ( customSort ) {
0 commit comments