Skip to content

Commit

Permalink
feat(mongodb): implement count MWL items
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Dec 9, 2023
1 parent 926de76 commit a19caa7
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
39 changes: 39 additions & 0 deletions api/dicom-web/controller/MWL-RS/count-mwlItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { ApiErrorArrayHandler } = require("@error/api-errors.handler");
const { Controller } = require("@root/api/controller.class");
const { ApiLogger } = require("@root/utils/logs/api-logger");
const { GetMwlItemCountService } = require("./service/count-mwlItem.service");

class GetMwlItemCountController extends Controller {
constructor(req, res) {
super(req, res);
this.apiLogger = new ApiLogger(this.request, "MWL-RS");
}

async mainProcess() {
try {
let getMwlItemCountService = new GetMwlItemCountService(this.request, this.response);
let count = await getMwlItemCountService.getMwlItemCount();
return this.response
.set("Content-Type", "application/dicom+json")
.status(200)
.json({
count
});

} catch (e) {
let apiErrorArrayHandler = new ApiErrorArrayHandler(this.response, this.apiLogger, e);
return apiErrorArrayHandler.doErrorResponse();
}
}
}

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

await controller.doPipeline();
};
15 changes: 15 additions & 0 deletions api/dicom-web/controller/MWL-RS/service/count-mwlItem.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { MwlItemModel } = require("@models/mongodb/models/mwlitems.model");
const { BaseQueryService } = require("@root/api/dicom-web/service/base-query.service");

class GetMwlItemCountService extends BaseQueryService {
constructor(req, res) {
super(req, res);
}

async getMwlItemCount() {

return await MwlItemModel.getCount(this.query);
}
}

module.exports.GetMwlItemCountService = GetMwlItemCountService;
22 changes: 22 additions & 0 deletions api/dicom-web/mwl-rs.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,26 @@ router.post("/mwlitems",
*/
router.get("/mwlitems",require("./controller/MWL-RS/get-mwlItem"));

/**
* @openapi
* /dicom-web/mwlitems/count:
* get:
* tags:
* - MWL-RS
* description: >
* This transaction get Modality WorkList items count.
* parameters:
* - $ref: "#/components/parameters/filter"
* responses:
* "200":
* description: Query successfully
* content:
* "application/dicom+json":
* schema:
* properties:
* count:
* type: number
*/
router.get("/mwlitems/count",require("./controller/MWL-RS/count-mwlItem"));

module.exports = router;
3 changes: 3 additions & 0 deletions models/mongodb/models/mwlitems.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ let mwlItemSchema = new mongoose.Schema(
getDicomJsonProjection: function (includeFields) {
let includeFieldsFactory = new IncludeFieldsFactory(includeFields);
return includeFieldsFactory.getMwlLevelFields();
},
getCount: async function (query) {
return await mongoose.model("mwlItems").countDocuments(query);
}
},
methods: {
Expand Down

0 comments on commit a19caa7

Please sign in to comment.