-
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 status of mwl item
- Loading branch information
1 parent
4c2c0bf
commit 302b2bd
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
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,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"); | ||
const { ChangeMwlItemStatusService } = require("./service/change-mwlItem-status"); | ||
|
||
class ChangeMwlItemStatusCountController extends Controller { | ||
constructor(req, res) { | ||
super(req, res); | ||
this.apiLogger = new ApiLogger(this.request, "MWL-RS"); | ||
} | ||
|
||
async mainProcess() { | ||
try { | ||
let changeMwlItemService = new ChangeMwlItemStatusService(this.request, this.response); | ||
let changedMwlItems = await changeMwlItemService.changeMwlItemsStatus(); | ||
|
||
return this.response | ||
.set("Content-Type", "application/dicom+json") | ||
.status(200) | ||
.json(changedMwlItems); | ||
|
||
} 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 ChangeMwlItemStatusCountController(req, res); | ||
|
||
await controller.doPipeline(); | ||
}; |
41 changes: 41 additions & 0 deletions
41
api/dicom-web/controller/MWL-RS/service/change-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,41 @@ | ||
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"); | ||
|
||
class ChangeMwlItemStatusService { | ||
constructor(req, res) { | ||
/** @type {import("express").Request} */ | ||
this.request = req; | ||
/** @type {import("express").Response} */ | ||
this.response = res; | ||
} | ||
|
||
async changeMwlItemsStatus() { | ||
let { status } = this.request.params; | ||
let mwlItem = await this.getMwlItemByStudyUIDAndSpsID(); | ||
if (!mwlItem) { | ||
throw new DicomWebServiceError(DicomWebStatusCodes.NoSuchObjectInstance, "No such object instance", 404); | ||
} | ||
|
||
_.set(mwlItem, `${dictionary.keyword.ScheduledProcedureStepSequence}.Value.0.${dictionary.keyword.ScheduledProcedureStepStatus}.Value.0`, status); | ||
await mwlItem.save(); | ||
|
||
return mwlItem.toDicomJson(); | ||
} | ||
|
||
async getMwlItemByStudyUIDAndSpsID() { | ||
return await MwlItemModel.findOne({ | ||
$and: [ | ||
{ | ||
"00400100.Value.0.00400009.Value.0": this.request.params.spsID | ||
}, | ||
{ | ||
"0020000D.Value.0": this.request.params.studyUID | ||
} | ||
] | ||
}); | ||
} | ||
} | ||
|
||
module.exports.ChangeMwlItemStatusService = ChangeMwlItemStatusService; |
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
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