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 184b01a7..2c722aab 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 @@ -67,7 +67,7 @@ class ImageMultipartWriter { if (!writeResult.status) { retrieveAuditService.eventResult = EventOutcomeIndicator.MajorFailure; await retrieveAuditService.completedRetrieve(); - + this.response.setHeader("Content-Type", "application/dicom+json"); return this.response.status(writeResult.code).json(writeResult); } @@ -98,7 +98,7 @@ class ImagePathFactory { return { status: false, code: 404, - message: `not found, ${this.getUidsString()}` + message: `not found, ${getUidsString(this.uids)}` }; } @@ -139,16 +139,6 @@ class ImagePathFactory { return existArr; } - getUidsString() { - let uidsKeys = Object.keys(this.uids); - let strArr = []; - for (let i = 0; i < uidsKeys.length; i++) { - let key = uidsKeys[i]; - strArr.push(`${key}: ${this.uids[key]}`); - } - return strArr.join(", "); - } - getPartialImagesPathString() { return JSON.stringify(this.imagePaths.slice(0, 10).map(v => v.instancePath)); } @@ -182,7 +172,7 @@ class InstanceImagePathFactory extends ImagePathFactory { async getImagePaths() { let imagePath = await dicomModel.getPathOfInstance(this.uids); - if(imagePath) + if (imagePath) this.imagePaths = [imagePath]; else this.imagePaths = []; @@ -255,6 +245,21 @@ function addHostnameOfBulkDataUrl(metadata, req) { } } +/** +* +* @param {import("../../../../../utils/typeDef/dicom").Uids} uids +* @returns +*/ +function getUidsString(uids) { + let uidsKeys = Object.keys(uids); + let strArr = []; + for (let i = 0; i < uidsKeys.length; i++) { + let key = uidsKeys[i]; + strArr.push(`${key}: ${uids[key]}`); + } + return strArr.join(", "); +} + module.exports.getAcceptType = getAcceptType; module.exports.supportInstanceMultipartType = supportInstanceMultipartType; module.exports.sendNotSupportedMediaType = sendNotSupportedMediaType; @@ -265,3 +270,4 @@ module.exports.SeriesImagePathFactory = SeriesImagePathFactory; module.exports.InstanceImagePathFactory = InstanceImagePathFactory; module.exports.multipartContentTypeWriter = multipartContentTypeWriter; module.exports.ImageMultipartWriter = ImageMultipartWriter; +module.exports.getUidsString = getUidsString; diff --git a/api/dicom-web/controller/WADO-RS/service/thumbnail.service.js b/api/dicom-web/controller/WADO-RS/service/thumbnail.service.js index b7f0b47f..2b629393 100644 --- a/api/dicom-web/controller/WADO-RS/service/thumbnail.service.js +++ b/api/dicom-web/controller/WADO-RS/service/thumbnail.service.js @@ -3,6 +3,7 @@ const dicomSeriesModel = require("../../../../../models/mongodb/models/dicomSeri const errorResponse = require("../../../../../utils/errorResponse/errorResponseMessage"); const renderedService = require("../service/rendered.service"); const _ = require("lodash"); +const { getUidsString } = require("./WADO-RS.service"); class ThumbnailService { /** @@ -60,7 +61,7 @@ class ThumbnailService { this.response.writeHead(404, { "Content-Type": "application/dicom+json" }); - let notFoundMessage = errorResponse.getNotFoundErrorMessage(`Not Found, ${this.thumbnailFactory.getUidsString()}`); + let notFoundMessage = errorResponse.getNotFoundErrorMessage(`Not Found, ${getUidsString(this.thumbnailFactory.uids)}`); let notFoundMessageStr = JSON.stringify(notFoundMessage); @@ -82,16 +83,6 @@ class ThumbnailFactory { } async getThumbnailInstance() { } - - getUidsString() { - let uidsKeys = Object.keys(this.uids); - let strArr = []; - for (let i = 0; i < uidsKeys.length; i++) { - let key = uidsKeys[i]; - strArr.push(`${key}: ${this.uids[key]}`); - } - return strArr.join(", "); - } } class StudyThumbnailFactory extends ThumbnailFactory {