From b60c4a8be900fddbd57d5cbfd692344defd95ce1 Mon Sep 17 00:00:00 2001 From: sunwen Date: Fri, 6 Sep 2024 17:29:25 +0800 Subject: [PATCH] refactor: Modify the display and interaction related to worklist. --- src/action/GetWorkListAction.cpp | 60 +- src/action/GetWorkListAction.h | 26 - src/device/DeviceManager.cpp | 26 +- src/device/DeviceManager.h | 3 + src/dialogs/DialogManager.cpp | 82 +- src/dialogs/DialogManager.h | 20 +- src/dialogs/EditPatientDialog.cpp | 31 +- src/dialogs/EditPatientDialog.h | 1 - src/dialogs/GUIMessageDialog.cpp | 2 +- src/dialogs/GetWorkListDialog.cpp | 551 ++++++----- src/dialogs/GetWorkListDialog.h | 92 +- src/dialogs/StartScanProcessDialog.cpp | 95 +- src/dialogs/StartScanProcessDialog.h | 3 + src/dialogs/StartScanProcessDialog.ui | 174 +++- src/dialogs/WorklistLoadingDialog.cpp | 22 + src/dialogs/WorklistLoadingDialog.h | 22 + src/dicom/MPPSAsyncAction.cpp | 36 +- src/dicom/MPPSAsyncAction.h | 6 +- src/dicom/MPPSManager.cpp | 32 +- src/dicom/MPPSManager.h | 1 - src/dicom/WorkListManager.cpp | 133 +-- src/dicom/WorkListManager.h | 2 +- src/event/EventCenter.h | 2 +- src/forms/recon/ReconFormWidget.cpp | 4 +- src/forms/scan/PatientInformationForm.cpp | 58 +- src/forms/scan/PatientInformationForm.h | 8 +- src/forms/scan/PatientInformationForm.ui | 14 +- src/forms/scan/ScanFormWidget.cpp | 223 +---- src/forms/scan/ScanFormWidget.h | 10 +- .../select/AbstractPatientInfomation.cpp | 7 + src/forms/select/AbstractPatientInfomation.h | 21 + src/forms/select/AccessionInformation.cpp | 50 + src/forms/select/AccessionInformation.h | 42 + src/forms/select/PatientDetailForm.cpp | 206 ++-- src/forms/select/PatientDetailForm.h | 50 +- src/forms/select/PatientInformation.cpp | 232 +++++ src/forms/select/PatientInformation.h | 86 +- src/forms/select/SelectFormWidget.cpp | 349 ++++--- src/forms/select/SelectFormWidget.h | 28 +- src/forms/select/WorklistTableModel.cpp | 193 ++++ src/forms/select/WorklistTableModel.h | 34 + src/forms/select/WorklistTableSelectModel.cpp | 151 +++ src/forms/select/WorklistTableSelectModel.h | 35 + .../select/WorklistTableStyleItemDelegate.cpp | 78 ++ .../select/WorklistTableStyleItemDelegate.h | 21 + src/forms/select/WorklistTableView.cpp | 133 +++ src/forms/select/WorklistTableView.h | 28 + src/forms/settings/GeneralForm.cpp | 71 +- src/json/jsonobject.cpp | 24 + src/json/jsonobject.h | 7 + src/main.cpp | 2 + src/recon/PACSSettingsDataModel.cpp | 1 + src/recon/PACSSettingsDataModel.h | 4 +- src/stylesheet/Dark2.css | 16 +- src/translations/en_US.ts | 183 +++- src/translations/zh_CN.ts | 934 +++++++++++------- src/utilities/ScanProcessSequence.cpp | 13 +- src/utilities/ScanProcessSequence.h | 8 +- src/utilities/WorklistFilterHelper.cpp | 81 ++ src/utilities/WorklistFilterHelper.h | 21 + 60 files changed, 3336 insertions(+), 1512 deletions(-) create mode 100644 src/dialogs/WorklistLoadingDialog.cpp create mode 100644 src/dialogs/WorklistLoadingDialog.h create mode 100644 src/forms/select/AbstractPatientInfomation.cpp create mode 100644 src/forms/select/AbstractPatientInfomation.h create mode 100644 src/forms/select/AccessionInformation.cpp create mode 100644 src/forms/select/AccessionInformation.h create mode 100644 src/forms/select/PatientInformation.cpp create mode 100644 src/forms/select/WorklistTableModel.cpp create mode 100644 src/forms/select/WorklistTableModel.h create mode 100644 src/forms/select/WorklistTableSelectModel.cpp create mode 100644 src/forms/select/WorklistTableSelectModel.h create mode 100644 src/forms/select/WorklistTableStyleItemDelegate.cpp create mode 100644 src/forms/select/WorklistTableStyleItemDelegate.h create mode 100644 src/forms/select/WorklistTableView.cpp create mode 100644 src/forms/select/WorklistTableView.h create mode 100644 src/utilities/WorklistFilterHelper.cpp create mode 100644 src/utilities/WorklistFilterHelper.h diff --git a/src/action/GetWorkListAction.cpp b/src/action/GetWorkListAction.cpp index a923e7f..f61683f 100644 --- a/src/action/GetWorkListAction.cpp +++ b/src/action/GetWorkListAction.cpp @@ -4,7 +4,6 @@ GetWorkListAction::GetWorkListAction(QObject* aParent) : AsyncAction(aParent) - , mSqlModel(nullptr) { } @@ -16,47 +15,30 @@ GetWorkListAction::~GetWorkListAction() void GetWorkListAction::run() { - if (!mQueryData.isEmpty()) + QList patients; + int result = WorkListManager::getPatientFromWorkList(patients); + if(result == Success && patients.isEmpty()) { - QList patients; - int result = WorkListManager::getPatientFromWorkList(mQueryData.mAccessionNum, mQueryData.mPatientId,patients); - if(result == Success && patients.isEmpty()) - { - emit actionCompleted(ActionResult(Failed,tr("No reference record find!"))); - } - else if(result == InitNetWorkError) - { - emit actionCompleted(ActionResult(Failed,tr("Worklist network init error!"))); - } - else if(result == ConnectError) - { - emit actionCompleted(ActionResult(Failed,tr("Worklist connect error!"))); - } - else if(result == ResponseError) - { - emit actionCompleted(ActionResult(Failed,tr("Worklist response find failed!"))); - } - else if(result == ContextError) - { - emit actionCompleted(ActionResult(Failed,tr("Worklist query context error!"))); - } - else - { - emit actionCompleted(ActionResult(Sucessed, QVariant::fromValue(patients))); - } + emit actionCompleted(ActionResult(Failed,tr("No reference record find!"))); + } + else if(result == InitNetWorkError) + { + emit actionCompleted(ActionResult(Failed,tr("Worklist network init error!"))); + } + else if(result == ConnectError) + { + emit actionCompleted(ActionResult(Failed,tr("Worklist connect error!"))); + } + else if(result == ResponseError) + { + emit actionCompleted(ActionResult(Failed,tr("Worklist response find failed!"))); + } + else if(result == ContextError) + { + emit actionCompleted(ActionResult(Failed,tr("Worklist query context error!"))); } else { - emit actionCompleted(ActionResult(Failed,tr("Search Query Error"))); + emit actionCompleted(ActionResult(Sucessed, QVariant::fromValue(patients))); } } - -void GetWorkListAction::setWorkListQueryData(const WorkListQueryData& aQueryData) -{ - mQueryData = aQueryData; -} - -void GetWorkListAction::setSqlModel(QSqlTableModel* aSqlModel) -{ - mSqlModel = aSqlModel; -} diff --git a/src/action/GetWorkListAction.h b/src/action/GetWorkListAction.h index 6746c51..a7a2805 100644 --- a/src/action/GetWorkListAction.h +++ b/src/action/GetWorkListAction.h @@ -3,25 +3,6 @@ #include "AsyncAction.h" -class QSqlTableModel; - -class WorkListQueryData -{ -public: - WorkListQueryData(const QString& aAccessionNum = QString(),const QString& aPatientId = QString()) - : mAccessionNum(aAccessionNum) - , mPatientId(aPatientId) - { - }; - bool isEmpty() - { - return mAccessionNum.isEmpty() && mPatientId.isEmpty(); - } - - QString mAccessionNum; - QString mPatientId; -}; - class GetWorkListAction : public AsyncAction { Q_OBJECT @@ -31,13 +12,6 @@ public: ~GetWorkListAction() override; void run() override; - void setWorkListQueryData(const WorkListQueryData& aQueryData); - void setSqlModel(QSqlTableModel* aSqlModel); - - -private: - WorkListQueryData mQueryData; - QSqlTableModel* mSqlModel; }; #endif //GUI_GETWORKLISTACTION_H diff --git a/src/device/DeviceManager.cpp b/src/device/DeviceManager.cpp index bf06bca..3e1db38 100644 --- a/src/device/DeviceManager.cpp +++ b/src/device/DeviceManager.cpp @@ -331,6 +331,9 @@ void DeviceManager::startScan(const QString& json, bool empty) mCurrentPatientName = patientInfo["PatientName"].toString(); mCurrentLaterality = patientInfo["Laterality"].toString(); mCurrentOperatorName = patientInfo["OperatorName"].toString(); + mCurrentMPPSUID = patientInfo["MPPSUID"].toString(); + mCurrentModality = patientInfo["Modality"].toString(); + mCurrentStudyUID = patientInfo["StudyUID"].toString(); mScanProgressTimer = startTimer(500); } } @@ -467,8 +470,8 @@ void DeviceManager::stopFullScan() DmsSyncActionResult result = mStopScanAction->execute(); if(!result.mIsSucessful) { - THROW_ERROR(result.mData); prepareFinishScan(false, ""); + THROW_ERROR(result.mData); return; } @@ -962,7 +965,7 @@ void DeviceManager::insertEmptyScanRecord() void DeviceManager::insertScanRecord() { - QString sql = QString("INSERT INTO Scan (ScanID, ReferenceID, PatientID, AccessionNumber, PatientName, ScanDateTime, Laterality, OperatorName, State) VALUES ('%1','%2','%3','%4','%5','%6','%7','%8', %9)") + QString sql = QString("INSERT INTO Scan (ScanID, ReferenceID, PatientID, AccessionNumber, PatientName, ScanDateTime, Laterality, OperatorName, State, StudyUID, Modality, MPPSUID) VALUES ('%1','%2','%3','%4','%5','%6','%7','%8', %9, '%10', '%11', '%12')") .arg(mCurrentScanMeasurementID) .arg(mCurrentEmptyMeasurementID) .arg(mCurrentPatientID) @@ -971,7 +974,10 @@ void DeviceManager::insertScanRecord() .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")) .arg(mCurrentLaterality) .arg(mCurrentOperatorName) - .arg(0); + .arg(0) + .arg(mCurrentStudyUID) + .arg(mCurrentModality) + .arg(mCurrentMPPSUID); if(!SQLHelper::exec(sql)) { QString msg = "DB Error. G401"; @@ -1174,7 +1180,7 @@ void DeviceManager::startCreateReconRecord() emit createEmptyScanToRecon(scanid, mReconTransferPath + "/" + scanid); } - sql = "SELECT ScanID, ReferenceID, PatientID, AccessionNumber FROM Scan WHERE State < 300 And State >= 200 ORDER BY ScanDateTime ASC"; + sql = "SELECT ScanID, ReferenceID, PatientID, AccessionNumber, StudyUID, MPPSUID FROM Scan WHERE State < 300 And State >= 200 ORDER BY ScanDateTime ASC"; result = SQLHelper::queryValues(sql); for (const QVariant &variant : result) { @@ -1183,16 +1189,9 @@ void DeviceManager::startCreateReconRecord() QString referenceID = record[1].toString(); QString patientID = record[2].toString(); QString AccessionNumber = record[3].toString(); + QString studyUID = record[4].toString(); + QString mppsUID = record[5].toString(); - QString pat_sql = "SELECT AccessionNumber, StudyUID, Modality, MPPSUID FROM Patient WHERE PatientID=:patID and AccessionNumber=:accno"; - QMap map; - QMap 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, mReconTransferPath + "/" + scanID); } startTransfer(); @@ -1344,6 +1343,7 @@ bool DeviceManager::startAutoLocate() return true; } } + emit startAutoLocateResult(false); TRIGGER_EVENT(StopScanProcess, nullptr, nullptr); QString errorMessage = tr("Start auto locate failed"); THROW_ERROR(errorMessage) diff --git a/src/device/DeviceManager.h b/src/device/DeviceManager.h index 3e50faf..237924d 100644 --- a/src/device/DeviceManager.h +++ b/src/device/DeviceManager.h @@ -209,6 +209,9 @@ private: QString mCurrentAccessionNumber = ""; QString mCurrentLaterality = ""; QString mCurrentOperatorName = ""; + QString mCurrentModality = ""; + QString mCurrentStudyUID = ""; + QString mCurrentMPPSUID = ""; QString mCurrentTransferMeasurementID = ""; QString mCurrentTransferPatientID = ""; QString mSoftwareVersion = ""; diff --git a/src/dialogs/DialogManager.cpp b/src/dialogs/DialogManager.cpp index 020a40d..a23c881 100644 --- a/src/dialogs/DialogManager.cpp +++ b/src/dialogs/DialogManager.cpp @@ -23,6 +23,7 @@ #include "dialogs/MppsSettingsDialog.h" #include "dialogs/StartScanProcessDialog.h" #include "dialogs/CEchoTestDialog.h" +#include "dialogs/WorklistLoadingDialog.h" #include "network/DicomCfgDialog.h" #include "network/GetAdminPsw.h" @@ -36,6 +37,7 @@ #include "screensaver/ScreenSaverWindow.h" #include "utilities/GetLockScreenTimeHelper.h" #include "utilities/GetProtocalHelper.h" +#include "utilities/WorklistFilterHelper.h" #include "appvals/AppGlobalValues.h" #include "json/jsonobject.h" @@ -47,14 +49,14 @@ namespace } DialogManager::DialogManager() -: QObject() -, mFunctionDialog(nullptr) -, mScreenSaverWindow(nullptr) -, mOperationMessageDialog(nullptr) -, mSyncDialog(nullptr) -, mTopWidget(nullptr) -, mGetWorkListDialog(nullptr) -, mCEchoTestDialog(nullptr) + : QObject() + , mFunctionDialog(nullptr) + , mScreenSaverWindow(nullptr) + , mOperationMessageDialog(nullptr) + , mSyncDialog(nullptr) + , mTopWidget(nullptr) + , mCEchoTestDialog(nullptr) + , mWorklistLoadingDialog(nullptr) { } @@ -66,10 +68,12 @@ void DialogManager::init(QWidget* aParent) { connect(EventCenter::Default(), &EventCenter::InvokeOperationProgress,this,&DialogManager::invokeOperationProgress); connect(EventCenter::Default(), &EventCenter::InvokeOperationPending,this,&DialogManager::invokeOperationPending); connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd,this,&DialogManager::invokeOperationEnd); - connect(EventCenter::Default(), &EventCenter::InputWorkListSearchValue,this,&DialogManager::receiveWorkListInput); MultyMessageDialogManager::getInstance()->setDialogParent(aParent); mTopWidget = aParent; mScreenSaverWindow = new ScreenSaverWindow(); + mWorklistLoadingDialog = new WorklistLoadingDialog(aParent); + + connect(EventCenter::Default(), &EventCenter::WorklistSearchFinished, mWorklistLoadingDialog, &QDialog::accept); } //得考虑多线程的问题 @@ -362,12 +366,6 @@ DialogResult DialogManager::requestInputAdminPasswd() int DialogManager::requestEditNetworkConfig() { -// NetworkCfgDialog dialog(mTopWidget); -// setTopWidget(&dialog); -// dialog.setWindowModality(Qt::WindowModal); -// int ret = dialog.exec(); -// releaseTopWidget(&dialog); -// return ret; IpSettingsDialog dialog(mTopWidget); setTopWidget(&dialog); dialog.setWindowModality(Qt::WindowModal); @@ -429,15 +427,28 @@ DialogResult DialogManager::reuqestConfirmStartScan(PatientInformation* aPatient return DialogResult(ret,dialog.getSelectedProtocal()); } -int DialogManager::requestPatientConfirm(PatientInformation* patientInf, int type) +DialogResult DialogManager::reuqestWorklistFilterModalityDialog() { - PatientConfirmDialog dialog(mTopWidget); + SelectDialog dialog(mTopWidget); setTopWidget(&dialog); - dialog.setPatientInformation(patientInf, type); dialog.setWindowModality(Qt::WindowModal); + dialog.setValues(WorklistFilterHelper::getWorklistFilterModalityList()); + dialog.setSelectedValue(WorklistFilterHelper::getCurrentWorklistFilterModality()); int ret = dialog.exec(); releaseTopWidget(&dialog); - return ret; + return DialogResult(ret,dialog.getSelectedValue()); +} + +DialogResult DialogManager::reuqestWorklistFilterDateDialog() +{ + SelectDialog dialog(mTopWidget); + setTopWidget(&dialog); + dialog.setWindowModality(Qt::WindowModal); + dialog.setValues(WorklistFilterHelper::getWorklistFilterDateList()); + dialog.setSelectedValue(WorklistFilterHelper::getCurrentWorklistFilterDate()); + int ret = dialog.exec(); + releaseTopWidget(&dialog); + return DialogResult(ret,dialog.getSelectedValue()); } int DialogManager::requestCEchoTest(const QList& aInputValue) @@ -454,38 +465,9 @@ int DialogManager::requestCEchoTest(const QList& aInputValue) return ret; } -int DialogManager::requestGetWorkList() +void DialogManager::requestLoadingWorklist() { - GetWorkListDialog dialog(WorkListManager::getInstance()->getTableModel(), WorkListManager::getInstance()->getTableView(), mTopWidget); - mGetWorkListDialog = &dialog; - setTopWidget(&dialog); - dialog.setWindowModality(Qt::WindowModal); - int ret = dialog.exec(); - releaseTopWidget(&dialog); - mGetWorkListDialog = nullptr; - return ret; -} - -int DialogManager::requestGetWorkList(const QString& aInputValue) -{ - GetWorkListDialog dialog(WorkListManager::getInstance()->getTableModel(), WorkListManager::getInstance()->getTableView(), mTopWidget); - mGetWorkListDialog = &dialog; - setTopWidget(&dialog); - dialog.setWindowModality(Qt::WindowModal); - mGetWorkListDialog->search(aInputValue); - int ret = dialog.exec(); - releaseTopWidget(&dialog); - mGetWorkListDialog = nullptr; - return ret; -} - -void DialogManager::receiveWorkListInput(QObject *parent, QObject *msg) -{ - QString inputValue = *(QString*)msg; - if(mGetWorkListDialog == nullptr) - { - requestGetWorkList(inputValue); - } + mWorklistLoadingDialog->exec(); } void DialogManager::raiseDeviceInfo(QObject* parent, QObject* aInfoData) diff --git a/src/dialogs/DialogManager.h b/src/dialogs/DialogManager.h index 1636e30..46831b3 100644 --- a/src/dialogs/DialogManager.h +++ b/src/dialogs/DialogManager.h @@ -7,6 +7,8 @@ #include #include #include + +#include "forms/select/PatientInformation.h" #include "dicom/CEchoSetting.h" class GUIMessageDialog; @@ -14,8 +16,7 @@ class QSqlTableModel; class QTableView; class LoginDialog; class ScreenSaverWindow; -class GetWorkListDialog; -class PatientInformation; +class WorklistLoadingDialog; class CEchoTestDialog; enum MessageLevel:unsigned int; @@ -26,7 +27,7 @@ struct DialogResult { ResultCode = aResultCode; ResultData = aResultData; - }; + } int ResultCode; QVariant ResultData; }; @@ -44,7 +45,7 @@ public: ~DialogManager() override; void init(QWidget* aParent); - void requestLogin(QWidget* aParent); + void requestLogin(QWidget* aParent); void requestScreenSaverPlay(); DialogResult requestResetAdminPwd(); int requestAddAccount(QSqlTableModel* model); @@ -66,16 +67,15 @@ public: int requestMppsSettings(); DialogResult requestInputAdminPasswd(); int requestEditNetworkConfig(); - int requestGetWorkList(); - int requestGetWorkList(const QString& aInputValue); - int requestPatientConfirm(PatientInformation* patientInf, int type); int requestCEchoTest(const QList& aInputValue); - + DialogResult requestEditIpAndNetMask(); DialogResult requestEditIpAndNetMask(const QStringList& aEditData); DialogResult requestEditRouteInfo(); DialogResult requestEditRouteInfo(const QStringList& aEditData); DialogResult reuqestConfirmStartScan(PatientInformation* aPatient); + DialogResult reuqestWorklistFilterModalityDialog(); + DialogResult reuqestWorklistFilterDateDialog(); void requestChangePassword(); void raiseDeviceError(QObject* parent, QObject* msg); void raiseDeviceInfo(QObject* parent, QObject* aInfoData); @@ -87,12 +87,12 @@ public: void invokeOperationPending(QObject* parent, QObject* msg); void invokeOperationEnd(QObject* parent, QObject* msg); void setFocusToTopDialog(); + void requestLoadingWorklist(); private: void clearMessageDialog(); void setTopWidget(QWidget* widget); void releaseTopWidget(QWidget* expectedTopWidget); - void receiveWorkListInput(QObject *parent, QObject *msg); signals: void loginDialogShown(); @@ -104,8 +104,8 @@ private: QPointer mSyncDialog; QWidget* mTopWidget; std::mutex mMutex; - GetWorkListDialog* mGetWorkListDialog; CEchoTestDialog* mCEchoTestDialog; + WorklistLoadingDialog* mWorklistLoadingDialog; int mDialogCount = 0; }; diff --git a/src/dialogs/EditPatientDialog.cpp b/src/dialogs/EditPatientDialog.cpp index 1b2596a..f6c264f 100644 --- a/src/dialogs/EditPatientDialog.cpp +++ b/src/dialogs/EditPatientDialog.cpp @@ -23,11 +23,11 @@ namespace { const int ENDLINE_SPACE = 3; - int queryValue(QSqlTableModel* model, int aColIDIndex, const QVariant& aPatId, int aColAccessionNumberIndex, const QVariant& aAccessionNumber) + int queryValue(QSqlTableModel* model, int aColIDIndex, const QVariant& aPatId) { for (int i = 0; i < model->rowCount(); ++i) { - if (model->data(model->index(i, aColIDIndex)) == aPatId && model->data(model->index(i, aColAccessionNumberIndex)) == aAccessionNumber) return i; + if (model->data(model->index(i, aColIDIndex)) == aPatId) return i; } return -1; } @@ -57,19 +57,6 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo lbl_endline1->setObjectName("endline"); layout->addWidget(lbl_endline1); - QLabel* lbl_AccessionNumber = new QLabel(this); - lbl_AccessionNumber->setText(tr("Accession Number")); - mAccessionNumber = new ULineEdit(this); - mAccessionNumber->setMaxLength(30); - mAccessionNumber->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mAccessionNumber)); - - layout->addWidget(lbl_AccessionNumber); - layout->addWidget(mAccessionNumber); - QLabel* accessionNumber_endline1 = new QLabel(this); - accessionNumber_endline1->setObjectName("endline"); - accessionNumber_endline1->setFixedHeight(ENDLINE_SPACE); - layout->addWidget(accessionNumber_endline1); - QLabel* lbl_name = new QLabel(this); lbl_name->setText(tr("Name") + QString("*")); le_name = new ULineEdit(this); @@ -151,10 +138,9 @@ void EditPatientDialog::setPatientInformation(PatientInformation* information) btnDate->setText(information->BirthDate); currentPatientUID = information->PatientUID; AddDate = information->AddDate; - mAccessionNumber->setText(information->AccessionNumber); le_id->setEnabled(false); - mAccessionNumber->setEnabled(false); } + } void EditPatientDialog::clearPatientInformation() @@ -162,7 +148,6 @@ void EditPatientDialog::clearPatientInformation() le_id->setText(""); // le_date->setText(""); le_name->setText(""); - mAccessionNumber->setText(""); } void EditPatientDialog::showErrorMessage(const QString& aMessage) @@ -181,6 +166,7 @@ void EditPatientDialog::showErrorMessage(const QString& aMessage) bool EditPatientDialog::updateReferenceData() { PatientInformation* inf = getPatientInformation(); + if (le_id->text().isEmpty()) { showErrorMessage(tr("ID can't be empty!")); @@ -192,16 +178,15 @@ bool EditPatientDialog::updateReferenceData() showErrorMessage(tr("Patient Name can't be empty!")); return false; } - inf->AccessionNumber = mAccessionNumber->text().trimmed(); inf->Name = le_name->text().trimmed(); int selectedRow = 0; bool isAdd = currentPatientUID.isEmpty(); if (isAdd) { - int ref_rowid = queryValue(model, 1, inf->ID, 2, inf->AccessionNumber); + int ref_rowid = queryValue(model, 1, inf->ID); if (ref_rowid >= 0) { - showErrorMessage(tr("The ID and Accession number is already existed!")); + showErrorMessage(tr("The ID is already existed!")); return false; } inf->PatientUID = QUuid::createUuid().toString(); @@ -211,14 +196,14 @@ bool EditPatientDialog::updateReferenceData() else { inf->PatientUID = currentPatientUID; - selectedRow = queryValue(model, 1, inf->ID, 2, inf->AccessionNumber); + selectedRow = queryValue(model, 1, inf->ID); inf->AddDate = AddDate; } inf->Sex = btnSex->text() == tr("Female") ? "F" : (tr("Male") == btnSex->text() ? "M" : "O"); inf->BirthDate = btnDate->text(); #define ADD_PATIENT_PROPERTY(val)\ - model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val); + model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf->val); EDIT_PATIENT() #undef ADD_PATIENT_PROPERTY if (model->submitAll()) diff --git a/src/dialogs/EditPatientDialog.h b/src/dialogs/EditPatientDialog.h index a5c1b68..7370146 100644 --- a/src/dialogs/EditPatientDialog.h +++ b/src/dialogs/EditPatientDialog.h @@ -34,7 +34,6 @@ protected: private: ULineEdit* le_id = nullptr; - ULineEdit* mAccessionNumber = nullptr; ULineEdit* le_name = nullptr; ULineEdit* le_sex = nullptr; ULineEdit* le_date = nullptr; diff --git a/src/dialogs/GUIMessageDialog.cpp b/src/dialogs/GUIMessageDialog.cpp index ca426c2..2a83fc8 100644 --- a/src/dialogs/GUIMessageDialog.cpp +++ b/src/dialogs/GUIMessageDialog.cpp @@ -116,8 +116,8 @@ void GUIMessageDialog::startLoading() { mTimerID = -1; } accept(); - EventCenter::Default()->triggerEvent(GUIEvents::RequestFullScanStop, nullptr, nullptr); LOG_USER_OPERATION("Stop Scan"); + EventCenter::Default()->triggerEvent(GUIEvents::RequestFullScanStop, nullptr, nullptr); }); connect(mConfirmCancleButton, &QToolButton::clicked, [=]() diff --git a/src/dialogs/GetWorkListDialog.cpp b/src/dialogs/GetWorkListDialog.cpp index 55b3f76..fc8912b 100644 --- a/src/dialogs/GetWorkListDialog.cpp +++ b/src/dialogs/GetWorkListDialog.cpp @@ -1,301 +1,300 @@ -#include "GetWorkListDialog.h" +//#include "GetWorkListDialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include -#include "components/ULineEdit.h" -#include "action/GetWorkListAction.h" -#include "action/ActionCreator.h" -#include "log/LogManager.h" -#include "event/EventCenter.h" +//#include "components/ULineEdit.h" +//#include "action/GetWorkListAction.h" +//#include "action/ActionCreator.h" +//#include "log/LogManager.h" +//#include "event/EventCenter.h" -GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent, Qt::WindowFlags aFlags) - : AsyncActionDialog(ActionCreator::getAsyncAction("GetWorkListAction"),"Work List", aParent, aFlags) - , mAccessionNumber(new ULineEdit(mContentWidget)) - , mPatientId(new ULineEdit(mContentWidget)) - , mErrorLabel(new QLabel(mContentWidget)) - , mAccessionNumText(new QLabel(mContentWidget)) - , mPatientIDText(new QLabel(mContentWidget)) - , mEditEndLine(new QLabel(mContentWidget)) - , mPatientSelectTable(new QTableView(mContentWidget)) - , mMode(PatientSearchMode) - , mSearchMode(ByAccessionNumber) - , mPatientSelectModel(new QStandardItemModel(mContentWidget)) - , mSqlModel(aSqlModel) - , mTableView(aTableView) - , mSearchedPatients() - , mRadioButtonArea(new QWidget(mContentWidget)) - , mIsAutoSearch(false) -{ - initializeContentWidgets(); - GetWorkListAction* action = qobject_cast(getAction()); - if (action != nullptr) - { - action->setSqlModel(aSqlModel); - } -} +//GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent, Qt::WindowFlags aFlags) +// : AsyncActionDialog(ActionCreator::getAsyncAction("GetWorkListAction"),"Work List", aParent, aFlags) +// , mAccessionNumber(new ULineEdit(mContentWidget)) +// , mPatientId(new ULineEdit(mContentWidget)) +// , mErrorLabel(new QLabel(mContentWidget)) +// , mAccessionNumText(new QLabel(mContentWidget)) +// , mPatientIDText(new QLabel(mContentWidget)) +// , mEditEndLine(new QLabel(mContentWidget)) +// , mPatientSelectTable(new QTableView(mContentWidget)) +// , mMode(PatientSearchMode) +// , mSearchMode(ByAccessionNumber) +// , mPatientSelectModel(new QStandardItemModel(mContentWidget)) +// , mSqlModel(aSqlModel) +// , mTableView(aTableView) +// , mSearchedPatients() +// , mRadioButtonArea(new QWidget(mContentWidget)) +// , mIsAutoSearch(false) +//{ +// initializeContentWidgets(); +// GetWorkListAction* action = qobject_cast(getAction()); +// if (action != nullptr) +// { +// action->setSqlModel(aSqlModel); +// } +//} -GetWorkListDialog::~GetWorkListDialog() -{ -} +//GetWorkListDialog::~GetWorkListDialog() +//{ +//} -void GetWorkListDialog::initializeContentWidgets() -{ - QVBoxLayout* contentLayout = new QVBoxLayout(mContentWidget); - mRadioButtonArea->setObjectName("RadioButtonArea"); - contentLayout->addWidget(mRadioButtonArea); - QHBoxLayout* radioButtonLayout = new QHBoxLayout(mRadioButtonArea); - radioButtonLayout->setSpacing(50); - QRadioButton* radioButton1 = new QRadioButton(tr("Accession Number"), this); - radioButton1->setChecked(true); - QRadioButton* radioButton2 = new QRadioButton(tr("Patient ID"), this); - radioButtonLayout->addWidget(radioButton1); - radioButtonLayout->addWidget(radioButton2); - QButtonGroup* buttonGroup = new QButtonGroup(this); - buttonGroup->addButton(radioButton1, 0); - buttonGroup->addButton(radioButton2, 1); - connect(buttonGroup, QOverload::of(&QButtonGroup::buttonClicked), [this](int aButtonIndex) - { - mAccessionNumber->clear(); - mPatientId->clear(); - if(aButtonIndex == 0) - { - mPatientIDText->setVisible(false); - mPatientId->setVisible(false); - mAccessionNumText->setVisible(true); - mAccessionNumber->setVisible(true); - mSearchMode = ByAccessionNumber; - } - else - { - mAccessionNumText->setVisible(false); - mAccessionNumber->setVisible(false); - mPatientIDText->setVisible(true); - mPatientId->setVisible(true); - mSearchMode = ByPatientId; - } - }); - //Accession Nummber - mAccessionNumText->setText(tr("Accession Nummber")); - contentLayout->addWidget(mAccessionNumText); - contentLayout->addWidget(mAccessionNumber); +//void GetWorkListDialog::initializeContentWidgets() +//{ +// QVBoxLayout* contentLayout = new QVBoxLayout(mContentWidget); +// mRadioButtonArea->setObjectName("RadioButtonArea"); +// contentLayout->addWidget(mRadioButtonArea); +// QHBoxLayout* radioButtonLayout = new QHBoxLayout(mRadioButtonArea); +// radioButtonLayout->setSpacing(50); +// QRadioButton* radioButton1 = new QRadioButton(tr("Accession Number"), this); +// radioButton1->setChecked(true); +// QRadioButton* radioButton2 = new QRadioButton(tr("Patient ID"), this); +// radioButtonLayout->addWidget(radioButton1); +// radioButtonLayout->addWidget(radioButton2); +// QButtonGroup* buttonGroup = new QButtonGroup(this); +// buttonGroup->addButton(radioButton1, 0); +// buttonGroup->addButton(radioButton2, 1); +// connect(buttonGroup, QOverload::of(&QButtonGroup::buttonClicked), [this](int aButtonIndex) +// { +// mAccessionNumber->clear(); +// mPatientId->clear(); +// if(aButtonIndex == 0) +// { +// mPatientIDText->setVisible(false); +// mPatientId->setVisible(false); +// mAccessionNumText->setVisible(true); +// mAccessionNumber->setVisible(true); +// mSearchMode = ByAccessionNumber; +// } +// else +// { +// mAccessionNumText->setVisible(false); +// mAccessionNumber->setVisible(false); +// mPatientIDText->setVisible(true); +// mPatientId->setVisible(true); +// mSearchMode = ByPatientId; +// } +// }); +// //Accession Nummber +// mAccessionNumText->setText(tr("Accession Nummber")); +// contentLayout->addWidget(mAccessionNumText); +// contentLayout->addWidget(mAccessionNumber); - //PatientId - mPatientIDText->setText(tr("Patient ID")); - contentLayout->addWidget(mPatientIDText); - contentLayout->addWidget(mPatientId); - mEditEndLine->setFixedHeight(3); - mEditEndLine->setObjectName("endline"); - contentLayout->addWidget(mEditEndLine); - mPatientIDText->setVisible(false); - mPatientId->setVisible(false); +// //PatientId +// mPatientIDText->setText(tr("Patient ID")); +// contentLayout->addWidget(mPatientIDText); +// contentLayout->addWidget(mPatientId); +// mEditEndLine->setFixedHeight(3); +// mEditEndLine->setObjectName("endline"); +// contentLayout->addWidget(mEditEndLine); +// mPatientIDText->setVisible(false); +// mPatientId->setVisible(false); - //TableView - contentLayout->addWidget(mPatientSelectTable); - mPatientSelectModel->setColumnCount(4); - mPatientSelectModel->setHorizontalHeaderItem(0, new QStandardItem("Patient ID")); - mPatientSelectModel->setHorizontalHeaderItem(1, new QStandardItem("Accession Number")); - mPatientSelectModel->setHorizontalHeaderItem(2, new QStandardItem("Patient Name")); - mPatientSelectModel->setHorizontalHeaderItem(3, new QStandardItem("Scheduled Date")); - mPatientSelectTable->setModel(mPatientSelectModel); - mPatientSelectTable->setColumnWidth(0, 200); - mPatientSelectTable->setColumnWidth(1, 200); - mPatientSelectTable->setColumnWidth(2, 200); - mPatientSelectTable->setColumnWidth(3, 200); +// //TableView +// contentLayout->addWidget(mPatientSelectTable); +// mPatientSelectModel->setColumnCount(4); +// mPatientSelectModel->setHorizontalHeaderItem(0, new QStandardItem("Patient ID")); +// mPatientSelectModel->setHorizontalHeaderItem(1, new QStandardItem("Accession Number")); +// mPatientSelectModel->setHorizontalHeaderItem(2, new QStandardItem("Patient Name")); +// mPatientSelectModel->setHorizontalHeaderItem(3, new QStandardItem("Scheduled Date")); +// mPatientSelectTable->setModel(mPatientSelectModel); +// mPatientSelectTable->setColumnWidth(0, 200); +// mPatientSelectTable->setColumnWidth(1, 200); +// mPatientSelectTable->setColumnWidth(2, 200); +// mPatientSelectTable->setColumnWidth(3, 200); - mPatientSelectTable->setAlternatingRowColors(true); - mPatientSelectTable->setSelectionMode(QAbstractItemView::SingleSelection); - mPatientSelectTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - mPatientSelectTable->setSelectionBehavior(QAbstractItemView::SelectRows); - // mTableView->verticalHeader()->setDefaultSectionSize(38); - // mTableView->horizontalHeader()->setStretchLastSection(true); - mPatientSelectTable->viewport()->ungrabGesture(Qt::PanGesture); - mPatientSelectTable->setSortingEnabled(false); // enable sortingEnabled - mPatientSelectTable->hide(); +// mPatientSelectTable->setAlternatingRowColors(true); +// mPatientSelectTable->setSelectionMode(QAbstractItemView::SingleSelection); +// mPatientSelectTable->setEditTriggers(QAbstractItemView::NoEditTriggers); +// mPatientSelectTable->setSelectionBehavior(QAbstractItemView::SelectRows); +// // mTableView->verticalHeader()->setDefaultSectionSize(38); +// // mTableView->horizontalHeader()->setStretchLastSection(true); +// mPatientSelectTable->viewport()->ungrabGesture(Qt::PanGesture); +// mPatientSelectTable->setSortingEnabled(false); // enable sortingEnabled +// mPatientSelectTable->hide(); - //ErrorLabel - contentLayout->addWidget(mErrorLabel); - mErrorLabel->setObjectName("warn"); - mErrorLabel->setWordWrap(true); - mErrorLabel->hide(); - mBtnWidget->setFixedHeight(80); -} +// //ErrorLabel +// contentLayout->addWidget(mErrorLabel); +// mErrorLabel->setObjectName("warn"); +// mErrorLabel->setWordWrap(true); +// mErrorLabel->hide(); +// mBtnWidget->setFixedHeight(80); +//} -void GetWorkListDialog::search(const QString& aInput) -{ - switch(mSearchMode) - { - case ByAccessionNumber: - mAccessionNumber->insert(aInput); - break; - case ByPatientId: - mPatientId->insert(aInput); - break; - } - mIsAutoSearch = true; -} +//void GetWorkListDialog::search(const QString& aInput) +//{ +// switch(mSearchMode) +// { +// case ByAccessionNumber: +// mAccessionNumber->insert(aInput); +// break; +// case ByPatientId: +// mPatientId->insert(aInput); +// break; +// } +// mIsAutoSearch = true; +//} -bool GetWorkListDialog::updateReferenceData() -{ - if(mMode == PatientSelectMode) - { - insertPatient(mSearchedPatients.at(mPatientSelectTable->currentIndex().row())); - return true; - } - QString accessionNum = mAccessionNumber->text(); - QString patientId = mPatientId->text(); - if (accessionNum.isEmpty() && patientId.isEmpty()) - { - mErrorLabel->setText(tr("Accession Number and Patient Id is Empty.")); - QFont font = mErrorLabel->font(); - QFontMetrics metrics(font); - int width = metrics.width(mErrorLabel->text()); - mErrorLabel->setFixedHeight(metrics.lineSpacing() * (width / this->width()) + 40 ); - mErrorLabel->show(); - return false; - } - GetWorkListAction* action = qobject_cast(getAction()); - if (action == nullptr) - { - mErrorLabel->setText(tr("Unknow Error. code:001001001")); - return false; - } - action->setWorkListQueryData(WorkListQueryData(accessionNum, patientId)); - return AsyncActionDialog::updateReferenceData(); -} +//bool GetWorkListDialog::updateReferenceData() +//{ +// if(mMode == PatientSelectMode) +// { +// insertPatient(mSearchedPatients.at(mPatientSelectTable->currentIndex().row())); +// return true; +// } +// QString accessionNum = mAccessionNumber->text(); +// QString patientId = mPatientId->text(); +// if (accessionNum.isEmpty() && patientId.isEmpty()) +// { +// mErrorLabel->setText(tr("Accession Number and Patient Id is Empty.")); +// QFont font = mErrorLabel->font(); +// QFontMetrics metrics(font); +// int width = metrics.width(mErrorLabel->text()); +// mErrorLabel->setFixedHeight(metrics.lineSpacing() * (width / this->width()) + 40 ); +// mErrorLabel->show(); +// return false; +// } +// GetWorkListAction* action = qobject_cast(getAction()); +// if (action == nullptr) +// { +// mErrorLabel->setText(tr("Unknow Error. code:001001001")); +// return false; +// } +// action->setWorkListQueryData(WorkListQueryData(accessionNum, patientId)); +// return AsyncActionDialog::updateReferenceData(); +//} -void GetWorkListDialog::handleFinishedAction(const ActionResult& aResult) -{ - if (aResult.Code == Failed) - { - mErrorLabel->setText(aResult.Data.toString()); - mContentWidget->show(); - mBtnWidget->show(); - mErrorLabel->show(); - mLoadingWidget->hide(); - return; - } +//void GetWorkListDialog::handleFinishedAction(const ActionResult& aResult) +//{ +// if (aResult.Code == Failed) +// { +// mErrorLabel->setText(aResult.Data.toString()); +// mContentWidget->show(); +// mBtnWidget->show(); +// mErrorLabel->show(); +// mLoadingWidget->hide(); +// return; +// } - mSearchedPatients = aResult.Data.value>(); +// mSearchedPatients = aResult.Data.value>(); - if(mSearchedPatients.size() > 1) - { - updatePatientSelectTable(); - } - else if(mSearchedPatients.size() == 1) - { - insertPatient(mSearchedPatients.at(0)); - AsyncActionDialog::handleFinishedAction(aResult); - } -} +// if(mSearchedPatients.size() > 1) +// { +// updatePatientSelectTable(); +// } +// else if(mSearchedPatients.size() == 1) +// { +// insertPatient(mSearchedPatients.at(0)); +// AsyncActionDialog::handleFinishedAction(aResult); +// } +//} -void GetWorkListDialog::updatePatientSelectTable() -{ - int rowCount = mSearchedPatients.size(); +//void GetWorkListDialog::updatePatientSelectTable() +//{ +// int rowCount = mSearchedPatients.size(); - mPatientSelectModel->setRowCount(rowCount); - for(int i=0; iindex(i, 0, QModelIndex()); - mPatientSelectModel->setData(index, patient->ID); +// mPatientSelectModel->setRowCount(rowCount); +// for(int i=0; iindex(i, 0, QModelIndex()); +// mPatientSelectModel->setData(index, patient->ID); - index = mPatientSelectModel->index(i, 1, QModelIndex()); - mPatientSelectModel->setData(index, patient->AccessionNumber); +// index = mPatientSelectModel->index(i, 1, QModelIndex()); +// //mPatientSelectModel->setData(index, patient->AccessionNumber); - index = mPatientSelectModel->index(i, 2, QModelIndex()); - mPatientSelectModel->setData(index, patient->Name); +// index = mPatientSelectModel->index(i, 2, QModelIndex()); +// mPatientSelectModel->setData(index, patient->Name); - index = mPatientSelectModel->index(i, 3, QModelIndex()); - mPatientSelectModel->setData(index, patient->ScheduledStartDate); - } - showPatientSelectTable(); -} +// index = mPatientSelectModel->index(i, 3, QModelIndex()); +// //mPatientSelectModel->setData(index, patient->ScheduledStartDate); +// } +// showPatientSelectTable(); +//} -void GetWorkListDialog::showPatientSelectTable() -{ - setFixedWidth(900); - QRect re = geometry(); - setGeometry(re.x() - 200, re.y(), 900, re.height()); - mMode = PatientSelectMode; - mRadioButtonArea->hide(); - mAccessionNumber->hide(); - mPatientId->hide(); - mErrorLabel->hide(); - mAccessionNumText->hide(); - mPatientIDText->hide(); - mEditEndLine->hide(); +//void GetWorkListDialog::showPatientSelectTable() +//{ +// setFixedWidth(900); +// QRect re = geometry(); +// setGeometry(re.x() - 200, re.y(), 900, re.height()); +// mMode = PatientSelectMode; +// mRadioButtonArea->hide(); +// mAccessionNumber->hide(); +// mPatientId->hide(); +// mErrorLabel->hide(); +// mAccessionNumText->hide(); +// mPatientIDText->hide(); +// mEditEndLine->hide(); - mPatientSelectTable->show(); - mContentWidget->show(); - mBtnWidget->show(); - mLoadingWidget->hide(); -} +// mPatientSelectTable->show(); +// mContentWidget->show(); +// mBtnWidget->show(); +// mLoadingWidget->hide(); +//} -void GetWorkListDialog::insertPatient(PatientInformationPointer aPatient) -{ - if (mSqlModel == nullptr) - { - return; - } - if (aPatient.isNull()) - { - return; - } - mSqlModel->setFilter(QString("PatientID='%1' And AccessionNumber='%2'").arg(aPatient->ID).arg(aPatient->AccessionNumber)); - if (mSqlModel->rowCount() > 0) - { - mSqlModel->setFilter(""); - int patientIdIndex = mSqlModel->record().indexOf("PatientID"); - int accessionNumberIndex = mSqlModel->record().indexOf("AccessionNumber"); - for (int i = 0; i < mSqlModel->rowCount(); ++i) - { - if (mSqlModel->data(mSqlModel->index(i, patientIdIndex)) == aPatient->ID && - mSqlModel->data(mSqlModel->index(i, accessionNumberIndex)) == aPatient->AccessionNumber) - { - mTableView->selectRow(i); - aPatient->PatientUID = mSqlModel->data(mSqlModel->index(i, 0)).toString(); - EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)(aPatient.data())); - return; - } - } - return; - } - mSqlModel->setFilter(""); - aPatient->PatientUID = QUuid::createUuid().toString(); - aPatient->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); - mSqlModel->insertRow(0); -#define ADD_PATIENT_PROPERTY(val)\ - mSqlModel->setData(mSqlModel->index(0, PatientInformationEnum:: val),aPatient->val); - ADD_PATIENT() - #undef ADD_PATIENT_PROPERTY - if (!mSqlModel->submitAll()) - { - mErrorLabel->setText( tr("DB Error,Patient Write Failed")); - mErrorLabel->show(); - } - mTableView->selectRow(0); - LOG_USER_OPERATION(QString("Add Patient, ID:%1").arg(aPatient->ID)); +//void GetWorkListDialog::insertPatient(PatientInformationPointer aPatient) +//{ +// if (mSqlModel == nullptr) +// { +// return; +// } +// if (aPatient.isNull()) +// { +// return; +// } +// mSqlModel->setFilter(QString("PatientID='%1'").arg(aPatient->ID)); +// if (mSqlModel->rowCount() > 0) +// { +// mSqlModel->setFilter(""); +// int patientIdIndex = mSqlModel->record().indexOf("PatientID"); +// int accessionNumberIndex = mSqlModel->record().indexOf("AccessionNumber"); +// for (int i = 0; i < mSqlModel->rowCount(); ++i) +// { +// if (mSqlModel->data(mSqlModel->index(i, patientIdIndex)) == aPatient->ID) +// { +// mTableView->selectRow(i); +// aPatient->PatientUID = mSqlModel->data(mSqlModel->index(i, 0)).toString(); +// EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)(aPatient.data())); +// return; +// } +// } +// return; +// } +// mSqlModel->setFilter(""); +// aPatient->PatientUID = QUuid::createUuid().toString(); +// aPatient->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); +// mSqlModel->insertRow(0); +//#define ADD_PATIENT_PROPERTY(val)\ +// mSqlModel->setData(mSqlModel->index(0, PatientInformationEnum:: val),aPatient->val); +// ADD_PATIENT() +// #undef ADD_PATIENT_PROPERTY +// if (!mSqlModel->submitAll()) +// { +// mErrorLabel->setText( tr("DB Error,Patient Write Failed")); +// mErrorLabel->show(); +// } +// mTableView->selectRow(0); +// LOG_USER_OPERATION(QString("Add Patient, ID:%1").arg(aPatient->ID)); - EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)(aPatient.data())); -} +// EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)(aPatient.data())); +//} -void GetWorkListDialog::showEvent(QShowEvent *aEvent) -{ - if(mIsAutoSearch) - { - mBtnOk->click(); - } - AsyncActionDialog::showEvent(aEvent); -} +//void GetWorkListDialog::showEvent(QShowEvent *aEvent) +//{ +// if(mIsAutoSearch) +// { +// mBtnOk->click(); +// } +// AsyncActionDialog::showEvent(aEvent); +//} diff --git a/src/dialogs/GetWorkListDialog.h b/src/dialogs/GetWorkListDialog.h index b115796..b2997ed 100644 --- a/src/dialogs/GetWorkListDialog.h +++ b/src/dialogs/GetWorkListDialog.h @@ -4,59 +4,59 @@ #include "dialogs/AsyncActionDialog.h" #include "forms/select/PatientInformation.h" -class ULineEdit; -class QLabel; -class QSqlTableModel; -class QTableView; -class QStandardItemModel; +//class ULineEdit; +//class QLabel; +//class QSqlTableModel; +//class QTableView; +//class QStandardItemModel; -enum GetWorkListDialogMode -{ - PatientSearchMode = 0, PatientSelectMode -}; +//enum GetWorkListDialogMode +//{ +// PatientSearchMode = 0, PatientSelectMode +//}; -enum WorkListSearchMode -{ - ByAccessionNumber = 0, ByPatientId -}; +//enum WorkListSearchMode +//{ +// ByAccessionNumber = 0, ByPatientId +//}; -class GetWorkListDialog : public AsyncActionDialog -{ - Q_OBJECT +//class GetWorkListDialog : public AsyncActionDialog +//{ +// Q_OBJECT -public: - explicit GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags()); - ~GetWorkListDialog() override; - void search(const QString& aInput); +//public: +// explicit GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags()); +// ~GetWorkListDialog() override; +// void search(const QString& aInput); -protected: - bool updateReferenceData() override; - void showEvent(QShowEvent *aEvent) override; +//protected: +// bool updateReferenceData() override; +// void showEvent(QShowEvent *aEvent) override; -private: - void initializeContentWidgets(); - void updatePatientSelectTable(); - void showPatientSelectTable(); - void insertPatient(PatientInformationPointer aPatient); - virtual void handleFinishedAction(const ActionResult& aResult) override; +//private: +// void initializeContentWidgets(); +// void updatePatientSelectTable(); +// void showPatientSelectTable(); +// void insertPatient(PatientInformationPointer aPatient); +// virtual void handleFinishedAction(const ActionResult& aResult) override; -private: - ULineEdit* mAccessionNumber; - ULineEdit* mPatientId; - QLabel* mErrorLabel; - QLabel* mAccessionNumText; - QLabel* mPatientIDText; - QLabel* mEditEndLine; - QTableView* mPatientSelectTable; - GetWorkListDialogMode mMode; - WorkListSearchMode mSearchMode; - QStandardItemModel* mPatientSelectModel; - QSqlTableModel* mSqlModel; - QTableView* mTableView; - QList mSearchedPatients; - QWidget* mRadioButtonArea; - bool mIsAutoSearch; +//private: +// ULineEdit* mAccessionNumber; +// ULineEdit* mPatientId; +// QLabel* mErrorLabel; +// QLabel* mAccessionNumText; +// QLabel* mPatientIDText; +// QLabel* mEditEndLine; +// QTableView* mPatientSelectTable; +// GetWorkListDialogMode mMode; +// WorkListSearchMode mSearchMode; +// QStandardItemModel* mPatientSelectModel; +// QSqlTableModel* mSqlModel; +// QTableView* mTableView; +// QList mSearchedPatients; +// QWidget* mRadioButtonArea; +// bool mIsAutoSearch; -}; +//}; #endif //GUI_GETWORKLISTDIALOG_H diff --git a/src/dialogs/StartScanProcessDialog.cpp b/src/dialogs/StartScanProcessDialog.cpp index c8ec180..ea50801 100644 --- a/src/dialogs/StartScanProcessDialog.cpp +++ b/src/dialogs/StartScanProcessDialog.cpp @@ -64,11 +64,69 @@ void StartScanProcessDialog::initButtons() void StartScanProcessDialog::setPatientDetailForm(PatientInformation* aPatient) { + setButtonModeFromPatient(aPatient); mUI->mPatientID->setText(aPatient->ID); mUI->mPatienName->setText(aPatient->Name); mUI->mPatientGender->setText(aPatient->Sex); mUI->mPatientBirth->setText(aPatient->BirthDate); - mUI->mAccessionNumber->setText(aPatient->AccessionNumber); + QList selectedAccesson = aPatient->getSelectedAccession(); + if(selectedAccesson.size() == 1) + { + mUI->mAccessionNumber_1->setText(selectedAccesson[0]->mAccessionNumber); + mUI->mScanProtocol_1->setText(selectedAccesson[0]->getProtocolText()); + showAccessionLabel_1(true); + showAccessionLabel_2(false); + return; + } + else if(selectedAccesson.size() == 2) + { + mUI->mAccessionNumber_1->setText(selectedAccesson[0]->mAccessionNumber); + mUI->mScanProtocol_1->setText(selectedAccesson[0]->getProtocolText()); + mUI->mAccessionNumber_2->setText(selectedAccesson[1]->mAccessionNumber); + mUI->mScanProtocol_2->setText(selectedAccesson[1]->getProtocolText()); + showAccessionLabel_1(true); + showAccessionLabel_2(true); + return; + } + showAccessionLabel_1(false); + showAccessionLabel_2(false); +} + +void StartScanProcessDialog::setButtonModeFromPatient(PatientInformation* aPatient) +{ + QList selectedAccession = aPatient->getSelectedAccession(); + if(selectedAccession.size() == 0) + { + return; + } + if(aPatient->mSelectedScanProtocol == ScanLeftRight) + { + mUI->mOnlyLeftButton->setEnabled(false); + mUI->mOnlyRightButton->setEnabled(false); + mUI->mLeftToRightButton->setChecked(true); + mScanProtocal = LSTAND; + return; + } + + if(aPatient->mSelectedScanProtocol == ScanLeft) + { + mUI->mLeftToRightButton->setEnabled(false); + mUI->mRightToLeftButton->setEnabled(false); + mUI->mOnlyRightButton->setEnabled(false); + mUI->mOnlyLeftButton->setChecked(true); + mScanProtocal = LONE; + return; + } + + if(aPatient->mSelectedScanProtocol == ScanRight) + { + mUI->mLeftToRightButton->setEnabled(false); + mUI->mRightToLeftButton->setEnabled(false); + mUI->mOnlyLeftButton->setEnabled(false); + mUI->mOnlyRightButton->setChecked(true); + mScanProtocal = RONE; + return; + } } void StartScanProcessDialog::accept() @@ -86,3 +144,38 @@ void StartScanProcessDialog::setSelectedScanProtocal(int aButtonIndex) mScanProtocal = static_cast(aButtonIndex); } +void StartScanProcessDialog::showAccessionLabel_1(bool aIsShow) +{ + if(aIsShow) + { + mUI->mAccessionNumberLabel_1->show(); + mUI->mScanProtocolLabel_1->show(); + mUI->mAccessionNumber_1->show(); + mUI->mScanProtocol_1->show(); + } + else + { + mUI->mAccessionNumberLabel_1->hide(); + mUI->mScanProtocolLabel_1->hide(); + mUI->mAccessionNumber_1->hide(); + mUI->mScanProtocol_1->hide(); + } +} +void StartScanProcessDialog::showAccessionLabel_2(bool aIsShow) +{ + if(aIsShow) + { + mUI->mAccessionNumberLabel_2->show(); + mUI->mScanProtocolLabel_2->show(); + mUI->mAccessionNumber_2->show(); + mUI->mScanProtocol_2->show(); + } + else + { + mUI->mAccessionNumberLabel_2->hide(); + mUI->mScanProtocolLabel_2->hide(); + mUI->mAccessionNumber_2->hide(); + mUI->mScanProtocol_2->hide(); + } +} + diff --git a/src/dialogs/StartScanProcessDialog.h b/src/dialogs/StartScanProcessDialog.h index 51ac543..7a91434 100644 --- a/src/dialogs/StartScanProcessDialog.h +++ b/src/dialogs/StartScanProcessDialog.h @@ -26,6 +26,9 @@ public slots: private: void initButtons(); + void showAccessionLabel_1(bool aIsShow); + void showAccessionLabel_2(bool aIsShow); + void setButtonModeFromPatient(PatientInformation* aPatient); private: Ui::StartScanProcessDialog *mUI; diff --git a/src/dialogs/StartScanProcessDialog.ui b/src/dialogs/StartScanProcessDialog.ui index 607cae7..3b3a0d7 100644 --- a/src/dialogs/StartScanProcessDialog.ui +++ b/src/dialogs/StartScanProcessDialog.ui @@ -7,7 +7,7 @@ 0 0 638 - 468 + 486 @@ -48,23 +48,8 @@ border-bottom: 1px solid gray; - - - - - -1 - - - - font-size:28px - - - PatientBirth: - - - - - + + -1 @@ -78,23 +63,8 @@ border-bottom: 1px solid gray; - - - - - -1 - - - - font-size:28px - - - PatientGender: - - - - - + + -1 @@ -108,6 +78,36 @@ border-bottom: 1px solid gray; + + + + + -1 + + + + font-size:28px + + + + + + + + + + + -1 + + + + font-size:28px + + + AccessionNumber: + + + @@ -123,8 +123,8 @@ border-bottom: 1px solid gray; - - + + -1 @@ -134,7 +134,22 @@ border-bottom: 1px solid gray; font-size:28px - AccessionNumber: + ScanProtocol: + + + + + + + + -1 + + + + font-size:28px + + + PatientGender: @@ -153,8 +168,38 @@ border-bottom: 1px solid gray; - - + + + + + -1 + + + + font-size:28px + + + + + + + + + + + -1 + + + + font-size:28px + + + AccessionNumber: + + + + + -1 @@ -183,8 +228,53 @@ border-bottom: 1px solid gray; - - + + + + + -1 + + + + font-size:28px + + + PatientBirth: + + + + + + + + -1 + + + + font-size:28px + + + ScanProtocol: + + + + + + + + -1 + + + + font-size:28px + + + + + + + + -1 diff --git a/src/dialogs/WorklistLoadingDialog.cpp b/src/dialogs/WorklistLoadingDialog.cpp new file mode 100644 index 0000000..e254b0e --- /dev/null +++ b/src/dialogs/WorklistLoadingDialog.cpp @@ -0,0 +1,22 @@ +#include "WorklistLoadingDialog.h" + +#include +#include + +#include "components/LoadingWidget.h" + +WorklistLoadingDialog::WorklistLoadingDialog(QWidget* aParent) + : GUIFormBaseDialog (aParent, Qt::WindowFlags()) + , mLoadingWidget(new LoadingWidget(mFormWidget)) +{ + QVBoxLayout* layout = new QVBoxLayout(mFormWidget); + + mLoadingWidget->setAttribute(Qt::WA_TranslucentBackground); + mLoadingWidget->setFixedHeight(180); + layout->addWidget(mLoadingWidget); + + setAttribute(Qt::WA_TranslucentBackground); + mFormWidget->setAttribute(Qt::WA_TranslucentBackground); + mBtnWidget->hide(); + setButtonMode(DialogButtonMode::None); +} diff --git a/src/dialogs/WorklistLoadingDialog.h b/src/dialogs/WorklistLoadingDialog.h new file mode 100644 index 0000000..7a60775 --- /dev/null +++ b/src/dialogs/WorklistLoadingDialog.h @@ -0,0 +1,22 @@ +#ifndef WORKLISTLOADINGDIALOG_H +#define WORKLISTLOADINGDIALOG_H + +#include "GUIFormBaseDialog.h" + +class LoadingWidget; + +class WorklistLoadingDialog : public GUIFormBaseDialog +{ + Q_OBJECT +public: + WorklistLoadingDialog(QWidget* aParent = nullptr); + +protected: + //bool updateReferenceData() override; + +private: + LoadingWidget* mLoadingWidget; + +}; + +#endif // WORKLISTLOADINGDIALOG_H diff --git a/src/dicom/MPPSAsyncAction.cpp b/src/dicom/MPPSAsyncAction.cpp index f2169a1..bcaf4f8 100644 --- a/src/dicom/MPPSAsyncAction.cpp +++ b/src/dicom/MPPSAsyncAction.cpp @@ -24,7 +24,7 @@ MPPSAsyncAction::~MPPSAsyncAction() void MPPSAsyncAction::run() { - if (mPatient.isNull()||mPatient->PatientUID.isEmpty() || !mPatient->MPPSUID.isEmpty())return; + if (mAccession == nullptr|| mAccession->mPatient->ID.isEmpty() || !mAccession->mMPPSUID.isEmpty())return; if (!dcmDataDict.isDictionaryLoaded()) { qDebug() << "dcmdatadict error"; @@ -47,6 +47,9 @@ void MPPSAsyncAction::run() scu.setPeerAETitle(serverInfo.ae.toLatin1().data()); scu.setVerbosePCMode(OFFalse); scu.addPresentationContext(UID_ModalityPerformedProcedureStepSOPClass, syntaxes); + scu.setACSETimeout(3); + scu.setDIMSETimeout(3); + scu.setConnectionTimeout(3); OFCondition cond = scu.initNetwork(); if (cond.bad()) @@ -80,24 +83,24 @@ void MPPSAsyncAction::run() DcmSequenceOfItems *attr_Seq = new DcmSequenceOfItems(DCM_ScheduledStepAttributesSequence); DcmItem *attr_item = new DcmItem(); - attr_item->putAndInsertString(DCM_StudyInstanceUID, mPatient->StudyUID.toStdString().data()); + attr_item->putAndInsertString(DCM_StudyInstanceUID, mAccession->mStudyUID.toStdString().data()); DcmSequenceOfItems *refSeq = new DcmSequenceOfItems(DCM_ReferencedStudySequence); attr_item->insert(refSeq); - attr_item->putAndInsertString(DCM_AccessionNumber, mPatient->AccessionNumber.toStdString().data()); + attr_item->putAndInsertString(DCM_AccessionNumber, mAccession->mAccessionNumber.toStdString().data()); - attr_item->putAndInsertString(DCM_RequestedProcedureID, mPatient->RPID.toStdString().data()); - attr_item->putAndInsertString(DCM_ScheduledProcedureStepID, mPatient->SPSID.toStdString().data()); + attr_item->putAndInsertString(DCM_RequestedProcedureID, mAccession->mRPID.toStdString().data()); + attr_item->putAndInsertString(DCM_ScheduledProcedureStepID, mAccession->mSPSID.toStdString().data()); DcmSequenceOfItems *protocolSeq = new DcmSequenceOfItems(DCM_ScheduledProtocolCodeSequence); attr_item->insert(protocolSeq); attr_Seq->insert(attr_item); dset->insert(attr_Seq); DcmSequenceOfItems *codeSeq = new DcmSequenceOfItems(DCM_ProcedureCodeSequence); dset->insert(codeSeq); - dset->putAndInsertString(DCM_PatientName, mPatient->Name.toStdString().data()); - dset->putAndInsertString(DCM_PatientID, mPatient->ID.toStdString().data()); - dset->putAndInsertString(DCM_PatientBirthDate, mPatient->BirthDate.toStdString().data()); - dset->putAndInsertString(DCM_PatientSex, mPatient->Sex.toStdString().data()); + dset->putAndInsertString(DCM_PatientName, mAccession->mPatient->Name.toStdString().data()); + dset->putAndInsertString(DCM_PatientID, mAccession->mPatient->ID.toStdString().data()); + dset->putAndInsertString(DCM_PatientBirthDate, mAccession->mPatient->BirthDate.toStdString().data()); + dset->putAndInsertString(DCM_PatientSex, mAccession->mPatient->Sex.toStdString().data()); DcmSequenceOfItems *refPSeq = new DcmSequenceOfItems(DCM_ReferencedPatientSequence); dset->insert(refPSeq); @@ -117,7 +120,7 @@ void MPPSAsyncAction::run() dset->putAndInsertString(DCM_PerformedProcedureStepEndDate, ""); dset->putAndInsertString(DCM_PerformedProcedureStepEndTime, ""); // get modality from MWL query resault - dset->putAndInsertString(DCM_Modality, mPatient->Modality.toStdString().data()); + dset->putAndInsertString(DCM_Modality, mAccession->mModality.toStdString().data()); dset->putAndInsertString(DCM_StudyID, ""); DcmSequenceOfItems *refpPSeq = new DcmSequenceOfItems(DCM_PerformedProtocolCodeSequence); @@ -130,7 +133,7 @@ void MPPSAsyncAction::run() char uidbuff[100]; dcmGenerateUniqueIdentifier(uidbuff); uid.append(uidbuff); - mPatient->MPPSUID = uidbuff; + mAccession->mMPPSUID = uidbuff; } cond = scu.sendNCreateRequest(pcid, uid, dset, responses); if (responses != 0) @@ -163,16 +166,11 @@ void MPPSAsyncAction::run() scu.abortAssociation(); } } - emit actionCompleted(ActionResult(Sucessed,QString("%0|%1").arg(mPatient->PatientUID).arg(mPatient->MPPSUID))); + emit actionCompleted(ActionResult(Sucessed,QString("%0|%1").arg(mAccession->mPatient->PatientUID).arg(mAccession->mMPPSUID))); return; } -void MPPSAsyncAction::setPatient(PatientInformationPointer aPatient) +void MPPSAsyncAction::setAccession(AccessionInformation* aInfo) { - mPatient = aPatient; -} - -PatientInformationPointer MPPSAsyncAction::getPatient() -{ - return mPatient; + mAccession = aInfo; } diff --git a/src/dicom/MPPSAsyncAction.h b/src/dicom/MPPSAsyncAction.h index ebdc105..f670703 100644 --- a/src/dicom/MPPSAsyncAction.h +++ b/src/dicom/MPPSAsyncAction.h @@ -4,6 +4,7 @@ #include "action/AsyncAction.h" #include class MPPSAsyncAction : public AsyncAction + { Q_OBJECT @@ -11,14 +12,13 @@ public: explicit MPPSAsyncAction(QObject* aParent); ~MPPSAsyncAction(); void run() override; - void setPatient(PatientInformationPointer aPatient); - PatientInformationPointer getPatient(); + void setAccession(AccessionInformation* aInfo); signals: void actionCompleted(const ActionResult& aResult); private: - PatientInformationPointer mPatient; + AccessionInformation* mAccession; }; #endif /* GUI_MPPS_ASYNC_ACTION_H */ diff --git a/src/dicom/MPPSManager.cpp b/src/dicom/MPPSManager.cpp index f88ba55..1b5cf23 100644 --- a/src/dicom/MPPSManager.cpp +++ b/src/dicom/MPPSManager.cpp @@ -9,29 +9,7 @@ #include "event/EventCenter.h" #include "json/jsonobject.h" #include "device/DeviceManager.h" - - -void MPPSManager::setPatientUID(const QString& aPatientUID) -{ - if (aPatientUID.isEmpty())return; - QMap result; - QMap 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); -} +#include "utilities/ScanProcessSequence.h" void MPPSManager::processMPPSResult(const ActionResult& aResult) { @@ -89,6 +67,10 @@ MPPSManager* MPPSManager::getInstance() void MPPSManager::sendMPPS() { - if (!action->getPatient()->MPPSUID.isEmpty())return; - action->execute(); + AccessionInformation* accession = ScanProcessSequence::getInstance()->topAccession().first; + if (accession != nullptr && JsonObject::Instance()->getMppsOpen() && !accession->mSPSID.isEmpty() && accession->mMPPSUID.isEmpty()) + { + action->setAccession(accession); + action->execute(); + } } diff --git a/src/dicom/MPPSManager.h b/src/dicom/MPPSManager.h index 1875c92..f58e4b2 100644 --- a/src/dicom/MPPSManager.h +++ b/src/dicom/MPPSManager.h @@ -15,7 +15,6 @@ class MPPSManager:public QObject public: static MPPSManager *getInstance(); void sendMPPS(); - void setPatientUID(const QString& aPatientID); public slots: void processMPPSResult(const ActionResult& aResult); private: diff --git a/src/dicom/WorkListManager.cpp b/src/dicom/WorkListManager.cpp index ca78861..d8ebb38 100644 --- a/src/dicom/WorkListManager.cpp +++ b/src/dicom/WorkListManager.cpp @@ -7,10 +7,47 @@ #include #include "json/jsonobject.h" +#include "utilities/WorklistFilterHelper.h" #include #include +namespace +{ + PatientInformation* findPatientId(const QList& aPatientList, const QString& aPatientId) + { + for(int i=0; iID == aPatientId) + { + return aPatientList[i]; + } + } + return nullptr; + } + + void setScanPosition(AccessionInformation* aAccession, const QString& aWorklistLabel) + { + QString position = aWorklistLabel.toLower(); + if(position == "lr" || position == "rl") + { + aAccession->mPosition = ScanLeftRight; + } + else if(position == "l") + { + aAccession->mPosition = ScanLeft; + } + else if(position == "r") + { + aAccession->mPosition = ScanRight; + } + else + { + aAccession->mPosition = ScanNone; + } + } +} + WorkListManager *WorkListManager::getInstance() { static WorkListManager instance; @@ -58,7 +95,7 @@ WorkListManager::~WorkListManager() { } -int WorkListManager::getPatientFromWorkList(const QString &aAccessionNum, const QString &aPatientId, QList& aOutPatient) +int WorkListManager::getPatientFromWorkList(QList& aOutPatient) { if (!dcmDataDict.isDictionaryLoaded()) { @@ -109,21 +146,9 @@ int WorkListManager::getPatientFromWorkList(const QString &aAccessionNum, const DcmFileFormat dcmff; DcmDataset *dset = dcmff.getDataset(); - if (!aPatientId.isEmpty()) - { - dset->putAndInsertString(DCM_PatientID, aPatientId.toStdString().data()); - } - else - { - dset->insertEmptyElement(DCM_PatientID); - } - if (!aAccessionNum.isEmpty()) - { - dset->putAndInsertString(DCM_AccessionNumber, aAccessionNum.toStdString().data()); - } - else{ - dset->insertEmptyElement(DCM_AccessionNumber); - } + dset->insertEmptyElement(DCM_PatientID); + + dset->insertEmptyElement(DCM_AccessionNumber); dset->insertEmptyElement(DCM_PatientName); dset->insertEmptyElement(DCM_PatientSex); dset->insertEmptyElement(DCM_PatientBirthDate); @@ -131,16 +156,16 @@ int WorkListManager::getPatientFromWorkList(const QString &aAccessionNum, const dset->insertEmptyElement(DCM_WorklistLabel); dset->insertEmptyElement(DCM_RequestedProcedureID); - DcmSequenceOfItems *step_Seq = new DcmSequenceOfItems(DCM_ScheduledProcedureStepSequence); - DcmItem *step_item = new DcmItem(); + DcmSequenceOfItems *step_Seq = new DcmSequenceOfItems(DCM_ScheduledProcedureStepSequence);//no need delete + DcmItem *step_item = new DcmItem();//no need delete // use local aetitle to retrieve step_item->putAndInsertString(DCM_ScheduledStationAETitle, serverInfo.localAE.toLatin1().data()); // PS: begin time fit begin date like date: 20240328-20240528 time:011201-020101 // means 2024-03-28 01:12:01 - 2024-05-28 02:01:01 - // step_item->putAndInsertString(DCM_ScheduledProcedureStepStartDate,"20240528-20240528"); + step_item->putAndInsertString(DCM_ScheduledProcedureStepStartDate, WorklistFilterHelper::getFilterDateStringInSCU().toStdString().c_str()); // step_item->putAndInsertString(DCM_ScheduledProcedureStepStartTime,"011201-030101"); - step_item->putAndInsertString(DCM_Modality, "CT"); + step_item->putAndInsertString(DCM_Modality, JsonObject::Instance()->getWorklistFilterModality().toStdString().c_str()); step_item->insertEmptyElement(DCM_ScheduledProtocolCodeSequence); step_item->insertEmptyElement(DCM_ScheduledProcedureStepID); @@ -154,34 +179,38 @@ int WorkListManager::getPatientFromWorkList(const QString &aAccessionNum, const if (responses.size() > 1) { qDebug()<<"cfind Response size:"<m_dataset) { - // (*item)->m_dataset->print(std::cout); - PatientInformationPointer patient = PatientInformationPointer(new PatientInformation()); OFString ID; - OFString Name; - OFString BirthDate; - OFString Sex; - OFString AccessionNumber; - OFString studyInstanceUID; - OFString modality; - - OFString scheduledStartDateStr; - OFString scheduledProcedureStepID; - OFString requestedProcedureID; - (*item)->m_dataset->findAndGetOFString(DCM_PatientID, ID); - if (ID.empty()) { continue; } - (*item)->m_dataset->findAndGetOFString(DCM_PatientName, Name); - (*item)->m_dataset->findAndGetOFString(DCM_PatientBirthDate, BirthDate); - (*item)->m_dataset->findAndGetOFString(DCM_PatientSex, Sex); - + QString patientID(ID.c_str()); + PatientInformation* newPatient = findPatientId(aOutPatient, patientID); + if(newPatient == nullptr) + { + OFString Name; + OFString BirthDate; + OFString Sex; + (*item)->m_dataset->findAndGetOFString(DCM_PatientName, Name); + (*item)->m_dataset->findAndGetOFString(DCM_PatientBirthDate, BirthDate); + (*item)->m_dataset->findAndGetOFString(DCM_PatientSex, Sex); + newPatient = new PatientInformation(patientID, QString(Name.c_str()), QString(Sex.c_str()), QDate::fromString(BirthDate.c_str(),"yyyyMMdd").toString("yyyy-MM-dd"), currentDateTime); + aOutPatient.push_back(newPatient); + } + AccessionInformation* accession = new AccessionInformation(newPatient, newPatient); + OFString AccessionNumber; + OFString studyInstanceUID; + OFString modality; + OFString scheduledStartDateStr; + OFString scheduledProcedureStepID; + OFString requestedProcedureID; + OFString worklistLabel; if ((*item)->m_dataset->findAndGetOFString(DCM_StudyInstanceUID, studyInstanceUID).bad()) { char uid[100]; @@ -190,30 +219,22 @@ int WorkListManager::getPatientFromWorkList(const QString &aAccessionNum, const } (*item)->m_dataset->findAndGetOFString(DCM_AccessionNumber, AccessionNumber); (*item)->m_dataset->findAndGetOFString(DCM_RequestedProcedureID, requestedProcedureID); - + (*item)->m_dataset->findAndGetOFString(DCM_WorklistLabel, worklistLabel); DcmItem *seqItem = nullptr; (*item)->m_dataset->findAndGetSequenceItem(DCM_ScheduledProcedureStepSequence, seqItem); seqItem->findAndGetOFString(DCM_Modality, modality); seqItem->findAndGetOFString(DCM_ScheduledProcedureStepStartDate, scheduledStartDateStr); - seqItem->findAndGetOFString(DCM_ScheduledProcedureStepID, scheduledProcedureStepID); + accession->mAccessionNumber = QString(AccessionNumber.c_str()); + accession->mScheduledStartDate = QDate::fromString(scheduledStartDateStr.c_str(),"yyyyMMdd").toString("yyyy-MM-dd"); + accession->mStudyUID = QString(studyInstanceUID.c_str()); + accession->mModality = QString(modality.c_str()); + accession->mSPSID = QString(scheduledProcedureStepID.c_str()); + accession->mRPID = QString(requestedProcedureID.c_str()); + setScanPosition(accession, QString(worklistLabel.c_str())); - patient->ID = QString(ID.c_str()); - patient->Name = QString(Name.c_str()); - patient->BirthDate = QString(BirthDate.c_str()).insert(4, "-").insert(7, "-"); - patient->Sex = QString(Sex.c_str()); - patient->AccessionNumber = QString(AccessionNumber.c_str()); - patient->ScheduledStartDate = QString(scheduledStartDateStr.c_str()); - patient->StudyUID = QString(studyInstanceUID.c_str()); - patient->Modality = QString(modality.c_str()); - patient->SPSID = QString(scheduledProcedureStepID.c_str()); - patient->RPID = QString(requestedProcedureID.c_str()); - // { - // char uid[100]; - // dcmGenerateUniqueIdentifier(uid); - // patient->MPPSUID = uid; - // } - aOutPatient.push_back(patient); + newPatient->setAccession(accession); + newPatient->prepareRecommendAccession(); } else{ diff --git a/src/dicom/WorkListManager.h b/src/dicom/WorkListManager.h index ef2f115..d9a3109 100644 --- a/src/dicom/WorkListManager.h +++ b/src/dicom/WorkListManager.h @@ -21,7 +21,7 @@ class WorkListManager { public: static WorkListManager* getInstance(); - static int getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId, QList& aOutPatients); + static int getPatientFromWorkList(QList& aOutPatients); void setTableModel(QSqlTableModel* aModel); void setTableView(QTableView* aTableView); diff --git a/src/event/EventCenter.h b/src/event/EventCenter.h index 1f1ae4f..014893c 100644 --- a/src/event/EventCenter.h +++ b/src/event/EventCenter.h @@ -36,7 +36,7 @@ ADD_EVENT_VALUE(DeviceInfoRaise)\ ADD_EVENT_VALUE(RequestScreenSaver)\ ADD_EVENT_VALUE(ReconConnectionUpdated)\ ADD_EVENT_VALUE(InputWorkListSearchValue)\ -ADD_EVENT_VALUE(DoWorkListSearch)\ +ADD_EVENT_VALUE(WorklistSearchFinished)\ ADD_EVENT_VALUE(WarningMessageRaise)\ ADD_EVENT_VALUE(ErrorStateActive)\ ADD_EVENT_VALUE(ErrorStateUnactive)\ diff --git a/src/forms/recon/ReconFormWidget.cpp b/src/forms/recon/ReconFormWidget.cpp index 05dce53..3eaf73b 100644 --- a/src/forms/recon/ReconFormWidget.cpp +++ b/src/forms/recon/ReconFormWidget.cpp @@ -81,7 +81,9 @@ void ReconFormWidget::initTableView(QHBoxLayout *contentLayout) mScanTable->setModel(mModel); mScanTable->hideColumn(getTableColumnIndex("ScanID")); mScanTable->hideColumn(getTableColumnIndex("ReferenceID")); - mScanTable->hideColumn(getTableColumnIndex("UpdateTime")); + mScanTable->hideColumn(getTableColumnIndex("StudyUID")); + mScanTable->hideColumn(getTableColumnIndex("Modality")); + mScanTable->hideColumn(getTableColumnIndex("MPPSUID")); mScanTable->setColumnWidth(getTableColumnIndex("PatientID"), 200); mScanTable->setColumnWidth(getTableColumnIndex("AccessionNumber"), 200); diff --git a/src/forms/scan/PatientInformationForm.cpp b/src/forms/scan/PatientInformationForm.cpp index 91bb26d..d24ea82 100644 --- a/src/forms/scan/PatientInformationForm.cpp +++ b/src/forms/scan/PatientInformationForm.cpp @@ -8,8 +8,10 @@ PatientInformationForm::PatientInformationForm(QWidget* parent) : QWidget(parent) , mUI(new Ui::PatientInformationForm) -, mInfo(nullptr) , mJsonStr(nullptr) +, mStudyUID() +, mModality() +, mMPPSUID() { mUI->setupUi(this); connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { @@ -23,15 +25,13 @@ PatientInformationForm::~PatientInformationForm() delete mJsonStr; } -void PatientInformationForm::setPatientInformation(PatientInformationPointer information, ScanProtocal aProtocal) { - if(information) +void PatientInformationForm::setPatientInformation(PatientInformation* information) { + if(information != nullptr) { mUI->mPatientID->setText(information->ID); mUI->mPatientBirthday->setText(information->BirthDate); mUI->mPatientName->setText(information->Name); - mUI->mPatientGender->setText(information->Sex); - mUI->mPaitenAccessionNumber->setText(information->AccessionNumber); - mUI->mScanProtocol->setText(getProtocolString(aProtocal)); + mUI->mPatientGender->setText(information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other"))); } else { @@ -40,15 +40,26 @@ void PatientInformationForm::setPatientInformation(PatientInformationPointer inf mUI->mPatientName->clear(); mUI->mPatientGender->clear(); mUI->mPaitenAccessionNumber->clear(); - mUI->mScanProtocol->clear(); + mStudyUID.clear(); + mModality.clear(); + mMPPSUID.clear(); } - - mInfo = information; } -PatientInformationPointer PatientInformationForm::getPatientInformation() +void PatientInformationForm::setAccessionNumber(AccessionInformation* aAccession) { - return mInfo->Copy(); + if(aAccession == nullptr) + { + mUI->mPaitenAccessionNumber->setText(""); + mStudyUID.clear(); + mModality.clear(); + mMPPSUID.clear(); + return; + } + mUI->mPaitenAccessionNumber->setText(aAccession->mAccessionNumber); + mStudyUID = aAccession->mStudyUID; + mModality = aAccession->mModality; + mMPPSUID = aAccession->mMPPSUID; } int PatientInformationForm::getProtocol() @@ -75,6 +86,14 @@ QString PatientInformationForm::getPatientID() void PatientInformationForm::setExecuteProtocol(bool aIsLeft) { mIsExecuteProtocolLeft = aIsLeft; + if(mIsExecuteProtocolLeft) + { + mUI->mScanProtocol->setText(tr("Left")); + } + else + { + mUI->mScanProtocol->setText(tr("Right")); + } } void PatientInformationForm::clear() @@ -85,24 +104,29 @@ void PatientInformationForm::clear() mUI->mPatientGender->clear(); mUI->mPaitenAccessionNumber->clear(); mUI->mScanProtocol->clear(); + mStudyUID.clear(); + mModality.clear(); + mMPPSUID.clear(); } const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) { cJSON* patientInfoObject = cJSON_CreateObject(); - cJSON_AddItemToObject(patientInfoObject, "PatientName", cJSON_CreateString(mInfo->Name.toStdString().data())); - cJSON_AddItemToObject(patientInfoObject, "PatientID", cJSON_CreateString(mInfo->ID.toStdString().data())); - cJSON_AddItemToObject(patientInfoObject, "AccessionNumber", cJSON_CreateString(mInfo->AccessionNumber.toStdString().data())); - cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mInfo->Sex.toStdString().data())); + cJSON_AddItemToObject(patientInfoObject, "PatientName", cJSON_CreateString(mUI->mPatientName->text().toStdString().data())); + cJSON_AddItemToObject(patientInfoObject, "PatientID", cJSON_CreateString(mUI->mPatientID->text().toStdString().data())); + cJSON_AddItemToObject(patientInfoObject, "AccessionNumber", cJSON_CreateString(mUI->mPaitenAccessionNumber->text().toStdString().data())); + cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mUI->mPatientGender->text().toStdString().data())); cJSON_AddItemToObject(patientInfoObject, "PatientBirthDate", - cJSON_CreateString(mInfo->BirthDate.replace("/", "").replace("-", "").replace(' ', '.').toStdString().data())); + cJSON_CreateString(mUI->mPatientBirthday->text().replace("/", "").replace("-", "").replace(' ', '.').toStdString().data())); 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())); cJSON_AddItemToObject(patientInfoObject, "InstitutionName", cJSON_CreateString("EQ9")); cJSON_AddItemToObject(patientInfoObject, "InstitutionAddress", cJSON_CreateString("HZ")); - + cJSON_AddItemToObject(patientInfoObject, "StudyUID", cJSON_CreateString(mStudyUID.toStdString().data())); + cJSON_AddItemToObject(patientInfoObject, "Modality", cJSON_CreateString(mModality.toStdString().data())); + cJSON_AddItemToObject(patientInfoObject, "MPPSUID", cJSON_CreateString(mMPPSUID.toStdString().data())); cJSON* rootObject = cJSON_CreateObject(); cJSON_AddItemToObject(rootObject, "Patient Info", patientInfoObject); delete mJsonStr; diff --git a/src/forms/scan/PatientInformationForm.h b/src/forms/scan/PatientInformationForm.h index 22931f2..47202b2 100644 --- a/src/forms/scan/PatientInformationForm.h +++ b/src/forms/scan/PatientInformationForm.h @@ -19,8 +19,8 @@ class PatientInformationForm : public QWidget public: explicit PatientInformationForm(QWidget *parent = nullptr); ~PatientInformationForm() override; - void setPatientInformation(PatientInformationPointer information, ScanProtocal aProtocal); - PatientInformationPointer getPatientInformation(); + void setPatientInformation(PatientInformation* information); + void setAccessionNumber(AccessionInformation* aAccession); int getProtocol(); QString getProtocolString(ScanProtocal aProtocal); void setExecuteProtocol(bool aIsLeft); @@ -31,10 +31,12 @@ public: private: Ui::PatientInformationForm *mUI; - PatientInformationPointer mInfo; bool mIsExecuteProtocolLeft = false; ScanProtocal mCurrentProtocol = LSTAND; char * mJsonStr = nullptr; + QString mStudyUID; + QString mModality; + QString mMPPSUID; }; #endif // PATIENTINFORMATIONFORM_H diff --git a/src/forms/scan/PatientInformationForm.ui b/src/forms/scan/PatientInformationForm.ui index f8e1d12..ada544e 100644 --- a/src/forms/scan/PatientInformationForm.ui +++ b/src/forms/scan/PatientInformationForm.ui @@ -62,7 +62,7 @@ - + @@ -73,14 +73,14 @@ - + - + @@ -101,7 +101,7 @@ - + @@ -115,7 +115,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -143,7 +143,7 @@ - + diff --git a/src/forms/scan/ScanFormWidget.cpp b/src/forms/scan/ScanFormWidget.cpp index e97d3f9..9546689 100644 --- a/src/forms/scan/ScanFormWidget.cpp +++ b/src/forms/scan/ScanFormWidget.cpp @@ -29,11 +29,11 @@ namespace { - const size_t PREVIEW_ROW = 140; - const size_t PREVIEW_COL = 140; - const float PIXEL_SPACING = 1.5f; - const float HALF_ROI_WIDTH = 100.0f; - const unsigned int DRAINAGE_TIME = 180000; // 3 minitues +const size_t PREVIEW_ROW = 140; +const size_t PREVIEW_COL = 140; +const float PIXEL_SPACING = 1.5f; +const float HALF_ROI_WIDTH = 100.0f; +const unsigned int DRAINAGE_TIME = 180000; // 3 minitues } ScanFormWidget::ScanFormWidget(QWidget* parent) @@ -41,7 +41,6 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) , mPatInf(new PatientInformationForm(this)) , mAccountButton(new QToolButton(this)) , mShutdownButton(new QToolButton(this)) - , mWorklistButton(new QToolButton(this)) , mStartScanButton(new QToolButton(this)) , mDrainageButton(new QToolButton(this)) , mXYLabel(new CoordinateXYWidget(this)) @@ -59,14 +58,13 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) initEvents(); mDrainageTimer->setSingleShot(true); connect(mDrainageTimer, &QTimer::timeout, this, [this]() - { + { mDrainageButton->click(); }); } void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) { - bool anonymousMode = JsonObject::Instance()->getAnonymousMode(); mAccountButton->setObjectName("btnAccount"); mAccountButton->setText(tr("Account")); layout->addWidget(mAccountButton); @@ -75,11 +73,6 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) mShutdownButton->setText(tr("ShutDown")); layout->addWidget(mShutdownButton); - mWorklistButton->setObjectName("btnWorklist"); - mWorklistButton->setText(tr("Worklist")); - mWorklistButton->setEnabled(!anonymousMode); - layout->addWidget(mWorklistButton); - mStartScanButton->setObjectName("btnScan"); mStartScanButton->setText(tr("Start Scan")); layout->addWidget(mStartScanButton); @@ -95,7 +88,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) layout->addWidget(mDrainageButton); connect(mDrainageButton, &QToolButton::clicked, [=](bool aSatus) - { + { //Drainage if(aSatus && DialogManager::Default()->requestAlertMessage(tr("Make sure to open the drain valve ?"), DialogButtonMode::OkAndCancel, tr("Confirm Drainage")) == QDialog::Rejected) { @@ -122,7 +115,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) }); connect(DeviceManager::Default(), &DeviceManager::startPumpControlResult, [this](bool aIsSucessful) - { + { mDrainageButton->setEnabled(true); if(!aIsSucessful) { @@ -143,23 +136,16 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) connect(mAccountButton, &QToolButton::clicked, DialogManager::Default(),&DialogManager::requestEditSelfAccount); connect(mShutdownButton, &QToolButton::clicked, []() - { + { if(DialogManager::Default()->requestAlertMessage(QString(tr("Shut down now ?")), DialogButtonMode::OkAndCancel,tr("Shut Down")) == QDialog::Accepted) { LOG_USER_OPERATION("Shut Down") - EventCenter::Default()->triggerEvent(GUIEvents::RequestShutdown, nullptr, nullptr); + EventCenter::Default()->triggerEvent(GUIEvents::RequestShutdown, nullptr, nullptr); } }); - connect(mWorklistButton, &QToolButton::clicked, [&]() - { - DialogManager::Default()->requestGetWorkList(); - }); - - connect(EventCenter::Default(), &EventCenter::AnonymousModeChanged, this, &ScanFormWidget::updateDataByAnonymousMode); - connect(mStartScanButton, &QToolButton::clicked, [this]() - { + { if(mStartScanButton->isChecked()) { LOG_USER_OPERATION(QString("Start Scan Process, ID: %1").arg(mPatInf->getPatientID())); @@ -173,19 +159,24 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) } }); - 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(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this](bool aResult) + { + if(aResult) + { + mAccountButton->setEnabled(false); + mDrainageButton->setEnabled(false); + mShutdownButton->setEnabled(false); + mStartScanButton->setText(tr("Stop Scan Process")); + mScanProcessLabel->setText(getAutoLocateMessage()); + } + + QPair accession = ScanProcessSequence::getInstance()->topAccession(); + mPatInf->setExecuteProtocol(accession.second == ScanPosition::Left); + mPatInf->setAccessionNumber(accession.first); }); connect(EventCenter::Default(), &EventCenter::StopScanProcess, [this]() - { - mWorklistButton->setEnabled(true); + { mAccountButton->setEnabled(true); mDrainageButton->setEnabled(true); mShutdownButton->setEnabled(true); @@ -200,12 +191,12 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) }); 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")); }); @@ -250,44 +241,6 @@ void ScanFormWidget::initScanContent() } -void ScanFormWidget::initScanControlBar(QHBoxLayout *layout) -{ - // connect(mBtnEScan, &QToolButton::clicked, [=]() { - // 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; - // QString patientInf(mPatInf->getCurrentPatientJsonString(true)); - // LOG_USER_OPERATION("Start Empty Scan") - // EventCenter::Default()->triggerEvent(RequestEmptyScan, nullptr, (QObject*)(&patientInf)); - // }); - // connect(mBtnPreview, &QToolButton::clicked, [=]() { - // LOG_USER_OPERATION(QString("Start Preview, ID: %1").arg(mPatInf->getPatientID())) - // EventCenter::Default()->triggerEvent(RequestPreviewScan, nullptr, nullptr); - - // }); - - - // connect(mBtnScan, &QToolButton::clicked, [=]() { - // if(JsonObject::Instance()->getScanConfirm()) - // { - // int ret = DialogManager::Default()->requestPatientConfirm(mPatInf->getPatientInformation(),mPatInf->getProtocol()); - // if (ret != QDialog::Accepted) return; - // } - // QString patientInf(mPatInf->getCurrentPatientJsonString(false)); - // LOG_USER_OPERATION(QString("Start Scan, ID: %1").arg(mPatInf->getPatientID())) - // if (!DeviceManager::Default()->hasValidEmptyScan()){ - // QString msg(tr("No refresh data exists, please do Refresh operation first.")); - // EventCenter::Default()->triggerEvent(DeviceErrorRaise, nullptr, (QObject*)(&msg)); - // return; - // } - // EventCenter::Default()->triggerEvent(RequestPatientScan, nullptr, (QObject*)(&patientInf)); - // }); - // connect(mBtnStop, &QToolButton::clicked, [=]() { - // LOG_USER_OPERATION("Stop Preview") - // EventCenter::Default()->triggerEvent(RequestPreviewStop, nullptr, nullptr); - // }); - -} - void ScanFormWidget::protocolChanged(int type) { LOG_USER_OPERATION(QString("Select Laterality %1").arg(type == 0 ? "Left" : "Right")); @@ -295,8 +248,6 @@ void ScanFormWidget::protocolChanged(int type) 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)); @@ -379,34 +330,19 @@ void ScanFormWidget::initEvents() connect(EventCenter::Default(), &EventCenter::PatientSelected, [=](QObject* sender, QObject* data) { if (data) { - PatientInformation* patientInfo = (PatientInformation*)data; - DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo); - if(result.ResultCode == QDialog::Accepted) - { - ScanProtocal protocal = static_cast(result.ResultData.toInt()); - mPatInf->setPatientInformation(patientInfo->Copy(), protocal); - setScanProtocal(protocal); - 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); - EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, patientInfo); - mStartScanButton->click(); + PatientInformation* patientInfo = (PatientInformation*)data; + DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo); + if(result.ResultCode == QDialog::Accepted) + { + ScanProtocal protocal = static_cast(result.ResultData.toInt()); + mPatInf->setPatientInformation(patientInfo); + setScanProtocal(patientInfo, protocal); + LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID)) + mStartScanButton->setEnabled(true); + EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, (QObject*)patientInfo); + mStartScanButton->click(); - } - -// mBtnScan->setEnabled(true); -// mBtnEScan->setEnabled(true); -// mBtnPreview->setEnabled(true); -// mBtnStop->setEnabled(true); - } - else{ -// mBtnScan->setEnabled(false); -// mBtnEScan->setEnabled(false); -// mBtnPreview->setEnabled(false); -// mBtnStop->setEnabled(false); + } } }); connect(EventCenter::Default(), &EventCenter::ResponseStopPreview, [=](QObject* sender, QObject* data) { @@ -424,18 +360,11 @@ void ScanFormWidget::reloadLanguage() { mAccountButton->setText(tr("Account")); mShutdownButton->setText(tr("ShutDown")); - mWorklistButton->setText(tr("Worklist")); mStartScanButton->setText(tr("Start Scan")); mScanProcessLabel->setText(tr("Please confirm checking patient information to start the process")); mDrainageButton->isChecked() ? mDrainageButton->setText(tr("Drainaging")) : mDrainageButton->setText(tr("Drainage")); } -void ScanFormWidget::updateDataByAnonymousMode() -{ - bool anonymousMode = JsonObject::Instance()->getAnonymousMode(); - mWorklistButton->setEnabled(!anonymousMode); -} - QString ScanFormWidget::getAutoLocateMessage() { ScanPosition position = ScanProcessSequence::getInstance()->topPosition(); @@ -449,84 +378,26 @@ QString ScanFormWidget::getAutoLocateMessage() return QString(""); } -void ScanFormWidget::setScanProtocal(int aProtocal) +void ScanFormWidget::setScanProtocal(PatientInformation* aPatient, int aProtocal) { ScanProcessSequence::getInstance()->clear(); switch (aProtocal) { case ScanProtocal::LSTAND: - ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right); - ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left); + ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanRight, false), ScanPosition::Right); + ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanLeft, true), ScanPosition::Left); return; case ScanProtocal::RSTAND: - ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left); - ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right); + ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanLeft, false), ScanPosition::Left); + ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanRight, true), ScanPosition::Right); return; case ScanProtocal::LONE: - ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left); + ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanLeft, true), ScanPosition::Left); return; case ScanProtocal::RONE: - ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right); + ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanRight, true), ScanPosition::Right); return; default: return; } } - - -void ScanFormWidget::keyPressEvent(QKeyEvent* aEvent) -{ - switch (aEvent->key()) - { - case Qt::Key_0: - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: - case Qt::Key_A: - case Qt::Key_B: - case Qt::Key_C: - case Qt::Key_D: - case Qt::Key_E: - case Qt::Key_F: - case Qt::Key_G: - case Qt::Key_H: - case Qt::Key_I: - case Qt::Key_J: - case Qt::Key_K: - case Qt::Key_L: - case Qt::Key_M: - case Qt::Key_N: - case Qt::Key_O: - case Qt::Key_P: - case Qt::Key_Q: - case Qt::Key_R: - case Qt::Key_S: - case Qt::Key_T: - case Qt::Key_U: - case Qt::Key_V: - case Qt::Key_W: - case Qt::Key_X: - case Qt::Key_Y: - case Qt::Key_Z: - { - WorkListManager::getInstance()->setSearchString(aEvent->text()); - break; - } - case Qt::Key_Enter: - case Qt::Key_Return: - { - QString text = WorkListManager::getInstance()->getSearchString(); - EventCenter::Default()->triggerEvent(InputWorkListSearchValue, nullptr, (QObject*)&text); - break; - } - default: - break; - } - QWidget::keyPressEvent(aEvent); -} diff --git a/src/forms/scan/ScanFormWidget.h b/src/forms/scan/ScanFormWidget.h index 0ce1ebe..b9f4b1d 100644 --- a/src/forms/scan/ScanFormWidget.h +++ b/src/forms/scan/ScanFormWidget.h @@ -7,6 +7,7 @@ #include class PatientInformationForm; +class PatientInformation; class QToolButton; class CoordinateXYWidget; class CoordinateZWidget; @@ -18,16 +19,12 @@ public: ~ScanFormWidget() override = default; void setPreviewing(bool val); -protected: - void keyPressEvent(QKeyEvent *event) override; - private: PatientInformationForm* mPatInf= nullptr; bool mUnInited = true; int mCurrentFrame = 0; QToolButton* mAccountButton; QToolButton* mShutdownButton; - QToolButton* mWorklistButton; QToolButton* mStartScanButton; QToolButton* mDrainageButton; CoordinateXYWidget* mXYLabel; @@ -36,19 +33,16 @@ private: 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); + void setScanProtocal(PatientInformation* aPatient, int aProtocal); QString getAutoLocateMessage(); private slots: void protocolChanged(int type); - void updateDataByAnonymousMode(); void prepareStartFullScan(); - //void updateScanProcessLabel(const QString& aText); void initEvents(); }; diff --git a/src/forms/select/AbstractPatientInfomation.cpp b/src/forms/select/AbstractPatientInfomation.cpp new file mode 100644 index 0000000..58175c7 --- /dev/null +++ b/src/forms/select/AbstractPatientInfomation.cpp @@ -0,0 +1,7 @@ +#include "AbstractPatientInfomation.h" + +AbstractPatientInfomation::AbstractPatientInfomation(QObject* aParent) + : QObject (aParent) +{ + +} diff --git a/src/forms/select/AbstractPatientInfomation.h b/src/forms/select/AbstractPatientInfomation.h new file mode 100644 index 0000000..ae53b22 --- /dev/null +++ b/src/forms/select/AbstractPatientInfomation.h @@ -0,0 +1,21 @@ +#ifndef ABSTRACTPATIENTINFOMATION_H +#define ABSTRACTPATIENTINFOMATION_H + +#include + +class AbstractPatientInfomation : public QObject +{ + Q_OBJECT +public: + enum AbstractInformationType + { + AccessionType = 0, PatientType + }; + + AbstractPatientInfomation(QObject* aParent); + virtual ~AbstractPatientInfomation() = default; + virtual int getType() = 0; + +}; + +#endif // ABSTRACTPATIENTINFOMATION_H diff --git a/src/forms/select/AccessionInformation.cpp b/src/forms/select/AccessionInformation.cpp new file mode 100644 index 0000000..a7614e1 --- /dev/null +++ b/src/forms/select/AccessionInformation.cpp @@ -0,0 +1,50 @@ +#include "AccessionInformation.h" + +AccessionInformation::AccessionInformation(PatientInformation* aPatient, QObject* aParent) + : AbstractPatientInfomation (aParent) + , mPatient(aPatient) +{ +} + +AccessionInformation::AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate, PatientInformation* aPatient, QObject* aParent) + : AbstractPatientInfomation(aParent) + , mAccessionNumber(aAccessionNumber) + , mPosition(aPosition) + , mScheduledStartDate(aScheduledStartDate) + , mPatient(aPatient) +{ + +} + +AccessionInformation::AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate, + const QString& aStudyUID, const QString& aRPID, const QString& aSPSID, const QString& aModality, + const QString& aMPPSUID, PatientInformation* aPatient, QObject* aParent) + : AbstractPatientInfomation(aParent) + , mAccessionNumber(aAccessionNumber) + , mPosition(aPosition) + , mScheduledStartDate(aScheduledStartDate) + , mStudyUID(aStudyUID) + , mRPID(aRPID) + , mSPSID(aSPSID) + , mModality(aModality) + , mMPPSUID(aMPPSUID) + , mPatient(aPatient) +{ +} + +QString AccessionInformation::getProtocolText() +{ + switch (mPosition) + { + case ScanLeft: return "L"; + case ScanRight: return "R"; + case ScanLeftRight: return "LR"; + case UnKnow:return tr("Position"); + default: return ""; + } +} + +int AccessionInformation::getType() +{ + return AccessionType; +} diff --git a/src/forms/select/AccessionInformation.h b/src/forms/select/AccessionInformation.h new file mode 100644 index 0000000..9df6812 --- /dev/null +++ b/src/forms/select/AccessionInformation.h @@ -0,0 +1,42 @@ +#ifndef ACCESSIONINFORMATION_H +#define ACCESSIONINFORMATION_H + +#include "AbstractPatientInfomation.h" + +enum ScanProtocol +{ + ScanNone = 0x00000000, + ScanLeft = 0x00000001, + ScanRight = 0x00000002, + ScanLeftRight = 0x00000003, + UnKnow = -1, +}; + +Q_DECLARE_FLAGS(ScanProtocols, ScanProtocol) +Q_DECLARE_OPERATORS_FOR_FLAGS(ScanProtocols) + +class PatientInformation; +class AccessionInformation : public AbstractPatientInfomation +{ + Q_OBJECT +public: + AccessionInformation(PatientInformation* aPatient, QObject* aParent); + AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate, PatientInformation* aPatient, QObject* aParent); + AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate, + const QString& aStudyUID, const QString& aRPID, const QString& aSPSID, const QString& aModality, + const QString& aMPPSUID, PatientInformation* aPatient, QObject* aParent); + QString getProtocolText(); + virtual int getType() override; + + QString mAccessionNumber; + ScanProtocol mPosition; + QString mScheduledStartDate; + QString mStudyUID; + QString mRPID; + QString mSPSID; + QString mModality; + QString mMPPSUID; + PatientInformation* mPatient; +}; + +#endif // ACCESSIONINFORMATION_H diff --git a/src/forms/select/PatientDetailForm.cpp b/src/forms/select/PatientDetailForm.cpp index 3e04f1e..a3ddcbb 100644 --- a/src/forms/select/PatientDetailForm.cpp +++ b/src/forms/select/PatientDetailForm.cpp @@ -12,43 +12,82 @@ #include "event/EventCenter.h" -PatientDetailForm::PatientDetailForm(QWidget* parent) : -QWidget(parent) -, mLblPatInfTitle(new QLabel(this)) -, mLblDOB(new QLabel(this)) -, mLblName(new QLabel(this)) -, mLblPatID(new QLabel(this)) -, mLblSex(new QLabel(this)) -, mLblAccno(new QLabel(this)) -, mLblAddDate(new QLabel(this)) +PatientDetailLabel::PatientDetailLabel(QLabel* aTitle, QLabel* aText) + : mLayout(new QHBoxLayout) + , mTitle(aTitle) + , mText(aText) +{ + mTitle->setObjectName("displayTitle"); + mText->setObjectName("displayDetail"); + mLayout->addWidget(mTitle); + mLayout->addWidget(mText); +} +void PatientDetailLabel::hide() +{ + mTitle->hide(); + mText->hide(); +} + +void PatientDetailLabel::show() +{ + mTitle->show(); + mText->show(); +} + +void PatientDetailLabel::setText(const QString &aText) +{ + mText->setText(aText); +} + +void PatientDetailLabel::setTitle(const QString &aTitle) +{ + mTitle->setText(aTitle); +} + +void PatientDetailLabel::clear() +{ + mText->clear(); +} + +void PatientDetailLabel::setLayout(QVBoxLayout* aLayout) +{ + aLayout->addLayout(mLayout); +} + + +PatientDetailForm::PatientDetailForm(QWidget* parent) + : QWidget(parent) + , mLblPatInfTitle(new QLabel(this)) + , mLblDOB(new PatientDetailLabel(new QLabel(tr("Birth Date")+":" ,this), new QLabel(this))) + , mLblName(new PatientDetailLabel(new QLabel(tr("Name")+":", this), new QLabel(this))) + , mLblPatID(new PatientDetailLabel(new QLabel(tr("PatientID")+":",this), new QLabel(this))) + , mLblSex(new PatientDetailLabel(new QLabel(tr("Gender")+":",this), new QLabel(this))) + , mLblAccno1(new PatientDetailLabel(new QLabel(tr("AccNo")+":",this), new QLabel(this))) + , mLblProto1(new PatientDetailLabel(new QLabel(tr("Position")+":",this), new QLabel(this))) + , mLblAccno2(new PatientDetailLabel(new QLabel(tr("AccNo")+":",this), new QLabel(this))) + , mLblProto2(new PatientDetailLabel(new QLabel(tr("Position")+":",this), new QLabel(this))) + , mLblAddDate(new PatientDetailLabel(new QLabel(tr("Add Date")+":",this), new QLabel(this))) { mLblPatInfTitle->setObjectName("PatInfTitle"); - mLblDOB->setObjectName("displayDetail"); - mLblName->setObjectName("displayDetail"); - mLblPatID->setObjectName("displayDetail"); - mLblSex->setObjectName("displayDetail"); - mLblAccno->setObjectName("displayDetail"); - mLblAddDate->setObjectName("displayDetail"); auto layout = new QVBoxLayout(this); - // mLblPatInfTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mLblPatInfTitle->setAlignment(Qt::AlignCenter); layout->addWidget(mLblPatInfTitle); mLblPatInfTitle->setText(tr("Patient Detail")); - addDetailLabel(layout,tr("Name")+":", mLblName); - addDetailLabel(layout,tr("Gender")+":", mLblSex); - addDetailLabel(layout,tr("Birth Date")+":", mLblDOB); - addDetailLabel(layout,tr("PatientID")+":", mLblPatID); - addDetailLabel(layout,tr("AccNo")+":", mLblAccno); - - auto widgetLayout = new QHBoxLayout; - layout->addLayout(widgetLayout); - - mLblAddDateTitle = new QLabel(tr("Add Date")+":",this); - mLblAddDateTitle->setObjectName("displayTitle"); - widgetLayout->addWidget(mLblAddDateTitle); - widgetLayout->addWidget(mLblAddDate); + mLblName->setLayout(layout); + mLblSex->setLayout(layout); + mLblDOB->setLayout(layout); + mLblPatID->setLayout(layout); + mLblAccno1->setLayout(layout); + mLblAccno1->hide(); + mLblProto1->setLayout(layout); + mLblProto1->hide(); + mLblAccno2->setLayout(layout); + mLblAccno2->hide(); + mLblProto2->setLayout(layout); + mLblProto2->hide(); + mLblAddDate->setLayout(layout); connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this,&PatientDetailForm::reloadLanguage); layout->addSpacerItem(new QSpacerItem(2,2,QSizePolicy::Expanding, QSizePolicy::Expanding)); @@ -66,15 +105,19 @@ void PatientDetailForm::addDetailLabel(QVBoxLayout *layout, const QString& aTitl widgetLayout->addWidget(aLabel); } -void PatientDetailForm::reloadLanguage() { - mLblSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : tr("Other"))); - QList strArray = {"Name","Gender","Birth Date","PatientID","AccNo"}; - for (size_t i = 0; i < strArray.length(); i++) - { - mBtnList[i]->setText(tr(strArray[i].data())+":"); - } - mLblAddDateTitle->setText(tr("Add Date")+":"); +void PatientDetailForm::reloadLanguage() +{ + mLblSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : mStore.Sex == "O" ? tr("Other") : "")); mLblPatInfTitle->setText(tr("Patient Detail")); + mLblDOB->setTitle(tr("Birth Date")+":"); + mLblName->setTitle(tr("Name")+":"); + mLblPatID->setTitle(tr("PatientID")+":"); + mLblSex->setTitle(tr("Gender")+":"); + mLblAccno1->setTitle(tr("AccNo")+":"); + mLblProto1->setTitle(tr("Position")+":"); + mLblAccno2->setTitle(tr("AccNo")+":"); + mLblProto2->setTitle(tr("Position")+":"); + mLblAddDate->setTitle(tr("Add Date")+":"); } @@ -83,38 +126,83 @@ PatientDetailForm::~PatientDetailForm() } -void PatientDetailForm::setPatientInformation(PatientInformation* information) { - if (information) - { - mLblPatID->setText(information->ID); - mLblDOB->setText(information->BirthDate); - mLblName->setText(information->Name); - mLblSex->setText((information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other")))); - mCurrentPatientUID = information->PatientUID; - mLblAddDate->setText(QDateTime::fromString(information->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss")); - mLblAccno->setText(information->AccessionNumber); - - mStore = *information; - } -} - void PatientDetailForm::clearPatientInformation() { mLblPatID->clear(); - mLblDOB->clear(); - mLblName->clear(); + mLblDOB->clear(); + mLblName->clear(); mLblSex->clear(); - mLblAddDate->clear(); - mLblAccno->clear(); + mLblAddDate->clear(); + mLblAccno1->clear(); + mLblProto1->clear(); + mLblAccno2->clear(); + mLblProto2->clear(); } void PatientDetailForm::confirmModeOn(int protocol) { - mLblPatInfTitle->setText(tr("Scan with this Patient?")); mLblAddDate->setText((protocol==0?tr("Left"):tr("Right"))); - mLblAddDateTitle->setText(tr("Protocol")); } -void PatientDetailForm::storePatientInformation() { +void PatientDetailForm::setEmptyInformation() +{ + mStore.clear(); + mLblPatID->setText(""); + mLblDOB->setText(""); + mLblName->setText(""); + mLblSex->setText(""); + mCurrentPatientUID = ""; + mLblAddDate->setText(""); + mLblAccno1->hide(); + mLblProto1->hide(); + mLblAccno2->hide(); + mLblProto2->hide(); } +PatientInformation* PatientDetailForm::getPatientInformation() +{ + return &mStore; +} + +void PatientDetailForm::setPatientInformation(PatientInformation* aInformation) +{ + if(aInformation == nullptr) + { + setEmptyInformation(); + return; + } + mStore = *aInformation; + mLblPatID->setText(aInformation->ID); + mLblDOB->setText(aInformation->BirthDate); + mLblName->setText(aInformation->Name); + mLblSex->setText((aInformation->Sex == "F" ? tr("Female") : (aInformation->Sex == "M" ? tr("Male") : tr("Other")))); + //mCurrentPatientUID = information->PatientUID; + mLblAddDate->setText(QDateTime::fromString(aInformation->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss")); + int selectAccesionSize = aInformation->mSelectedAccessions.size(); + if(selectAccesionSize == 1) + { + mLblAccno1->setText(aInformation->mSelectedAccessions[0]->mAccessionNumber); + mLblProto1->setText(aInformation->mSelectedAccessions[0]->getProtocolText()); + mLblAccno1->show(); + mLblProto1->show(); + mLblAccno2->hide(); + mLblProto2->hide(); + return; + } + else if(selectAccesionSize == 2) + { + mLblAccno1->setText(aInformation->mSelectedAccessions[0]->mAccessionNumber); + mLblProto1->setText(aInformation->mSelectedAccessions[0]->getProtocolText()); + mLblAccno2->setText(aInformation->mSelectedAccessions[1]->mAccessionNumber); + mLblProto2->setText(aInformation->mSelectedAccessions[1]->getProtocolText()); + mLblAccno1->show(); + mLblProto1->show(); + mLblAccno2->show(); + mLblProto2->show(); + return; + } + mLblAccno1->hide(); + mLblProto1->hide(); + mLblAccno2->hide(); + mLblProto2->hide(); +} diff --git a/src/forms/select/PatientDetailForm.h b/src/forms/select/PatientDetailForm.h index 8c0e7f7..cad542a 100644 --- a/src/forms/select/PatientDetailForm.h +++ b/src/forms/select/PatientDetailForm.h @@ -3,9 +3,29 @@ #include #include "PatientInformation.h" +#include "WorklistTableModel.h" + class QToolButton; class QLabel; class QVBoxLayout; +class QHBoxLayout; + +class PatientDetailLabel +{ +public: + PatientDetailLabel(QLabel* aTitle, QLabel* aText); + void show(); + void hide(); + void setText(const QString& aText); + void setTitle(const QString& aTitle); + void clear(); + void setLayout(QVBoxLayout* aLayout); + +private: + QHBoxLayout* mLayout; + QLabel* mTitle; + QLabel* mText; +}; class PatientDetailForm : public QWidget { @@ -14,32 +34,36 @@ public: explicit PatientDetailForm(QWidget *parent = nullptr); void addDetailLabel(QVBoxLayout *layout, const QString& aTitleText, QLabel* aLabel); ~PatientDetailForm(); - void setPatientInformation(PatientInformation *information); - PatientInformation *getPatientInformation() - { - return &mStore; - } + PatientInformation* getPatientInformation(); void confirmModeOn(int protocol); void clearPatientInformation(); + +public slots: + void setPatientInformation(PatientInformation* information); + signals: void hideBtnClicked(); void editClicked(); void deleteClicked(); private: - void storePatientInformation(); void reloadLanguage(); + void setEmptyInformation(); + +private: QString mCurrentPatientUID; QString mAddDate; PatientInformation mStore; QLabel* mLblPatInfTitle; - QLabel* mLblDOB; - QLabel* mLblName; - QLabel* mLblPatID; - QLabel* mLblSex; - QLabel* mLblAccno; - QLabel* mLblAddDate; - QLabel* mLblAddDateTitle; + PatientDetailLabel* mLblDOB; + PatientDetailLabel* mLblName; + PatientDetailLabel* mLblPatID; + PatientDetailLabel* mLblSex; + PatientDetailLabel* mLblAccno1; + PatientDetailLabel* mLblProto1; + PatientDetailLabel* mLblAccno2; + PatientDetailLabel* mLblProto2; + PatientDetailLabel* mLblAddDate; QList mBtnList; }; diff --git a/src/forms/select/PatientInformation.cpp b/src/forms/select/PatientInformation.cpp new file mode 100644 index 0000000..423b697 --- /dev/null +++ b/src/forms/select/PatientInformation.cpp @@ -0,0 +1,232 @@ +#include "PatientInformation.h" + +PatientInformation::PatientInformation() + : AbstractPatientInfomation(nullptr) + , ID() + , Name() + , BirthDate() + , Sex() + , AddDate() +{ +} + +PatientInformation::PatientInformation(const QString& aID, const QString& aName, const QString& aGender, const QString& aBirthDate, const QString& aAddDate) + : AbstractPatientInfomation(nullptr) + , mHeader(new AccessionInformation(tr("Accession Number"), ScanProtocol::UnKnow,tr("Scheduled Date"), this, this)) + , mAccessionList(QList()< aAccessionList) +{ + mAccessionList.append(aAccessionList); + prepareRecommendAccession(); +} + +void PatientInformation::setAccession(AccessionInformation* aAccession) +{ + mAccessionList.append(aAccession); +} + +void PatientInformation::prepareRecommendAccession() +{ + mRecommendAccessions.clear(); + if(mAccessionList.size() < 2) + { + return; + } + for(int i=1; imPosition & ScanLeftRight) + { + if(!contains(mRecommendAccessions, mAccessionList[i]->mPosition)) + { + mRecommendAccessions << mAccessionList[i]; + } + } + } + + if(mRecommendAccessions.size() == 0) + { + mRecommendAccessions << mAccessionList[1]; + } +} + +void PatientInformation::selectAccession(AccessionInformation* aAccession) +{ + mSelectedAccessions.push_back(aAccession); + mSelectedScanProtocol |= aAccession->mPosition; +} + +void PatientInformation::unSelectAccession(AccessionInformation* aAccession) +{ + mSelectedAccessions.removeOne(aAccession); + mSelectedScanProtocol &= ~aAccession->mPosition; +} + +int PatientInformation::unSelectLastAccession() +{ + if(mSelectedAccessions.size() == 0) + { + return -1; + } + AccessionInformation* accession = mSelectedAccessions.takeLast(); + mSelectedScanProtocol &= ~accession->mPosition; + return getAccessionIndex(accession); +} + +int PatientInformation::unSelectFirstAccession() +{ + if(mSelectedAccessions.size() == 0) + { + return -1; + } + AccessionInformation* accession = mSelectedAccessions.takeFirst(); + mSelectedScanProtocol &= ~accession->mPosition; + return getAccessionIndex(accession); +} + +int PatientInformation::getAccessionIndex(AccessionInformation* aAccession) +{ + return mAccessionList.indexOf(aAccession); +} + +bool PatientInformation::isSelectedMax(AccessionInformation* aAccession) +{ + return mSelectedAccessions.size() >= 2 || + ((mSelectedScanProtocol & ScanLeft) && (mSelectedScanProtocol & ScanRight)) || + (aAccession->mPosition == ScanLeftRight && mSelectedAccessions.size() !=0); +} + +void PatientInformation::clearSelectedAccession() +{ + mSelectedAccessions.clear(); + mSelectedScanProtocol = ScanNone; +} + +bool PatientInformation::contains(ScanProtocol aProtocol) +{ + return mSelectedScanProtocol & aProtocol; +} + +bool PatientInformation::contains(QList aAccessions, ScanProtocol aProtocol) +{ + bool result = false; + for(int i=0; imPosition & aProtocol); + } + return result; +} + +QList PatientInformation::unSelectAccession(ScanProtocol aPreSelectProtocol) +{ + QList result; + for(int i=mSelectedAccessions.size() - 1; i>=0; --i) + { + if(mSelectedAccessions[i]->mPosition & aPreSelectProtocol) + { + result << getAccessionIndex(mSelectedAccessions[i]); + mSelectedScanProtocol &= ~mSelectedAccessions[i]->mPosition; + mSelectedAccessions.removeAt(i); + } + } + return result; +} + +QList PatientInformation::getSelectedAccessionIndex() +{ + QList result; + for(int i=0; imPosition & aProtocol) + { + return mSelectedAccessions[i]; + } + } + + if(aIfEmptyGetTop) + { + return mSelectedAccessions.first(); + } + else + { + return mSelectedAccessions.last(); + } +} + +void PatientInformation::reloadHeaderLanguage() +{ + mHeader->mAccessionNumber = tr("Accession Number"); + mHeader->mScheduledStartDate = tr("Scheduled Date"); +} + +void PatientInformation::operator=(const PatientInformation& aOther) +{ + this->PatientUID = aOther.PatientUID; + this->ID = aOther.ID; + this->Name = aOther.Name; + this->BirthDate = aOther.BirthDate; + this->Sex = aOther.Sex; + this->Comment = aOther.Comment; + this->AddDate = aOther.AddDate; + this->mHeader = aOther.mHeader; + this->mAccessionList = aOther.mAccessionList; + this->mSelectedScanProtocol = aOther.mSelectedScanProtocol; + this->mSelectedAccessions = aOther.mSelectedAccessions; + this->mRecommendAccessions = aOther.mRecommendAccessions; +} + +QList PatientInformation::getSelectedAccession() +{ + return mSelectedAccessions; +} + +int PatientInformation::getType() +{ + return PatientType; +} diff --git a/src/forms/select/PatientInformation.h b/src/forms/select/PatientInformation.h index c94e30d..a6a7196 100644 --- a/src/forms/select/PatientInformation.h +++ b/src/forms/select/PatientInformation.h @@ -3,25 +3,15 @@ #define EDIT_PATIENT()\ ADD_PATIENT_PROPERTY(PatientUID)\ ADD_PATIENT_PROPERTY(ID)\ -ADD_PATIENT_PROPERTY(AccessionNumber)\ ADD_PATIENT_PROPERTY(Name)\ ADD_PATIENT_PROPERTY(BirthDate)\ ADD_PATIENT_PROPERTY(Sex)\ ADD_PATIENT_PROPERTY(AddDate)\ - #define ADD_PATIENT()\ EDIT_PATIENT()\ -ADD_PATIENT_PROPERTY(StudyUID)\ -ADD_PATIENT_PROPERTY(RPID)\ -ADD_PATIENT_PROPERTY(SPSID)\ -ADD_PATIENT_PROPERTY(Modality)\ -ADD_PATIENT_PROPERTY(MPPSUID)\ ADD_PATIENT_PROPERTY(Comment) - - - enum PatientInformationEnum{ #define ADD_PATIENT_PROPERTY(val) val, ADD_PATIENT() @@ -30,56 +20,54 @@ enum PatientInformationEnum{ #include #include +#include "AccessionInformation.h" /** * @brief this class was designed to be a edit form, * but now has been change to a detail display class. */ -class PatientInformation:public QObject{ +class PatientInformation : public AbstractPatientInfomation +{ Q_OBJECT public: + PatientInformation(); + PatientInformation(const QString& aID, const QString& aName, const QString& aGender, const QString& aBirthDate, const QString& aAddDate); + void operator=(const PatientInformation& aOther); + + int getType() override; + void clear(); + void setAccessionList(const QList aAccessionList); + void setAccession(AccessionInformation* aAccession); + void prepareRecommendAccession(); + void selectAccession(AccessionInformation* aAccession); + void unSelectAccession(AccessionInformation* aAccession); + int unSelectLastAccession(); + int unSelectFirstAccession(); + int getAccessionIndex(AccessionInformation* aAccession); + bool isSelectedMax(AccessionInformation* aAccession); + void clearSelectedAccession(); + bool contains(ScanProtocol aProtocol); + bool contains(QList aAccessions, ScanProtocol aProtocol); + QList unSelectAccession(ScanProtocol aPreSelectProtocol); + QList getSelectedAccessionIndex(); + void selectRecommendAccessions(); + void reloadHeaderLanguage(); + QList getSelectedAccession(); + AccessionInformation* findSelectedAccession(ScanProtocol aProtocol, bool aIfEmptyGetTop); + + + AccessionInformation* mHeader; + QList mAccessionList; + ScanProtocols mSelectedScanProtocol; + QList mSelectedAccessions; + QList mRecommendAccessions; + #define ADD_PATIENT_PROPERTY(val) QString val; ADD_PATIENT() #undef ADD_PATIENT_PROPERTY - PatientInformation() - : QObject() - { - } - void operator=(const PatientInformation& other){ - this->PatientUID = other.PatientUID; - this->ID = other.ID; - this->Name = other.Name; - this->BirthDate = other.BirthDate; - this->Sex = other.Sex; - this->Comment = other.Comment; - this->AccessionNumber = other.AccessionNumber; - this->AddDate = other.AddDate; - this->RPID = other.RPID; - this->SPSID = other.SPSID; - this->MPPSUID = other.MPPSUID; - this->StudyUID = other.StudyUID; - this->Modality = other.Modality; - } - QString ScheduledStartDate; - QSharedPointer Copy() - { - QSharedPointer n= QSharedPointer(new PatientInformation); - n->PatientUID = this->PatientUID; - n->ID = this->ID; - n->Name = this->Name; - n->BirthDate = this->BirthDate; - n->Sex = this->Sex; - n->Comment = this->Comment; - n->AccessionNumber = this->AccessionNumber; - n->AddDate = this->AddDate; - n->RPID = this->RPID; - n->SPSID = this->SPSID; - n->MPPSUID = this->MPPSUID; - n->StudyUID = this->StudyUID; - n->Modality = this->Modality; - return n; - } +// QString ScheduledStartDate; +// QString AccessionNumber; }; typedef QSharedPointer PatientInformationPointer; diff --git a/src/forms/select/SelectFormWidget.cpp b/src/forms/select/SelectFormWidget.cpp index 7a1cc92..914a05f 100644 --- a/src/forms/select/SelectFormWidget.cpp +++ b/src/forms/select/SelectFormWidget.cpp @@ -2,11 +2,12 @@ #include "SelectFormWidget.h" #include -#include +#include #include #include #include #include +#include #include #include @@ -22,17 +23,30 @@ #include "PatientAddDateDelegate.h" #include "dicom/WorkListManager.h" #include "utilities/ScanProcessSequence.h" +#include "WorklistTableView.h" +#include "WorklistTableModel.h" +#include "WorklistTableSelectModel.h" +#include "WorklistTableStyleItemDelegate.h" +#include "action/ActionCreator.h" +#include "action/GetWorkListAction.h" SelectFormWidget::SelectFormWidget(QWidget* parent) -: TabFormWidget(parent) -, mBtnEdit(new QToolButton()) -, mBtnDelete(new QToolButton()) -, mBtnAdd(new QToolButton(this)) -, mBtnSelect(new QToolButton(this)) -, mPatTable(new SlideTableView(this)) -, mModel(nullptr) -, patientDetailForm(new PatientDetailForm(this)) -, mSelectTabTitle(new QLabel(this)) + : TabFormWidget(parent) + , mTabWidget(new QTabWidget(this)) + , mSelectedPatientUID() + , mBtnEdit(new QToolButton(this)) + , mBtnDelete(new QToolButton(this)) + , mBtnAdd(new QToolButton(this)) + , mBtnPull(new QToolButton(this)) + , mBtnSelect(new QToolButton(this)) + , mWorklistPatTable(new WorklistTableView(this)) + , mWorklistTableModel(new WorklistTableModel(this)) + , mWorklistTableSelectModel(new WorklistTableSelectModel(mWorklistTableModel, mWorklistPatTable)) + , mLocalPatTable(new SlideTableView(this)) + , mLocalPatientModel(nullptr) + , mPatientDetailForm(new PatientDetailForm(this)) + , mSelectTabTitle(new QLabel(this)) + , mGetWorklistAction(ActionCreator::getAsyncAction("GetWorkListAction")) { //process expired patient list QDate date = QDate::currentDate().addDays(-JsonObject::Instance()->getPatientListExpireDays()); @@ -58,13 +72,43 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) addVerticalLine(contentLayout); auto gridBox = new QVBoxLayout; contentLayout->addLayout(gridBox); - initTableView(gridBox); + initTableView(); + connect(mWorklistTableSelectModel, &WorklistTableSelectModel::WorklistTableSelectChanged, this, &SelectFormWidget::setWorklistPatientDetail); + mWorklistPatTable->setModel(mWorklistTableModel); + mWorklistPatTable->setSelectionModel(mWorklistTableSelectModel); + + mWorklistPatTable->setColumnWidth(0, 300); + mWorklistPatTable->setColumnWidth(1, 300); + mWorklistPatTable->setColumnWidth(2, 300); + mWorklistPatTable->setColumnWidth(3, 200); + mWorklistPatTable->header()->setDefaultAlignment(Qt::AlignCenter); + mWorklistPatTable->setIndentation(0); + mWorklistPatTable->setAlternatingRowColors(true); + mWorklistPatTable->setSelectionMode(QAbstractItemView::MultiSelection); + mWorklistPatTable->setSelectionBehavior(QAbstractItemView::SelectRows); + mWorklistPatTable->setItemDelegate(new WorklistTableStyleItemDelegate(mWorklistPatTable->header(), mWorklistPatTable)); + + mTabWidget->addTab(mWorklistPatTable,tr("Worklist")); + mTabWidget->addTab(mLocalPatTable, tr("Local")); + gridBox->addWidget(mTabWidget); gridBox->addWidget(ui->commandWidget); + connect(mTabWidget, &QTabWidget::tabBarClicked, [this](int aIndex) + { + if(aIndex == 0) + { + switchToWorklistMode(); + } + else + { + switchToLocalMode(); + } + }); + //select default row 0 - if (mModel->rowCount() > 0) + if (mLocalPatientModel->rowCount() > 0) { - mPatTable->selectRow(0); - setPatientDetail(mPatTable, mModel, patientDetailForm); + mLocalPatTable->selectRow(0); + setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm); } // event ResponsePreview slot connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) { @@ -86,17 +130,20 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) }); connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::ScanProcessSequenceFinished, this, &SelectFormWidget::clearSelectedPatient); + connect(mGetWorklistAction, &AsyncAction::actionCompleted, this, &SelectFormWidget::processWorklistSearchResult); //first prepare buttons! prepareButtons(false); //init WorkListManager table view - WorkListManager::getInstance()->setTableView(mPatTable); + WorkListManager::getInstance()->setTableView(mLocalPatTable); + //init in worklist mode bt default + switchToWorklistMode(); } void SelectFormWidget::prepareButtons(bool disableALL) { bool anonymousMode = JsonObject::Instance()->getAnonymousMode(); - bool stateFlag = (mPatTable->currentIndex().row() >= 0); + bool stateFlag = (mLocalPatTable->currentIndex().row() >= 0); mBtnAdd->setEnabled(!anonymousMode && !disableALL); if (mBtnAdd)mBtnEdit->setEnabled(!anonymousMode && stateFlag && !disableALL); @@ -108,15 +155,18 @@ void SelectFormWidget::initPatEditButtons(QHBoxLayout *layout) { mBtnAdd->setObjectName("btnAdd"); mBtnEdit->setObjectName("btnPatEdit"); mBtnDelete->setObjectName("btnPatDelete"); + mBtnPull->setObjectName("btnAdd"); mBtnSelect->setObjectName("btnSelect"); mBtnEdit->setText(tr("Edit")); mBtnDelete->setText(tr("Delete")); mBtnAdd->setText(tr("Add")); + mBtnPull->setText(tr("Pull")); mBtnSelect->setText(tr("Select")); layout->addWidget(mBtnAdd); layout->addWidget(mBtnEdit); layout->addWidget(mBtnDelete); + layout->addWidget(mBtnPull); addVerticalLine(layout); layout->addWidget(mBtnSelect); @@ -131,51 +181,53 @@ void SelectFormWidget::initPatEditButtons(QHBoxLayout *layout) { // mBtn select slot connect(mBtnSelect, &QToolButton::clicked, this, &SelectFormWidget::selectPatient); + + connect(mBtnPull, &QToolButton::clicked, this, &SelectFormWidget::pullPatient); } void SelectFormWidget::editPatient() { bool addFlag = sender() == mBtnAdd; - auto index = mPatTable->currentIndex(); + auto index = mLocalPatTable->currentIndex(); // accept change - if (DialogManager::Default()->requestEditPatientInfo(addFlag ? nullptr:patientDetailForm->getPatientInformation(),mModel) == QDialog::Accepted) { + if (DialogManager::Default()->requestEditPatientInfo(addFlag ? nullptr:mPatientDetailForm->getPatientInformation(),mLocalPatientModel) == QDialog::Accepted) { if (addFlag){ - mPatTable->selectRow(0); - mModel->selectRow(0); - LOG_USER_OPERATION(QString("Add Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID)) + mLocalPatTable->selectRow(0); + mLocalPatientModel->selectRow(0); + LOG_USER_OPERATION(QString("Add Patient, ID: %1").arg(mPatientDetailForm->getPatientInformation()->ID)) } else{ - mPatTable->selectRow(index.row()); - mModel->selectRow(index.row()); - setPatientDetail(mPatTable, mModel, patientDetailForm); - LOG_USER_OPERATION(QString("Edit Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID)) + mLocalPatTable->selectRow(index.row()); + mLocalPatientModel->selectRow(index.row()); + setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm); + LOG_USER_OPERATION(QString("Edit Patient, ID: %1").arg(mPatientDetailForm->getPatientInformation()->ID)) } mBtnSelect->setEnabled(true); } } void SelectFormWidget::delPatient() { - if (mPatTable->currentIndex().row() < 0) return; - QString pUid = mModel->index(mPatTable->currentIndex().row(), PatientUID).data().toString(); + if (mLocalPatTable->currentIndex().row() < 0) return; + QString pUid = mLocalPatientModel->index(mLocalPatTable->currentIndex().row(), PatientUID).data().toString(); // patient has been selected as the scan patient! if (mSelectedPatientUID == pUid){ DialogManager::Default()->requestAlertMessage(tr("Can't delete selected Patient !"),DialogButtonMode::OkOnly,tr("Alert")); return; } // not the selected one, confirm! - QString pat_name = mModel->index(mPatTable->currentIndex().row(), Name).data().toString(); + QString pat_name = mLocalPatientModel->index(mLocalPatTable->currentIndex().row(), Name).data().toString(); if (DialogManager::Default()->requestAlertMessage(QString(tr("Delete Patient \"%1\" ?")),pat_name,DialogButtonMode::OkAndCancel,tr("Confirm")) != QDialog::Accepted) return; // need delete clear edit panel detail - patientDetailForm->clearPatientInformation(); - //mModel->setData(mModel->index(mPatTable->currentIndex().row(), Flag), 9); - mModel->removeRow(mPatTable->currentIndex().row()); + mPatientDetailForm->clearPatientInformation(); + //mLocalPatientModel->setData(mLocalPatientModel->index(mLocalPatTable->currentIndex().row(), Flag), 9); + mLocalPatientModel->removeRow(mLocalPatTable->currentIndex().row()); - if (mModel->submitAll()) { - mModel->select(); - if (mModel->rowCount() > 0) { - mPatTable->selectRow(0); - mModel->selectRow(0); - setPatientDetail(mPatTable, mModel, patientDetailForm); - LOG_USER_OPERATION(QString("Delete Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID)) + if (mLocalPatientModel->submitAll()) { + mLocalPatientModel->select(); + if (mLocalPatientModel->rowCount() > 0) { + mLocalPatTable->selectRow(0); + mLocalPatientModel->selectRow(0); + setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm); + LOG_USER_OPERATION(QString("Delete Patient, ID: %1").arg(mPatientDetailForm->getPatientInformation()->ID)) } } else { //TODO:error handle @@ -185,7 +237,7 @@ void SelectFormWidget::delPatient() { } void SelectFormWidget::selectPatient() { - EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)patientDetailForm->getPatientInformation()); + EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)mPatientDetailForm->getPatientInformation()); } void SelectFormWidget::setSelectedPatient(PatientInformation* aPatient) @@ -199,93 +251,88 @@ void SelectFormWidget::clearSelectedPatient() } void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel - patientDetailForm->setObjectName("patientDetailWidget"); - contentLayout->addWidget(patientDetailForm); + mPatientDetailForm->setObjectName("patientDetailWidget"); + contentLayout->addWidget(mPatientDetailForm); } -void SelectFormWidget::initTableView(QLayout *contentLayout) +void SelectFormWidget::initTableView() { // TableView for patient - mPatTable->setAlternatingRowColors(true); - mPatTable->setSelectionMode(QAbstractItemView::SingleSelection); - mPatTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - mPatTable->setSelectionBehavior(QAbstractItemView::SelectRows); - mPatTable->verticalHeader()->setDefaultSectionSize(38); - mPatTable->horizontalHeader()->setStretchLastSection(true); + mLocalPatTable->setAlternatingRowColors(true); + mLocalPatTable->setSelectionMode(QAbstractItemView::SingleSelection); + mLocalPatTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + mLocalPatTable->setSelectionBehavior(QAbstractItemView::SelectRows); + mLocalPatTable->verticalHeader()->setDefaultSectionSize(38); + mLocalPatTable->horizontalHeader()->setStretchLastSection(true); //avoid pan comsumed by tableview! - mPatTable->viewport()->ungrabGesture(Qt::PanGesture); + mLocalPatTable->viewport()->ungrabGesture(Qt::PanGesture); - mPatTable->setSortingEnabled(true); // enable sortingEnabled - mPatTable->setModel((QAbstractItemModel*) mModel); - mPatTable->hideColumn(0); - mPatTable->hideColumn(7); - mPatTable->hideColumn(8); - mPatTable->hideColumn(9); - mPatTable->hideColumn(10); - mPatTable->hideColumn(11); - mPatTable->hideColumn(12); + mLocalPatTable->setSortingEnabled(true); // enable sortingEnabled + mLocalPatTable->setModel(mLocalPatientModel); + mLocalPatTable->hideColumn(0); + mLocalPatTable->hideColumn(6); + mLocalPatTable->hideColumn(7); + mLocalPatTable->hideColumn(8); + mLocalPatTable->hideColumn(9); + mLocalPatTable->hideColumn(10); + mLocalPatTable->hideColumn(11); - mPatTable->show(); + mLocalPatTable->show(); - mPatTable->setColumnWidth(1, 250); - mPatTable->setColumnWidth(2, 250); - mPatTable->setColumnWidth(3, 250); - mPatTable->setColumnWidth(4, 120); - mPatTable->setColumnWidth(5, 80); - mPatTable->setColumnWidth(6, 120); - contentLayout->addWidget(mPatTable); + mLocalPatTable->setColumnWidth(1, 300); + mLocalPatTable->setColumnWidth(2, 300); + mLocalPatTable->setColumnWidth(3, 300); + mLocalPatTable->setColumnWidth(4, 200); //table current row selection changing event - connect(mPatTable, &SlideTableView::currentRowChanged, [=](int row) { - setPatientDetail(mPatTable, mModel, patientDetailForm); + connect(mLocalPatTable, &SlideTableView::currentRowChanged, [=](int row) { + setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm); prepareButtons(false); }); // after sort by column - connect(mPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){ - patientDetailForm->clearPatientInformation(); + connect(mLocalPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){ + mPatientDetailForm->clearPatientInformation(); prepareButtons(false); - if(mModel->rowCount() > 0){ - mPatTable->selectRow(0); - mModel->selectRow(0); + if(mLocalPatientModel->rowCount() > 0){ + mLocalPatTable->selectRow(0); + mLocalPatientModel->selectRow(0); } }); - PatientAddDateDelegate* patientAddDateDelegate = new PatientAddDateDelegate(mPatTable); - mPatTable->setItemDelegateForColumn(6, patientAddDateDelegate); + PatientAddDateDelegate* patientAddDateDelegate = new PatientAddDateDelegate(mLocalPatTable); + mLocalPatTable->setItemDelegateForColumn(5, patientAddDateDelegate); } void SelectFormWidget::initDataModel() { - mModel = SQLHelper::getTable("Patient"); - WorkListManager::getInstance()->setTableModel(mModel); - mModel->sort(mModel->record().indexOf("AddDate"), Qt::DescendingOrder); - mModel->setEditStrategy(QSqlTableModel::OnManualSubmit); + mLocalPatientModel = SQLHelper::getTable("Patient"); + WorkListManager::getInstance()->setTableModel(mLocalPatientModel); + mLocalPatientModel->sort(mLocalPatientModel->record().indexOf("AddDate"), Qt::DescendingOrder); + mLocalPatientModel->setEditStrategy(QSqlTableModel::OnManualSubmit); bool anonymousMode = JsonObject::Instance()->getAnonymousMode(); if (anonymousMode) { - mModel->setFilter("1=2"); + mLocalPatientModel->setFilter("1=2"); } - mModel->select(); + mLocalPatientModel->select(); if (anonymousMode) { - mModel->insertRow(0); - mModel->setData(mModel->index(0,0),"000000001"); - mModel->setData(mModel->index(0,1),"AnonymousPatient"); - mModel->setData(mModel->index(0,2),""); - mModel->setData(mModel->index(0,3),"AnonymousPatient"); - mModel->setData(mModel->index(0,4),"2000-01-01"); - mModel->setData(mModel->index(0,5),"F"); - mModel->setData(mModel->index(0,6),"2000-01-01"); - mModel->setData(mModel->index(0,7),""); + mLocalPatientModel->insertRow(0); + mLocalPatientModel->setData(mLocalPatientModel->index(0,0),"000000001"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,1),"AnonymousPatient"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,2),"AnonymousPatient"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,3),"2000-01-01"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,4),"F"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,5),"2000-01-01"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,6),""); } - mModel->setHeaderData(1, Qt::Horizontal, tr("ID")); - mModel->setHeaderData(2, Qt::Horizontal, tr("AccessionNumber")); - mModel->setHeaderData(3, Qt::Horizontal, tr("Name")); - mModel->setHeaderData(4, Qt::Horizontal, tr("Birth Date")); - mModel->setHeaderData(5, Qt::Horizontal, tr("Gender")); - mModel->setHeaderData(6, Qt::Horizontal, tr("Add Date")); - mModel->setHeaderData(7, Qt::Horizontal, tr("Comment")); + mLocalPatientModel->setHeaderData(1, Qt::Horizontal, tr("ID")); + mLocalPatientModel->setHeaderData(2, Qt::Horizontal, tr("Name")); + mLocalPatientModel->setHeaderData(3, Qt::Horizontal, tr("Birth Date")); + mLocalPatientModel->setHeaderData(4, Qt::Horizontal, tr("Gender")); + mLocalPatientModel->setHeaderData(5, Qt::Horizontal, tr("Add Date")); + mLocalPatientModel->setHeaderData(6, Qt::Horizontal, tr("Comment")); } void SelectFormWidget::setPatientDetail(const SlideTableView *table, const QSqlTableModel *model, @@ -296,22 +343,39 @@ void SelectFormWidget::setPatientDetail(const SlideTableView *table, const QSqlT ADD_PATIENT() #undef ADD_PATIENT_PROPERTY edit_patient->setPatientInformation(&pat); + mBtnSelect->setEnabled(true); +} + +void SelectFormWidget::setWorklistPatientDetail(PatientInformation* aPatient) +{ + mPatientDetailForm->setPatientInformation(aPatient); + if(aPatient == nullptr || aPatient->getSelectedAccessionIndex().size() == 0) + { + mBtnSelect->setEnabled(false); + } + else + { + mBtnSelect->setEnabled(true); + } } void SelectFormWidget::reloadLanguage(){ - mModel->setHeaderData(1, Qt::Horizontal, "ID"); - mModel->setHeaderData(2, Qt::Horizontal, tr("AccessionNumber")); - mModel->setHeaderData(3, Qt::Horizontal, tr("Name")); - mModel->setHeaderData(4, Qt::Horizontal, tr("Birth Date")); - mModel->setHeaderData(5, Qt::Horizontal, tr("Gender")); - mModel->setHeaderData(6, Qt::Horizontal, tr("Add Date")); - mModel->setHeaderData(7, Qt::Horizontal, tr("Comment")); + mLocalPatientModel->setHeaderData(1, Qt::Horizontal, "ID"); + mLocalPatientModel->setHeaderData(2, Qt::Horizontal, tr("Name")); + mLocalPatientModel->setHeaderData(3, Qt::Horizontal, tr("Birth Date")); + mLocalPatientModel->setHeaderData(4, Qt::Horizontal, tr("Gender")); + mLocalPatientModel->setHeaderData(5, Qt::Horizontal, tr("Add Date")); + mLocalPatientModel->setHeaderData(6, Qt::Horizontal, tr("Comment")); mBtnEdit->setText(tr("Edit")); mBtnDelete->setText(tr("Delete")); mBtnAdd->setText(tr("Add")); mBtnSelect->setText(tr("Select")); + mBtnPull->setText(tr("Pull")); mSelectTabTitle->setText(tr("Patient Information Manage")); + + mTabWidget->setTabText(0,tr("Worklist")); + mTabWidget->setTabText(1, tr("Local")); } void SelectFormWidget::updateDataByAnonymousMode(){ @@ -319,31 +383,70 @@ void SelectFormWidget::updateDataByAnonymousMode(){ EventCenter::Default()->triggerEvent(GUIEvents::PatientSelected,this,nullptr); if (anonymousMode) { - mModel->setFilter("1=2"); - mModel->select(); - mModel->insertRow(0); - mModel->setData(mModel->index(0,0),"000000001"); - mModel->setData(mModel->index(0,1),"AnonymousPatient"); - mModel->setData(mModel->index(0,2),""); - mModel->setData(mModel->index(0,3),"AnonymousPatient"); - mModel->setData(mModel->index(0,4),"2000-01-01"); - mModel->setData(mModel->index(0,5),"M"); - mModel->setData(mModel->index(0,6),"2000-01-01"); - mModel->setData(mModel->index(0,7),""); - mPatTable->selectRow(0); - mModel->selectRow(0); + mLocalPatientModel->setFilter("1=2"); + mLocalPatientModel->select(); + mLocalPatientModel->insertRow(0); + mLocalPatientModel->setData(mLocalPatientModel->index(0,0),"000000001"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,1),"AnonymousPatient"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,2),""); + mLocalPatientModel->setData(mLocalPatientModel->index(0,3),"AnonymousPatient"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,4),"2000-01-01"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,5),"M"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,6),"2000-01-01"); + mLocalPatientModel->setData(mLocalPatientModel->index(0,7),""); + mLocalPatTable->selectRow(0); + mLocalPatientModel->selectRow(0); } else{ - mModel->revertAll(); - mModel->setFilter(""); - mModel->select(); - if (mModel->rowCount()>0){ - mPatTable->selectRow(0); - mModel->selectRow(0); + mLocalPatientModel->revertAll(); + mLocalPatientModel->setFilter(""); + mLocalPatientModel->select(); + if (mLocalPatientModel->rowCount()>0){ + mLocalPatTable->selectRow(0); + mLocalPatientModel->selectRow(0); } } prepareButtons(false); } +void SelectFormWidget::switchToWorklistMode() +{ + mBtnAdd->hide(); + mBtnDelete->hide(); + mBtnEdit->hide(); + mBtnPull->show(); + setWorklistPatientDetail(mWorklistTableSelectModel->getSelectedPatient()); + mPatientDetailForm->setPatientInformation(mWorklistTableSelectModel->getSelectedPatient()); +} +void SelectFormWidget::switchToLocalMode() +{ + mBtnAdd->show(); + mBtnDelete->show(); + mBtnEdit->show(); + mBtnPull->hide(); + setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm); +} + +void SelectFormWidget::pullPatient() +{ + mGetWorklistAction->execute(); + DialogManager::Default()->requestLoadingWorklist(); +} + +void SelectFormWidget::processWorklistSearchResult(const ActionResult& aResult) +{ + EventCenter::Default()->triggerEvent(GUIEvents::WorklistSearchFinished, nullptr, nullptr); + mWorklistTableSelectModel->clearSelect(); + if(aResult.Code == Sucessed) + { + QList patientList = aResult.Data.value>(); + mWorklistTableModel->instertPatients(patientList); + } + else + { + mWorklistTableModel->instertPatients(QList()); + DialogManager::Default()->requestAlertMessage(aResult.Data.toString(), DialogButtonMode::OkOnly); + } +} diff --git a/src/forms/select/SelectFormWidget.h b/src/forms/select/SelectFormWidget.h index e690df7..cf78f26 100644 --- a/src/forms/select/SelectFormWidget.h +++ b/src/forms/select/SelectFormWidget.h @@ -6,10 +6,13 @@ #include "dialogs/EditPatientDialog.h" class PatientDetailForm; - class SlideTableView; - class QToolButton; +class QTabWidget; +class QTreeView; +class WorklistTableModel; +class WorklistTableSelectModel; +class AsyncAction; class SelectFormWidget : public TabFormWidget { Q_OBJECT @@ -20,8 +23,11 @@ public: public slots: void updateDataByAnonymousMode(); + void processWorklistSearchResult(const ActionResult& aResult); + private: void setPatientDetail(const SlideTableView *table, const QSqlTableModel *model, PatientDetailForm *edit_patient) const; + void setWorklistPatientDetail(PatientInformation* aPatient); void prepareButtons(bool disableALL); void initPatEditButtons(QHBoxLayout *layout); void editPatient(); @@ -30,20 +36,30 @@ private: void setSelectedPatient(PatientInformation* aPatient); void initDataModel(); void initDetailPanel(QHBoxLayout *contentLayout); - void initTableView(QLayout *contentLayout); + void initTableView(); void reloadLanguage(); void clearSelectedPatient(); + void switchToWorklistMode(); + void switchToLocalMode(); + void changeSelectButtonState(); + void pullPatient(); private: + QTabWidget* mTabWidget; QString mSelectedPatientUID; QToolButton *mBtnEdit; QToolButton *mBtnDelete; QToolButton *mBtnAdd; + QToolButton* mBtnPull; QToolButton *mBtnSelect; - SlideTableView *mPatTable; - QSqlTableModel *mModel; - PatientDetailForm *patientDetailForm; + QTreeView* mWorklistPatTable; + WorklistTableModel* mWorklistTableModel; + WorklistTableSelectModel* mWorklistTableSelectModel; + SlideTableView *mLocalPatTable; + QSqlTableModel *mLocalPatientModel; + PatientDetailForm *mPatientDetailForm; QLabel* mSelectTabTitle; + AsyncAction* mGetWorklistAction; }; diff --git a/src/forms/select/WorklistTableModel.cpp b/src/forms/select/WorklistTableModel.cpp new file mode 100644 index 0000000..e8b54c7 --- /dev/null +++ b/src/forms/select/WorklistTableModel.cpp @@ -0,0 +1,193 @@ +#include "WorklistTableModel.h" + +#include "event/EventCenter.h" + +WorklistTableModel::WorklistTableModel(QObject* aParent) + : QAbstractItemModel(aParent) + , mPatientList() + , mHeader(QStringList()<< tr("ID") << tr("Name") << tr("Birth Date") << tr("Gender") << tr("Add Date")) +{ + connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this, &WorklistTableModel::reloadLanguage); +} + +WorklistTableModel::~WorklistTableModel() +{ + qDeleteAll(mPatientList); +} + +QVariant WorklistTableModel::headerData(int aSection, Qt::Orientation aOrientation, int aRole) const +{ + if(aOrientation == Qt::Horizontal && aRole == Qt::DisplayRole) + { + if(aSection < mHeader.size()) + { + return mHeader[aSection]; + } + } + return QVariant(); +} + +int WorklistTableModel::rowCount(const QModelIndex &aParent) const +{ + if (!aParent.isValid()) + { + return mPatientList.count(); + } + + AbstractPatientInfomation* item = static_cast(aParent.internalPointer()); + if(item->getType() != AbstractPatientInfomation::PatientType) + { + return 0; + } + PatientInformation* patientItem = static_cast(item); + return patientItem->mAccessionList.count(); +} + +int WorklistTableModel::columnCount(const QModelIndex &aParent) const +{ + return mHeader.size(); +} + +QModelIndex WorklistTableModel::index(int aRow, int aColumn, const QModelIndex &aParent) const +{ + if (!hasIndex(aRow, aColumn, aParent)) + { + return QModelIndex(); + } + if (!aParent.isValid()) + { + return createIndex(aRow, aColumn, mPatientList[aRow]); + } + AbstractPatientInfomation* item = static_cast(aParent.internalPointer()); + + if(item->getType() == AbstractPatientInfomation::PatientType) + { + PatientInformation* patientItem = static_cast(item); + return createIndex(aRow, aColumn, patientItem->mAccessionList[aRow]); + } + return QModelIndex(); +} + +QVariant WorklistTableModel::data(const QModelIndex &aIndex, int aRole) const +{ + if (aRole != Qt::DisplayRole) + { + return QVariant(); + } + if (!aIndex.isValid()) + { + return QVariant(); + } + + AbstractPatientInfomation* item = static_cast(aIndex.internalPointer()); + if(item->getType() == AbstractPatientInfomation::PatientType) + { + PatientInformation* patientItem = dynamic_cast(item); + switch (aIndex.column()) + { + case 0:return patientItem->ID; + case 1:return patientItem->Name; + case 2:return patientItem->BirthDate; + case 3:return patientItem->Sex == "F" ? tr("Female") : (patientItem->Sex == "M" ? tr("Male") : tr("Other")); + case 4:return patientItem->AddDate; + default:return QVariant(); + } + } + + if(item->getType() == AbstractPatientInfomation::AccessionType) + { + AccessionInformation* accessionItem = static_cast(item); + switch (aIndex.column()) + { + case 1:return accessionItem->mAccessionNumber; + case 2:return accessionItem->getProtocolText(); + case 3:return accessionItem->mScheduledStartDate; + default:return QVariant(); + } + } + return QVariant(); +} + +QModelIndex WorklistTableModel::parent(const QModelIndex &aChild) const +{ + if (!aChild.isValid()) + { + return QModelIndex(); + } + AbstractPatientInfomation *item = static_cast(aChild.internalPointer()); + if(item->getType() != AbstractPatientInfomation::AccessionType) + { + return QModelIndex(); + } + AccessionInformation* accessionItem = static_cast(item); + int row = mPatientList.indexOf(accessionItem->mPatient); + //parent column must be 0 + return createIndex(row, 0, accessionItem->mPatient); +} + +void WorklistTableModel::reloadLanguage() +{ + beginResetModel(); + mHeader = QStringList()<< tr("ID") << tr("Name") << tr("Birth Date") << tr("Gender") << tr("Add Date"); + emit headerDataChanged(Qt::Horizontal, 0, mHeader.count() - 1); + for(int i=0; ireloadHeaderLanguage(); + } + endResetModel(); +} + +void WorklistTableModel::instertPatients(const QList& aPatientList) +{ + beginResetModel(); + qDeleteAll(mPatientList); + mPatientList.clear(); + mPatientList = aPatientList; + endResetModel(); +// PatientInformation* p1 = new PatientInformation("PAT001","Sun","F","1998-08-21","2022-03-03 19:25:23"); +// AccessionInformation* a = new AccessionInformation("a1",ScanLeft,"a3", p1, p1); +// AccessionInformation* b = new AccessionInformation("b1",ScanLeft,"b3", p1, p1); +// p1->setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()<setAccessionList(QList()< + +#include "PatientInformation.h" + +class ActionResult; + +class WorklistTableModel : public QAbstractItemModel +{ + Q_OBJECT +public: + WorklistTableModel(QObject* aParent = nullptr); + ~WorklistTableModel() override; + + QVariant headerData(int aSection, Qt::Orientation aOrientation, int aRole = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &aParent = QModelIndex()) const override; + int columnCount(const QModelIndex &aParent = QModelIndex()) const override; + QVariant data(const QModelIndex &aIndex, int aRole) const override; + QModelIndex parent(const QModelIndex &aChild) const override; + QModelIndex index(int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const override; + void instertPatients(const QList& aPatientList); + +private: + void reloadLanguage(); + +private: + QList mPatientList; + QStringList mHeader; + +}; + +#endif // WORKLISTTABLEMODEL_H diff --git a/src/forms/select/WorklistTableSelectModel.cpp b/src/forms/select/WorklistTableSelectModel.cpp new file mode 100644 index 0000000..477314f --- /dev/null +++ b/src/forms/select/WorklistTableSelectModel.cpp @@ -0,0 +1,151 @@ +#include "WorklistTableSelectModel.h" + +#include + +WorklistTableSelectModel::WorklistTableSelectModel(QAbstractItemModel *aItemModel, QObject *aParent) + : QItemSelectionModel(aItemModel, aParent) + , mSelectedPatient(nullptr) +{ + +} + +WorklistTableSelectModel::~WorklistTableSelectModel() +{ + +} + +void WorklistTableSelectModel::select(const QItemSelection &aIndex, QItemSelectionModel::SelectionFlags aCommand) +{ + if(aIndex.size() == 0) + { + return QItemSelectionModel::select(aIndex, aCommand);; + } + + if(aCommand & QItemSelectionModel::Select) + { + QModelIndex index = aIndex.indexes()[0]; + if(!index.parent().isValid()) + { + setSelectedPatient(index); + } + else if(mSelectedPatient != nullptr) + { + setSelectedAccession(index); + } + } + else if(aCommand & QItemSelectionModel::Deselect) + { + QModelIndex index = aIndex.indexes()[0]; + if(index.parent().isValid()) + { + setUnselectedAccession(index); + } + else + { + mSelectedPatient = nullptr; + } + } + + QItemSelectionModel::select(aIndex, aCommand); + emit WorklistTableSelectChanged(mSelectedPatient); +} + +void WorklistTableSelectModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) +{ + QItemSelectionModel::select(index, command); +} + +void WorklistTableSelectModel::setSelectedPatient(const QModelIndex& aClickModelIndex) +{ + AbstractPatientInfomation* item = static_cast(aClickModelIndex.internalPointer()); + if(item->getType() != AbstractPatientInfomation::PatientType) + { + return; + } + PatientInformation* patient = static_cast(item); + if(mSelectedPatient != nullptr) + { + mSelectedPatient->clearSelectedAccession(); + } + + mSelectedPatient = patient; +// //handle init selected accession +// { +// mSelectedPatient->selectAccession(mSelectedPatient->mAccessionList[1]); +// //mSelectedPatient->selectAccession(mSelectedPatient->mAccessionList[3]); + mSelectedPatient->selectRecommendAccessions(); +// } + updateSelectAccession(aClickModelIndex); +} + +void WorklistTableSelectModel::setSelectedAccession(const QModelIndex& aClickModelIndex) +{ + AbstractPatientInfomation* item = static_cast(aClickModelIndex.internalPointer()); + if(item->getType() != AbstractPatientInfomation::AccessionType || aClickModelIndex.row() == 0) + { + return; + } + AccessionInformation* accession = static_cast(item); + + if(mSelectedPatient->contains(accession->mPosition)) + { + QList rowIndexs = mSelectedPatient->unSelectAccession(accession->mPosition); + for(int i=0; iisSelectedMax(accession)) + { + int rowIndex = mSelectedPatient->unSelectLastAccession(); + if(rowIndex == -1) + { + break; + } + unselectRow(aClickModelIndex.parent(), rowIndex); + } + + mSelectedPatient->selectAccession(accession); + +} + +void WorklistTableSelectModel::setUnselectedAccession(const QModelIndex& aClickModelIndex) +{ + AbstractPatientInfomation* item = static_cast(aClickModelIndex.internalPointer()); + if(item->getType() != AbstractPatientInfomation::AccessionType) + { + return; + } + AccessionInformation* accession = static_cast(item); + mSelectedPatient->unSelectAccession(accession); +} + +void WorklistTableSelectModel::updateSelectAccession(const QModelIndex& aClickModelIndex) +{ + QList selectedIndex = mSelectedPatient->getSelectedAccessionIndex(); + for(int i=0; icolumnCount() - 1); + QItemSelectionModel::select(QItemSelection(start, end), QItemSelectionModel::Select); + } +} + +void WorklistTableSelectModel::unselectRow(const QModelIndex& aParientlIndex, int aRow) +{ + QModelIndex start = model()->index(aRow, 0, aParientlIndex); + QModelIndex end = model()->index(aRow, model()->columnCount() - 1, aParientlIndex); + QItemSelectionModel::select(QItemSelection(start, end), QItemSelectionModel::Deselect); +} + +PatientInformation* WorklistTableSelectModel::getSelectedPatient() +{ + return mSelectedPatient; +} + +void WorklistTableSelectModel::clearSelect() +{ + mSelectedPatient = nullptr; + emit WorklistTableSelectChanged(mSelectedPatient); +} diff --git a/src/forms/select/WorklistTableSelectModel.h b/src/forms/select/WorklistTableSelectModel.h new file mode 100644 index 0000000..e9de2b0 --- /dev/null +++ b/src/forms/select/WorklistTableSelectModel.h @@ -0,0 +1,35 @@ +#ifndef WORKLISTTABLESELECTMODEL_H +#define WORKLISTTABLESELECTMODEL_H + +#include + +#include "WorklistTableModel.h" + +class WorklistTableSelectModel : public QItemSelectionModel +{ + Q_OBJECT +public: + WorklistTableSelectModel(QAbstractItemModel *aItemModel, QObject *aParent = nullptr); + ~WorklistTableSelectModel() override; + + void select(const QItemSelection &aIndex, QItemSelectionModel::SelectionFlags aCommand) override; + void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override; + PatientInformation* getSelectedPatient(); + void clearSelect(); + +signals: + void WorklistTableSelectChanged(PatientInformation* aPatient); + +private: + void setSelectedPatient(const QModelIndex& aClickModelIndex); + void setSelectedAccession(const QModelIndex& aClickModelIndex); + void setUnselectedAccession(const QModelIndex& aClickModelIndex); + void updateSelectAccession(const QModelIndex& aClickModelIndex); + inline void unselectRow(const QModelIndex& aParientlIndex, int aRow); + + +private: + PatientInformation* mSelectedPatient; +}; + +#endif // WORKLISTTABLESELECTMODEL_H diff --git a/src/forms/select/WorklistTableStyleItemDelegate.cpp b/src/forms/select/WorklistTableStyleItemDelegate.cpp new file mode 100644 index 0000000..52e6e1c --- /dev/null +++ b/src/forms/select/WorklistTableStyleItemDelegate.cpp @@ -0,0 +1,78 @@ +#include "WorklistTableStyleItemDelegate.h" + +#include +#include + +#include "WorklistTableModel.h" +#include + +WorklistTableStyleItemDelegate::WorklistTableStyleItemDelegate(QHeaderView* aHeaderView, QObject* aParent) + : QStyledItemDelegate(aParent) + , mHeaderView(aHeaderView) + , mCheckedIcon(new QPixmap(":icons/radio_check.png")) + , mUncheckedIcon(new QPixmap(":/icons/radio_uncheck.png")) +{ + +} + +WorklistTableStyleItemDelegate::~WorklistTableStyleItemDelegate() +{ + delete mCheckedIcon; + delete mUncheckedIcon; +} + +void WorklistTableStyleItemDelegate::paint(QPainter* aPainter, const QStyleOptionViewItem& aOption, const QModelIndex& aIndex) const +{ + if(aIndex.data().isValid()) + { + if (aIndex.parent().isValid() && aIndex.row() == 0) + { + aPainter->save(); + QStyleOptionHeader header; + header.initFrom(mHeaderView); + header.state = QStyle::State_None; + header.rect = aOption.rect; + header.text = aIndex.data().toString(); + header.textAlignment = Qt::AlignCenter; + + aPainter->fillRect(header.rect, QBrush(QColor("#595959"))); + mHeaderView->style()->drawControl(QStyle::CE_HeaderLabel, &header, aPainter, mHeaderView); + aPainter->restore(); + + } + else + { + QStyleOptionViewItem changedOption = aOption; + changedOption.state &= ~QStyle::State_HasFocus; + changedOption.displayAlignment = Qt::AlignCenter; + QStyledItemDelegate::paint(aPainter, changedOption, aIndex); + } + } + + aPainter->save(); + if (aIndex.parent().isValid() && aIndex.column() == 0 && aIndex.row() != 0) + { + bool isSelected = aOption.state & QStyle::State_Selected; + QStyleOptionButton checkBoxOption; + checkBoxOption.rect = aOption.rect; + checkBoxOption.state |= QStyle::State_On; + checkBoxOption.rect.setWidth(30); + checkBoxOption.rect.setHeight(30); + checkBoxOption.rect.moveLeft(260); + checkBoxOption.rect.moveTop(checkBoxOption.rect.top() + 4); + aPainter->setRenderHint(QPainter::SmoothPixmapTransform, true); + if(isSelected) + { + aPainter->drawPixmap(checkBoxOption.rect,*mCheckedIcon); + } + else + { + aPainter->drawPixmap(checkBoxOption.rect,*mUncheckedIcon); + } + } + + aPainter->setPen(QPen(Qt::black)); + aPainter->drawLine(aOption.rect.topRight(), aOption.rect.bottomRight()); + aPainter->drawLine(aOption.rect.bottomLeft(), aOption.rect.bottomRight()); + aPainter->restore(); +} diff --git a/src/forms/select/WorklistTableStyleItemDelegate.h b/src/forms/select/WorklistTableStyleItemDelegate.h new file mode 100644 index 0000000..d9a31dd --- /dev/null +++ b/src/forms/select/WorklistTableStyleItemDelegate.h @@ -0,0 +1,21 @@ +#ifndef WORKLISTTABLESTYLEITEMDELEGATE_H +#define WORKLISTTABLESTYLEITEMDELEGATE_H + +#include +#include + +class WorklistTableStyleItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + WorklistTableStyleItemDelegate(QHeaderView* aHeaderView, QObject* aParent = nullptr); + ~WorklistTableStyleItemDelegate(); + void paint(QPainter* aPainter, const QStyleOptionViewItem& aOption, const QModelIndex& aIndex) const override; + +private: + QHeaderView* mHeaderView; + QPixmap* mCheckedIcon; + QPixmap* mUncheckedIcon; +}; + +#endif // WORKLISTTABLESTYLEITEMDELEGATE_H diff --git a/src/forms/select/WorklistTableView.cpp b/src/forms/select/WorklistTableView.cpp new file mode 100644 index 0000000..dc06f37 --- /dev/null +++ b/src/forms/select/WorklistTableView.cpp @@ -0,0 +1,133 @@ +#include "WorklistTableView.h" + +#include +#include +#include +#include +#include + +namespace +{ + const int ROW_HEIGHT = 30.0l; +} + +WorklistTableView::WorklistTableView(QWidget *aParent) + : QTreeView (aParent) + , mOriginPosY(-1) + , mOriginScrollBarV(0) + , mIsMoved(false) +{ + setExpandsOnDoubleClick(false); +} + +WorklistTableView::~WorklistTableView() +{ + +} + +void WorklistTableView::singleClickExpand(const QModelIndex& aIndex) +{ + if(!aIndex.isValid()) + { + return; + } + if(!aIndex.parent().isValid()) + { + QModelIndex nodeIndex = model()->index(aIndex.row(), 0, aIndex.parent()); + if(isExpanded(nodeIndex)) + { + collapse(model()->index(aIndex.row(), 0, aIndex.parent())); + } + else + { + collapseAll(); + expand(nodeIndex); + } + } +} + +void WorklistTableView::mousePressEvent(QMouseEvent *aEvent) +{ + if(aEvent == nullptr) + { + return; + } + mOriginPosY = aEvent->pos().y(); + mOriginScrollBarV = this->verticalScrollBar()->value(); + aEvent->ignore(); + return; +} + +void WorklistTableView::mouseReleaseEvent(QMouseEvent *aEvent) +{ + if(aEvent == nullptr) + { + return; + } + + QModelIndex index = indexAt(aEvent->pos()); + if(mIsMoved) + { + mIsMoved = false; + return QTreeView::mouseReleaseEvent(aEvent); + } + QItemSelectionModel *selectionModel = this->selectionModel(); + if (index.isValid()) + { + if (selectionModel->isSelected(index)) + { + QModelIndex startIndex = model()->index(index.row(), 0, index.parent()); + QModelIndex endIndex = model()->index(index.row(), model()->columnCount() - 1, index.parent()); + selectionModel->select(QItemSelection(startIndex, endIndex), QItemSelectionModel::Deselect); + if(!index.parent().isValid()) + { + singleClickExpand(index); + } + return; + } + if(!index.parent().isValid()) + { + selectionModel->clear(); + } + } + QModelIndex startIndex = model()->index(index.row(), 0, index.parent()); + QModelIndex endIndex = model()->index(index.row(), model()->columnCount() - 1, index.parent()); + selectionModel->select(QItemSelection(startIndex, endIndex), QItemSelectionModel::Select); + //QTreeView::mousePressEvent(mPressEvent); + singleClickExpand(index); + QTreeView::mouseReleaseEvent(aEvent); +} + +void WorklistTableView::mouseMoveEvent(QMouseEvent* aEvent) +{ + if(aEvent == nullptr) + { + return; + } + + if (this->verticalScrollBar()->isVisible()) + { + int nv = (int) round(((double) mOriginScrollBarV * ROW_HEIGHT + ((double) (mOriginPosY - aEvent->pos().y()))) + / ROW_HEIGHT); +// int nv = mOriginScrollBarV * ROW_HEIGHT + ( (mOriginPosY - aEvent->pos().y())) +// / ROW_HEIGHT; + int max = this->verticalScrollBar()->maximum(); + int min = this->verticalScrollBar()->minimum(); + nv = nv > max ? max : (nv < min ? min : nv); + if(this->verticalScrollBar()->value() != nv ) + { + mIsMoved = true; + this->verticalScrollBar()->setValue(nv); + } + } + aEvent->ignore(); +} + +void WorklistTableView::mouseDoubleClickEvent(QMouseEvent* aEvent) +{ + if(aEvent == nullptr) + { + return; + } + aEvent->ignore(); +} diff --git a/src/forms/select/WorklistTableView.h b/src/forms/select/WorklistTableView.h new file mode 100644 index 0000000..c959f96 --- /dev/null +++ b/src/forms/select/WorklistTableView.h @@ -0,0 +1,28 @@ +#ifndef WORKLISTTABLEVIEW_H +#define WORKLISTTABLEVIEW_H + +#include + +class WorklistTableView : public QTreeView +{ + Q_OBJECT +public: + WorklistTableView(QWidget *aParent = nullptr); + ~WorklistTableView() override; + +protected: + void mousePressEvent(QMouseEvent *aEvent) override; + void mouseReleaseEvent(QMouseEvent *aEvent) override; + void mouseDoubleClickEvent(QMouseEvent* aEvent) override; + void mouseMoveEvent(QMouseEvent* aEvent) override; + +private: + void singleClickExpand(const QModelIndex& aIndex); + +private: + int mOriginPosY; + int mOriginScrollBarV; + bool mIsMoved; +}; + +#endif // WORKLISTTABLEVIEW_H diff --git a/src/forms/settings/GeneralForm.cpp b/src/forms/settings/GeneralForm.cpp index 65cd821..9b0c3af 100644 --- a/src/forms/settings/GeneralForm.cpp +++ b/src/forms/settings/GeneralForm.cpp @@ -22,6 +22,7 @@ #include "utilities/DiskInfoWorker.h" #include "utilities/GetLockScreenTimeHelper.h" #include "utilities/GetProtocalHelper.h" +#include "utilities/WorklistFilterHelper.h" GeneralForm::GeneralForm(QWidget* aParent) : QWidget(aParent) @@ -63,8 +64,9 @@ GeneralForm::GeneralForm(QWidget* aParent) lanHeaderLayout->addWidget(languageLabel); lanHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); QToolButton* btnLan = new ListBox(lanHeader); + btnLan->setFixedWidth(180); lanHeaderLayout->addWidget(btnLan); - lanHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); + lanHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); //Lock Screen QWidget* lockHeader = new QWidget(this); @@ -74,8 +76,9 @@ GeneralForm::GeneralForm(QWidget* aParent) lockHeaderLayout->addWidget(lockScreenLabel); lockHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); ListBox* lockTime = new ListBox(lockHeader); + lockTime->setFixedWidth(180); lockHeaderLayout->addWidget(lockTime); - lockHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); + lockHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); //Scan Protocol QWidget* scanProtocolHeader = new QWidget(this); @@ -86,8 +89,35 @@ GeneralForm::GeneralForm(QWidget* aParent) scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); ListBox* scanProtocolButton = new ListBox(scanProtocolHeader); scanProtocolButton->setText(GetProtocalHelper::getProtocalStr()); + scanProtocolButton->setFixedWidth(180); scanProtocalHeaderLayout->addWidget(scanProtocolButton); - scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); + scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); + + //Worklist Modality Filter + QWidget* worklistModalityFilterHeader = new QWidget(this); + mLayout->addWidget(worklistModalityFilterHeader); + QHBoxLayout* worklistFilterModalityHeaderLayout = new QHBoxLayout(worklistModalityFilterHeader); + QLabel* worklistFilterModalityLabel = new QLabel(tr("Worklist Modality Filter"), this); + worklistFilterModalityHeaderLayout->addWidget(worklistFilterModalityLabel); + worklistFilterModalityHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); + ListBox* worklistFilterModalityButton = new ListBox(worklistModalityFilterHeader); + worklistFilterModalityButton->setText(WorklistFilterHelper::getCurrentWorklistFilterModality()); + worklistFilterModalityButton->setFixedWidth(180); + worklistFilterModalityHeaderLayout->addWidget(worklistFilterModalityButton); + worklistFilterModalityHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); + + //Worklist Date Filter + QWidget* worklistDateFilterHeader = new QWidget(this); + mLayout->addWidget(worklistDateFilterHeader); + QHBoxLayout* worklistFilterDateHeaderLayout = new QHBoxLayout(worklistDateFilterHeader); + QLabel* worklistFilterDateLabel = new QLabel(tr("Worklist Date Filter"), this); + worklistFilterDateHeaderLayout->addWidget(worklistFilterDateLabel); + worklistFilterDateHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); + ListBox* worklistFilterDateButton = new ListBox(worklistDateFilterHeader); + worklistFilterDateButton->setFixedWidth(180); + worklistFilterDateButton->setText(WorklistFilterHelper::getCurrentWorklistFilterDate()); + worklistFilterDateHeaderLayout->addWidget(worklistFilterDateButton); + worklistFilterDateHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); //Complete Notify QWidget* scanCompleteHeader = new QWidget(this); @@ -100,7 +130,7 @@ GeneralForm::GeneralForm(QWidget* aParent) scanCompleteHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); scanCompleteHeaderLayout->addWidget(scanCompleteButton); scanCompleteButton->setChecked(JsonObject::Instance()->getCompleteNotify()); - scanCompleteHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); + scanCompleteHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); //Anonymous QWidget* anonyHeader = new QWidget(this); @@ -112,7 +142,7 @@ GeneralForm::GeneralForm(QWidget* aParent) ImageSwitch* anonyButton = new ImageSwitch(anonyHeader); anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode()); anonyHeaderLayout->addWidget(anonyButton); - anonyHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); + anonyHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); //Screen Saver QWidget* screenSaverHeader = new QWidget(this); @@ -124,7 +154,7 @@ GeneralForm::GeneralForm(QWidget* aParent) ImageSwitch* screenSaverButton = new ImageSwitch(screenSaverHeader); screenSaverButton->setChecked(JsonObject::Instance()->getScreenSaverMode()); screenSaverHeaderLayout->addWidget(screenSaverButton); - screenSaverHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); + screenSaverHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed)); //DiskIcon QWidget* diskHeader = new QWidget(this); @@ -209,8 +239,12 @@ GeneralForm::GeneralForm(QWidget* aParent) anonyLabel->setText(tr("Anonymous Mode")); screenSaverLabel->setText(tr("Screen Saver")); diskLabel->setText(tr("Disk Storage")); + worklistFilterDateLabel->setText(tr("Worklist Date Filter")); + worklistFilterModalityLabel->setText(tr("Worklist Modality Filter")); anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode()); scanProtocolButton->setText(GetProtocalHelper::getProtocalStr()); + worklistFilterDateButton->setText(WorklistFilterHelper::getCurrentWorklistFilterDate()); + worklistFilterModalityButton->setText(WorklistFilterHelper::getCurrentWorklistFilterModality()); lockTime->setText(GetLockScreenTimeHelper::getLockScreenTimeStr()); updateStorageSize(); updateStorageUsed(); @@ -245,6 +279,31 @@ GeneralForm::GeneralForm(QWidget* aParent) } }); + connect(worklistFilterModalityButton, &QPushButton::clicked, [=]() + { + DialogResult result = DialogManager::Default()->reuqestWorklistFilterModalityDialog(); + if (result.ResultCode == QDialog::Accepted) + { + QString modality = result.ResultData.toString(); + worklistFilterModalityButton->setText(modality); + JsonObject::Instance()->setWorklistFilterModality(WorklistFilterHelper::processSelectedWorklistFilterModality(modality)); + LOG_USER_OPERATION(QString("Set Worklist Modality Filter:%1").arg(modality)); + } + }); + + connect(worklistFilterDateButton, &QPushButton::clicked, [=]() + { + DialogResult result = DialogManager::Default()->reuqestWorklistFilterDateDialog(); + if (result.ResultCode == QDialog::Accepted) + { + QString date = result.ResultData.toString(); + worklistFilterDateButton->setText(date); + JsonObject::Instance()->setWorklistFilterDate(date); + JsonObject::Instance()->setWorklistFilterDate(WorklistFilterHelper::processSelectedWorklistFilterDate(date)); + LOG_USER_OPERATION(QString("Set Worklist Date Filter:%1").arg(date)); + } + }); + connect(scanCompleteButton, &ImageSwitch::clicked, [=]() { bool isOpen = scanCompleteButton->getChecked(); diff --git a/src/json/jsonobject.cpp b/src/json/jsonobject.cpp index e77180a..5760e7d 100644 --- a/src/json/jsonobject.cpp +++ b/src/json/jsonobject.cpp @@ -78,6 +78,8 @@ void JsonObject::init() mWorklistHost.ip = QString(getJsonString("worklist", "ip")); mWorklistHost.localAE = QString(getJsonString("worklist", "localAE")); mWorklistHost.port = QString(getJsonString("worklist", "port")); + mWorklistFilterModality = QString(getJsonString("worklistfilter","modality")); + mWorklistFilterDays = QString(getJsonString("worklistfilter","date")); mPacsHost.ae = QString(getJsonString("pacs", "ae")); mPacsHost.ip = QString(getJsonString("pacs", "ip")); @@ -665,3 +667,25 @@ bool JsonObject::getScanCanWithoutRecon() { return mScanCanWithoutRecon; } + +QString JsonObject::getWorklistFilterModality() +{ + return mWorklistFilterModality; +} + +void JsonObject::setWorklistFilterModality(const QString& aModality) +{ + mWorklistFilterModality = aModality; + setJsonString("worklistfilter","modality", aModality.toStdString().c_str()); +} + +QString JsonObject::getWorklistFilterDate() +{ + return mWorklistFilterDays; +} + +void JsonObject::setWorklistFilterDate(const QString& aDate) +{ + mWorklistFilterDays = aDate; + setJsonString("worklistfilter","date", aDate.toStdString().c_str()); +} diff --git a/src/json/jsonobject.h b/src/json/jsonobject.h index 13f387a..5e27379 100644 --- a/src/json/jsonobject.h +++ b/src/json/jsonobject.h @@ -128,6 +128,11 @@ public: bool getScanCanWithoutRecon(); + QString getWorklistFilterModality(); + void setWorklistFilterModality(const QString& aModality); + QString getWorklistFilterDate(); + void setWorklistFilterDate(const QString& aDate); + private: void setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save = true); @@ -162,6 +167,8 @@ private: QString mInterfaceName; QString mGateway; QString mReconTransferPath; + QString mWorklistFilterModality; + QString mWorklistFilterDays; QStringList mLockScreenTimeList; QStringList mProtocalList; diff --git a/src/main.cpp b/src/main.cpp index a90125c..fd3e7e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,6 +19,7 @@ #include "keyboard/KeyboardManager.h" #include "appvals/AppGlobalValues.h" #include "log/LogManager.h" +#include "dicom/MPPSManager.h" #include QString loadFontFromFile(QString path) @@ -94,6 +95,7 @@ int main(int argc, char* argv[]) MainWindow w; DialogManager::Default()->init(&w); LogManager::getInstance(); + MPPSManager::getInstance(); LOG_USER_OPERATION("GUI Started"); QObject::connect(TouchScreenSignalSender::getInstance(), SIGNAL(touchScreen()), Locker::getInstance(), SLOT(refreshTimer())); diff --git a/src/recon/PACSSettingsDataModel.cpp b/src/recon/PACSSettingsDataModel.cpp index dfff461..4966965 100644 --- a/src/recon/PACSSettingsDataModel.cpp +++ b/src/recon/PACSSettingsDataModel.cpp @@ -47,6 +47,7 @@ QVariant PACSSettingsDataModel::headerData(int section, Qt::Orientation orientat } PACSSettingsDataModel::PACSSettingsDataModel(QObject *parent) + : QAbstractTableModel(parent) { mHeaderStrings< #include -class PACSSettingsDataModel : public QAbstractTableModel{ +class PACSSettingsDataModel : public QAbstractTableModel +{ + Q_OBJECT public: PACSSettingsDataModel(QObject *parent = nullptr); ~PACSSettingsDataModel(){} diff --git a/src/stylesheet/Dark2.css b/src/stylesheet/Dark2.css index 3950844..520f2ff 100644 --- a/src/stylesheet/Dark2.css +++ b/src/stylesheet/Dark2.css @@ -172,6 +172,18 @@ QTableView { margin: 5 0 5 5; } +QTreeView { + border: none; + alternate-background-color: #595959; + selection-color: #fcfcfc; + selection-background-color: #0078d8; + margin: 5 0 5 5; +} + +QTreeView::item { + height: 38px; +} + QListView { border: none; margin: 5px; @@ -846,10 +858,6 @@ QToolButton#mppsSettingsButton{ text-align: center; } -QPushButton#cechoButton{ - background: #365880; -} - /*------AccountTableForm-----------------------------------------------------*/ QWidget#commandWidgetnoBBorder { min-height: 123px; diff --git a/src/translations/en_US.ts b/src/translations/en_US.ts index 0465033..4a716ca 100644 --- a/src/translations/en_US.ts +++ b/src/translations/en_US.ts @@ -68,6 +68,13 @@ + + AccessionInformation + + Position + + + AccountFormDialog @@ -243,11 +250,11 @@ - Connecting test from server to %1:%2...... + Connection test from server to %1:%2 failed - Connection test from server to %1:%2 failed + Connecting from server to %1:%2...... @@ -518,11 +525,11 @@ progress:99% - Accession Number + ID - ID + ID can't be empty! @@ -530,11 +537,7 @@ progress:99% - The ID and Accession number is already existed! - - - - ID can't be empty! + The ID is already existed! @@ -627,6 +630,14 @@ progress:99% Scan Protocol + + Worklist Modality Filter + + + + Worklist Date Filter + + GetAdminPsw @@ -690,10 +701,6 @@ progress:99% GetWorkListAction - - Search Query Error - - No reference record find! @@ -715,33 +722,6 @@ progress:99% - - GetWorkListDialog - - Accession Nummber - - - - Patient ID - - - - Accession Number and Patient Id is Empty. - - - - Unknow Error. code:001001001 - - - - Accession Number - - - - DB Error,Patient Write Failed - - - InputModeMenu @@ -1257,10 +1237,6 @@ progress:99% Name - - Gender - - Female @@ -1306,7 +1282,22 @@ progress:99% - Protocol + Position + + + + Gender + + + + + PatientInformation + + Scheduled Date + + + + Accession Number @@ -1360,6 +1351,26 @@ progress:99% RONE + + Left + + + + Right + + + + Female + + + + Male + + + + Other + + QObject @@ -1387,6 +1398,22 @@ progress:99% Right + + None + + + + Today + + + + Last 3 days + + + + Last 7 days + + ReconFormWidget @@ -1534,10 +1561,6 @@ progress:99% ShutDown - - Worklist - - Start Scan @@ -1696,10 +1719,6 @@ progress:99% Can't delete selected Patient , db submit error! - - AccessionNumber - - Patient Information Manage @@ -1716,6 +1735,18 @@ progress:99% ID + + Pull + + + + Worklist + + + + Local + + SettingFormWidget @@ -1817,6 +1848,10 @@ progress:99% <html><head/><body><p><br/></p></body></html> + + ScanProtocol: + + SystemCorrectionForm @@ -1982,6 +2017,13 @@ progress:99% + + WorklistLoadingDialog + + Worklist Settings + Worklist + + WorklistSettingsDialog @@ -2017,4 +2059,39 @@ progress:99% + + WorklistTableModel + + ID + + + + Name + + + + Birth Date + + + + Gender + + + + Add Date + + + + Female + + + + Male + + + + Other + + + diff --git a/src/translations/zh_CN.ts b/src/translations/zh_CN.ts index 060ad4e..c04d0f7 100644 --- a/src/translations/zh_CN.ts +++ b/src/translations/zh_CN.ts @@ -94,6 +94,14 @@ 正在加载 + + AccessionInformation + + + Position + 检查身侧 + + AccountFormDialog @@ -461,27 +469,27 @@ DeviceManager - - + + DMS connection error DMS失去连接 - - + + progress:%1% 进度:%1% - + Patient can leave. progress:%1% 检查对象可以起身 进度:%1% - + Data quality assessment in progress progress:99% 数据质量判断中 @@ -489,8 +497,8 @@ progress:99% - - + + Initialize Failed. 初始化失败 @@ -510,75 +518,75 @@ progress:99% 设备状态错误,无法开始空水扫查 - + Scan completed! 扫查结束 - + Error: 错误: - + Start scan failed. Reason:time out. 扫查启动失败,原因:超时 - + Start scan failed. Reason:%1 扫查启动失败,原因:%1 - + Start CE Scan Failed. CE扫查启动失败 - + Data is currently being transmitted, please shut down later. 数据传输中,请稍后再执行关机。 - + Shut down failed, please push emergency button to shutdown. 关机失败,请按紧急按钮进行关机。 - - - + + + Scan data transfer failed. 扫查数据上传失败 - + Scan data transfer Succeeded! - + Create empty scan data failed 空水数据新增失败 - + Create scan data failed 扫查数据新增失败 - + Recon disconnected. 重建服务器已断开连接 - - + + Open pump failed. 排水阀打开失败 - + Recon error, can't start scan process 重建服务器错误,无法开始检查流程 @@ -594,65 +602,80 @@ progress:99% 扫查数据质量较低,请重新开始检查流程 + + DialogManager + + None + + + + Today + 今天 + + + Last 7 days + 过去7天 + + DicomCfgDialog - + Dialog 检查对象信息 - + DICOM Settings DICOM 配置 - - - + + + IP - - - + + + AE AE - - - + + + Port - - - + + + Name 姓名 - - - + + + ... DICOM - + Worklist 新增(拉取) - + PACS - + 3D Recon @@ -670,27 +693,27 @@ progress:99% DicomSettingsArea - + Form - + Local AE 本机AE - + Server Ip 服务器地址 - + Server AE 服务器AE - + Server Port 服务器端口 @@ -708,72 +731,75 @@ progress:99% - Accession Number - 检查单号 + 检查单号 - + Name 姓名 - + Gender 性别 - - - - + + + + Female - - - + + + Male - - + + Other 其他 - + Birth Date 出生日期 - + ID can't be empty! ID不能为空 - + Patient Name can't be empty! 姓名不能为空 - + + The ID is already existed! + + + The ID and Accession number is already existed! - ID和检查单号已存在 + ID和检查单号已存在 Comment 备注 - + F - + M @@ -794,7 +820,7 @@ progress:99% GUIMessageDialog - + Dialog @@ -826,56 +852,72 @@ progress:99% GeneralForm - - + + Language 语言 - + Institution Name 机构名称 - - - + + + Institution Addr 机构地址 - - + + Lock Screen 锁屏时间 - - + + Scan Protocol 默认检查协议 - - + + + Worklist Modality Filter + Worklist模态过滤器 + + + + + Worklist Date Filter + Worklist时间过滤器 + + + + Anonymous Mode 匿名模式 - - + + Screen Saver 屏保 - - + + Complete Notify 检查结束确认 - - + Worklist Filter + Worklist过滤器 + + + + Disk Storage 磁盘存储 @@ -884,22 +926,22 @@ progress:99% 中文 - + Used: %1G - + Total: %1G - + Get disk used size fail! 磁盘使用空间获取失败! - + Get disk total size fail! 磁盘总空间获取失败! @@ -948,7 +990,7 @@ progress:99% Fail to get PACSSettings - + 获取PACS设置失败 @@ -987,74 +1029,54 @@ progress:99% GetWorkListAction - + No reference record find! 无该检查对象信息 - + Worklist network init error! - + Worklist connect error! Worklist连接失败 - + Worklist response find failed! - + Worklist query context error! - - - Search Query Error - - GetWorkListDialog - Accession Nummber - 检查单号 + 检查单号 - - Patient ID - 检查对象ID + 检查对象ID - Accession Number - 检查单号 + 检查单号 - Accession Number and Patient Id is Empty. - 检查单号或病人ID为空! - - - - Unknow Error. code:001001001 - - - - - DB Error,Patient Write Failed - + 检查单号或病人ID为空! InputModeMenu - + Form @@ -1100,204 +1122,274 @@ progress:99% Keyboard - + Form - + q - + w - + e - + r - + t - + y - + u - + i - + o - + p - - + + Back - + a - + s - + d - + f - + g - + h - + j - + k - + l - + Enter - + 小写 - + z - + x - + c - + v - + b - + n - + m - + - + ?123 - - + + En - + Space - - + + Hide - + - + - + - + Clear + + LocalPatientLocalPatientSelectFormWidget + + Patient Information Manage + 检查对象信息录入 + + + + LocalPatientSelectFormWidget + + Edit + 编辑 + + + Delete + 删除 + + + Add + 新增 + + + Select + 选择 + + + Can't delete selected Patient ! + 不能删除已经被选择的对象 + + + Delete Patient "%1" ? + 删除检查对象"%1"? + + + Confirm + 确认 + + + ID + 检查对象ID + + + AccessionNumber + 检查单号 + + + Name + 姓名 + + + Birth Date + 出生日期 + + + Gender + 性别 + + + Add Date + 添加日期 + + + Comment + 备注 + + + Patient Information Manage + 检查对象信息录入 + + LoginDialog @@ -1393,22 +1485,22 @@ progress:99% - + MPPS initNetwork failed! - + MPPS connect failed! - + MPPS连接失败 - + MPPS context error! - + MPPS fail by error: @@ -1416,12 +1508,12 @@ progress:99% MPPSManager - + Create MPPSUID error! - + Update MPPSUID success! @@ -1429,7 +1521,7 @@ progress:99% MainWindow - + MainWindow @@ -1551,102 +1643,102 @@ progress:99% NetworkCfgDialog - - + + Network Settings 网络配置 - + IP Address IP地址 - + DHCP - + Dev 设备 - + Subnet Mask 子网掩码 - + Additional Address 额外地址 - - + + Add 新增 - - + + Edit 编辑 - - + + Delete 删除 - + Address IP配置 - + Default IPv4 Gateway 默认网关 - + Routing Table 路由表 - + Routing 路由配置 - + Name 姓名 - + Port - + AE AE - + IP - + DICOM - + Result 结果 @@ -1690,27 +1782,27 @@ progress:99% - + AETitle - + IP - + Port - + Server AE 服务器AE - + Use SC @@ -1763,7 +1855,8 @@ progress:99% DICOM - + + Name 姓名 @@ -1776,7 +1869,8 @@ progress:99% 备注 - + + Gender 性别 @@ -1789,67 +1883,79 @@ progress:99% 删除 - - + + Female - - + + Male - - + + Other 其他 - + Patient Detail 当前检查对象信息 - + + Birth Date 出生日期 - + + PatientID 检查对象ID - + + + + AccNo 检查单号 - - + + + + + Position + 检查身侧 + + + + Add Date 添加日期 - + Scan with this Patient? - Protocol - 扫描协议 + 扫描协议 - + Left 单侧左 - + Right 单侧右 @@ -1862,68 +1968,108 @@ progress:99% 接受 + + PatientInformation + + + + Scheduled Date + 检查日期 + + + + + Accession Number + 检查单号 + + PatientInformationForm - + Form - + Current Patient 当前患者信息 - + Patient Name: 患者姓名: - + Patient ID: 患者编码: - + Patient Birthday: 出生日期: - + Patient Gender: 患者性别: - + Patient AccessionNum: 检查单号: - + Scan Protocol: 检查身侧: - + + Female + + + + + Male + + + + + Other + 其他 + + + RSTAND 从右至左 - + LSTAND 从左至右 - + LONE 单侧左 - + RONE 单侧右 + + + Left + 左侧 + + + + Right + 右侧 + QObject @@ -1962,6 +2108,37 @@ progress:99% Right 单侧右 + + + + + + + + None + + + + + + + Today + 今天 + + + + + + Last 3 days + 过去3天 + + + + + + Last 7 days + 过去7天 + ReconFormWidget @@ -1974,44 +2151,44 @@ progress:99% 刷新 - - + + Patient ID 检查对象ID - - + + Accession Number 检查单号 - - + + Patient Name 检查对象姓名 - - + + Operator Name 操作员 - - + + Scan Time 检查时间 - - + + Laterality 检查位置 - - + + State 重建状态 @@ -2154,94 +2331,92 @@ progress:99% 空扫 - - - - + + + + Drainage 排水 - - + + Account 账户 - - + + ShutDown 关机 - - Worklist - 录入检查对象 + 录入检查对象 - - - + + + Start Scan 开始检查流程 - + Make sure to open the drain valve ? 请确认是否打开排水阀? - + Confirm Drainage 排水确认 - - - + + + Drainaging 排水中 - + Shut down now ? 是否需要进行设备关机操作,请确认? - + Shut Down 关机 - - - + + + Please confirm checking patient information to start the process 请确定检查对象信息开始流程 - + Data scanning, please keep the current position and don't move. 数据扫查中,请检查对象保持当前姿势,不要移动 - + Data exporting, patient can leave the holder 数据导出中,检查对象可以离开检查仓 - + Left side scan initiated, auto positioning in progress. 左侧扫查启动,自动定位中 - + Right side scan initiated, auto positioning in progress. 右侧扫查启动,自动定位中 - + Stop Scan Process 退出检查流程 @@ -2260,37 +2435,37 @@ parameters ScanSearchCriteriaForm - + Form - + Scan Search 按日期查找 - + Today 今天 - + Yesterday 昨天 - + Last 7 days 过去7天 - + Search All 所有信息 - + Scan date from 开始日期 @@ -2299,52 +2474,52 @@ parameters DICOM - + Scan date to 结束日期 - + Search Dates 检索 - + Search Criteria 按条件查找 - + Retrieve 检索 - + Accession Number 检查单号 - + Manual Refresh 手动刷新 - + Refresh 刷新 - + Patient ID 检查对象ID - + Patient Name 检查对象姓名 - + Clear Fields 清空 @@ -2356,103 +2531,115 @@ parameters 账户 + + Worklist - 新增(拉取) + 在线 - - + + Add 新增 - - + + Edit 编辑 - - + + Patient Information Manage 检查对象信息录入 - - + + + Local + 本地 + + + + Delete 删除 - - + + + Pull + 拉取 + + + + Select 选择 - + Can't delete selected Patient ! 不能删除已经被选择的对象 - - + + Alert - + Delete Patient "%1" ? 删除检查对象"%1"? - + Confirm 确认 - + Can't delete selected Patient , db submit error! - + ID 检查对象ID - - AccessionNumber - 检查单号 + 检查单号 - - + + Name 姓名 - - + + Birth Date 出生日期 - - + + Gender 性别 - - + + Add Date 添加日期 - - + + Comment 备注 @@ -2522,77 +2709,84 @@ parameters StartScanProcessDialog - + Dialog 检查对象信息 - + Patien Information 检查对象信息 - + PatientBirth: 出生日期: - + PatientGender: 患者性别: - + + AccessionNumber: 检查单号: - + + + ScanProtocol: + 检查身侧: + + + PatientName: 患者姓名: - + PatientID: 患者编码: - + Protocol Settings 当前流程设置 - + <html><head/><body><p><br/></p></body></html> - + left->right 左->右 - + right->left 右->左 - + only left 单侧左 - + only right 单侧右 - + start Scan 立即开始 - + Cancel 稍后开始 @@ -2657,7 +2851,7 @@ parameters SystemSettingForm - + Form @@ -2678,7 +2872,7 @@ parameters 自动验证 - + IP @@ -2687,22 +2881,22 @@ parameters Worklist过滤器 - + Recon Settings Recon - + Worklist Settings Worklist - + Pacs Settings Pacs - + Mpps Settings Mpps @@ -2722,7 +2916,7 @@ parameters TabFormWidget - + Form @@ -2887,6 +3081,54 @@ parameters 服务器端口格式必须为小于65535的数字 + + WorklistTableModel + + + + ID + 检查对象ID + + + + + Name + 姓名 + + + + + Birth Date + 出生日期 + + + + + Gender + 性别 + + + + + Add Date + 添加日期 + + + + Female + + + + + Male + + + + + Other + 其他 + + cmdHelper diff --git a/src/utilities/ScanProcessSequence.cpp b/src/utilities/ScanProcessSequence.cpp index 980b4c3..33263b8 100644 --- a/src/utilities/ScanProcessSequence.cpp +++ b/src/utilities/ScanProcessSequence.cpp @@ -25,14 +25,19 @@ void ScanProcessSequence::updateAutoLocatePosition(int aX, int aY, int aZ) emit autoLocateZUpdated(aZ); } -void ScanProcessSequence::pushPosition(ScanPosition aPostion) +void ScanProcessSequence::pushAccession(AccessionInformation* aAccession, ScanPosition aPostion) { - mScanProtocol.push(aPostion); + mScanProtocol.push(QPair(aAccession, aPostion)); +} + +QPair ScanProcessSequence::topAccession() +{ + return mScanProtocol.top(); } ScanPosition ScanProcessSequence::popPosition() { - ScanPosition result = mScanProtocol.pop(); + ScanPosition result = mScanProtocol.pop().second; if(mScanProtocol.size() == 0) { emit ScanProcessSequenceFinished(); @@ -42,7 +47,7 @@ ScanPosition ScanProcessSequence::popPosition() ScanPosition ScanProcessSequence::topPosition() { - return mScanProtocol.top(); + return mScanProtocol.top().second; } void ScanProcessSequence::clear() diff --git a/src/utilities/ScanProcessSequence.h b/src/utilities/ScanProcessSequence.h index 2c7c208..a518b6e 100644 --- a/src/utilities/ScanProcessSequence.h +++ b/src/utilities/ScanProcessSequence.h @@ -4,19 +4,23 @@ #include #include + enum ScanPosition { Left = 0, Right }; +class AccessionInformation; + class ScanProcessSequence : public QObject { Q_OBJECT public: static ScanProcessSequence* getInstance(); - void pushPosition(ScanPosition aPosition); + void pushAccession(AccessionInformation* aAccession, ScanPosition aPosition); ScanPosition popPosition(); ScanPosition topPosition(); + QPair topAccession(); int getScanPositionSize(); void clear(); @@ -35,7 +39,7 @@ private slots: private: ScanProcessSequence(QObject* aParent = nullptr); - QStack mScanProtocol; + QStack> mScanProtocol; }; diff --git a/src/utilities/WorklistFilterHelper.cpp b/src/utilities/WorklistFilterHelper.cpp new file mode 100644 index 0000000..ecd6fe3 --- /dev/null +++ b/src/utilities/WorklistFilterHelper.cpp @@ -0,0 +1,81 @@ +#include "WorklistFilterHelper.h" + +#include +#include + +#include "json/jsonobject.h" + +QStringList WorklistFilterHelper::getWorklistFilterModalityList() +{ + return QStringList()<< QObject::tr("None") << "US" << "CT"; +} + +QString WorklistFilterHelper::getCurrentWorklistFilterModality() +{ + QString modality = JsonObject::Instance()->getWorklistFilterModality(); + if(modality.isEmpty()) + { + return QObject::tr("None"); + } + return modality; +} + +QString WorklistFilterHelper::processSelectedWorklistFilterModality(const QString& aModality) +{ + if(aModality == QObject::tr("None")) + { + return ""; + } + + return aModality; +} + +QStringList WorklistFilterHelper::getWorklistFilterDateList() +{ + return QStringList()<< QObject::tr("None") << QObject::tr("Today") << QObject::tr("Last 3 days") << QObject::tr("Last 7 days"); +} + +QString WorklistFilterHelper::getCurrentWorklistFilterDate() +{ + int date = JsonObject::Instance()->getWorklistFilterDate().toInt(); + switch (date) + { + case -1:return QObject::tr("None"); + case 0:return QObject::tr("Today"); + case 3:return QObject::tr("Last 3 days"); + case 7:return QObject::tr("Last 7 days"); + default: return QObject::tr("None"); + } +} + +QString WorklistFilterHelper::processSelectedWorklistFilterDate(const QString& aModality) +{ + if(aModality == QObject::tr("Today")) + { + return "0"; + } + + if(aModality == QObject::tr("Last 3 days")) + { + return "3"; + } + + if(aModality == QObject::tr("Last 7 days")) + { + return "7"; + } + + return "-1"; +} + +QString WorklistFilterHelper::getFilterDateStringInSCU() +{ + int date = JsonObject::Instance()->getWorklistFilterDate().toInt(); + if(date < 0) + { + return ""; + } + QDate today = QDate::currentDate(); + QDate startDate = today.addDays(0-date); + return startDate.toString("yyyyMMdd") + "-" + today.toString("yyyyMMdd"); +} diff --git a/src/utilities/WorklistFilterHelper.h b/src/utilities/WorklistFilterHelper.h new file mode 100644 index 0000000..342ca96 --- /dev/null +++ b/src/utilities/WorklistFilterHelper.h @@ -0,0 +1,21 @@ +#ifndef WORKLISTFILTERHELPER_H +#define WORKLISTFILTERHELPER_H + +#include + +class WorklistFilterHelper +{ +public: + WorklistFilterHelper() = delete; + + static QStringList getWorklistFilterModalityList(); + static QString getCurrentWorklistFilterModality(); + static QString processSelectedWorklistFilterModality(const QString& aModality); + + static QStringList getWorklistFilterDateList(); + static QString getCurrentWorklistFilterDate(); + static QString processSelectedWorklistFilterDate(const QString& aModality); + static QString getFilterDateStringInSCU(); +}; + +#endif // WORKLISTFILTERHELPER_H