-
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.
feat(mongodb): implement change filtered mwl items' status
- Loading branch information
1 parent
302b2bd
commit 2e9a48d
Showing
4 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
api/dicom-web/controller/MWL-RS/change-filtered-mwlItem-status.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,40 @@ | ||
const { ApiErrorArrayHandler } = require("@error/api-errors.handler"); | ||
const { Controller } = require("@root/api/controller.class"); | ||
const { ApiLogger } = require("@root/utils/logs/api-logger"); | ||
const { ChangeFilteredMwlItemStatusService } = require("./service/change-filtered-mwlItem-status"); | ||
|
||
class ChangeFilteredMwlItemStatusController extends Controller { | ||
constructor(req, res) { | ||
super(req, res); | ||
this.apiLogger = new ApiLogger(this.request, "MWL-RS"); | ||
} | ||
|
||
async mainProcess() { | ||
try { | ||
let changeFilteredMwlItemService = new ChangeFilteredMwlItemStatusService(this.request, this.response); | ||
let changedMwlItemsCount = await changeFilteredMwlItemService.changeMwlItemsStatus(); | ||
|
||
return this.response | ||
.set("Content-Type", "application/dicom+json") | ||
.status(200) | ||
.json({ | ||
updatedCount: changedMwlItemsCount | ||
}); | ||
|
||
} 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 ChangeFilteredMwlItemStatusController(req, res); | ||
|
||
await controller.doPipeline(); | ||
}; |
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
34 changes: 34 additions & 0 deletions
34
api/dicom-web/controller/MWL-RS/service/change-filtered-mwlItem-status.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,34 @@ | ||
const _ = require("lodash"); | ||
const { MwlItemModel } = require("@models/mongodb/models/mwlitems.model"); | ||
const { DicomWebServiceError, DicomWebStatusCodes } = require("@error/dicom-web-service"); | ||
const { dictionary } = require("@models/DICOM/dicom-tags-dic"); | ||
const { convertRequestQueryToMongoQuery } = require("../../QIDO-RS/service/query-dicom-json-factory"); | ||
const { BaseQueryService } = require("@root/api/dicom-web/service/base-query.service"); | ||
|
||
class ChangeFilteredMwlItemStatusService extends BaseQueryService { | ||
constructor(req, res) { | ||
super(req, res); | ||
} | ||
|
||
async changeMwlItemsStatus() { | ||
let { status } = this.request.params; | ||
let mwlItems = await this.getMwlItems(); | ||
if (mwlItems.length === 0) { | ||
throw new DicomWebServiceError(DicomWebStatusCodes.NoSuchObjectInstance, "Can not found any MWL item from query", 404); | ||
} | ||
|
||
for (let mwlItem of mwlItems) { | ||
_.set(mwlItem, `${dictionary.keyword.ScheduledProcedureStepSequence}.Value.0.${dictionary.keyword.ScheduledProcedureStepStatus}.Value.0`, status); | ||
await mwlItem.save(); | ||
} | ||
|
||
return mwlItems.length; | ||
} | ||
|
||
async getMwlItems() { | ||
let query = (await convertRequestQueryToMongoQuery(this.query)).$match; | ||
return await MwlItemModel.find(query); | ||
} | ||
} | ||
|
||
module.exports.ChangeFilteredMwlItemStatusService = ChangeFilteredMwlItemStatusService; |
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