feat: Display series specified by URL parameters in viewer (#2979)

* WIP

* WIP

* WIP

* fixed Bill comments on PR - https://github.com/OHIF/Viewers/pull/2979

* added series number to series filter and removed extra console.log

* changed the filter of seriesFilterKeys to studyFilterKeys

* changed the seriesInstaceUID to SeriesInstanceUID to make coerence with StudyInstanceUID

* reverted change on extension retrieveMetadataLoaderAsync and make the right change on Mode.tsx

* fixed PR comments and add small information about the filters

Co-authored-by: Thomas Forster <thomasforster@MacBookPro-Thomas.local>
This commit is contained in:
Bill WallaceandThomas Forster authored and GitHub committed 2022-10-25 10:20:32 -04:00
1 parent 5482de08bc
commit 2507a4b546
4 files changed
+80 -20

No files matched your search

@@ -70,6 +70,7 @@ function createDicomWebApi(dicomWebConfig, UserAuthenticationService) {
const wadoConfig = {
url: wadoRoot,
staticWado,
singlepart,
headers: UserAuthenticationService.getAuthorizationHeader(),
errorInterceptor: errorHandler.getHTTPErrorHandler(),
@@ -80,7 +81,10 @@ function createDicomWebApi(dicomWebConfig, UserAuthenticationService) {
const qidoDicomWebClient = staticWado
? new StaticWadoClient(qidoConfig)
: new api.DICOMwebClient(qidoConfig);
const wadoDicomWebClient = new api.DICOMwebClient(wadoConfig);
const wadoDicomWebClient = staticWado
? new StaticWadoClient(wadoConfig)
: new api.DICOMwebClient(wadoConfig);
const implementation = {
initialize: ({ params, query }) => {
@@ -171,7 +171,7 @@ function mapParams(params, options = {}) {
// Named
PatientName: withWildcard(params.patientName),
//PatientID: withWildcard(params.patientId),
"00100020": withWildcard(params.patientId), // Temporarily to make the tests pass with dicomweb-server.. Apparently it's broken?
'00100020': withWildcard(params.patientId), // Temporarily to make the tests pass with dicomweb-server.. Apparently it's broken?
AccessionNumber: withWildcard(params.accessionNumber),
StudyDescription: withWildcard(params.studyDescription),
ModalitiesInStudy: params.modalitiesInStudy,
@@ -8,14 +8,19 @@ import { api } from 'dicomweb-client';
* by manually implementing a query option.
*/
export default class StaticWadoClient extends api.DICOMwebClient {
static filterKeys = {
"StudyInstanceUID": "0020000D",
"PatientName": "00100010",
"00100020": "mrn",
"StudyDescription": "00081030",
"StudyDate": "00080020",
"ModalitiesInStudy": "00080061",
AccessionNumber: "00080050",
static studyFilterKeys = {
StudyInstanceUID: '0020000D',
PatientName: '00100010',
'00100020': 'mrn',
StudyDescription: '00081030',
StudyDate: '00080020',
ModalitiesInStudy: '00080061',
AccessionNumber: '00080050',
};
static seriesFilterKeys = {
SeriesInstanceUID: '0020000E',
SeriesNumber: '00200011',
};
constructor(qidoConfig) {
@@ -36,7 +41,7 @@ export default class StaticWadoClient extends api.DICOMwebClient {
const { queryParams } = options;
if (!queryParams) return searchResult;
const filtered = searchResult.filter(study => {
for (const key of Object.keys(StaticWadoClient.filterKeys)) {
for (const key of Object.keys(StaticWadoClient.studyFilterKeys)) {
if (!this.filterItem(key, queryParams, study)) return false;
}
return true;
@@ -44,6 +49,22 @@ export default class StaticWadoClient extends api.DICOMwebClient {
return filtered;
}
async searchForSeries(options) {
if (!this.staticWado) return super.searchForSeries(options);
let searchResult = await super.searchForSeries(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
const filtered = searchResult.filter(study => {
for (const key of Object.keys(StaticWadoClient.studyFilterKeys)) {
if (!this.filterItem(key, queryParams, study)) return false;
}
return true;
});
return filtered;
}
/**
* Compares values, matching any instance of desired to any instance of
* actual by recursively go through the paired set of values. That is,
@@ -66,7 +87,7 @@ export default class StaticWadoClient extends api.DICOMwebClient {
if (actual?.Alphabetic) {
actual = actual.Alphabetic;
}
if (typeof (actual) == 'string') {
if (typeof actual == 'string') {
if (actual.length === 0) return true;
if (desired.length === 0 || desired === '*') return true;
if (desired[0] === '*' && desired[desired.length - 1] === '*') {
@@ -75,7 +96,10 @@ export default class StaticWadoClient extends api.DICOMwebClient {
} else if (desired[desired.length - 1] === '*') {
return actual.indexOf(desired.substring(0, desired.length - 1)) != -1;
} else if (desired[0] === '*') {
return actual.indexOf(desired.substring(1)) === actual.length - desired.length + 1;
return (
actual.indexOf(desired.substring(1)) ===
actual.length - desired.length + 1
);
}
}
return desired === actual;
@@ -88,8 +112,7 @@ export default class StaticWadoClient extends api.DICOMwebClient {
if (dash === -1) return this.compareValues(range, value);
const start = range.substring(0, dash);
const end = range.substring(dash + 1);
return (!start || value >= start) &&
(!end || value <= end);
return (!start || value >= start) && (!end || value <= end);
}
/**
@@ -101,13 +124,15 @@ export default class StaticWadoClient extends api.DICOMwebClient {
* @returns
*/
filterItem(key, queryParams, study) {
const altKey = StaticWadoClient.filterKeys[key] || key;
const altKey = StaticWadoClient.studyFilterKeys[key] || key;
if (!queryParams) return true;
const testValue = queryParams[key] || queryParams[altKey];
if (!testValue) return true;
const valueElem = study[key] || study[altKey];
if (!valueElem) return false;
if (valueElem.vr == 'DA') return this.compareDateRange(testValue, valueElem.Value[0]);
if (valueElem.vr == 'DA') {
return this.compareDateRange(testValue, valueElem.Value[0]);
}
const value = valueElem.Value;
return this.compareValues(testValue, value) && true;
}