-
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.
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
api/dicom-web/controller/WADO-RS/retrieveRenderedInstances.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,44 @@ | ||
const _ = require("lodash"); | ||
const wadoService = require("./service/WADO-RS.service"); | ||
const renderedService = require("./service/rendered.service"); | ||
const { MultipartWriter } = require("../../../../utils/multipartWriter"); | ||
const errorResponse = require("../../../../utils/errorResponse/errorResponseMessage"); | ||
const { logger, apiInfoLog } = require("../../../../utils/log"); | ||
|
||
/** | ||
* | ||
* @param {import("http").IncomingMessage} req | ||
* @param {import("http").ServerResponse} res | ||
* @returns | ||
*/ | ||
module.exports = async function(req, res) { | ||
let headerAccept = _.get(req.headers, "accept", ""); | ||
apiInfoLog("WADO-RS", req.originalUrl, `[Get study's series' rendered instances, study UID: ${req.params.studyUID}, series UID: ${req.params.seriesUID}]`); | ||
if (!headerAccept == `multipart/related; type="image/jpeg"`) { | ||
let badRequestMessage = errorResponse.getBadRequestErrorMessage(`header accept only allow \`multipart/related; type="image/jpeg"\`, exception : ${headerAccept}`); | ||
res.writeHead(badRequestMessage.HttpStatus, { | ||
"Content-Type": "application/dicom+json" | ||
}); | ||
return res.end(JSON.stringify(badRequestMessage)); | ||
} | ||
|
||
try { | ||
let imagePathObj = await wadoService.getInstanceImagePath(req.params); | ||
|
||
if (imagePathObj) { | ||
let multipartWriter = new MultipartWriter([], res, req); | ||
let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj); | ||
let dicomNumberOfFrames = _.get(instanceFramesObj, "00280008.Value.0", 1); | ||
dicomNumberOfFrames = parseInt(dicomNumberOfFrames); | ||
await renderedService.writeRenderedImages(req, dicomNumberOfFrames, instanceFramesObj, multipartWriter); | ||
multipartWriter.writeFinalBoundary(); | ||
} | ||
apiInfoLog("WADO-RS", req.originalUrl, `[Write Multipart Successfully, study's series' instances' rendered images, study UID: ${req.params.studyUID}, series UID: ${req.params.seriesUID}, instance UID: ${req.params.instanceUID}]`); | ||
return res.end(); | ||
} catch(e) { | ||
res.writeHead(500, { | ||
"Content-Type": "application/dicom+json" | ||
}); | ||
res.end(JSON.stringify(e)); | ||
} | ||
}; |
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