Add WorkList Module.
This commit is contained in:
148
src/dicom/WorkListManager.cpp
Normal file
148
src/dicom/WorkListManager.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
#include "WorkListManager.h"
|
||||
|
||||
#include <dcmtk/dcmnet/scu.h>
|
||||
#include <dcmtk/dcmdata/dcpath.h>
|
||||
#include "json/jsonobject.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
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<OFString> 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";
|
||||
}
|
||||
/*<2A><><EFBFBD><EFBFBD> scu*/
|
||||
OFList<OFString> 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()<<cond.code() <<cond.text();
|
||||
qDebug()<<"worklist initNetwork failed";
|
||||
return PatientInformationPointer();
|
||||
}
|
||||
cond = scu.negotiateAssociation();
|
||||
if(cond.bad())
|
||||
{
|
||||
qDebug()<<cond.code();//<< "----"<<cond.text();
|
||||
qDebug()<<"worklist connect failed";
|
||||
return PatientInformationPointer();
|
||||
}
|
||||
|
||||
cond = EC_Normal;
|
||||
T_ASC_PresentationContextID pcid = scu.findPresentationContextID(UID_FINDModalityWorklistInformationModel,"");
|
||||
if (pcid == 0)
|
||||
{
|
||||
qDebug()<<"worklist pcid bad";
|
||||
return PatientInformationPointer();
|
||||
}
|
||||
|
||||
DcmFileFormat dcmff;
|
||||
DcmDataset *dset = dcmff.getDataset();
|
||||
OFList<QRResponse*> responses;
|
||||
//<2F><>ѯ
|
||||
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;
|
||||
}
|
||||
18
src/dicom/WorkListManager.h
Normal file
18
src/dicom/WorkListManager.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef GUI_WORKLISTMANAGER_H
|
||||
#define GUI_WORKLISTMANAGER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "forms/select/PatientInformation.h"
|
||||
|
||||
class WorkListManager
|
||||
{
|
||||
public:
|
||||
WorkListManager();
|
||||
~WorkListManager();
|
||||
|
||||
static PatientInformationPointer getPatientFromWorkList(const QString& aAccessionNum, const QString& aPatientId);
|
||||
|
||||
};
|
||||
|
||||
#endif //GUI_WORKLISTMANAGER_H
|
||||
Reference in New Issue
Block a user