feat: Add MPPS logic to Scan Procedure

This commit is contained in:
chenhuijun
2024-06-06 13:39:30 +08:00
parent c8904e3ce6
commit eb6413a147
2 changed files with 139 additions and 124 deletions

View File

@@ -1151,18 +1151,26 @@ void DeviceManager::startCreateReconRecord()
emit createEmptyScanToRecon(scanid, RECON_TRANSFER_PATH + "/" + scanid); emit createEmptyScanToRecon(scanid, RECON_TRANSFER_PATH + "/" + scanid);
} }
sql = "SELECT ScanID, ReferenceID, PatientID FROM Scan WHERE State < 300 And State >= 200 ORDER BY ScanDateTime ASC"; sql = "SELECT ScanID, ReferenceID, PatientID, AccessionNumber FROM Scan WHERE State < 300 And State >= 200 ORDER BY ScanDateTime ASC";
result = SQLHelper::queryValues(sql); result = SQLHelper::queryValues(sql);
for (const QVariant &variant : result) for (const QVariant &variant : result)
{ {
QList<QVariant> record = variant.value<QList<QVariant>>(); QList<QVariant> record = variant.value<QList<QVariant>>();
QString scanID = record[0].toString(); QString scanID = record[0].toString();
QString referenceID = record[1].toString(); QString referenceID = record[1].toString();
// QString patientID = record[2].toString();; QString patientID = record[2].toString();
//TODO:need StudyUID & MPPS Uid QString AccessionNumber = record[3].toString();
QString studyUID;
QString mppsUID; QString pat_sql = "SELECT AccessionNumber, StudyUID, Modality, MPPSUID FROM Patient WHERE PatientID=:patID and AccessionNumber=:accno";
emit createScanToRecon(scanID, studyUID,mppsUID, referenceID, RECON_TRANSFER_PATH + "/" + scanID); QMap<QString,QVariant> map;
QMap<QString,QVariant> params;
params[":patID"] = patientID;
params[":accno"] = AccessionNumber;
SQLHelper::QueryFirst(pat_sql, map, params);
QString studyUID = map.contains("StudyUID")?map["StudyUID"].toString():"";
QString mppsUID = map.contains("MPPSUID")?map["MPPSUID"].toString():"";
emit createScanToRecon(scanID, studyUID, mppsUID, referenceID, RECON_TRANSFER_PATH + "/" + scanID);
} }
startTransfer(); startTransfer();
} }

View File

@@ -20,18 +20,20 @@
#include "components/CoordinateXYWidget.h" #include "components/CoordinateXYWidget.h"
#include "components/CoordinateZWidget.h" #include "components/CoordinateZWidget.h"
#include "utilities/ScanProcessSequence.h" #include "utilities/ScanProcessSequence.h"
#include "dicom/MPPSManager.h"
#ifdef WIN32 #ifdef WIN32
#else #else
#include <cmath> #include <cmath>
#endif #endif
namespace{ namespace
{
const size_t PREVIEW_ROW = 140; const size_t PREVIEW_ROW = 140;
const size_t PREVIEW_COL = 140; const size_t PREVIEW_COL = 140;
const float PIXEL_SPACING = 1.5f; const float PIXEL_SPACING = 1.5f;
const float HALF_ROI_WIDTH = 100.0f; const float HALF_ROI_WIDTH = 100.0f;
const unsigned int DRAINAGE_TIME = 180000; //3 minitues const unsigned int DRAINAGE_TIME = 180000; // 3 minitues
} }
ScanFormWidget::ScanFormWidget(QWidget* parent) ScanFormWidget::ScanFormWidget(QWidget* parent)
@@ -57,7 +59,7 @@ ScanFormWidget::ScanFormWidget(QWidget* parent)
initEvents(); initEvents();
mDrainageTimer->setSingleShot(true); mDrainageTimer->setSingleShot(true);
connect(mDrainageTimer, &QTimer::timeout, this, [this]() connect(mDrainageTimer, &QTimer::timeout, this, [this]()
{ {
mDrainageButton->click(); mDrainageButton->click();
}); });
} }
@@ -93,7 +95,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
layout->addWidget(mDrainageButton); layout->addWidget(mDrainageButton);
connect(mDrainageButton, &QToolButton::clicked, [=](bool aSatus) connect(mDrainageButton, &QToolButton::clicked, [=](bool aSatus)
{ {
//Drainage //Drainage
if(aSatus && DialogManager::Default()->requestAlertMessage(tr("Make sure to open the drain valve ?"), DialogButtonMode::OkAndCancel, tr("Confirm Drainage")) == QDialog::Rejected) if(aSatus && DialogManager::Default()->requestAlertMessage(tr("Make sure to open the drain valve ?"), DialogButtonMode::OkAndCancel, tr("Confirm Drainage")) == QDialog::Rejected)
{ {
@@ -120,7 +122,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
}); });
connect(DeviceManager::Default(), &DeviceManager::startPumpControlResult, [this](bool aIsSucessful) connect(DeviceManager::Default(), &DeviceManager::startPumpControlResult, [this](bool aIsSucessful)
{ {
mDrainageButton->setEnabled(true); mDrainageButton->setEnabled(true);
if(!aIsSucessful) if(!aIsSucessful)
{ {
@@ -141,7 +143,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
connect(mAccountButton, &QToolButton::clicked, DialogManager::Default(),&DialogManager::requestEditSelfAccount); connect(mAccountButton, &QToolButton::clicked, DialogManager::Default(),&DialogManager::requestEditSelfAccount);
connect(mShutdownButton, &QToolButton::clicked, []() connect(mShutdownButton, &QToolButton::clicked, []()
{ {
if(DialogManager::Default()->requestAlertMessage(QString(tr("Shut down now ?")), DialogButtonMode::OkAndCancel,tr("Shut Down")) == QDialog::Accepted) if(DialogManager::Default()->requestAlertMessage(QString(tr("Shut down now ?")), DialogButtonMode::OkAndCancel,tr("Shut Down")) == QDialog::Accepted)
{ {
LOG_USER_OPERATION("Shut Down") LOG_USER_OPERATION("Shut Down")
@@ -150,14 +152,14 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
}); });
connect(mWorklistButton, &QToolButton::clicked, [&]() connect(mWorklistButton, &QToolButton::clicked, [&]()
{ {
DialogManager::Default()->requestGetWorkList(); DialogManager::Default()->requestGetWorkList();
}); });
connect(EventCenter::Default(), &EventCenter::AnonymousModeChanged, this, &ScanFormWidget::updateDataByAnonymousMode); connect(EventCenter::Default(), &EventCenter::AnonymousModeChanged, this, &ScanFormWidget::updateDataByAnonymousMode);
connect(mStartScanButton, &QToolButton::clicked, [this]() connect(mStartScanButton, &QToolButton::clicked, [this]()
{ {
if(mStartScanButton->isChecked()) if(mStartScanButton->isChecked())
{ {
EventCenter::Default()->triggerEvent(GUIEvents::StartScanProcess, nullptr, nullptr); EventCenter::Default()->triggerEvent(GUIEvents::StartScanProcess, nullptr, nullptr);
@@ -170,7 +172,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
}); });
connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this]() connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this]()
{ {
mWorklistButton->setEnabled(false); mWorklistButton->setEnabled(false);
mAccountButton->setEnabled(false); mAccountButton->setEnabled(false);
mDrainageButton->setEnabled(false); mDrainageButton->setEnabled(false);
@@ -180,7 +182,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
}); });
connect(EventCenter::Default(), &EventCenter::StopScanProcess, [this]() connect(EventCenter::Default(), &EventCenter::StopScanProcess, [this]()
{ {
mWorklistButton->setEnabled(true); mWorklistButton->setEnabled(true);
mAccountButton->setEnabled(true); mAccountButton->setEnabled(true);
mDrainageButton->setEnabled(true); mDrainageButton->setEnabled(true);
@@ -196,12 +198,12 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
}); });
connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [this]() connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [this]()
{ {
mScanProcessLabel->setText(tr("Data scanning, please keep the current position and don't move.")); mScanProcessLabel->setText(tr("Data scanning, please keep the current position and don't move."));
}); });
connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::fullScanDataExport, [this]() connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::fullScanDataExport, [this]()
{ {
mScanProcessLabel->setText(tr("Data exporting, patient can leave the holder")); mScanProcessLabel->setText(tr("Data exporting, patient can leave the holder"));
}); });
@@ -248,39 +250,39 @@ void ScanFormWidget::initScanContent()
void ScanFormWidget::initScanControlBar(QHBoxLayout *layout) void ScanFormWidget::initScanControlBar(QHBoxLayout *layout)
{ {
// connect(mBtnEScan, &QToolButton::clicked, [=]() { // connect(mBtnEScan, &QToolButton::clicked, [=]() {
// int result = DialogManager::Default()->requestAlertMessage(tr("Please make sure the holder is only contain water!"),DialogButtonMode::OkAndCancel,tr("Confirm Scan")); // int result = DialogManager::Default()->requestAlertMessage(tr("Please make sure the holder is only contain water!"),DialogButtonMode::OkAndCancel,tr("Confirm Scan"));
// if (result != QDialog::Accepted)return; // if (result != QDialog::Accepted)return;
// QString patientInf(mPatInf->getCurrentPatientJsonString(true)); // QString patientInf(mPatInf->getCurrentPatientJsonString(true));
// LOG_USER_OPERATION("Start Empty Scan") // LOG_USER_OPERATION("Start Empty Scan")
// EventCenter::Default()->triggerEvent(RequestEmptyScan, nullptr, (QObject*)(&patientInf)); // EventCenter::Default()->triggerEvent(RequestEmptyScan, nullptr, (QObject*)(&patientInf));
// }); // });
// connect(mBtnPreview, &QToolButton::clicked, [=]() { // connect(mBtnPreview, &QToolButton::clicked, [=]() {
// LOG_USER_OPERATION(QString("Start Preview, ID: %1").arg(mPatInf->getPatientID())) // LOG_USER_OPERATION(QString("Start Preview, ID: %1").arg(mPatInf->getPatientID()))
// EventCenter::Default()->triggerEvent(RequestPreviewScan, nullptr, nullptr); // EventCenter::Default()->triggerEvent(RequestPreviewScan, nullptr, nullptr);
// }); // });
// connect(mBtnScan, &QToolButton::clicked, [=]() { // connect(mBtnScan, &QToolButton::clicked, [=]() {
// if(JsonObject::Instance()->getScanConfirm()) // if(JsonObject::Instance()->getScanConfirm())
// { // {
// int ret = DialogManager::Default()->requestPatientConfirm(mPatInf->getPatientInformation(),mPatInf->getProtocol()); // int ret = DialogManager::Default()->requestPatientConfirm(mPatInf->getPatientInformation(),mPatInf->getProtocol());
// if (ret != QDialog::Accepted) return; // if (ret != QDialog::Accepted) return;
// } // }
// QString patientInf(mPatInf->getCurrentPatientJsonString(false)); // QString patientInf(mPatInf->getCurrentPatientJsonString(false));
// LOG_USER_OPERATION(QString("Start Scan, ID: %1").arg(mPatInf->getPatientID())) // LOG_USER_OPERATION(QString("Start Scan, ID: %1").arg(mPatInf->getPatientID()))
// if (!DeviceManager::Default()->hasValidEmptyScan()){ // if (!DeviceManager::Default()->hasValidEmptyScan()){
// QString msg(tr("No refresh data exists, please do Refresh operation first.")); // QString msg(tr("No refresh data exists, please do Refresh operation first."));
// EventCenter::Default()->triggerEvent(DeviceErrorRaise, nullptr, (QObject*)(&msg)); // EventCenter::Default()->triggerEvent(DeviceErrorRaise, nullptr, (QObject*)(&msg));
// return; // return;
// } // }
// EventCenter::Default()->triggerEvent(RequestPatientScan, nullptr, (QObject*)(&patientInf)); // EventCenter::Default()->triggerEvent(RequestPatientScan, nullptr, (QObject*)(&patientInf));
// }); // });
// connect(mBtnStop, &QToolButton::clicked, [=]() { // connect(mBtnStop, &QToolButton::clicked, [=]() {
// LOG_USER_OPERATION("Stop Preview") // LOG_USER_OPERATION("Stop Preview")
// EventCenter::Default()->triggerEvent(RequestPreviewStop, nullptr, nullptr); // EventCenter::Default()->triggerEvent(RequestPreviewStop, nullptr, nullptr);
// }); // });
} }
@@ -300,11 +302,11 @@ void ScanFormWidget::prepareStartFullScan()
void ScanFormWidget::setPreviewing(bool val) void ScanFormWidget::setPreviewing(bool val)
{ {
// mBtnPreview->setCheckable(val); // mBtnPreview->setCheckable(val);
// mBtnPreview->setChecked(val); // mBtnPreview->setChecked(val);
// mBtnPreview->setEnabled(!val); // mBtnPreview->setEnabled(!val);
// mBtnEScan->setEnabled(!val); // mBtnEScan->setEnabled(!val);
// mBtnScan->setEnabled(!val); // mBtnScan->setEnabled(!val);
mDrainageButton->setEnabled(!val); mDrainageButton->setEnabled(!val);
} }
@@ -383,9 +385,14 @@ void ScanFormWidget::initEvents()
mPatInf->setPatientInformation(patientInfo->Copy(), protocal); mPatInf->setPatientInformation(patientInfo->Copy(), protocal);
setScanProtocal(protocal); setScanProtocal(protocal);
LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID)) LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID))
if (JsonObject::Instance()->getMppsOpen() && !patientInfo->SPSID.isEmpty() && patientInfo->MPPSUID.isEmpty())
{
MPPSManager::getInstance()->setPatientUID(patientInfo->PatientUID);
}
mStartScanButton->setEnabled(true); mStartScanButton->setEnabled(true);
EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, patientInfo); EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, patientInfo);
mStartScanButton->click(); mStartScanButton->click();
} }
// mBtnScan->setEnabled(true); // mBtnScan->setEnabled(true);
@@ -431,10 +438,10 @@ QString ScanFormWidget::getAutoLocateMessage()
ScanPosition position = ScanProcessSequence::getInstance()->topPosition(); ScanPosition position = ScanProcessSequence::getInstance()->topPosition();
switch (position) switch (position)
{ {
case ScanPosition::Left: case ScanPosition::Left:
return tr("Left side scan initiated, auto positioning in progress."); return tr("Left side scan initiated, auto positioning in progress.");
case ScanPosition::Right: case ScanPosition::Right:
return tr("Right side scan initiated, auto positioning in progress."); return tr("Right side scan initiated, auto positioning in progress.");
} }
return QString(""); return QString("");
} }
@@ -444,22 +451,22 @@ void ScanFormWidget::setScanProtocal(int aProtocal)
ScanProcessSequence::getInstance()->clear(); ScanProcessSequence::getInstance()->clear();
switch (aProtocal) switch (aProtocal)
{ {
case ScanProtocal::LSTAND: case ScanProtocal::LSTAND:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right); ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left); ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
return; return;
case ScanProtocal::RSTAND: case ScanProtocal::RSTAND:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left); ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right); ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
return; return;
case ScanProtocal::LONE: case ScanProtocal::LONE:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left); ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
return; return;
case ScanProtocal::RONE: case ScanProtocal::RONE:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right); ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
return; return;
default: default:
return; return;
} }
} }
@@ -468,54 +475,54 @@ void ScanFormWidget::keyPressEvent(QKeyEvent* aEvent)
{ {
switch (aEvent->key()) switch (aEvent->key())
{ {
case Qt::Key_0: case Qt::Key_0:
case Qt::Key_1: case Qt::Key_1:
case Qt::Key_2: case Qt::Key_2:
case Qt::Key_3: case Qt::Key_3:
case Qt::Key_4: case Qt::Key_4:
case Qt::Key_5: case Qt::Key_5:
case Qt::Key_6: case Qt::Key_6:
case Qt::Key_7: case Qt::Key_7:
case Qt::Key_8: case Qt::Key_8:
case Qt::Key_9: case Qt::Key_9:
case Qt::Key_A: case Qt::Key_A:
case Qt::Key_B: case Qt::Key_B:
case Qt::Key_C: case Qt::Key_C:
case Qt::Key_D: case Qt::Key_D:
case Qt::Key_E: case Qt::Key_E:
case Qt::Key_F: case Qt::Key_F:
case Qt::Key_G: case Qt::Key_G:
case Qt::Key_H: case Qt::Key_H:
case Qt::Key_I: case Qt::Key_I:
case Qt::Key_J: case Qt::Key_J:
case Qt::Key_K: case Qt::Key_K:
case Qt::Key_L: case Qt::Key_L:
case Qt::Key_M: case Qt::Key_M:
case Qt::Key_N: case Qt::Key_N:
case Qt::Key_O: case Qt::Key_O:
case Qt::Key_P: case Qt::Key_P:
case Qt::Key_Q: case Qt::Key_Q:
case Qt::Key_R: case Qt::Key_R:
case Qt::Key_S: case Qt::Key_S:
case Qt::Key_T: case Qt::Key_T:
case Qt::Key_U: case Qt::Key_U:
case Qt::Key_V: case Qt::Key_V:
case Qt::Key_W: case Qt::Key_W:
case Qt::Key_X: case Qt::Key_X:
case Qt::Key_Y: case Qt::Key_Y:
case Qt::Key_Z: case Qt::Key_Z:
{ {
WorkListManager::getInstance()->setSearchString(aEvent->text()); WorkListManager::getInstance()->setSearchString(aEvent->text());
break; break;
} }
case Qt::Key_Enter: case Qt::Key_Enter:
case Qt::Key_Return: case Qt::Key_Return:
{ {
QString text = WorkListManager::getInstance()->getSearchString(); QString text = WorkListManager::getInstance()->getSearchString();
EventCenter::Default()->triggerEvent(InputWorkListSearchValue, nullptr, (QObject*)&text); EventCenter::Default()->triggerEvent(InputWorkListSearchValue, nullptr, (QObject*)&text);
break; break;
} }
default: default:
break; break;
} }
QWidget::keyPressEvent(aEvent); QWidget::keyPressEvent(aEvent);