refactor: Scan process.

This commit is contained in:
sunwen
2024-05-24 13:49:54 +08:00
parent 9c72bee9f7
commit 370e7326bc
18 changed files with 921 additions and 74 deletions

View File

@@ -72,6 +72,21 @@ QString PatientInformationForm::getPatientID()
return mUI->mPatientID->text();
}
void PatientInformationForm::setExecuteProtocol(bool aIsLeft)
{
mIsExecuteProtocolLeft = aIsLeft;
}
void PatientInformationForm::clear()
{
mUI->mPatientID->clear();
mUI->mPatientBirthday->clear();
mUI->mPatientName->clear();
mUI->mPatientGender->clear();
mUI->mPaitenAccessionNumber->clear();
mUI->mScanProtocol->clear();
}
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
{
cJSON* patientInfoObject = cJSON_CreateObject();
@@ -81,7 +96,7 @@ const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mInfo->Sex.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientBirthDate",
cJSON_CreateString(mInfo->BirthDate.replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "Laterality", cJSON_CreateString(mCurrentProtocol ? "R" : "L"));
cJSON_AddItemToObject(patientInfoObject, "Laterality", cJSON_CreateString(mIsExecuteProtocolLeft ? "L" : "R"));
cJSON_AddItemToObject(patientInfoObject, "IsEmptyData", cJSON_CreateNumber(empty ? 1 : 0));
cJSON_AddItemToObject(patientInfoObject, "OperatorName", cJSON_CreateString(User::Current()->getUserName().toStdString().c_str()));
cJSON_AddItemToObject(patientInfoObject, "ReferringPhysicianName", cJSON_CreateString(User::Current()->getUserName().toStdString().c_str()));

View File

@@ -23,6 +23,8 @@ public:
PatientInformationPointer getPatientInformation();
int getProtocol();
QString getProtocolString(ScanProtocal aProtocal);
void setExecuteProtocol(bool aIsLeft);
void clear();
const char * getCurrentPatientJsonString(bool emptyScan);
QString getPatientID();
@@ -30,6 +32,7 @@ public:
private:
Ui::PatientInformationForm *mUI;
PatientInformationPointer mInfo;
bool mIsExecuteProtocolLeft = false;
ScanProtocal mCurrentProtocol = LSTAND;
char * mJsonStr = nullptr;
};

View File

@@ -17,6 +17,9 @@
#include "json/jsonobject.h"
#include "device/DeviceManager.h"
#include "dicom/WorkListManager.h"
#include "components/CoordinateXYWidget.h"
#include "components/CoordinateZWidget.h"
#include "utilities/ScanProcessSequence.h"
#ifdef WIN32
#else
@@ -39,8 +42,8 @@ ScanFormWidget::ScanFormWidget(QWidget* parent)
, mWorklistButton(new QToolButton(this))
, mStartScanButton(new QToolButton(this))
, mDrainageButton(new QToolButton(this))
, mXYLabel(new QLabel(this))
, mZLabel(new QLabel(this))
, mXYLabel(new CoordinateXYWidget(this))
, mZLabel(new CoordinateZWidget(this))
, mScanProcessLabel(new QLabel(this))
, mDrainageTimer(new QTimer(this))
{
@@ -78,6 +81,8 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
mStartScanButton->setObjectName("btnScan");
mStartScanButton->setText(tr("Start Scan"));
layout->addWidget(mStartScanButton);
mStartScanButton->setEnabled(false);
mStartScanButton->setCheckable(true);
layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
addVerticalLine(layout);
@@ -151,14 +156,58 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
connect(EventCenter::Default(), &EventCenter::AnonymousModeChanged, this, &ScanFormWidget::updateDataByAnonymousMode);
connect(mStartScanButton, &QToolButton::clicked, [this]()
{
if(mStartScanButton->isChecked())
{
EventCenter::Default()->triggerEvent(GUIEvents::StartScanProcess, nullptr, nullptr);
}
else
{
EventCenter::Default()->triggerEvent(GUIEvents::StopScanProcess, nullptr, nullptr);
}
});
connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this]()
{
mWorklistButton->setEnabled(false);
mAccountButton->setEnabled(false);
mDrainageButton->setEnabled(false);
mShutdownButton->setEnabled(false);
mStartScanButton->setText(tr("Stop Scan Process"));
mScanProcessLabel->setText(getAutoLocateMessage());
});
connect(EventCenter::Default(), &EventCenter::RequestFullScanStop, EventCenter::Default(), &EventCenter::StopScanProcess);
connect(EventCenter::Default(), &EventCenter::StopScanProcess, [this]()
{
mWorklistButton->setEnabled(true);
mAccountButton->setEnabled(true);
mDrainageButton->setEnabled(true);
mShutdownButton->setEnabled(true);
mStartScanButton->setChecked(false);
mStartScanButton->setText(tr("Start Scan"));
if(ScanProcessSequence::getInstance()->getScanPositionSize() == 0)
{
mStartScanButton->setEnabled(false);
mPatInf->clear();
}
mScanProcessLabel->setText(tr("Please confirm checking patient information to start the process"));
});
connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [this]()
{
mScanProcessLabel->setText(tr("Data scanning, please keep the current position and don't move."));
});
connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::fullScanDataExport, [this]()
{
mScanProcessLabel->setText(tr("Data exporting, patient can leave the holder"));
});
connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::startFullScan, this, &ScanFormWidget::prepareStartFullScan, Qt::QueuedConnection);
// auto group = new QButtonGroup(ui->commandWidget);
// mBtnLeft->setCheckable(true);
// mBtnLeft->setChecked(true);
// mBtnRight->setCheckable(true);
// group->addButton(mBtnRight, 1);
// group->addButton(mBtnLeft, 0);
// connect(group, SIGNAL(buttonClicked(int)), this, SLOT(protocolChanged(int)));
}
void ScanFormWidget::initScanContent()
@@ -212,13 +261,6 @@ void ScanFormWidget::initScanControlBar(QHBoxLayout *layout)
// EventCenter::Default()->triggerEvent(RequestPreviewScan, nullptr, nullptr);
// });
connect(DeviceManager::Default(), &DeviceManager::startPreviewScanResult, [this](bool aIsSucessful)
{
if(!aIsSucessful)
{
setPreviewing(false);
}
});
// connect(mBtnScan, &QToolButton::clicked, [=]() {
@@ -248,6 +290,15 @@ void ScanFormWidget::protocolChanged(int type)
LOG_USER_OPERATION(QString("Select Laterality %1").arg(type == 0 ? "Left" : "Right"));
}
void ScanFormWidget::prepareStartFullScan()
{
ScanPosition position = ScanProcessSequence::getInstance()->topPosition();
mPatInf->setExecuteProtocol(position == ScanPosition::Left);
QString patientInf(mPatInf->getCurrentPatientJsonString(false));
LOG_USER_OPERATION(QString("Start Scan, ID: %1").arg(mPatInf->getPatientID()))
EventCenter::Default()->triggerEvent(RequestPatientScan, nullptr, (QObject*)(&patientInf));
}
void ScanFormWidget::setPreviewing(bool val)
{
// mBtnPreview->setCheckable(val);
@@ -329,9 +380,13 @@ void ScanFormWidget::initEvents()
DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo);
if(result.ResultCode == QDialog::Accepted)
{
mPatInf->setPatientInformation(patientInfo->Copy(), static_cast<ScanProtocal>(result.ResultData.toInt()));
ScanProtocal protocal = static_cast<ScanProtocal>(result.ResultData.toInt());
mPatInf->setPatientInformation(patientInfo->Copy(), protocal);
setScanProtocal(protocal);
LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID))
EventCenter::Default()->triggerEvent(StartScanProcess, nullptr, patientInfo);
mStartScanButton->setEnabled(true);
EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, patientInfo);
mStartScanButton->click();
}
// mBtnScan->setEnabled(true);
@@ -372,6 +427,44 @@ void ScanFormWidget::updateDataByAnonymousMode()
mWorklistButton->setEnabled(!anonymousMode);
}
QString ScanFormWidget::getAutoLocateMessage()
{
ScanPosition position = ScanProcessSequence::getInstance()->topPosition();
switch (position)
{
case ScanPosition::Left:
return tr("Left side scan initiated, auto positioning in progress.");
case ScanPosition::Right:
return tr("Right side scan initiated, auto positioning in progress.");
}
return QString("");
}
void ScanFormWidget::setScanProtocal(int aProtocal)
{
ScanProcessSequence::getInstance()->clear();
switch (aProtocal)
{
case ScanProtocal::LSTAND:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
return;
case ScanProtocal::RSTAND:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
return;
case ScanProtocal::LONE:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
return;
case ScanProtocal::RONE:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
return;
default:
return;
}
}
void ScanFormWidget::keyPressEvent(QKeyEvent* aEvent)
{
switch (aEvent->key())

View File

@@ -4,9 +4,13 @@
#include "src/forms/TabFormWidget.h"
#include <functional>
#include <QtWidgets/QLabel>
#include <QStack>
class PatientInformationForm;
class QToolButton;
class CoordinateXYWidget;
class CoordinateZWidget;
class ScanFormWidget :public TabFormWidget {
Q_OBJECT
public:
@@ -26,19 +30,25 @@ private:
QToolButton* mWorklistButton;
QToolButton* mStartScanButton;
QToolButton* mDrainageButton;
QLabel* mXYLabel;
QLabel* mZLabel;
CoordinateXYWidget* mXYLabel;
CoordinateZWidget* mZLabel;
QLabel* mScanProcessLabel;
QTimer* mDrainageTimer;
void initCommandWidget(QHBoxLayout *layout);
void initScanControlBar(QHBoxLayout *layout);
void initScanContent();
void renderLoading();
void renderPreviewData(const QObject* sender, const QObject *data);
void reloadLanguage();
void setScanProtocal(int aProtocal);
QString getAutoLocateMessage();
private slots:
void protocolChanged(int type);
void updateDataByAnonymousMode();
void prepareStartFullScan();
//void updateScanProcessLabel(const QString& aText);
void initEvents();
};

View File

@@ -77,7 +77,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent)
connect(EventCenter::Default(), &EventCenter::AnonymousModeChanged, this, &SelectFormWidget::updateDataByAnonymousMode);
connect(EventCenter::Default(), &EventCenter::StartScanProcess, this, [=](QObject* sender, QObject* data)
connect(EventCenter::Default(), &EventCenter::SetSelectedPatient, this, [=](QObject* sender, QObject* data)
{
PatientInformation* patientInfo = (PatientInformation*)data;
this->setSelectedPatient(patientInfo);