Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OHI-1357] feat(static-wado): add support for case-insensitive searching #4603

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extensions/default/src/DicomWebDataSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const metadataProvider = classes.MetadataProvider;
* @param {boolean} dicomWebConfig.bulkDataURI - Whether to enable bulkDataURI
* @param {function} dicomWebConfig.onConfiguration - Function that is called after the configuration is initialized
* @param {boolean} dicomWebConfig.staticWado - Whether to use the static WADO client
* @param {boolean} dicomWebConfig.caseSensitive - Whether to use case sensitive filtering on results (default: true)
* @param {object} userAuthenticationService - User authentication service
* @param {object} userAuthenticationService.getAuthorizationHeader - Function that returns the authorization header
* @returns {object} - DICOM Web API object
Expand Down Expand Up @@ -107,6 +108,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) {
url: dicomWebConfig.qidoRoot,
staticWado: dicomWebConfig.staticWado,
singlepart: dicomWebConfig.singlepart,
caseSensitive: dicomWebConfig.caseSensitive,
headers: userAuthenticationService.getAuthorizationHeader(),
errorInterceptor: errorHandler.getHTTPErrorHandler(),
};
Expand All @@ -115,6 +117,7 @@ function createDicomWebApi(dicomWebConfig, servicesManager) {
url: dicomWebConfig.wadoRoot,
staticWado: dicomWebConfig.staticWado,
singlepart: dicomWebConfig.singlepart,
caseSensitive: dicomWebConfig.caseSensitive,
headers: userAuthenticationService.getAuthorizationHeader(),
errorInterceptor: errorHandler.getHTTPErrorHandler(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ export default class StaticWadoClient extends api.DICOMwebClient {
}

const lowerParams = this.toLowerParams(queryParams);
const caseSensitive = this.config.caseSensitive;
const filtered = searchResult.filter(study => {
for (const key of Object.keys(StaticWadoClient.studyFilterKeys)) {
if (!this.filterItem(key, lowerParams, study, StaticWadoClient.studyFilterKeys)) {
if (
!this.filterItem(key, lowerParams, study, StaticWadoClient.studyFilterKeys, caseSensitive)
) {
return false;
}
}
Expand Down Expand Up @@ -156,19 +159,28 @@ export default class StaticWadoClient extends api.DICOMwebClient {
*
* @param {*} desired
* @param {*} actual
* @param {boolean} caseSensitive
* @returns true if the values match
*/
compareValues(desired, actual) {
compareValues(desired, actual, caseSensitive = true) {
if (Array.isArray(desired)) {
return desired.find(item => this.compareValues(item, actual));
return desired.find(item => this.compareValues(item, actual, caseSensitive));
}
if (Array.isArray(actual)) {
return actual.find(actualItem => this.compareValues(desired, actualItem));
return actual.find(actualItem => this.compareValues(desired, actualItem, caseSensitive));
}
if (actual?.Alphabetic) {
actual = actual.Alphabetic;
}
if (typeof actual == 'string') {
if (!caseSensitive) {
if (typeof desired === 'string') {
desired = desired.toLowerCase();
IbrahimCSAE marked this conversation as resolved.
Show resolved Hide resolved
}
if (typeof actual === 'string') {
IbrahimCSAE marked this conversation as resolved.
Show resolved Hide resolved
actual = actual.toLowerCase();
}
}
if (actual.length === 0) {
return true;
}
Expand Down Expand Up @@ -208,9 +220,10 @@ export default class StaticWadoClient extends api.DICOMwebClient {
* @param queryParams -
* @param {*} study
* @param {*} sourceFilterMap
* @param {boolean} caseSensitive
* @returns
*/
filterItem(key: string, queryParams, study, sourceFilterMap) {
filterItem(key: string, queryParams, study, sourceFilterMap, caseSensitive = true) {
const altKey = sourceFilterMap[key] || key;
if (!queryParams) {
return true;
Expand All @@ -227,7 +240,7 @@ export default class StaticWadoClient extends api.DICOMwebClient {
return this.compareDateRange(testValue, valueElem.Value[0]);
}
const value = valueElem.Value;
IbrahimCSAE marked this conversation as resolved.
Show resolved Hide resolved
return this.compareValues(testValue, value);
return this.compareValues(testValue, value, caseSensitive);
}

/** Converts the query parameters to lower case query parameters */
Expand Down
1 change: 1 addition & 0 deletions platform/app/public/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ window.config = {
supportsFuzzyMatching: false,
supportsWildcard: true,
staticWado: true,
caseSensitive: false,
IbrahimCSAE marked this conversation as resolved.
Show resolved Hide resolved
singlepart: 'bulkdata,video',
// whether the data source should use retrieveBulkData to grab metadata,
// and in case of relative path, what would it be relative to, options
Expand Down
Loading