Files
ohif-viewer/Packages/ohif-studies/imports/both/services/qido/studies.js
T
Egor Lezhnin 9486522552 feat(google-cloud): Add support for Google Cloud Healthcare API DICOM Store Switch (#325)
* NOTASK: PoC for loading data from Healthcare API

* NOTASK: PoC for loading data from Healthcare API fix

* Add sample dialog for loading test dicom-picker

* Fix incorrect promise resolving

* NOTASK: PoC for loading dicom store

* Add web-components as git submodules. (Probably will be changed later)

* Add rough dicomStore picker

* Add dataset selector

* NOTASK: QIDO metadata first draft

* NOTASK: Not Implemented error for color images

* NOTASK: clean-up

* Dicom files uploader intermediate version

* NOTASK: Accept header

* NOTASK: docker configs

* NOTASK: fix

* NOTASK: howTo

* Add draft of DICOM uploader

* Add missing files

* Fix error with missing clientId

* Update submodule

* NOTASK: HowTo

* NOTASK: config for dev

* NOTASK: new docker file

* clean-up

* Update GCP web-components

* Add integration with async web components

* Fix errors in nginx.conf

* Structured reports views basic implementation

* NOTASK: qido -> wado

* NOTASK: config fix

* NOTASK: dirty copy-paste implementation

* Add "Change dicom store" button.
Add an ability to clear date.
Fix bug, when OAuth dosn't work if URL is not /

* Fix studylist filtering

* Fix dockerfile

* NOTASK: meteor update

* NOTASK: fix of package structure

* NOTASK: merge fix

* improvements

Move check for now SR into SR modal
Use simple button to open SR modal
Remove button styling
cleanup

* copy SR data retrieval to wado

* make search of SR simpler

* Codestyle fix

* NOTASK: palette color error message

* Fix date filter.
Fix server settings on first loading.
Add SR and PS buttons

* NOTASK: PS is now hidden by default

* NOTASK: dirty solution

* NOTASK:  new wadoimage lib version

* Fix PS and SR buttons

* Make modal dialogs vertically centered

* Update web components. Quick UI fixes

* Add missing files to the previous commit

* NOTASK:  show-hide for PS

* NOTASK:  show-hide for PS

* NOTASK:  fix of min-max PixelValue bug

* Add "sign out" functionality for Google OAuth. Update web-components.

* intermediate commit

* Add demo signin page

* Beautifying demo sign in page

* NOTASK:  merge

* NOTASK:  clean-up

* Use npm for getting healthcare-api-adapter instead of git submodule.

* NOTASK:  clean-up

* meteor update

* clean-up

* clean-up

* Clean up code

* Update healthcare-api-adapter version. Add location to dicom store path. Fix buttons style.

* Downgrade meteor and packages to master version. Use meteor-build-client-fixed2
2019-03-22 16:42:26 +01:00

133 lines
4.5 KiB
JavaScript

import { OHIF } from 'meteor/ohif:core';
import DICOMwebClient from 'dicomweb-client';
const { DICOMWeb } = OHIF;
// TODO: Is there an easier way to do this?
if (Meteor.isServer) {
var XMLHttpRequest = require('xhr2');
global.XMLHttpRequest = XMLHttpRequest;
}
/**
* Creates a QIDO date string for a date range query
* Assumes the year is positive, at most 4 digits long.
*
* @param date The Date object to be formatted
* @returns {string} The formatted date string
*/
function dateToString(date) {
if (!date) return '';
let year = date.getFullYear().toString();
let month = (date.getMonth() + 1).toString();
let day = date.getDate().toString();
year = '0'.repeat(4 - year.length).concat(year);
month = '0'.repeat(2 - month.length).concat(month);
day = '0'.repeat(2 - day.length).concat(day);
return ''.concat(year, month, day);
}
/**
* Produces a QIDO URL given server details and a set of specified search filter
* items
*
* @param filter
* @param serverSupportsQIDOIncludeField
* @returns {string} The URL with encoded filter query data
*/
function getQIDOQueryParams(filter, serverSupportsQIDOIncludeField) {
const commaSeparatedFields = [
// this is temp '00081030', // Study Description
// '00080060' //Modality
// Add more fields here if you want them in the result
].join(',');
const parameters = {
PatientName: filter.patientName,
PatientID: filter.patientId,
AccessionNumber: filter.accessionNumber,
StudyDescription: filter.studyDescription,
ModalitiesInStudy: filter.modalitiesInStudy,
limit: filter.limit,
offset: filter.offset,
includefield: serverSupportsQIDOIncludeField ? commaSeparatedFields : 'all'
};
// build the StudyDate range parameter
if (filter.studyDateFrom || filter.studyDateTo) {
const dateFrom = dateToString(new Date(filter.studyDateFrom));
const dateTo = dateToString(new Date(filter.studyDateTo));
parameters.StudyDate = `${dateFrom}-${dateTo}`;
}
// Build the StudyInstanceUID parameter
if (filter.studyInstanceUid) {
let studyUids = filter.studyInstanceUid;
studyUids = Array.isArray(studyUids) ? studyUids.join() : studyUids;
studyUids = studyUids.replace(/[^0-9.]+/g, '\\');
parameters.StudyInstanceUID = studyUids;
}
// Clean query params of undefined values.
const params = {};
Object.keys(parameters).forEach(key => {
if (parameters[key] !== undefined &&
parameters[key] !== "") {
params[key] = parameters[key];
}
});
return params;
}
/**
* Parses resulting data from a QIDO call into a set of Study MetaData
*
* @param resultData
* @returns {Array} An array of Study MetaData objects
*/
function resultDataToStudies(resultData) {
const studies = [];
if (!resultData || !resultData.length) return;
resultData.forEach(study => studies.push({
studyInstanceUid: DICOMWeb.getString(study['0020000D']),
// 00080005 = SpecificCharacterSet
studyDate: DICOMWeb.getString(study['00080020']),
studyTime: DICOMWeb.getString(study['00080030']),
accessionNumber: DICOMWeb.getString(study['00080050']),
referringPhysicianName: DICOMWeb.getString(study['00080090']),
// 00081190 = URL
patientName: DICOMWeb.getName(study['00100010']),
patientId: DICOMWeb.getString(study['00100020']),
patientBirthdate: DICOMWeb.getString(study['00100030']),
patientSex: DICOMWeb.getString(study['00100040']),
studyId: DICOMWeb.getString(study['00200010']),
numberOfStudyRelatedSeries: DICOMWeb.getString(study['00201206']),
numberOfStudyRelatedInstances: DICOMWeb.getString(study['00201208']),
studyDescription: DICOMWeb.getString(study['00081030']),
// modality: DICOMWeb.getString(study['00080060']),
// modalitiesInStudy: DICOMWeb.getString(study['00080061']),
modalities: DICOMWeb.getString(DICOMWeb.getModalities(study['00080060'], study['00080061']))
}));
return studies;
}
OHIF.studies.services.QIDO.Studies = (server, filter) => {
const config = {
url: server.qidoRoot,
headers: OHIF.DICOMWeb.getAuthorizationHeader()
};
const dicomWeb = new DICOMwebClient.api.DICOMwebClient(config);
const queryParams = getQIDOQueryParams(filter, server.qidoSupportsIncludeField);
const options = {
queryParams
};
return dicomWeb.searchForStudies(options).then(resultDataToStudies);
};