From 93157293f2083f39a1e42f1df80a38bed170050c Mon Sep 17 00:00:00 2001 From: chin Date: Wed, 23 Aug 2023 20:34:34 +0800 Subject: [PATCH] feat: log DIMSE query and extend parent's queries --- dimse/instanceQueryTask.js | 11 ++++++++--- dimse/patientQueryTask.js | 2 ++ dimse/seriesQueryTask.js | 9 ++++++++- dimse/studyQueryTask.js | 2 ++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dimse/instanceQueryTask.js b/dimse/instanceQueryTask.js index 086ce3ba..7000f05f 100644 --- a/dimse/instanceQueryTask.js +++ b/dimse/instanceQueryTask.js @@ -7,6 +7,8 @@ const dicomModel = require("@models/mongodb/models/dicom"); const { InstanceQueryTask } = require("@java-wrapper/org/github/chinlinlee/dcm777/net/InstanceQueryTask"); const { Attributes } = require("@dcm4che/data/Attributes"); const { createInstanceQueryTaskInjectProxy } = require("@java-wrapper/org/github/chinlinlee/dcm777/net/InstanceQueryTaskInject"); +const { Tag } = require("@dcm4che/data/Tag"); +const { logger } = require("@root/utils/logs/log"); class JsInstanceQueryTask extends JsSeriesQueryTask { @@ -77,9 +79,7 @@ class JsInstanceQueryTask extends JsSeriesQueryTask { }, getInstance: async () => { this.instance = await this.instanceCursor.next(); - console.time("getAttributes"); this.instanceAttr = this.instance ? await this.instance.getAttributes() : null; - console.timeEnd("getAttributes"); }, findNextInstance: async () => { if (!this.seriesAttr) @@ -109,12 +109,17 @@ class JsInstanceQueryTask extends JsSeriesQueryTask { } async getNextInstanceCursor() { - let queryBuilder = new DimseQueryBuilder(this.keys, "instance"); + let queryAttr = await Attributes.newInstanceAsync(); + await queryAttr.addAll(this.keys); + await queryAttr.addSelected(this.seriesAttr, [Tag.PatientID, Tag.StudyInstanceUID, Tag.SeriesInstanceUID]); + + let queryBuilder = new DimseQueryBuilder(queryAttr, "instance"); let normalQuery = await queryBuilder.toNormalQuery(); let mongoQuery = await queryBuilder.getMongoQuery(normalQuery); let returnKeys = this.getReturnKeys(normalQuery); + logger.info(`do DIMSE Instance query: ${JSON.stringify(mongoQuery.$match)}`); this.instanceCursor = await dicomModel.getDimseResultCursor({ ...mongoQuery.$match }, returnKeys); diff --git a/dimse/patientQueryTask.js b/dimse/patientQueryTask.js index fe82bb35..86352098 100644 --- a/dimse/patientQueryTask.js +++ b/dimse/patientQueryTask.js @@ -9,6 +9,7 @@ const { DimseQueryBuilder } = require("./queryBuilder"); const patientModel = require("@models/mongodb/models/patient"); const { Association } = require("@dcm4che/net/Association"); const { PresentationContext } = require("@dcm4che/net/pdu/PresentationContext"); +const { logger } = require("@root/utils/logs/log"); class JsPatientQueryTask { @@ -145,6 +146,7 @@ class JsPatientQueryTask { let returnKeys = this.getReturnKeys(normalQuery); + logger.info(`do DIMSE Patient query: ${JSON.stringify(mongoQuery.$match)}`); this.cursor = await patientModel.getDimseResultCursor({ ...mongoQuery.$match }, returnKeys); diff --git a/dimse/seriesQueryTask.js b/dimse/seriesQueryTask.js index 96b2b882..9428f4b5 100644 --- a/dimse/seriesQueryTask.js +++ b/dimse/seriesQueryTask.js @@ -7,6 +7,8 @@ const dicomSeriesModel = require("@models/mongodb/models/dicomSeries"); const { SeriesQueryTask } = require("@java-wrapper/org/github/chinlinlee/dcm777/net/SeriesQueryTask"); const { Attributes } = require("@dcm4che/data/Attributes"); const { createSeriesQueryTaskInjectProxy } = require("@java-wrapper/org/github/chinlinlee/dcm777/net/SeriesQueryTaskInject"); +const { Tag } = require("@dcm4che/data/Tag"); +const { logger } = require("@root/utils/logs/log"); class JsSeriesQueryTask extends JsStudyQueryTask { constructor(as, pc, rq, keys) { @@ -105,12 +107,17 @@ class JsSeriesQueryTask extends JsStudyQueryTask { } async getNextSeriesCursor() { - let queryBuilder = new DimseQueryBuilder(this.keys, "series"); + let queryAttr = await Attributes.newInstanceAsync(); + await queryAttr.addAll(this.keys); + await queryAttr.addSelected(this.studyAttr, [Tag.PatientID, Tag.StudyInstanceUID]); + + let queryBuilder = new DimseQueryBuilder(queryAttr, "series"); let normalQuery = await queryBuilder.toNormalQuery(); let mongoQuery = await queryBuilder.getMongoQuery(normalQuery); let returnKeys = this.getReturnKeys(normalQuery); + logger.info(`do DIMSE Series query: ${JSON.stringify(mongoQuery.$match)}`); this.seriesCursor = await dicomSeriesModel.getDimseResultCursor({ ...mongoQuery.$match }, returnKeys); diff --git a/dimse/studyQueryTask.js b/dimse/studyQueryTask.js index ddde45b9..c32415e0 100644 --- a/dimse/studyQueryTask.js +++ b/dimse/studyQueryTask.js @@ -8,6 +8,7 @@ const { StudyQueryTaskInjectInterface, createStudyQueryTaskInjectProxy } = requi const { DimseQueryBuilder } = require("./queryBuilder"); const dicomStudyModel = require("@models/mongodb/models/dicomStudy"); const { Attributes } = require("@dcm4che/data/Attributes"); +const { logger } = require("@root/utils/logs/log"); class JsStudyQueryTask extends JsPatientQueryTask { constructor(as, pc, rq, keys) { @@ -114,6 +115,7 @@ class JsStudyQueryTask extends JsPatientQueryTask { let returnKeys = this.getReturnKeys(normalQuery); + logger.info(`do DIMSE Study query: ${JSON.stringify(mongoQuery.$match)}`); this.studyCursor = await dicomStudyModel.getDimseResultCursor({ ...mongoQuery.$match }, returnKeys);