feat: Add MPPSManager & MPPSAsyncAction
This commit is contained in:
94
src/dicom/MPPSManager.cpp
Normal file
94
src/dicom/MPPSManager.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include "MPPSManager.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QDate>
|
||||
|
||||
#include "dialogs/MultyMessageDialogManager.h"
|
||||
#include "db/SQLHelper.h"
|
||||
#include "event/EventCenter.h"
|
||||
#include "json/jsonobject.h"
|
||||
#include "device/DeviceManager.h"
|
||||
|
||||
|
||||
void MPPSManager::setPatientUID(const QString& aPatientUID)
|
||||
{
|
||||
if (aPatientUID.isEmpty())return;
|
||||
QMap<QString,QVariant> result;
|
||||
QMap<QString,QVariant> parms;
|
||||
parms[":patid"] = aPatientUID;
|
||||
SQLHelper::QueryFirst("select * from Patient where PatientUID=:patid",result,parms);
|
||||
PatientInformationPointer pat = PatientInformationPointer(new PatientInformation);
|
||||
pat->PatientUID= result["PatientUID"].toString();
|
||||
pat->ID = result["PatientID"].toString();
|
||||
pat->AccessionNumber = result.contains("AccessionNumber")?result["AccessionNumber"].toString():"";
|
||||
pat->Name = result["PatientName"].toString();
|
||||
pat->Sex = result["Sex"].toString();
|
||||
pat->BirthDate = result["BirthDate"].toString();
|
||||
pat->StudyUID = result.contains("StudyUID")?result["StudyUID"].toString():"";
|
||||
pat->RPID = result.contains("RPID")?result["RPID"].toString():"";
|
||||
pat->SPSID = result.contains("SPSID")?result["SPSID"].toString():"";
|
||||
pat->Modality = result.contains("Modality")?result["Modality"].toString():"CT";
|
||||
pat->MPPSUID = result["MPPSUID"].toString();
|
||||
action->setPatient(pat);
|
||||
}
|
||||
|
||||
void MPPSManager::processMPPSResult(const ActionResult& aResult)
|
||||
{
|
||||
if(aResult.Code == Failed){
|
||||
MultyMessageDialogManager::getInstance()->raiseDialog(aResult.Data.toString(),MessageLevel::Warning);
|
||||
}
|
||||
else{
|
||||
QStringList list = aResult.Data.toString().split("|");
|
||||
if (list.length()<2)
|
||||
{
|
||||
MultyMessageDialogManager::getInstance()->raiseDialog(tr("Create MPPSUID error!"),MessageLevel::Warning);
|
||||
return;
|
||||
}
|
||||
QString sql = "update Patient set MPPSUID=:mppsuid where PatientUID=:patuid";
|
||||
QMap<QString,QVariant> params;
|
||||
params[":mppsuid"] = list[1];
|
||||
params[":patuid"] = list[0];
|
||||
|
||||
int result = SQLHelper::ExecuteNoQuery(sql,params);
|
||||
if(result<1)return;
|
||||
MultyMessageDialogManager::getInstance()->raiseDialog(tr("Update MPPSUID success!"),MessageLevel::Warning);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MPPSManager::MPPSManager():QObject(nullptr),action(new MPPSAsyncAction(nullptr))
|
||||
{
|
||||
connect(action,&MPPSAsyncAction::actionCompleted,this,&MPPSManager::processMPPSResult);
|
||||
// connect(EventCenter::Default(),&EventCenter::SetSelectedPatient,[=](QObject* sender, QObject* data){
|
||||
// PatientInformation* patientInfo = (PatientInformation*)data;
|
||||
// if (JsonObject::Instance()->getMppsOpen()&&!patientInfo->SPSID.isEmpty()&&patientInfo->MPPSUID.isEmpty())
|
||||
// {
|
||||
// MPPSManager::getInstance()->setPatientUID(patientInfo->PatientUID);
|
||||
// }
|
||||
// });
|
||||
connect(DeviceManager::Default(), & DeviceManager::startAutoLocateResult,[=](bool result){
|
||||
if (result)
|
||||
{
|
||||
sendMPPS();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
MPPSManager::~MPPSManager()
|
||||
{
|
||||
delete action;
|
||||
}
|
||||
|
||||
MPPSManager* MPPSManager::getInstance()
|
||||
{
|
||||
static MPPSManager instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void MPPSManager::sendMPPS()
|
||||
{
|
||||
if (!action->getPatient()->MPPSUID.isEmpty())return;
|
||||
action->execute();
|
||||
}
|
||||
Reference in New Issue
Block a user