95 lines
3.2 KiB
C++
95 lines
3.2 KiB
C++
#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::Error);
|
|
}
|
|
else{
|
|
QStringList list = aResult.Data.toString().split("|");
|
|
if (list.length()<2)
|
|
{
|
|
MultyMessageDialogManager::getInstance()->raiseDialog(tr("Create MPPSUID error!"),MessageLevel::Error);
|
|
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::Info);
|
|
}
|
|
|
|
}
|
|
|
|
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();
|
|
}
|