diff --git a/CMakeLists.txt b/CMakeLists.txt index 9278ea9..8991d1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,11 @@ source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cxx}) source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cc}) source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_c}) -find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard Network REQUIRED Multimedia MultimediaWidgets) +find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard Network Multimedia MultimediaWidgets REQUIRED) +find_package(DCMTK REQUIRED) +include_directories(${DCMTK_INCLUDE_DIRS}) + + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) file(GLOB_RECURSE project_uis ./src/*.ui) @@ -60,6 +64,10 @@ set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_SOURC qt5_create_translation(QM_FILES ${cpp_source_all} ${ui_FILES} ${TS_FILES}) add_executable(${PROJECT_NAME} ${project_headers} ${project_cpps} ${project_cxx} ${project_res} ${project_cc} ${project_c} ${ui_FILES} ${QM_FILES} ) +if(${DCMTK_FOUND}) + target_link_libraries(${PROJECT_NAME} ${DCMTK_LIBRARIES}) +endif() + if(NOT UNIX) find_program(POWERSHELL_PATH NAMES powershell) diff --git a/src/action/ActionCreator.cpp b/src/action/ActionCreator.cpp new file mode 100644 index 0000000..6f4e3da --- /dev/null +++ b/src/action/ActionCreator.cpp @@ -0,0 +1,3 @@ +#include "ActionCreator.h" + +QMap ActionCreator::mAsyncActionContainer; diff --git a/src/action/ActionCreator.h b/src/action/ActionCreator.h new file mode 100644 index 0000000..89e4b1b --- /dev/null +++ b/src/action/ActionCreator.h @@ -0,0 +1,31 @@ +#ifndef GUI_ACTIONCREATOR_H +#define GUI_ACTIONCREATOR_H + +#include "AsyncAction.h" + +#include +#include + +class ActionCreator +{ +public: + template + static T* getAsyncAction(const QString& aActionId) + { + if (mAsyncActionContainer.contains(aActionId)) + { + return static_cast(mAsyncActionContainer.value(aActionId).data()); + } + else + { + T* action = new T(); + mAsyncActionContainer.insert(aActionId, AsyncActionPointer(action)); + return action; + } + }; + +private: + static QMap mAsyncActionContainer; +}; + +#endif //GUI_ACTIONCREATOR_H diff --git a/src/action/AsyncAction.cpp b/src/action/AsyncAction.cpp new file mode 100644 index 0000000..4980fa2 --- /dev/null +++ b/src/action/AsyncAction.cpp @@ -0,0 +1,22 @@ +#include "AsyncAction.h" + +#include +#include +#include + +AsyncAction::AsyncAction(QObject* aParent) + : QObject(aParent) + , QRunnable() +{ + setAutoDelete(false); +} + +AsyncAction::~AsyncAction() +{ + +} + +void AsyncAction::execute() +{ + QThreadPool::globalInstance()->start(this); +} diff --git a/src/action/AsyncAction.h b/src/action/AsyncAction.h new file mode 100644 index 0000000..bb16247 --- /dev/null +++ b/src/action/AsyncAction.h @@ -0,0 +1,41 @@ +#ifndef GUI_ASYNCACTION_H +#define GUI_ASYNCACTION_H + +#include +#include +#include +#include + +enum ActionCode :unsigned int +{ + Sucessed, Failed +}; + +class ActionResult +{ +public: + ActionResult(ActionCode aCode = Sucessed, const QString& aMessage = "") + { + Code = aCode; + Message = aMessage; + } + ActionCode Code; + QString Message; +}; + +class AsyncAction : public QObject, public QRunnable +{ + Q_OBJECT + +public: + explicit AsyncAction(QObject* aParent); + ~AsyncAction(); + void execute(); + +signals: + void actionCompleted(const ActionResult& aResult); +}; + +typedef QSharedPointer AsyncActionPointer; + +#endif //GUI_ASYNCACTION_H diff --git a/src/action/GetWorkListAction.cpp b/src/action/GetWorkListAction.cpp new file mode 100644 index 0000000..a7d6b3f --- /dev/null +++ b/src/action/GetWorkListAction.cpp @@ -0,0 +1,77 @@ +#include "GetWorkListAction.h" +#include "dicom/WorkListManager.h" + +#include +#include +#include +#include +#include + +GetWorkListAction::GetWorkListAction(QObject* aParent) + : AsyncAction(aParent) + , mSqlModel(nullptr) +{ + +} + +GetWorkListAction::~GetWorkListAction() +{ + +} + +void GetWorkListAction::run() +{ + if (!mQueryData.isEmpty()) + { + PatientInformationPointer info = WorkListManager::getPatientFromWorkList(mQueryData.mAccessionNum, mQueryData.mPatientId); + emit actionCompleted(insertPatientFromWorkList(info)); + } + else + { + emit actionCompleted(ActionResult(Failed,tr("Search Query Error"))); + } +} + +void GetWorkListAction::setWorkListQueryData(const WorkListQueryData& aQueryData) +{ + mQueryData = aQueryData; +} + +void GetWorkListAction::setSqlModel(QSqlTableModel* aSqlModel) +{ + mSqlModel = aSqlModel; +} + +ActionResult GetWorkListAction::insertPatientFromWorkList(PatientInformationPointer aPatientInformation) +{ + if (mSqlModel == nullptr) + { + return ActionResult(Failed,tr("DB Unknow Error")); + } + if (aPatientInformation.isNull()) + { + return ActionResult(Failed,tr("WorkList Search Failed")); + } + mSqlModel->setFilter(QString("PatientID='%1'").arg(aPatientInformation->ID)); + if (mSqlModel->rowCount() > 0) + { + mSqlModel->setFilter(""); + return ActionResult(Failed,tr("Same Patient Existed")); + } + mSqlModel->setFilter(""); + aPatientInformation->PatientUID = QUuid::createUuid().toString(); + aPatientInformation->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),aPatientInformation->val); + EDIT_PATIENT() +#undef ADD_PATIENT_PROPERTY + if (mSqlModel->submitAll()) + { + return ActionResult(); + } + else + { + return ActionResult(Failed,tr("DB Error,Patient Write Failed"));; + } +} diff --git a/src/action/GetWorkListAction.h b/src/action/GetWorkListAction.h new file mode 100644 index 0000000..4ca7d44 --- /dev/null +++ b/src/action/GetWorkListAction.h @@ -0,0 +1,46 @@ +#ifndef GUI_GETWORKLISTACTION_H +#define GUI_GETWORKLISTACTION_H + +#include "AsyncAction.h" +#include "forms/select/PatientInformation.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 + +public: + explicit GetWorkListAction(QObject* aParent = nullptr); + ~GetWorkListAction() override; + + void run() override; + void setWorkListQueryData(const WorkListQueryData& aQueryData); + void setSqlModel(QSqlTableModel* aSqlModel); + +private: + ActionResult insertPatientFromWorkList(PatientInformationPointer aPatientInformation); + +private: + WorkListQueryData mQueryData; + QSqlTableModel* mSqlModel; +}; + +#endif //GUI_GETWORKLISTACTION_H \ No newline at end of file diff --git a/src/components/LoadingWidget.cpp b/src/components/LoadingWidget.cpp new file mode 100644 index 0000000..7e457aa --- /dev/null +++ b/src/components/LoadingWidget.cpp @@ -0,0 +1,101 @@ +#include "LoadingWidget.h" + +#include +#include +#include +#include + +LoadingWidget::LoadingWidget(QWidget* aParent) + : QWidget(aParent) + , mTimer(new QTimer(this)) + , mColor(QColor(Qt::white)) + , mCount(12) + , mMaxDiameter(30) + , mMinDiameter(5) +{ + connect(mTimer,&QTimer::timeout,this,QOverload<>::of(&QWidget::repaint)); + initPaintArea(); +} + +LoadingWidget::~LoadingWidget() +{ + +} + +void LoadingWidget::setMaxDiameter(const int aValue) +{ + mMaxDiameter = aValue; +} + +void LoadingWidget::setMinDiameter(const int aValue) +{ + mMinDiameter = aValue; +} + +void LoadingWidget::setColor(const QColor& aColor) +{ + mColor = aColor; +} + +void LoadingWidget::setCount(const int aCount) +{ + mCount = aCount; +} + +void LoadingWidget::resizeEvent(QResizeEvent *aEvent) +{ + QWidget::resizeEvent(aEvent); + initPaintArea(); +} + +void LoadingWidget::showEvent(QShowEvent *aEvent) +{ + QWidget::showEvent(aEvent); + mTimer->start(60); +} + +void LoadingWidget::hideEvent(QHideEvent *aEvent) +{ + QWidget::hideEvent(aEvent); + mTimer->stop(); +} + +void LoadingWidget::initPaintArea() +{ + double halfWidth = width() /2; + double halfHeight = height() /2; + double half = qMin(width(),height())/2; + double distance = half - mMaxDiameter/2 - 1; + + double gap = (mMaxDiameter - mMinDiameter)/(mCount-1)/2; + double angleGap = 360/mCount; + + mPointList.clear(); + mRadiusList.clear(); + + for(int i=0;i + +class QTimer; +class QColor; + +class LoadingWidget : public QWidget +{ +public: + explicit LoadingWidget(QWidget* aParent); + ~LoadingWidget() override; + + void setMaxDiameter(const int aValue); + void setMinDiameter(const int aValue); + void setColor(const QColor& aColor); + void setCount(const int aCount); + +protected: + void paintEvent(QPaintEvent *aEvent) override; + void resizeEvent(QResizeEvent *aEvent) override; + void showEvent(QShowEvent *aEvent) override; + void hideEvent(QHideEvent *aEvent) override; + +private: + void initPaintArea(); + +private: + QTimer* mTimer; + QColor mColor; + int mCount; + double mMaxDiameter; + double mMinDiameter; + QRect mPaintAreaRect; + QList mPointList; + QList mRadiusList; + int mStatus = 0; + + +}; + +#endif // LOADINGWIDGET_H diff --git a/src/components/ULineEdit.cpp b/src/components/ULineEdit.cpp index 8198f29..f86be0b 100644 --- a/src/components/ULineEdit.cpp +++ b/src/components/ULineEdit.cpp @@ -57,6 +57,7 @@ void ULineEdit::focusOutEvent(QFocusEvent* aEvent) QWidget* widget = QApplication::focusWidget(); if (nullptr == widget) { + KeyboardManager::getInstance()->hideKeyboard(); return; } diff --git a/src/components/UTextEdit.cpp b/src/components/UTextEdit.cpp index db0d346..015c131 100644 --- a/src/components/UTextEdit.cpp +++ b/src/components/UTextEdit.cpp @@ -57,6 +57,7 @@ void UTextEdit::focusOutEvent(QFocusEvent* aEvent) QWidget* widget = QApplication::focusWidget(); if (nullptr == widget) { + KeyboardManager::getInstance()->hideKeyboard(); return; } diff --git a/src/dialogs/AsyncActionDialog.cpp b/src/dialogs/AsyncActionDialog.cpp new file mode 100644 index 0000000..286f59d --- /dev/null +++ b/src/dialogs/AsyncActionDialog.cpp @@ -0,0 +1,73 @@ +#include "AsyncActionDialog.h" + +#include +#include + +#include "action/AsyncAction.h" +#include "components/LoadingWidget.h" + +AsyncActionDialog::AsyncActionDialog(AsyncAction* aAsyncAction,const QString& aTitle, QWidget* aParent, Qt::WindowFlags aFlags) + : GUIFormBaseDialog(aParent,aFlags) + , mContentWidget(new QWidget(mFormWidget)) + , mLoadingWidget(new QWidget(mFormWidget)) + , mAction(aAsyncAction) + , mLayout(new QVBoxLayout(mFormWidget)) +{ + setFocusPolicy(Qt::ClickFocus); + mLoadingWidget->hide(); + + initializeTitle(aTitle); + initializeProgressBar(); + connect(mAction,&AsyncAction::actionCompleted,this,&AsyncActionDialog::handleFinishedAction); + + mLayout->setSpacing(10); + mLayout->addWidget(mContentWidget); + mLayout->addWidget(mLoadingWidget); +} + +AsyncActionDialog::~AsyncActionDialog() +{ + +} + +void AsyncActionDialog::initializeTitle(const QString& aTitle) +{ + QLabel* title = new QLabel(this); + title->setAlignment(Qt::AlignCenter); + title->setText(tr(aTitle.toLatin1())); + title->setObjectName("title"); + title->setFixedHeight(40); + mLayout->addWidget(title); +} + +void AsyncActionDialog::initializeProgressBar() +{ + QVBoxLayout* loadingLayout = new QVBoxLayout(mLoadingWidget); + + LoadingWidget* loadingWidget = new LoadingWidget(mLoadingWidget); + loadingLayout->addWidget(loadingWidget); + +} + +AsyncAction* AsyncActionDialog::getAction() +{ + return mAction; +} + +bool AsyncActionDialog::updateReferenceData() +{ + mAction->execute(); + mContentWidget->hide(); + mBtnWidget->hide(); + mLoadingWidget->show(); + return false; +} + +void AsyncActionDialog::handleFinishedAction(const ActionResult& aResult) +{ + mLoadingWidget->hide(); + if (aResult.Code == Sucessed) + { + accept(); + } +} diff --git a/src/dialogs/AsyncActionDialog.h b/src/dialogs/AsyncActionDialog.h new file mode 100644 index 0000000..2516913 --- /dev/null +++ b/src/dialogs/AsyncActionDialog.h @@ -0,0 +1,39 @@ +#ifndef GUI_ASYNCACTIONDIALOG_H +#define GUI_ASYNCACTIONDIALOG_H + +#include "GUIFormBaseDialog.h" +#include "action/AsyncAction.h" + +class QVBoxLayout; + +class AsyncActionDialog : public GUIFormBaseDialog +{ + Q_OBJECT + +public: + AsyncActionDialog(AsyncAction* aAsyncAction,const QString& aTitle, QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags()); + ~AsyncActionDialog() override; + +protected: + AsyncAction* getAction(); + bool updateReferenceData() override; + +protected slots: + virtual void handleFinishedAction(const ActionResult& aResult); + +private: + void initializeTitle(const QString& aTitle); + void initializeProgressBar(); + +protected: + QWidget* mContentWidget; + QWidget* mLoadingWidget; + +private: + AsyncAction* mAction; + QVBoxLayout* mLayout; + +}; + + +#endif //GUI_ASYNCACTIONDIALOG_H diff --git a/src/dialogs/DialogManager.cpp b/src/dialogs/DialogManager.cpp index f8acb48..fa56eae 100644 --- a/src/dialogs/DialogManager.cpp +++ b/src/dialogs/DialogManager.cpp @@ -16,6 +16,7 @@ #include "dialogs/AlertDialog.h" #include "dialogs/DateSelectDialog.h" #include "dialogs/SelectDialog.h" +#include "dialogs/GetWorkListDialog.h" #include "network/DicomCfgDialog.h" #include "network/GetAdminPsw.h" @@ -295,6 +296,16 @@ DialogResult DialogManager::requestEditRouteInfo(const QStringList& aEditData) return DialogResult(ret,dialog.getList()); } +int DialogManager::requestGetWorkList(QSqlTableModel* aModel) +{ + GetWorkListDialog dialog(aModel,mTopWidget); + setTopWidget(&dialog); + dialog.setWindowModality(Qt::WindowModal); + int ret = dialog.exec(); + releaseTopWidget(&dialog); + return ret; +} + void DialogManager::raiseDeviceInfo(QObject* parent, QObject* aInfoData) { QPair* infoData = (QPair*)(aInfoData); diff --git a/src/dialogs/DialogManager.h b/src/dialogs/DialogManager.h index 76b871c..7a1b683 100644 --- a/src/dialogs/DialogManager.h +++ b/src/dialogs/DialogManager.h @@ -58,6 +58,7 @@ public: int requestEditDicomConfig(); int requestInputAdminPasswd(); int requestEditNetworkConfig(); + int requestGetWorkList(QSqlTableModel* aModel); DialogResult requestEditIpAndNetMask(); DialogResult requestEditIpAndNetMask(const QStringList& aEditData); DialogResult requestEditRouteInfo(); diff --git a/src/dialogs/GetWorkListDialog.cpp b/src/dialogs/GetWorkListDialog.cpp new file mode 100644 index 0000000..69a1c4e --- /dev/null +++ b/src/dialogs/GetWorkListDialog.cpp @@ -0,0 +1,86 @@ +#include "GetWorkListDialog.h" + +#include +#include +#include + +#include "components/ULineEdit.h" +#include "action/GetWorkListAction.h" +#include "action/ActionCreator.h" + +GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, 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)) +{ + initializeContentWidgets(); + GetWorkListAction* action = qobject_cast(getAction()); + if (action != nullptr) + { + action->setSqlModel(aSqlModel); + } +} + +GetWorkListDialog::~GetWorkListDialog() +{ +} + +void GetWorkListDialog::initializeContentWidgets() +{ + QVBoxLayout* contentLayout = new QVBoxLayout(mContentWidget); + //Accession Nummber + QLabel* accessionNumText = new QLabel(mContentWidget); + accessionNumText->setText(tr("Accession Nummber")); + contentLayout->addWidget(accessionNumText); + contentLayout->addWidget(mAccessionNumber); + QLabel* endLine1 = new QLabel(mContentWidget); + endLine1->setObjectName("endline"); + contentLayout->addWidget(endLine1); + + //PatientId + QLabel* patientIdText = new QLabel(mContentWidget); + patientIdText->setText(tr("Patient ID")); + contentLayout->addWidget(patientIdText); + contentLayout->addWidget(mPatientId); + QLabel* endLine2 = new QLabel(mContentWidget); + endLine2->setObjectName("endline"); + contentLayout->addWidget(endLine2); + + //ErrorLabel + contentLayout->addWidget(mErrorLabel); + mErrorLabel->setObjectName("warn"); + mErrorLabel->hide(); +} + +bool GetWorkListDialog::updateReferenceData() +{ + QString accessionNum = mAccessionNumber->text(); + QString patientId = mPatientId->text(); + if (accessionNum.isEmpty() && patientId.isEmpty()) + { + mErrorLabel->setText(tr("Accession Number and Patient Id is Empty.")); + 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.Message); + mContentWidget->show(); + mBtnWidget->show(); + mErrorLabel->show(); + } + AsyncActionDialog::handleFinishedAction(aResult); +} diff --git a/src/dialogs/GetWorkListDialog.h b/src/dialogs/GetWorkListDialog.h new file mode 100644 index 0000000..2be3f5c --- /dev/null +++ b/src/dialogs/GetWorkListDialog.h @@ -0,0 +1,32 @@ +#ifndef GUI_GETWORKLISTDIALOG_H +#define GUI_GETWORKLISTDIALOG_H + +#include "dialogs/AsyncActionDialog.h" + +class ULineEdit; +class QLabel; +class QSqlTableModel; + +class GetWorkListDialog : public AsyncActionDialog +{ + Q_OBJECT + +public: + explicit GetWorkListDialog(QSqlTableModel* aSqlModel, QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags()); + ~GetWorkListDialog() override; + +protected: + bool updateReferenceData() override; + +private: + void initializeContentWidgets(); + virtual void handleFinishedAction(const ActionResult& aResult) override; + +private: + ULineEdit* mAccessionNumber; + ULineEdit* mPatientId; + QLabel* mErrorLabel; + +}; + +#endif //GUI_GETWORKLISTDIALOG_H diff --git a/src/dicom/WorkListManager.cpp b/src/dicom/WorkListManager.cpp new file mode 100644 index 0000000..fa8137a --- /dev/null +++ b/src/dicom/WorkListManager.cpp @@ -0,0 +1,148 @@ +#include "WorkListManager.h" + +#include +#include +#include "json/jsonobject.h" + +#include + +WorkListManager::WorkListManager() +{ +} + +WorkListManager::~WorkListManager() +{ +} + +PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId) +{ + DcmSCU scu; + OFString temp_str; + host serverInfo = JsonObject::Instance()->getServer(JsonObject::WORKLIST); + QByteArray ip = serverInfo.ip.toLatin1(); + QByteArray aeTitle = serverInfo.ae.toLatin1(); + OFList overrideKeys; + overrideKeys.push_back(OFString((QString("0008,0050=") + aAccessionNum).toLatin1())); + overrideKeys.push_back(OFString((QString("0010,0020=") + aPatientId).toLatin1())); + overrideKeys.push_back("0010,0010"); + overrideKeys.push_back("0010,0030"); + overrideKeys.push_back("0010,0040"); + if (!dcmDataDict.isDictionaryLoaded()) + { + qDebug()<<"dcmdatadict error"; + } + /* scu*/ + OFList syntaxes; + syntaxes.push_back(UID_LittleEndianImplicitTransferSyntax); + scu.setMaxReceivePDULength(ASC_DEFAULTMAXPDU); + scu.setACSETimeout(30); + scu.setDIMSEBlockingMode(DIMSE_BLOCKING); + scu.setDIMSETimeout(0); + scu.setAETitle("USCT"); + scu.setPeerHostName(ip.data()); + scu.setPeerPort(OFstatic_cast(Uint16, serverInfo.port.toInt())); + scu.setPeerAETitle(aeTitle.data()); + scu.setVerbosePCMode(OFFalse); + scu.addPresentationContext(UID_FINDModalityWorklistInformationModel, syntaxes);//UID_FINDStudyRootQueryRetrieveInformationModel + OFCondition cond = scu.initNetwork(); + + if(cond.bad()) + { + qDebug()< responses; + //ѯ + DcmPathProcessor proc; + proc.setItemWildcardSupport(OFFalse); + proc.checkPrivateReservations(OFFalse); + + for(auto &item:overrideKeys) + { + proc.applyPathWithValue(dset, item); + } + + + PatientInformationPointer result = PatientInformationPointer(new PatientInformation()); + cond = scu.sendFINDRequest(pcid, dset, &responses); + if (!responses.empty()) + { + auto item = *responses.begin(); + if (item->m_dataset) + { + OFString ID; + OFString Name; + OFString BirthDate; + OFString Sex; + item->m_dataset->findAndGetOFString(DCM_PatientID, ID); + if (ID.empty()) + { + return PatientInformationPointer(); + } + item->m_dataset->findAndGetOFString(DCM_PatientName, Name); + item->m_dataset->findAndGetOFString(DCM_PatientBirthDate, BirthDate); + item->m_dataset->findAndGetOFString(DCM_PatientSex, Sex); + result->ID = QString(ID.c_str()); + result->Name = QString(Name.c_str()); + result->BirthDate = QString(BirthDate.c_str()).insert(4,"-").insert(7,"-"); + result->Sex = QString(Sex.c_str()); + //if (patientName.bad()) + //{ + // std::cout << patientName.text() << std::endl; + //} + } + else + { + return PatientInformationPointer(); + } + + OFListIterator(QRResponse*) iter = responses.begin(); + OFListConstIterator(QRResponse*) last = responses.end(); + while (iter != last) + { + delete (*iter); + iter = responses.erase(iter); + } + } + else + { + return PatientInformationPointer(); + } + + if (cond == EC_Normal) + { + scu.releaseAssociation(); + } + else + { + if (cond == DUL_PEERREQUESTEDRELEASE) + scu.closeAssociation(DCMSCU_PEER_REQUESTED_RELEASE); + else if (cond == DUL_PEERABORTEDASSOCIATION) + scu.closeAssociation(DCMSCU_PEER_ABORTED_ASSOCIATION); + else + { + scu.abortAssociation(); + } + + } + return result; +} diff --git a/src/dicom/WorkListManager.h b/src/dicom/WorkListManager.h new file mode 100644 index 0000000..a582081 --- /dev/null +++ b/src/dicom/WorkListManager.h @@ -0,0 +1,18 @@ +#ifndef GUI_WORKLISTMANAGER_H +#define GUI_WORKLISTMANAGER_H + +#include + +#include "forms/select/PatientInformation.h" + +class WorkListManager +{ +public: + WorkListManager(); + ~WorkListManager(); + + static PatientInformationPointer getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId); + +}; + +#endif //GUI_WORKLISTMANAGER_H \ No newline at end of file diff --git a/src/forms/select/PatientInformation.h b/src/forms/select/PatientInformation.h index cf1247a..abb835b 100644 --- a/src/forms/select/PatientInformation.h +++ b/src/forms/select/PatientInformation.h @@ -23,6 +23,9 @@ enum PatientInformationEnum{ #undef ADD_PATIENT_PROPERTY }; +#include +#include + /** * @brief this class was designed to be a edit form, * but now has been change to a detail display class. @@ -33,7 +36,9 @@ public: #define ADD_PATIENT_PROPERTY(val) QString val; EDIT_PATIENT(); #undef ADD_PATIENT_PROPERTY - PatientInformation(){ + PatientInformation() + : QObject() + { this->Flag = QString("0"); } PatientInformation* Copy() @@ -48,4 +53,5 @@ public: return n; } }; +typedef QSharedPointer PatientInformationPointer; #endif //GUI_PATIENTINFORMATION_H diff --git a/src/forms/select/SelectFormWidget.cpp b/src/forms/select/SelectFormWidget.cpp index 19a9016..b4aae6d 100644 --- a/src/forms/select/SelectFormWidget.cpp +++ b/src/forms/select/SelectFormWidget.cpp @@ -83,6 +83,13 @@ void SelectFormWidget::initGeneralButtons(QHBoxLayout *layout) { layout->addWidget(mBtnWorklist); // mBtn account slot connect(mBtnAccount, &QToolButton::clicked, DialogManager::Default(),&DialogManager::requestEditSelfAccount); + connect(mBtnWorklist, &QToolButton::clicked, [&]() + { + if (DialogManager::Default()->requestGetWorkList(mModel) == QDialog::Accepted) + { + mPatTable->selectRow(0); + } + }); } void SelectFormWidget::initPatEditButtons(QHBoxLayout *layout) { @@ -140,7 +147,8 @@ void SelectFormWidget::delPatient() { if (DialogManager::Default()->requestAlertMessage(QString(tr("Delete Patient \"%1\" ?")).arg(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->setData(mModel->index(mPatTable->currentIndex().row(), Flag), 9); + mModel->removeRow(mPatTable->currentIndex().row()); if (mModel->submitAll()) { mModel->select(); @@ -229,7 +237,6 @@ void SelectFormWidget::initTableView(QHBoxLayout *contentLayout) {// TableView f void SelectFormWidget::initDataModel() {//TODO:单独初始化预防SQL错误 mModel = SQLHelper::getTable("Patient"); - mModel->setFilter("Flag=0"); mModel->sort(5, Qt::DescendingOrder); mModel->select(); mModel->setHeaderData(1, Qt::Horizontal, "ID"); diff --git a/src/main.cpp b/src/main.cpp index 14ece5b..ab3b9f2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include #include "dialogs/DialogManager.h" #include "dialogs/MultyMessageDialogManager.h" +#include "action/AsyncAction.h" #include "json/jsonobject.h" #include "src/utilities/Locker.h" #include "src/utilities/LanguageSwitcher.h" @@ -47,6 +48,9 @@ int main(int argc, char* argv[]) UsctApplication a(argc, argv); qRegisterMetaType>("QPair"); + qRegisterMetaType("Qt::Orientation"); + qRegisterMetaType("ActionResult"); + QString layouts_path = QString(QCoreApplication::applicationDirPath()).append("/layouts"); qputenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH", QByteArray(layouts_path.toStdString().c_str()));