Very basic search test based on query param
This commit is contained in:
parent
6f9c27f10b
commit
45ca73946d
@ -37,22 +37,12 @@ const { getString, getName, getModalities } = DICOMWeb;
|
|||||||
* @returns {Array} An array of Study MetaData objects
|
* @returns {Array} An array of Study MetaData objects
|
||||||
*/
|
*/
|
||||||
function processResults(qidoStudies) {
|
function processResults(qidoStudies) {
|
||||||
debugger;
|
|
||||||
if (!qidoStudies || !qidoStudies.length) {
|
if (!qidoStudies || !qidoStudies.length) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const studies = [];
|
const studies = [];
|
||||||
|
|
||||||
// LIST
|
|
||||||
// AccessionNumber,
|
|
||||||
// Modalities,
|
|
||||||
// Instances,
|
|
||||||
// StudyDescription,
|
|
||||||
// PatientId,
|
|
||||||
// PatientName,
|
|
||||||
// StudyDate,
|
|
||||||
|
|
||||||
qidoStudies.forEach(qidoStudy =>
|
qidoStudies.forEach(qidoStudy =>
|
||||||
studies.push({
|
studies.push({
|
||||||
studyInstanceUid: getString(qidoStudy['0020000D']),
|
studyInstanceUid: getString(qidoStudy['0020000D']),
|
||||||
@ -140,10 +130,10 @@ function mapParams(params) {
|
|||||||
AccessionNumber: params.accessionNumber,
|
AccessionNumber: params.accessionNumber,
|
||||||
StudyDescription: params.studyDescription,
|
StudyDescription: params.studyDescription,
|
||||||
ModalitiesInStudy: params.modalitiesInStudy,
|
ModalitiesInStudy: params.modalitiesInStudy,
|
||||||
limit: params.limit,
|
limit: params.limit || 101,
|
||||||
offset: params.offset,
|
offset: params.offset || 0,
|
||||||
fuzzymatching: params.fuzzymatching,
|
fuzzymatching: params.fuzzymatching === undefined ? false : true,
|
||||||
includefield: serverSupportsQIDOIncludeField ? commaSeparatedFields : 'all',
|
includefield: commaSeparatedFields, // serverSupportsQIDOIncludeField ? commaSeparatedFields : 'all',
|
||||||
};
|
};
|
||||||
|
|
||||||
// build the StudyDate range parameter
|
// build the StudyDate range parameter
|
||||||
@ -162,14 +152,14 @@ function mapParams(params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean query params of undefined values.
|
// Clean query params of undefined values.
|
||||||
// const params = {};
|
const final = {};
|
||||||
Object.keys(parameters).forEach(key => {
|
Object.keys(parameters).forEach(key => {
|
||||||
if (parameters[key] !== undefined && parameters[key] !== '') {
|
if (parameters[key] !== undefined && parameters[key] !== '') {
|
||||||
params[key] = parameters[key];
|
final[key] = parameters[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return params;
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
|
|||||||
import { MODULE_TYPES } from '@ohif/core';
|
import { MODULE_TYPES } from '@ohif/core';
|
||||||
//
|
//
|
||||||
import { appConfig, extensionManager } from '../App.js';
|
import { appConfig, extensionManager } from '../App.js';
|
||||||
|
import { useQuery } from './../hooks';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses route properties to determine the data source that should be passed
|
* Uses route properties to determine the data source that should be passed
|
||||||
@ -15,6 +16,9 @@ import { appConfig, extensionManager } from '../App.js';
|
|||||||
*/
|
*/
|
||||||
function DataSourceWrapper(props) {
|
function DataSourceWrapper(props) {
|
||||||
const { children: LayoutTemplate, ...rest } = props;
|
const { children: LayoutTemplate, ...rest } = props;
|
||||||
|
const query = useQuery();
|
||||||
|
const queryFilterValues = _getQueryFilterValues(query);
|
||||||
|
|
||||||
// TODO: Fetch by type, name, etc?
|
// TODO: Fetch by type, name, etc?
|
||||||
const dataSourceModules = extensionManager.modules[MODULE_TYPES.DATA_SOURCE];
|
const dataSourceModules = extensionManager.modules[MODULE_TYPES.DATA_SOURCE];
|
||||||
// TODO: Good usecase for flatmap?
|
// TODO: Good usecase for flatmap?
|
||||||
@ -44,16 +48,28 @@ function DataSourceWrapper(props) {
|
|||||||
// studies.processResults --> <LayoutTemplate studies={} />
|
// studies.processResults --> <LayoutTemplate studies={} />
|
||||||
// But only for LayoutTemplate type of 'list'?
|
// But only for LayoutTemplate type of 'list'?
|
||||||
// Or no data fetching here, and just hand down my source
|
// Or no data fetching here, and just hand down my source
|
||||||
|
|
||||||
debugger;
|
|
||||||
const [data, setData] = useState();
|
const [data, setData] = useState();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
|
// 204: no content
|
||||||
async function getData() {
|
async function getData() {
|
||||||
const searchResult = await dataSource.query.studies.search();
|
const searchResult = await dataSource.query.studies.search({
|
||||||
|
patientName: queryFilterValues.patientName,
|
||||||
|
});
|
||||||
setData(searchResult);
|
setData(searchResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
getData();
|
getData();
|
||||||
}, [dataSource.query.studies]);
|
} catch (ex) {
|
||||||
|
console.warn(ex);
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log('DataSourceWrapper: useEffect');
|
||||||
|
}, []);
|
||||||
|
// queryFilterValues
|
||||||
|
|
||||||
|
console.log(rest);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
@ -68,3 +84,62 @@ DataSourceWrapper.propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default DataSourceWrapper;
|
export default DataSourceWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicated in `studyListContainer`
|
||||||
|
* Need generic that can be shared? Isn't this what qs is for?
|
||||||
|
* @param {*} query
|
||||||
|
*/
|
||||||
|
function _getQueryFilterValues(query) {
|
||||||
|
const queryFilterValues = {
|
||||||
|
patientName: query.get('patientName'),
|
||||||
|
// mrn: query.get('mrn'), patientId?
|
||||||
|
studyDate: _tryParseDates(query.get('studyDate'), undefined),
|
||||||
|
studyDescription: query.get('description'),
|
||||||
|
modalitiesInStudy: _tryParseJson(query.get('modality'), undefined),
|
||||||
|
accessionNumber: query.get('accession'),
|
||||||
|
sortBy: query.get('soryBy'),
|
||||||
|
sortDirection: query.get('sortDirection'),
|
||||||
|
page: _tryParseInt(query.get('page'), undefined),
|
||||||
|
resultsPerPage: _tryParseInt(query.get('resultsPerPage'), undefined),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Delete null/undefined keys
|
||||||
|
Object.keys(queryFilterValues).forEach(
|
||||||
|
key => queryFilterValues[key] == null && delete queryFilterValues[key]
|
||||||
|
);
|
||||||
|
|
||||||
|
return queryFilterValues;
|
||||||
|
|
||||||
|
function _tryParseInt(str, defaultValue) {
|
||||||
|
var retValue = defaultValue;
|
||||||
|
if (str !== null) {
|
||||||
|
if (str.length > 0) {
|
||||||
|
if (!isNaN(str)) {
|
||||||
|
retValue = parseInt(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _tryParseJson(str, defaultValue) {
|
||||||
|
return str ? JSON.parse(str) : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _tryParseDates(str, defaultValue) {
|
||||||
|
const studyDateObject = _tryParseJson(str, defaultValue);
|
||||||
|
|
||||||
|
if (studyDateObject) {
|
||||||
|
studyDateObject.startDate = studyDateObject.startDate
|
||||||
|
? moment(new Date(studyDateObject.startDate))
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
studyDateObject.endDate = studyDateObject.endDate
|
||||||
|
? moment(new Date(studyDateObject.endDate))
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return studyDateObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user