Skip to content

Commit

Permalink
feat: query instance route
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Aug 8, 2023
1 parent 44b558e commit 33bb29d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
46 changes: 46 additions & 0 deletions api-sql/dicom-web/controller/QIDO-RS/queryAllInstances.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const {
QidoRsService
} = require("./service/QIDO-RS.service");
const { ApiLogger } = require("@root/utils/logs/api-logger");
const { Controller } = require("@root/api/controller.class");

class QueryAllInstancesController extends Controller {
constructor(req, res) {
super(req, res);
}

async mainProcess() {
let apiLogger = new ApiLogger(this.request, "QIDO-RS");

apiLogger.addTokenValue();
apiLogger.logger.info("Query all instances");

try {
let qidoRsService = new QidoRsService(this.request, this.response, "instance");

await qidoRsService.getAndResponseDicomJson();
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
apiLogger.logger.error(errorStr);

this.response.writeHead(500, {
"Content-Type": "application/dicom+json"
});
this.response.end(JSON.stringify({
code: 500,
message: "Server error occurred"
}));
}
}
}

/**
*
* @param {import('express').Request} req
* @param {import('express').Response} res
*/
module.exports = async function (req, res) {
let controller = new QueryAllInstancesController(req, res);

await controller.doPipeline();
};
12 changes: 6 additions & 6 deletions api-sql/dicom-web/qido-rs.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ router.get(
* - $ref: "#/components/schemas/SeriesRequiredMatchingAttributes"
* - $ref: "#/components/schemas/InstanceRequiredMatchingAttributes"
*/
// router.get(
// "/instances", validateParams(queryValidation, "query", {
// allowUnknown: true
// }),
// require("./controller/QIDO-RS/queryAllInstances")
// );
router.get(
"/instances", validateParams(queryValidation, "query", {
allowUnknown: true
}),
require("./controller/QIDO-RS/queryAllInstances")
);

/**
* @openapi
Expand Down

0 comments on commit 33bb29d

Please sign in to comment.