From 667267b52ec040abac014c05935dee0e06118e47 Mon Sep 17 00:00:00 2001 From: chin Date: Sat, 1 Apr 2023 20:47:00 +0800 Subject: [PATCH] refactor: swap args(req, res) of `MultipartWriter` --- api/dicom-web/controller/WADO-RS/rendered/instanceFrames.js | 2 +- api/dicom-web/controller/WADO-RS/rendered/instances.js | 2 +- api/dicom-web/controller/WADO-RS/rendered/series.js | 2 +- api/dicom-web/controller/WADO-RS/rendered/study.js | 2 +- api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js | 6 +++--- utils/multipartWriter.js | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/dicom-web/controller/WADO-RS/rendered/instanceFrames.js b/api/dicom-web/controller/WADO-RS/rendered/instanceFrames.js index e6ba8f16..96acbc06 100644 --- a/api/dicom-web/controller/WADO-RS/rendered/instanceFrames.js +++ b/api/dicom-web/controller/WADO-RS/rendered/instanceFrames.js @@ -83,7 +83,7 @@ class RetrieveRenderedInstanceFramesController extends Controller { } throw new Error(`Can not process this image, instanceUID: ${instanceFramesObj.instanceUID}, frameNumber: ${this.request.frameNumber[0]}`); } else { - let multipartWriter = new MultipartWriter([], this.response, this.request); + let multipartWriter = new MultipartWriter([], this.request, this.response); await renderedService.writeSpecificFramesRenderedImages(this.request, frameNumber, instanceFramesObj, multipartWriter); multipartWriter.writeFinalBoundary(); diff --git a/api/dicom-web/controller/WADO-RS/rendered/instances.js b/api/dicom-web/controller/WADO-RS/rendered/instances.js index c37a887f..0806146a 100644 --- a/api/dicom-web/controller/WADO-RS/rendered/instances.js +++ b/api/dicom-web/controller/WADO-RS/rendered/instances.js @@ -31,7 +31,7 @@ class RetrieveRenderedInstancesController extends Controller { let imagePathObj = await mongoose.model("dicom").getPathOfInstance(this.request.params); if (imagePathObj) { - let multipartWriter = new MultipartWriter([], this.response, this.request); + let multipartWriter = new MultipartWriter([], this.request, this.response); let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj); let dicomNumberOfFrames = _.get(instanceFramesObj, "00280008.Value.0", 1); dicomNumberOfFrames = parseInt(dicomNumberOfFrames); diff --git a/api/dicom-web/controller/WADO-RS/rendered/series.js b/api/dicom-web/controller/WADO-RS/rendered/series.js index fb9e937b..c42d04da 100644 --- a/api/dicom-web/controller/WADO-RS/rendered/series.js +++ b/api/dicom-web/controller/WADO-RS/rendered/series.js @@ -26,7 +26,7 @@ class RetrieveRenderedSeriesController extends Controller { let instancesInSeries = await mongoose.model("dicomSeries").getPathGroupOfInstances(this.request.params); if (instancesInSeries.length > 0) { - let multipartWriter = new MultipartWriter([], this.response, this.request); + let multipartWriter = new MultipartWriter([], this.request, this.response); for(let imagePathObj of instancesInSeries) { let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj); diff --git a/api/dicom-web/controller/WADO-RS/rendered/study.js b/api/dicom-web/controller/WADO-RS/rendered/study.js index a71c3ac8..b475efe6 100644 --- a/api/dicom-web/controller/WADO-RS/rendered/study.js +++ b/api/dicom-web/controller/WADO-RS/rendered/study.js @@ -30,7 +30,7 @@ class RetrieveRenderedStudyController extends Controller { let pathGroupOfInstancesInStudy = await mongoose.model("dicomStudy").getPathGroupOfInstances(this.request.params); if (pathGroupOfInstancesInStudy.length > 0) { - let multipartWriter = new MultipartWriter([], this.response, this.request); + let multipartWriter = new MultipartWriter([], this.request, this.response); for(let imagePathObj of pathGroupOfInstancesInStudy) { let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj); diff --git a/api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js b/api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js index dbc46075..ed38825d 100644 --- a/api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js +++ b/api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js @@ -32,7 +32,7 @@ const multipartFunc = { code: 404, message: `not found, Study UID: ${iParam.studyUID}` }; - let multipartWriter = new MultipartWriter(imagesPath, res, req); + let multipartWriter = new MultipartWriter(imagesPath, req, res); return multipartWriter.writeDICOMFiles(type); }, getSeriesDICOMFiles: async (iParam, req, res, type) => { @@ -42,7 +42,7 @@ const multipartFunc = { code: 404, message: `not found, Series UID: ${iParam.seriesUID}, Study UID: ${iParam.studyUID}` }; - let multipartWriter = new MultipartWriter(imagesPath, res, req); + let multipartWriter = new MultipartWriter(imagesPath, req, res); return multipartWriter.writeDICOMFiles(type); }, getInstanceDICOMFile: async (iParam, req, res, type) => { @@ -52,7 +52,7 @@ const multipartFunc = { code: 404, message: `not found, Instance UID: ${iParam.instanceUID}, Series UID: ${iParam.seriesUID}, Study UID: ${iParam.studyUID}` }; - let multipartWriter = new MultipartWriter([imagePath], res, req); + let multipartWriter = new MultipartWriter([imagePath], req, res); return multipartWriter.writeDICOMFiles(type); } } diff --git a/utils/multipartWriter.js b/utils/multipartWriter.js index 771cb368..db513c28 100644 --- a/utils/multipartWriter.js +++ b/utils/multipartWriter.js @@ -24,14 +24,14 @@ class MultipartWriter { /** * * @param {Array} imagePathObjList The path list of the images - * @param {import('express').Response} res The express response * @param {import('express').Request} req + * @param {import('express').Response} res The express response */ - constructor(imagePathObjList, res, req = {}) { + constructor(imagePathObjList, req={}, res) { this.BOUNDARY = `${uuid.v4()}-${uuid.v4()}-raccoon`; this.imagePathObjList = imagePathObjList; - this.res = res; this.req = req; + this.res = res; } /**