Last active
January 31, 2023 16:53
-
-
Save Ouwen/9b618600bd7ac358930ba63cb90c045b to your computer and use it in GitHub Desktop.
Query Dicoms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { api } from 'dicomweb-client'; // see: https://www.npmjs.com/package/dicomweb-client | |
const c = { | |
name: 'aws', | |
wadoUriRoot: 'https://.../dicomweb', | |
qidoRoot: 'https://.../dicomweb', | |
wadoRoot: 'https://.../dicomweb', | |
qidoSupportsIncludeField: false, | |
supportsReject: false, | |
imageRendering: 'wadors', | |
thumbnailRendering: 'wadors', | |
enableStudyLazyLoad: true, | |
supportsFuzzyMatching: false, | |
supportsWildcard: true, | |
staticWado: true, | |
singlepart: 'bulkdata,video,pdf', | |
}, | |
const qidoConfig = { | |
url: c.qidoRoot, | |
staticWado: c.staticWado, | |
singlepart: c.singlepart, | |
headers: null, // UserAuthenticationService.getAuthorizationHeader(), or other headers/cookies | |
errorInterceptor: console.error // errorHandler.getHTTPErrorHandler(), | |
}; | |
qidoDicomWebClient = api.DICOMwebClient(qidoConfig); | |
qidoDicomWebClient.headers = headers; | |
const studyInstanceUID = 'my study of interset' | |
const result = await qidoClient.searchForSeries({ studyInstanceUID }); | |
result.forEach(async qidoSeries => { | |
seriesInstanceUID = getString(qidoSeries['0020000E']) | |
const instances = await qidoClient.searchForInstance ({ studyInstanceUID, seriesInstanceUID }); | |
console.log(instances ) | |
}) | |
// form the /dicomweb/study/<studyid>/series/<seriesid>/instances/<instanceid>/frame/1 and send requests via fetch | |
const url = 'my formed url' | |
const request = new Request(url, {method: 'GET', headers: {}}); | |
const response = await fetch(request, headers={}) | |
// add to the caches object with the following hierachy | |
// caches => | |
// cache /dicomweb/study/<studyid>/series/<seriesid> | |
// res cache.put(request, response) | |
// cache /dicomweb/study/<studyid>/series/<seriesid> | |
// cache /dicomweb/study/<studyid>/series/<seriesid> | |
// this cache will be avaliable to OHIF app | |
// helper functions | |
// gets a string from dicomweb-client | |
function getString(element, defaultValue) { | |
if (!element) { | |
return defaultValue; | |
} | |
// Value is not present if the attribute has a zero length value | |
if (!element.Value) { | |
return defaultValue; | |
} | |
// Sanity check to make sure we have at least one entry in the array. | |
if (!element.Value.length) { | |
return defaultValue; | |
} | |
// Join the array together separated by backslash | |
// NOTE: Orthanc does not correctly split values into an array so the join is a no-op | |
return element.Value.join('\\'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment