]> Creatis software - clitk.git/commitdiff
simplify query/retrieve calls
authorcervenansky <frederic.cervenansky@creatis.insa-lyon.fr>
Tue, 16 Jul 2013 10:08:50 +0000 (12:08 +0200)
committercervenansky <frederic.cervenansky@creatis.insa-lyon.fr>
Tue, 16 Jul 2013 10:08:50 +0000 (12:08 +0200)
vv/vvQPacsConnection.cxx
vv/vvQPacsConnection.h

index 9a65bbd5a4062e8b8dea9167f1a5152dce152784..cda824e6e9f5c51feb8edeac029fca1892dbf789 100644 (file)
@@ -76,16 +76,16 @@ void vvQPacsConnection::on_scanButton_clicked()
        manageStudiesFilter(true);
 
        // test first if echo works
-       bool didItWork = gdcm::CompositeNetworkFunctions::CEcho(m_adress.c_str(), atoi(m_port.c_str()), "CREATIS", m_nickname.c_str() );
+       bool didItWork = gdcm::CompositeNetworkFunctions::CEcho(m_adress.c_str(), atoi(m_port.c_str()), getDicomClientAETitle().c_str(), m_nickname.c_str() );
        if (didItWork)
        {
                m_level =gdcm::ePatient;
                std::vector<gdcm::DataSet> theDataSet;
-               gdcm::EQueryLevel theLevel = gdcm::ePatient;
-               gdcm::ERootType theRoot  = gdcm::ePatientRootType;//ePatientRootType;
-               m_query =  gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,
-                                                       getPatientKeys(ui.patientName->toPlainText().toStdString(),     ui.patientID->toPlainText().toStdString()));
-               bool cfindWork = gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), m_query, theDataSet,    "CREATIS", m_nickname.c_str());
+               f_query = getQueryPatient(ui.patientName->toPlainText().toStdString(),  ui.patientID->toPlainText().toStdString());
+
+               bool cfindWork = gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), 
+                       gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys),
+                       theDataSet, getDicomClientAETitle().c_str()     , m_nickname.c_str());
                if( cfindWork)
                {
                        convertDataSet(theDataSet,Patientmodel,getPatientKeys("",""));
@@ -94,7 +94,7 @@ void vvQPacsConnection::on_scanButton_clicked()
 }
 
 
-
+/// show Options DialogBox to set a new Dicom Server
 void vvQPacsConnection::on_optionsButton_clicked()
 {
        vvPacsSettingsDialog *dg  = new vvPacsSettingsDialog(this);
@@ -153,6 +153,7 @@ void vvQPacsConnection::createTreeView()
        Studylist.push_back(tr("DESCRIPTION"));
        Studylist.push_back(tr("DATE"));
        Studylist.push_back(tr("HOUR"));
+       Studylist.push_back(tr("STUDY ID"));
        Studymodel->setHorizontalHeaderLabels(Studylist);
        ui.studyTreeView->setModel(Studymodel);
        connect(ui.studyTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectSeries(QModelIndex)));
@@ -189,22 +190,29 @@ void vvQPacsConnection::cleanTree()
 
 void vvQPacsConnection::selectStudies(const QModelIndex &index)
 {
-       m_level =gdcm::eStudy;
+
+                       
        Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex());
        QVariant elt= Patientmodel->data(index.sibling(index.row(),1));
        m_patient=elt.toString().toStdString();
        manageSeriesFilter(true);
        
        std::vector<gdcm::DataSet> theDataSet;
-        m_query = mquery.composeQueryStudy(m_patient);
+                m_query = getQueryPatient("",m_patient);
+        f_query = getQueryforStudy(m_patient);
+                
+                
        if (  gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), 
-               m_query, theDataSet, "CREATIS", m_nickname.c_str()) )
+               gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys)
+               , theDataSet, getDicomClientAETitle().c_str(), m_nickname.c_str()) )
        {
                convertDataSet(theDataSet, Studymodel, getStudyKeys(""));
        }
 }
 
 
+
+
 void vvQPacsConnection::selectSeries(const QModelIndex &index)
 {
        m_level =gdcm::eSeries;
@@ -229,8 +237,10 @@ void vvQPacsConnection::selectSeries(const QModelIndex &index)
        keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString()));
        // Acceptance NUmber????
        keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), elt.toString().toStdString()));
-       m_query = mquery.composeQuerySeries(keys);
-       if ( gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), m_query, theDataSet, "CREATIS", m_nickname.c_str()), "C:\\Boost")
+       f_query =getQueryforSeries(elt.toString().toStdString());
+       if ( gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), 
+               gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys), theDataSet, 
+                getDicomClientAETitle().c_str(), m_nickname.c_str()))
        {
                keys.clear();
        // Modality
@@ -298,6 +308,16 @@ void vvQPacsConnection::manageSeriesFilter(bool i_enable)
        ui.modalityTab->setEnabled(i_enable);
 }
 
+vvQuery vvQPacsConnection::getQueryPatient(const std::string i_patname, const std::string i_patid)
+{
+       vvQuery query;
+       query.theRoot = gdcm::ePatientRootType;
+       query.theLevel = gdcm::ePatient;
+       query.keys = getPatientKeys(i_patname, i_patid);
+       return query;
+
+}
+
 std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getPatientKeys(const std::string i_patname, const std::string i_patid)
 {
        std::vector< std::pair<gdcm::Tag, std::string> > keys;
@@ -330,8 +350,15 @@ std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getStudyKeys
        return keys;
 }
 
-
-std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getSeriesKeys(const std::string i_val)
+vvQuery vvQPacsConnection::getQueryforSeries(const std::string study_id)
+{
+       vvQuery query;
+       query.theRoot = gdcm::ePatientRootType;
+       query.theLevel = gdcm::eSeries;
+       query.keys = getSeriesKeys(study_id);
+       return query;
+}
+std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getSeriesKeys(const std::string study_id)
 {
        std::vector< std::pair<gdcm::Tag, std::string> > keys;
        // Modality
@@ -345,7 +372,7 @@ std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getSeriesKey
        keys.push_back(std::make_pair(tagsdh, ""));
        // Study Instance UID
        gdcm::Tag tagsid(0x0020,0x1209);
-       keys.push_back(std::make_pair(tagsid, i_val));
+       keys.push_back(std::make_pair(tagsid, study_id));
 
        return keys;
 }
@@ -440,34 +467,11 @@ void vvQPacsConnection::chooseServer(int index)
 
 void vvQPacsConnection::on_importButton_clicked()
        {
-               int sel = 0;
-               //QModelIndexList list = ui.imagesTreeView-selectedIndexes();
-               QModelIndexList indices =  ui.imagesTreeView->selectionModel()->selectedRows(); 
-               QModelIndexList::iterator it = indices.begin();
-               for(; it != indices.end(); it++)
-                       sel = it->row();
-               QModelIndex index;
-               QVariant elt= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1));
-               
-
-               gdcm::ERootType theRoot  = gdcm::ePatientRootType;//ePatientRootType;
-               std::vector<gdcm::DataSet> theDataSet;
-               std::vector< std::pair<gdcm::Tag, std::string> > keys;
-
-
-               // Study Description
-       //      gdcm::Tag tagsdc(0x0010,0x0020);
-               //keys.push_back(std::make_pair(tagsdc, elt.toString().toStdString()));
-
        
-       // Study Description
-
-
-               //gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =  gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, m_level ,fillMoveKeys(), true);
-
-               bool didItWork =  gdcm::CompositeNetworkFunctions::CMove(m_adress.c_str(),atoi(m_port.c_str()), m_query, getDicomClientPort(),
-      getDicomClientAETitle().c_str(), m_aetitle.c_str(),"D:\\move" );
-                gdcm::Directory theDir;
+               bool didItWork =  gdcm::CompositeNetworkFunctions::CMove(m_adress.c_str(),atoi(m_port.c_str()),
+                       gdcm::CompositeNetworkFunctions::ConstructQuery(m_query.theRoot, m_query.theLevel ,m_query.keys,true), getDicomClientPort(),
+                        getDicomClientAETitle().c_str(), m_aetitle.c_str(),"D:\\move" );
+               gdcm::Directory theDir;
                theDir.Load("D:\\move");
           m_files =    theDir.GetFilenames();
           accept();
@@ -491,5 +495,39 @@ std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::fillMoveKeys
                        break;
        }
 
+       return keys;
+}
+
+vvQuery vvQPacsConnection::getQueryforStudy(const  std::string patient_id)
+{
+       vvQuery query;
+       query.keys = getQueryKeysforStudy( patient_id);
+       query.theRoot = gdcm::ePatientRootType;
+       query.theLevel = gdcm::ePatient;
+       return query;
+}
+
+std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getQueryKeysforStudy(const std::string patient_id)
+{
+       std::vector< std::pair<gdcm::Tag, std::string> > keys;
+
+       // Study Description
+       gdcm::Tag tagsd(0x0010,0x0020);
+       keys.push_back(std::make_pair(tagsd, ""));
+       // Study Description
+       gdcm::Tag tagsdc(0x0008,0x1030);
+       keys.push_back(std::make_pair(tagsdc, ""));
+       // Study date
+       gdcm::Tag tagdb(0x0008,0x0020);
+       keys.push_back(std::make_pair(tagdb, ""));
+       // Study Hour
+       gdcm::Tag tagsdh(0x0008,0x0030);
+       keys.push_back(std::make_pair(tagsdh, ""));
+
+       // Study Hour
+       gdcm::Tag tagsid(0x020,0x000d);
+       keys.push_back(std::make_pair(tagsid, patient_id.c_str()));
+
+
        return keys;
 }
\ No newline at end of file
index 365a40f502bf841563e7a1821933315ca4136acb..36e715a1006c43bfe5ba712b0d83cdb37623c497 100644 (file)
    */
   //=====================================================================
  //======================================================================
+
+struct vvQuery{
+       gdcm::ERootType theRoot;
+       gdcm::EQueryLevel theLevel;
+       std::vector< std::pair<gdcm::Tag, std::string> > keys;
+};
+
   class vvQPacsConnection : public QDialog 
   {
          Q_OBJECT
@@ -40,6 +47,10 @@ public slots:
  void modifyServer();
 
   private :
+
+                vvQuery getQueryPatient(const std::string i_patname, const std::string i_patid);
+
+
          Ui::vvPacsConnection ui;
        std::vector< std::pair<gdcm::Tag, std::string> > getKeys();
        std::vector< std::pair<gdcm::Tag, std::string> > getPatientKeys(const std::string , const std::string );
@@ -66,8 +77,14 @@ public slots:
        std::string m_adress;
        std::string m_nickname;
        vvDicomServerQueryFactory mquery;
-       gdcm::SmartPointer<gdcm::BaseRootQuery> m_query;
+       vvQuery m_query;
+       vvQuery f_query;
         gdcm::Directory::FilenamesType m_files;
+
+        vvQuery getQueryforSeries(const std::string study_id);
+
+        vvQuery getQueryforStudy(const std::string patient_id);
+        std::vector< std::pair<gdcm::Tag, std::string> > getQueryKeysforStudy(const std::string patient_id);
        
   }; // class vvQPacsConnection
   //=====================================================================