Skip to content

Commit

Permalink
refactor: extract query info model(level)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Aug 21, 2023
1 parent 1c11f1d commit 941408b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
21 changes: 2 additions & 19 deletions dimse/c-find.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,7 @@ const { JsPatientQueryTask } = require("./patientQueryTask");
const { JsStudyQueryTask } = require("./studyQueryTask");
const { JsSeriesQueryTask } = require("./seriesQueryTask");
const { JsInstanceQueryTask } = require("./instanceQueryTask");

const PATIENT_ROOT_LEVELS = EnumSet.ofSync(
QueryRetrieveLevel2.PATIENT,
QueryRetrieveLevel2.STUDY,
QueryRetrieveLevel2.SERIES,
QueryRetrieveLevel2.IMAGE
);

const STUDY_ROOT_LEVELS = EnumSet.ofSync(
QueryRetrieveLevel2.STUDY,
QueryRetrieveLevel2.SERIES,
QueryRetrieveLevel2.IMAGE
);

const PATIENT_STUDY_ONLY_LEVELS = EnumSet.ofSync(
QueryRetrieveLevel2.PATIENT,
QueryRetrieveLevel2.STUDY
);
const { PATIENT_ROOT_LEVELS, STUDY_ROOT_LEVELS, PATIENT_STUDY_ONLY_LEVELS } = require("./level");

class JsCFindScp {
constructor() { }
Expand Down Expand Up @@ -108,7 +91,7 @@ class JsCFindScp {
return await (new JsStudyQueryTask(as, pc, rq, keys)).get();
} else if (await level.compareTo(QueryRetrieveLevel2.SERIES) === 0) {
return await (new JsSeriesQueryTask(as, pc, rq, keys)).get();
} else if (await level.compareTo(QueryRetrieveLevel2.IMAGE) === 0) {
} else if (await level.compareTo(QueryRetrieveLevel2.IMAGE) === 0) {
return await (new JsInstanceQueryTask(as, pc, rq, keys)).get();
}
} catch (e) {
Expand Down
24 changes: 24 additions & 0 deletions dimse/level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { EnumSet } = require("@java-wrapper/java/util/EnumSet");
const { QueryRetrieveLevel2 } = require("@dcm4che/net/service/QueryRetrieveLevel2");

const PATIENT_ROOT_LEVELS = EnumSet.ofSync(
QueryRetrieveLevel2.PATIENT,
QueryRetrieveLevel2.STUDY,
QueryRetrieveLevel2.SERIES,
QueryRetrieveLevel2.IMAGE
);

const STUDY_ROOT_LEVELS = EnumSet.ofSync(
QueryRetrieveLevel2.STUDY,
QueryRetrieveLevel2.SERIES,
QueryRetrieveLevel2.IMAGE
);

const PATIENT_STUDY_ONLY_LEVELS = EnumSet.ofSync(
QueryRetrieveLevel2.PATIENT,
QueryRetrieveLevel2.STUDY
);

module.exports.PATIENT_ROOT_LEVELS = PATIENT_ROOT_LEVELS;
module.exports.STUDY_ROOT_LEVELS = STUDY_ROOT_LEVELS;
module.exports.PATIENT_STUDY_ONLY_LEVELS = PATIENT_STUDY_ONLY_LEVELS;

0 comments on commit 941408b

Please sign in to comment.