-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactoring, move the get DICOM Json of each level to `QIDO-RS.service.js` file - Add query All Instances, /instances - Add query All Series, /series - Add query Study's Instances, /studies/{study}/instances
- Loading branch information
1 parent
e549625
commit 70efb15
Showing
8 changed files
with
370 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const _ = require("lodash"); | ||
const { | ||
convertAllQueryToDICOMTag, | ||
getInstanceDicomJson | ||
} = require("./service/QIDO-RS.service"); | ||
const { logger } = require("../../../../utils/log"); | ||
|
||
/** | ||
* @openapi | ||
* /dicom-web/studies: | ||
* get: | ||
* tags: | ||
* - QIDO-RS | ||
* description: Query for studies | ||
* parameters: | ||
* - $ref: "#/components/parameters/StudyDate" | ||
* - $ref: "#/components/parameters/StudyTime" | ||
* - $ref: "#/components/parameters/AccessionNumber" | ||
* - $ref: "#/components/parameters/ModalitiesInStudy" | ||
* - $ref: "#/components/parameters/ReferringPhysicianName" | ||
* - $ref: "#/components/parameters/PatientName" | ||
* - $ref: "#/components/parameters/PatientID" | ||
* - $ref: "#/components/parameters/StudyID" | ||
* responses: | ||
* 200: | ||
* description: Query successfully | ||
*/ | ||
|
||
/** | ||
* | ||
* @param {import('http').IncomingMessage} req | ||
* @param {import('http').ServerResponse} res | ||
*/ | ||
module.exports = async function (req, res) { | ||
logger.info( | ||
`[QIDO-RS] [Query all instances]` | ||
); | ||
try { | ||
let limit = parseInt(req.query.limit) || 100; | ||
let skip = parseInt(req.query.offset) || 0; | ||
delete req.query["limit"]; | ||
delete req.query["offset"]; | ||
let query = _.cloneDeep(req.query); | ||
let queryKeys = Object.keys(query).sort(); | ||
for (let i = 0; i < queryKeys.length; i++) { | ||
let queryKey = queryKeys[i]; | ||
if (!query[queryKey]) delete query[queryKey]; | ||
} | ||
|
||
let dicomTagQuery = convertAllQueryToDICOMTag(query); | ||
let studiesJson = await getInstanceDicomJson( | ||
dicomTagQuery, | ||
limit, | ||
skip, | ||
req | ||
); | ||
res.writeHead(200, { | ||
"Content-Type": "application/dicom+json" | ||
}); | ||
res.end(JSON.stringify(studiesJson.data)); | ||
} catch (e) { | ||
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e)); | ||
logger.error(`[QIDO-RS] [Error: ${errorStr}]`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const _ = require("lodash"); | ||
const mongoose = require("mongoose"); | ||
const moment = require("moment"); | ||
const { | ||
convertAllQueryToDICOMTag, | ||
getSeriesDicomJson | ||
} = require("./service/QIDO-RS.service"); | ||
const { logger } = require("../../../../utils/log"); | ||
|
||
/** | ||
* @openapi | ||
* /dicom-web/studies: | ||
* get: | ||
* tags: | ||
* - QIDO-RS | ||
* description: Query for studies | ||
* parameters: | ||
* - $ref: "#/components/parameters/StudyDate" | ||
* - $ref: "#/components/parameters/StudyTime" | ||
* - $ref: "#/components/parameters/AccessionNumber" | ||
* - $ref: "#/components/parameters/ModalitiesInStudy" | ||
* - $ref: "#/components/parameters/ReferringPhysicianName" | ||
* - $ref: "#/components/parameters/PatientName" | ||
* - $ref: "#/components/parameters/PatientID" | ||
* - $ref: "#/components/parameters/StudyID" | ||
* responses: | ||
* 200: | ||
* description: Query successfully | ||
*/ | ||
|
||
/** | ||
* | ||
* @param {import('http').IncomingMessage} req | ||
* @param {import('http').ServerResponse} res | ||
*/ | ||
module.exports = async function (req, res) { | ||
logger.info( | ||
`[QIDO-RS] [Query all series]` | ||
); | ||
try { | ||
let limit = parseInt(req.query.limit) || 100; | ||
let skip = parseInt(req.query.offset) || 0; | ||
delete req.query["limit"]; | ||
delete req.query["offset"]; | ||
let query = _.cloneDeep(req.query); | ||
let queryKeys = Object.keys(query).sort(); | ||
for (let i = 0; i < queryKeys.length; i++) { | ||
let queryKey = queryKeys[i]; | ||
if (!query[queryKey]) delete query[queryKey]; | ||
} | ||
|
||
let dicomTagQuery = convertAllQueryToDICOMTag(query); | ||
let studiesJson = await getSeriesDicomJson( | ||
dicomTagQuery, | ||
limit, | ||
skip, | ||
req | ||
); | ||
res.writeHead(200, { | ||
"Content-Type": "application/dicom+json" | ||
}); | ||
res.end(JSON.stringify(studiesJson.data)); | ||
} catch (e) { | ||
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e)); | ||
logger.error(`[QIDO-RS] [Error: ${errorStr}]`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
api/dicom-web/controller/QIDO-RS/queryStudies-Instances.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const _ = require("lodash"); | ||
const { | ||
convertAllQueryToDICOMTag, | ||
getInstanceDicomJson | ||
} = require("./service/QIDO-RS.service"); | ||
const { logger } = require("../../../../utils/log"); | ||
|
||
/** | ||
* @openapi | ||
* /dicom-web/studies/{studyUID}/series: | ||
* get: | ||
* tags: | ||
* - QIDO-RS | ||
* description: Query for studies | ||
* parameters: | ||
* - $ref: "#/components/parameters/studyUID" | ||
* - $ref: "#/components/parameters/StudyDate" | ||
* - $ref: "#/components/parameters/StudyTime" | ||
* - $ref: "#/components/parameters/AccessionNumber" | ||
* - $ref: "#/components/parameters/ModalitiesInStudy" | ||
* - $ref: "#/components/parameters/ReferringPhysicianName" | ||
* - $ref: "#/components/parameters/PatientName" | ||
* - $ref: "#/components/parameters/PatientID" | ||
* - $ref: "#/components/parameters/StudyID" | ||
* - $ref: "#/components/parameters/Modality" | ||
* - $ref: "#/components/parameters/SeriesNumber" | ||
* responses: | ||
* 200: | ||
* description: Query successfully | ||
*/ | ||
|
||
/** | ||
* | ||
* @param {import('http').IncomingMessage} req | ||
* @param {import('http').ServerResponse} res | ||
*/ | ||
module.exports = async function (req, res) { | ||
logger.info( | ||
`[QIDO-RS] [Query instances in study, Study UID: ${req.params.studyUID}]` | ||
); | ||
try { | ||
let limit = parseInt(req.query.limit) || 100; | ||
let skip = parseInt(req.query.offset) || 0; | ||
delete req.query["limit"]; | ||
delete req.query["offset"]; | ||
let query = _.cloneDeep(req.query); | ||
let queryKeys = Object.keys(query).sort(); | ||
for (let i = 0; i < queryKeys.length; i++) { | ||
let queryKey = queryKeys[i]; | ||
if (!query[queryKey]) delete query[queryKey]; | ||
} | ||
|
||
let dicomTagQuery = convertAllQueryToDICOMTag(query); | ||
let studiesJson = await getInstanceDicomJson( | ||
dicomTagQuery, | ||
limit, | ||
skip, | ||
req | ||
); | ||
res.writeHead(200, { | ||
"Content-Type": "application/dicom+json" | ||
}); | ||
res.end(JSON.stringify(studiesJson.data)); | ||
} catch (e) { | ||
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e)); | ||
logger.error(`[QIDO-RS] [Error: ${errorStr}]`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.