From ee2ec31938dd1a6f7f4a95cd81013d61029dff7c Mon Sep 17 00:00:00 2001 From: chinlinlee Date: Thu, 18 Jan 2024 21:20:53 +0800 Subject: [PATCH] feat: add `QueryUpsDicomJsonFactory` and using in `geWorkItemService` --- .../QIDO-RS/service/query-dicom-json-factory.js | 9 +++++++++ .../controller/UPS-RS/service/get-workItem.service.js | 10 ++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/api/dicom-web/controller/QIDO-RS/service/query-dicom-json-factory.js b/api/dicom-web/controller/QIDO-RS/service/query-dicom-json-factory.js index 3a020c86..93e37f23 100644 --- a/api/dicom-web/controller/QIDO-RS/service/query-dicom-json-factory.js +++ b/api/dicom-web/controller/QIDO-RS/service/query-dicom-json-factory.js @@ -52,6 +52,7 @@ function getWildCardQuery(value) { } /** + * TODO: separate this function to single file * convert all request query object to to $or query and push to $and query * @param {Object} iQuery * @returns @@ -204,9 +205,17 @@ class QueryInstanceDicomJsonFactory extends QueryDicomJsonFactory { } } +class QueryUpsDicomJsonFactory extends QueryDicomJsonFactory { + constructor(queryOptions) { + super(queryOptions); + this.model = require("@dbModels/workitems.model").WorkItemModel; + } +} + module.exports.QueryDicomJsonFactory = QueryDicomJsonFactory; module.exports.QueryPatientDicomJsonFactory = QueryPatientDicomJsonFactory; module.exports.QueryStudyDicomJsonFactory = QueryStudyDicomJsonFactory; module.exports.QuerySeriesDicomJsonFactory = QuerySeriesDicomJsonFactory; module.exports.QueryInstanceDicomJsonFactory = QueryInstanceDicomJsonFactory; +module.exports.QueryUpsDicomJsonFactory = QueryUpsDicomJsonFactory; module.exports.convertRequestQueryToMongoQuery = convertRequestQueryToMongoQuery; diff --git a/api/dicom-web/controller/UPS-RS/service/get-workItem.service.js b/api/dicom-web/controller/UPS-RS/service/get-workItem.service.js index 1b90158d..17f9c561 100644 --- a/api/dicom-web/controller/UPS-RS/service/get-workItem.service.js +++ b/api/dicom-web/controller/UPS-RS/service/get-workItem.service.js @@ -1,7 +1,6 @@ const _ = require("lodash"); -const { WorkItemModel } = require("@dbModels/workitems.model"); const { - convertRequestQueryToMongoQuery + QueryUpsDicomJsonFactory } = require("../../QIDO-RS/service/query-dicom-json-factory"); const { convertAllQueryToDicomTag } = require("@root/api/dicom-web/service/base-query.service"); @@ -28,16 +27,15 @@ class GetWorkItemService { } async getUps() { - let mongoQuery = (await convertRequestQueryToMongoQuery(this.query)).$match; - let queryOptions = { - query: mongoQuery, + query: this.query, skip: this.skip_, limit: this.limit_, requestParams: this.request.params }; + let queryFactory = new QueryUpsDicomJsonFactory(queryOptions); - let docs = await WorkItemModel.getDicomJson(queryOptions); + let docs = await queryFactory.getDicomJson(); return this.adjustDocs(docs); }