Enable the worklist to retrieve more results based on different combinations of Patient ID and accession number.

This commit is contained in:
sunwen
2023-08-28 16:31:52 +08:00
parent 89ccd96278
commit 52605ed981
11 changed files with 239 additions and 113 deletions

View File

@@ -2,7 +2,7 @@
#define GUI_ASYNCACTION_H
#include <QObject>
#include <QString>
#include <QVariant>
#include <QRunnable>
#include <QSharedPointer>
@@ -14,13 +14,13 @@ enum ActionCode :unsigned int
class ActionResult
{
public:
ActionResult(ActionCode aCode = Sucessed, const QString& aMessage = "")
ActionResult(ActionCode aCode = Sucessed, const QVariant& aData = QVariant())
{
Code = aCode;
Message = aMessage;
Data = aData;
}
ActionCode Code;
QString Message;
QVariant Data;
};
class AsyncAction : public QObject, public QRunnable

View File

@@ -1,11 +1,6 @@
#include "GetWorkListAction.h"
#include "dicom/WorkListManager.h"
#include <QThread>
#include <QDateTime>
#include <QSqlTableModel>
#include <QUuid>
#include <QDebug>
#include "forms/select/PatientInformation.h"
GetWorkListAction::GetWorkListAction(QObject* aParent)
: AsyncAction(aParent)
@@ -23,8 +18,15 @@ void GetWorkListAction::run()
{
if (!mQueryData.isEmpty())
{
PatientInformationPointer info = WorkListManager::getPatientFromWorkList(mQueryData.mAccessionNum, mQueryData.mPatientId);
emit actionCompleted(insertPatientFromWorkList(info));
QList<PatientInformationPointer> patients = WorkListManager::getPatientFromWorkList(mQueryData.mAccessionNum, mQueryData.mPatientId);
if(patients.isEmpty())
{
emit actionCompleted(ActionResult(Failed,tr("WorkList Search Failed")));
}
else
{
emit actionCompleted(ActionResult(Sucessed, QVariant::fromValue(patients)));
}
}
else
{
@@ -41,37 +43,3 @@ 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"));;
}
}

View File

@@ -2,7 +2,6 @@
#define GUI_GETWORKLISTACTION_H
#include "AsyncAction.h"
#include "forms/select/PatientInformation.h"
class QSqlTableModel;
@@ -35,8 +34,6 @@ public:
void setWorkListQueryData(const WorkListQueryData& aQueryData);
void setSqlModel(QSqlTableModel* aSqlModel);
private:
ActionResult insertPatientFromWorkList(PatientInformationPointer aPatientInformation);
private:
WorkListQueryData mQueryData;

View File

@@ -313,9 +313,9 @@ DialogResult DialogManager::requestEditRouteInfo(const QStringList& aEditData)
return DialogResult(ret,dialog.getList());
}
int DialogManager::requestGetWorkList(QSqlTableModel* aModel)
int DialogManager::requestGetWorkList(QSqlTableModel* aModel, QTableView* aTableView)
{
GetWorkListDialog dialog(aModel,mTopWidget);
GetWorkListDialog dialog(aModel, aTableView, mTopWidget);
setTopWidget(&dialog);
dialog.setWindowModality(Qt::WindowModal);
int ret = dialog.exec();

View File

@@ -14,6 +14,7 @@
class GUIMessageDialog;
class QSqlTableModel;
class QTableView;
class PatientInformation;
class LoginDialog;
class ScreenSaverWindow;
@@ -59,7 +60,7 @@ public:
int requestEditDicomConfig();
int requestInputAdminPasswd();
int requestEditNetworkConfig();
int requestGetWorkList(QSqlTableModel* aModel);
int requestGetWorkList(QSqlTableModel* aModel, QTableView* aTableView);
DialogResult requestEditIpAndNetMask();
DialogResult requestEditIpAndNetMask(const QStringList& aEditData);
DialogResult requestEditRouteInfo();

View File

@@ -2,17 +2,33 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QTableView>
#include <QStandardItemModel>
#include <QLabel>
#include <QSqlTableModel>
#include <QUuid>
#include <QDateTime>
#include <QSqlRecord>
#include "components/ULineEdit.h"
#include "action/GetWorkListAction.h"
#include "action/ActionCreator.h"
GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QWidget* aParent, Qt::WindowFlags aFlags)
GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent, Qt::WindowFlags aFlags)
: AsyncActionDialog(ActionCreator::getAsyncAction<GetWorkListAction>("GetWorkListAction"),"Work List", aParent, aFlags)
, mAccessionNumber(new ULineEdit(mContentWidget))
, mPatientId(new ULineEdit(mContentWidget))
, mErrorLabel(new QLabel(mContentWidget))
, mAccessionNumText(new QLabel(mContentWidget))
, mAccessionNumEndLine(new QLabel(mContentWidget))
, mPatientIDText(new QLabel(mContentWidget))
, mPatientIDLine(new QLabel(mContentWidget))
, mPatientSelectTable(new QTableView(mContentWidget))
, mMode(PatientSearchMode)
, mPatientSelectModel(new QStandardItemModel(mContentWidget))
, mSqlModel(aSqlModel)
, mTableView(aTableView)
, mSearchedPatients()
{
initializeContentWidgets();
GetWorkListAction* action = qobject_cast<GetWorkListAction*>(getAction());
@@ -30,22 +46,41 @@ void GetWorkListDialog::initializeContentWidgets()
{
QVBoxLayout* contentLayout = new QVBoxLayout(mContentWidget);
//Accession Nummber
QLabel* accessionNumText = new QLabel(mContentWidget);
accessionNumText->setText(tr("Accession Nummber"));
contentLayout->addWidget(accessionNumText);
mAccessionNumText->setText(tr("Accession Nummber"));
contentLayout->addWidget(mAccessionNumText);
contentLayout->addWidget(mAccessionNumber);
QLabel* endLine1 = new QLabel(mContentWidget);
endLine1->setObjectName("endline");
contentLayout->addWidget(endLine1);
mAccessionNumEndLine->setObjectName("endline");
contentLayout->addWidget(mAccessionNumEndLine);
//PatientId
QLabel* patientIdText = new QLabel(mContentWidget);
patientIdText->setText(tr("Patient ID"));
contentLayout->addWidget(patientIdText);
mPatientIDText->setText(tr("Patient ID"));
contentLayout->addWidget(mPatientIDText);
contentLayout->addWidget(mPatientId);
QLabel* endLine2 = new QLabel(mContentWidget);
endLine2->setObjectName("endline");
contentLayout->addWidget(endLine2);
mPatientIDLine->setObjectName("endline");
contentLayout->addWidget(mPatientIDLine);
//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();
//ErrorLabel
contentLayout->addWidget(mErrorLabel);
@@ -55,6 +90,11 @@ void GetWorkListDialog::initializeContentWidgets()
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())
@@ -77,10 +117,108 @@ void GetWorkListDialog::handleFinishedAction(const ActionResult& aResult)
{
if (aResult.Code == Failed)
{
mErrorLabel->setText(aResult.Message);
mErrorLabel->setText(aResult.Data.toString());
mContentWidget->show();
mBtnWidget->show();
mErrorLabel->show();
return;
}
mSearchedPatients = aResult.Data.value<QList<PatientInformationPointer>>();
if(mSearchedPatients.size() > 1)
{
updatePatientSelectTable();
}
else if(mSearchedPatients.size() == 1)
{
insertPatient(mSearchedPatients.at(0));
AsyncActionDialog::handleFinishedAction(aResult);
}
}
void GetWorkListDialog::updatePatientSelectTable()
{
int rowCount = mSearchedPatients.size();
mPatientSelectModel->setRowCount(rowCount);
for(int i=0; i<rowCount; ++i)
{
PatientInformationPointer patient = mSearchedPatients.at(i);
QModelIndex index = mPatientSelectModel->index(i, 0, QModelIndex());
mPatientSelectModel->setData(index, patient->ID);
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, 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;
mAccessionNumber->hide();
mPatientId->hide();
mErrorLabel->hide();
mAccessionNumText->hide();
mAccessionNumEndLine->hide();
mPatientIDText->hide();
mPatientIDLine->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);
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);
EDIT_PATIENT()
#undef ADD_PATIENT_PROPERTY
if (!mSqlModel->submitAll())
{
mErrorLabel->setText( tr("DB Error,Patient Write Failed"));
mErrorLabel->show();
}
mTableView->selectRow(0);
}

View File

@@ -2,17 +2,25 @@
#define GUI_GETWORKLISTDIALOG_H
#include "dialogs/AsyncActionDialog.h"
#include "forms/select/PatientInformation.h"
class ULineEdit;
class QLabel;
class QSqlTableModel;
class QTableView;
class QStandardItemModel;
enum GetWorkListDialogMode
{
PatientSearchMode = 0, PatientSelectMode
};
class GetWorkListDialog : public AsyncActionDialog
{
Q_OBJECT
public:
explicit GetWorkListDialog(QSqlTableModel* aSqlModel, QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags());
explicit GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags());
~GetWorkListDialog() override;
protected:
@@ -20,12 +28,25 @@ protected:
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* mAccessionNumEndLine;
QLabel* mPatientIDText;
QLabel* mPatientIDLine;
QTableView* mPatientSelectTable;
GetWorkListDialogMode mMode;
QStandardItemModel* mPatientSelectModel;
QSqlTableModel* mSqlModel;
QTableView* mTableView;
QList<PatientInformationPointer> mSearchedPatients;
};

View File

@@ -5,6 +5,7 @@
#include "json/jsonobject.h"
#include <QDebug>
#include <QDate>
WorkListManager::WorkListManager()
{
@@ -14,7 +15,7 @@ WorkListManager::~WorkListManager()
{
}
PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId)
QList<PatientInformationPointer> WorkListManager::getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId)
{
DcmSCU scu;
OFString temp_str;
@@ -27,6 +28,7 @@ PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString&
overrideKeys.push_back("0010,0010");
overrideKeys.push_back("0010,0030");
overrideKeys.push_back("0010,0040");
overrideKeys.push_back("0040,0002");
if (!dcmDataDict.isDictionaryLoaded())
{
qDebug()<<"dcmdatadict error";
@@ -38,7 +40,7 @@ PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString&
scu.setACSETimeout(30);
scu.setDIMSEBlockingMode(DIMSE_BLOCKING);
scu.setDIMSETimeout(0);
scu.setAETitle("USCT");
scu.setAETitle(serverInfo.name.toLatin1().data());
scu.setPeerHostName(ip.data());
scu.setPeerPort(OFstatic_cast(Uint16, serverInfo.port.toInt()));
scu.setPeerAETitle(aeTitle.data());
@@ -50,14 +52,14 @@ PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString&
{
qDebug()<<cond.code() <<cond.text();
qDebug()<<"worklist initNetwork failed";
return PatientInformationPointer();
return QList<PatientInformationPointer>();
}
cond = scu.negotiateAssociation();
if(cond.bad())
{
qDebug()<<cond.code();//<< "----"<<cond.text();
qDebug()<<"worklist connect failed";
return PatientInformationPointer();
return QList<PatientInformationPointer>();
}
cond = EC_Normal;
@@ -65,7 +67,7 @@ PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString&
if (pcid == 0)
{
qDebug()<<"worklist pcid bad";
return PatientInformationPointer();
return QList<PatientInformationPointer>();
}
DcmFileFormat dcmff;
@@ -79,42 +81,41 @@ PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString&
{
proc.applyPathWithValue(dset, item);
}
PatientInformationPointer result = PatientInformationPointer(new PatientInformation());
QList<PatientInformationPointer> result;
cond = scu.sendFINDRequest(pcid, dset, &responses);
if (!responses.empty())
if (responses.size() > 1)
{
auto item = *responses.begin();
if (item->m_dataset)
for(auto item = responses.begin(); item != responses.end(); ++item)
{
if ((*item)->m_dataset)
{
PatientInformationPointer patient = PatientInformationPointer(new PatientInformation());
OFString ID;
OFString Name;
OFString BirthDate;
OFString Sex;
OFString AccessionNumber;
item->m_dataset->findAndGetOFString(DCM_PatientID, ID);
OFString scheduledStartDateStr;
(*item)->m_dataset->findAndGetOFString(DCM_PatientID, ID);
if (ID.empty())
{
return PatientInformationPointer();
return QList<PatientInformationPointer>();
}
item->m_dataset->findAndGetOFString(DCM_PatientName, Name);
item->m_dataset->findAndGetOFString(DCM_PatientBirthDate, BirthDate);
item->m_dataset->findAndGetOFString(DCM_PatientSex, Sex);
item->m_dataset->findAndGetOFString(DCM_AccessionNumber, AccessionNumber);
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());
result->AccessionNumber = QString(AccessionNumber.c_str());
//if (patientName.bad())
//{
// std::cout << patientName.text() << std::endl;
//}
(*item)->m_dataset->findAndGetOFString(DCM_PatientName, Name);
(*item)->m_dataset->findAndGetOFString(DCM_PatientBirthDate, BirthDate);
(*item)->m_dataset->findAndGetOFString(DCM_PatientSex, Sex);
(*item)->m_dataset->findAndGetOFString(DCM_AccessionNumber, AccessionNumber);
(*item)->m_dataset->findAndGetOFString(DCM_ScheduledProcedureStepStartDate, scheduledStartDateStr);
//(*item)->m_dataset->print(std::cerr);
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());
result.push_back(patient);
}
else
{
return PatientInformationPointer();
}
OFListIterator(QRResponse*) iter = responses.begin();
@@ -127,7 +128,7 @@ PatientInformationPointer WorkListManager::getPatientFromWorkList(const QString&
}
else
{
return PatientInformationPointer();
return QList<PatientInformationPointer>();
}
if (cond == EC_Normal)

View File

@@ -2,6 +2,7 @@
#define GUI_WORKLISTMANAGER_H
#include <QString>
#include <QList>
#include "forms/select/PatientInformation.h"
@@ -11,7 +12,7 @@ public:
WorkListManager();
~WorkListManager();
static PatientInformationPointer getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId);
static QList<PatientInformationPointer> getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId);
};

View File

@@ -40,6 +40,7 @@ public:
: QObject()
{
}
QString ScheduledStartDate;
PatientInformation* Copy()
{
PatientInformation* n=new PatientInformation;

View File

@@ -10,6 +10,7 @@
#include <QHeaderView>
#include <QUuid>
#include <QDate>
#include <QSqlRecord>
#include <QDebug>
#include "components/SlideTableView.h"
@@ -85,10 +86,7 @@ void SelectFormWidget::initGeneralButtons(QHBoxLayout *layout) {
connect(mBtnAccount, &QToolButton::clicked, DialogManager::Default(),&DialogManager::requestEditSelfAccount);
connect(mBtnWorklist, &QToolButton::clicked, [&]()
{
if (DialogManager::Default()->requestGetWorkList(mModel) == QDialog::Accepted)
{
mPatTable->selectRow(0);
}
DialogManager::Default()->requestGetWorkList(mModel, mPatTable);
});
}
@@ -237,7 +235,7 @@ void SelectFormWidget::initTableView(QHBoxLayout *contentLayout) {// TableView f
void SelectFormWidget::initDataModel() {//TODO:单独初始化预防SQL错误
mModel = SQLHelper::getTable("Patient");
mModel->sort(5, Qt::DescendingOrder);
mModel->sort(mModel->record().indexOf("AddDate"), Qt::DescendingOrder);
mModel->select();
mModel->setHeaderData(1, Qt::Horizontal, "ID");
mModel->setHeaderData(2, Qt::Horizontal, tr("AccessionNumber"));