50 lines
1.7 KiB
JavaScript
50 lines
1.7 KiB
JavaScript
const BaseController = require("./base");
|
|
const child_process = require('child_process');
|
|
const path = require('path');
|
|
|
|
class PacsController extends BaseController {
|
|
constructor(props) {
|
|
super(props);
|
|
}
|
|
|
|
async findFromPacs() {
|
|
// 验证数据
|
|
try {
|
|
this.ctx.validate({
|
|
ip:"string",
|
|
port:"string",
|
|
title:"string",
|
|
})
|
|
} catch (e) {
|
|
return this.error(e)
|
|
}
|
|
|
|
let {ip,port,title}=this.ctx.request.body
|
|
let PatientName =this.ctx.request.body.PatientName||""
|
|
let PatientID =this.ctx.request.body.PatientID||""
|
|
let StudyDate =this.ctx.request.body.StudyDate||""
|
|
let ModalitiesInStudy =this.ctx.request.body.ModalitiesInStudy||""
|
|
let StudyInstanceUID =this.ctx.request.body.StudyInstanceUID||""
|
|
let QueryRetrieveLevel = this.ctx.request.body.QueryRetrieveLevel||"STUDY"
|
|
|
|
let pythonFilePath=path.join(__dirname, '../python/findscu.py')
|
|
let args ="-remotehost="+ip +" -remoteport="+port +" -aec=" +title +" -QueryRetrieveLevel=" +QueryRetrieveLevel+" -PatientName=" +PatientName +" -PatientID=" +PatientID+" -StudyDate=" +StudyDate +" -ModalitiesInStudy="+ ModalitiesInStudy+" -StudyInstanceUID="+ StudyInstanceUID
|
|
|
|
let result=""
|
|
try{
|
|
let res= await child_process.execSync(`python ${pythonFilePath} ${args}`).toString()
|
|
if (res.indexOf("Findsuccess")!=-1) {
|
|
result = JSON.parse(res.split("=|=")[1])
|
|
}
|
|
}catch(e){
|
|
}
|
|
|
|
if (result!=""){
|
|
return this.success(result)
|
|
}
|
|
else{
|
|
return this.error("未查询到结果")
|
|
}
|
|
}
|
|
}
|
|
module.exports = PacsController; |