Skip to content

Commit

Permalink
feat: log DIMSE query and extend parent's queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Aug 23, 2023
1 parent 962b46c commit 9315729
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
11 changes: 8 additions & 3 deletions dimse/instanceQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions dimse/patientQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion dimse/seriesQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions dimse/studyQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9315729

Please sign in to comment.