Skip to content

Commit

Permalink
feat: add retrieve study's series' instances
Browse files Browse the repository at this point in the history
- Add, `getZipOfSeriesDICOMFiles`
- Fix, missing the `instancePath` field name when path.join in
`getSeriesImagesPath` and `WADOZip.js`
- Docs(openapi), move openapi documentation into router index.js file
- Docs(openapi), add query parameters of study's series' instances
- Docs(openapi), add response of Multipart related with DICOM
  • Loading branch information
Chinlinlee committed May 13, 2022
1 parent dcd90ca commit 1b0f235
Show file tree
Hide file tree
Showing 12 changed files with 257 additions and 143 deletions.
21 changes: 0 additions & 21 deletions api/dicom-web/controller/QIDO-RS/queryAllInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ const {
} = 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
Expand Down
21 changes: 0 additions & 21 deletions api/dicom-web/controller/QIDO-RS/queryAllSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@ const {
} = 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
Expand Down
21 changes: 0 additions & 21 deletions api/dicom-web/controller/QIDO-RS/queryAllStudies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@ const {
} = 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
Expand Down
24 changes: 0 additions & 24 deletions api/dicom-web/controller/QIDO-RS/queryStudies-Instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@ const {
} = 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
Expand Down
24 changes: 0 additions & 24 deletions api/dicom-web/controller/QIDO-RS/queryStudies-Series-Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@ const {
} = 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
Expand Down
24 changes: 0 additions & 24 deletions api/dicom-web/controller/QIDO-RS/queryStudies-Series.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@ const {
} = 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
Expand Down
49 changes: 49 additions & 0 deletions api/dicom-web/controller/WADO-RS/retrieveStudy-Series-Instances.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { logger } = require("../../../../utils/log");
const wadoService = require("./service/WADO-RS.service");
const { WADOZip } = require("./service/WADOZip");
const errorResponse = require("../../../../utils/errorResponse/errorResponseMessage");
/**
*
* @param {import("http").IncomingMessage} req
* @param {import("http").ServerResponse} res
*/
module.exports = async function(req, res) {
try {
logger.info(`[WADO-RS] [Get study's series' instances, study UID: ${req.params.studyUID}, series UID: ${req.params.seriesUID}] [Request Accept: ${req.headers.accept}]`);
if (req.headers.accept.toLowerCase() === "application/zip") {
let wadoZip = new WADOZip(req.params, res);
let zipResult = await wadoZip.getZipOfSeriesDICOMFiles();
if (zipResult.status) {
return res.end();
}
} else if (req.headers.accept.includes("multipart/related")) {
let type = wadoService.getAcceptType(req);
let isSupported = wadoService.supportInstanceMultipartType.indexOf(type) > -1;
if (!isSupported) {
let errorMessage = errorResponse.getNotSupportedErrorMessage(`The type ${type} is not supported, server supported multipart/related; type="application/dicom", multipart/related; type="application/octet-stream" and application/zip`);
res.writeHead(errorMessage.HttpStatus, {
"Content-Type": "application/dicom+json"
});
return res.end(JSON.stringify(errorMessage));
}
let writeMultipartResult = await wadoService.multipartFunc[type].getSeriesDICOMFiles(req.params, req, res, type);
if (!writeMultipartResult.status) {
res.writeHead(writeMultipartResult.code, {
"Content-Type": "application/dicom+json"
});
return res.end(JSON.stringify(writeMultipartResult));
}
}
return res.end();
} catch(e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[WADO-RS] [Error: ${errorStr}]`);
res.writeHead(500, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify({
code: 500,
message: errorStr
}));
}
};
4 changes: 2 additions & 2 deletions api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ async function getSeriesImagesPath(iParam) {
let pathList = docs.pop().pathList;
if (pathList.length > 0) {
for (let i = 0; i < pathList.length; i++) {
pathList[i] = path.join(
pathList[i].instancePath = path.join(
process.env.DICOM_STORE_ROOTPATH,
pathList[i]
pathList[i].instancePath
);
}
return pathList;
Expand Down
16 changes: 10 additions & 6 deletions api/dicom-web/controller/WADO-RS/service/WADOZip.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WADOZip {

let folders = [];
for (let i = 0; i < imagesPathList.length; i++) {
let imagesFolder = path.dirname(imagesPathList[i]);
let imagesFolder = path.dirname(imagesPathList[i].instancePath);
if (!folders.includes(imagesFolder)) {
folders.push(imagesFolder);
}
Expand All @@ -34,11 +34,15 @@ class WADOZip {
}

async getZipOfSeriesDICOMFiles() {
let seriesPathList = await wadoService.getSeriesImagesPath(
this.studyUID,
this.seriesUID
);

let imagesPathList = await wadoService.getSeriesImagesPath(this.requestParams);
if (imagesPathList) {
this.setHeaders(this.seriesUID);

let folders = [];
let seriesPath = path.dirname(imagesPathList[0].instancePath);
folders.push(seriesPath);
return await toZip(this.res, folders);
}
}
}

Expand Down
Loading

0 comments on commit 1b0f235

Please sign in to comment.