1 #include "vvQPacsConnection.h"
2 #include "gdcmCompositeNetworkFunctions.h"
3 #include <QtGui/qlistview.h>
8 #include "vvPacsSettingsDialog.h"
13 vvQPacsConnection::vvQPacsConnection(QWidget *i_parent)
17 setWindowTitle(QString::fromUtf8("PACS CONNECTIONHHHH"));
19 ui.tabFilter->setTabText(0,QString(tr("Modality")));
20 ui.tabFilter->setTabText(1,QString(tr("Date")));
22 ui. tabNetwork->setTabText(0,QString(tr("Network")));
23 ui. tabNetwork->setTabText(1,QString(tr("Configuration")));
24 ui.check_ModAll->setEnabled(true);
25 ui.networkCombo->addItem("");
26 ui.networkCombo->addItems(getDicomServers());
29 connect(ui.networkCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(chooseServer(int)));
30 connect(ui.removeNetworkButton,SIGNAL(clicked()),this,SLOT(removeServer()));
31 connect(ui.NetworkButton,SIGNAL(clicked()),this,SLOT(modifyServer()));
36 // remote a Dicom Server in VV settings
37 void vvQPacsConnection::removeServer()
39 removeDicomServer(m_nickname);
40 ui.networkCombo->removeItem(ui.networkCombo->findText(QString(m_nickname.c_str())));
45 // modify a Dicom Server in VV settings
46 void vvQPacsConnection::modifyServer()
48 AddDicomServer(ui.NameEdit->text().toStdString(),ui.AETitleEdit->text().toStdString(),ui.AdressEdit->text().toStdString(),ui.PortEdit->text().toStdString());
52 // refresh the list of Dicom Servers available from VV settings
53 void vvQPacsConnection::refreshNetworks()
55 ui.networkCombo->clear();
56 ui.networkCombo->addItem(QString());
57 ui.networkCombo->addItems(getDicomServers());
58 ui.NameEdit->setText(QString());
59 ui.AETitleEdit->setText(QString());
60 ui.AdressEdit->setText(QString());
61 ui.PortEdit->setText(QString());
62 ui.tabNetwork->setCurrentIndex(0);
65 void vvQPacsConnection::on_clearButton_clicked()
67 Patientmodel->removeRows(0, Patientmodel->rowCount(),QModelIndex());
68 Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex());
69 Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex());
70 Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex());
73 void vvQPacsConnection::on_scanButton_clicked()
76 manageStudiesFilter(true);
78 // test first if echo works
79 bool didItWork = gdcm::CompositeNetworkFunctions::CEcho(m_adress.c_str(), atoi(m_port.c_str()), getDicomClientAETitle().c_str(), m_nickname.c_str() );
82 m_level =gdcm::ePatient;
83 std::vector<gdcm::DataSet> theDataSet;
84 f_query = mQFactory.getQueryPatient(ui.patientName->toPlainText().toStdString(), ui.patientID->toPlainText().toStdString());
86 bool cfindWork = gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()),
87 gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys),
88 theDataSet, getDicomClientAETitle().c_str() , m_nickname.c_str());
91 convertDataSet(theDataSet,Patientmodel,mQFactory.getPatientKeys("",""));
97 /// show Options DialogBox to set a new Dicom Server
98 void vvQPacsConnection::on_optionsButton_clicked()
100 vvPacsSettingsDialog *dg = new vvPacsSettingsDialog(this);
104 void vvQPacsConnection::convertDataSet(std::vector<gdcm::DataSet> i_ds, QStandardItemModel *i_model, std::vector< std::pair<gdcm::Tag, std::string> > keys)
107 std::vector<gdcm::DataSet>::iterator it_ds = i_ds.begin();
108 for(; it_ds != i_ds.end(); it_ds++)
110 QList<QStandardItem *> items;
111 const gdcm::DataSet ds = (*it_ds);
112 std::vector< std::pair<gdcm::Tag, std::string> >::iterator it_key = keys.begin();
114 for(; it_key != keys.end(); it_key++, ind++)
116 gdcm::DataElement de = ds.GetDataElement((*it_key).first);
117 QStandardItem *item = new QStandardItem;
118 const gdcm::ByteValue *bv = (de).GetByteValue();
121 std::string buffer = std::string( bv->GetPointer(), bv->GetLength() );
122 item->setText(tr(buffer.c_str()));
126 item->setText(tr(""));
130 item->setCheckable(true);
132 items.push_back(item);
134 i_model->appendRow(items);
138 // TreeViews creation
139 void vvQPacsConnection::createTreeView()
142 Patientmodel = new QStandardItemModel(0,2,this);
143 QStringList Patientlist;
144 Patientlist.push_back(tr("PATIENT NAME"));
145 Patientlist.push_back(tr("PATIENT ID"));
146 Patientmodel->setHorizontalHeaderLabels(Patientlist);
147 ui.patientTreeView->setModel(Patientmodel);
148 ui.patientTreeView->setEnabled(true);
149 connect(ui.patientTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectStudies(QModelIndex)));
152 Studymodel = new QStandardItemModel(0,3,this);
153 QStringList Studylist;
154 Studylist.push_back(tr("DESCRIPTION"));
155 Studylist.push_back(tr("DATE"));
156 Studylist.push_back(tr("HOUR"));
157 Studylist.push_back(tr("STUDY ID"));
158 Studymodel->setHorizontalHeaderLabels(Studylist);
159 ui.studyTreeView->setModel(Studymodel);
160 connect(ui.studyTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectSeries(QModelIndex)));
164 Seriesmodel = new QStandardItemModel(0,2,this);
165 QStringList Serieslist;
166 Serieslist.push_back(tr("MODALITY"));
167 Serieslist.push_back(tr("DESCRIPTION"));
168 Serieslist.push_back(tr("no. accept."));
169 Seriesmodel->setHorizontalHeaderLabels(Serieslist);
170 ui.seriesTreeView->setModel(Seriesmodel);
171 connect(ui.seriesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImages(QModelIndex)));
172 connect(ui.imagesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImage(QModelIndex)));
174 Imagesmodel = new QStandardItemModel(0,1,this);
175 QStringList Imageslist;
176 Imageslist.push_back(tr("instance number"));
177 Imageslist.push_back(tr("sopuid"));
178 Imagesmodel->setHorizontalHeaderLabels(Imageslist);
179 ui.imagesTreeView->setModel(Imagesmodel);
182 // clean the different model Trees
183 void vvQPacsConnection::cleanTree()
185 Patientmodel->removeRows(0,Patientmodel->rowCount(),QModelIndex());
186 Studymodel->removeRows(0,Patientmodel->rowCount(),QModelIndex());
187 Seriesmodel->removeRows(0,Patientmodel->rowCount(),QModelIndex());
188 Imagesmodel->removeRows(0,Patientmodel->rowCount(),QModelIndex());
192 void vvQPacsConnection::selectStudies(const QModelIndex &index)
195 m_patient= Patientmodel->data(index.sibling(index.row(),1)).toString().toStdString();
196 Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex());
197 Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex());
198 Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex());
199 manageSeriesFilter(true);
200 m_query = mQFactory.getQueryPatient("",m_patient);
201 convertDataSet( findQuery( mQFactory.getQueryforStudy(m_patient, false)) , Studymodel, mQFactory.getQueryKeysforStudy("",true));
207 void vvQPacsConnection::selectSeries(const QModelIndex &index)
209 m_study= Studymodel->data(index.sibling(index.row(),3)).toString().toStdString();
210 Seriesmodel->removeRows(0, Seriesmodel->rowCount());
211 Imagesmodel->removeRows(0, Imagesmodel->rowCount());
212 m_query = mQFactory.getQueryforSeries(m_patient,m_study, false);
213 convertDataSet( findQuery( mQFactory.getQueryforSeries(m_patient,m_study, false)), Seriesmodel, mQFactory.getSeriesKeys("","",true));
217 void vvQPacsConnection::selectImages(const QModelIndex &index)
219 m_series = Seriesmodel->data(index.sibling(index.row(),2)).toString().toStdString();
220 Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex());
221 m_query = mQFactory.getQueryforImages(m_patient,m_study, m_series, false);
222 convertDataSet( findQuery( mQFactory.getQueryforImages(m_patient,m_study, m_series, false) ), Imagesmodel, mQFactory.getQueryKeysforImages("","","",true));
226 void vvQPacsConnection::selectImage(const QModelIndex &index)
228 std::string _image = Imagesmodel->data(index.sibling(index.row(),1)).toString().toStdString();
229 mQFactory.setQueryforImage(m_patient,m_study, m_series, _image);
234 std::vector<gdcm::DataSet> vvQPacsConnection::findQuery(vvQuery i_query)
236 std::vector<gdcm::DataSet> theDataSet;
237 gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()),
238 gdcm::CompositeNetworkFunctions::ConstructQuery(i_query.theRoot, i_query.theLevel,i_query.keys), theDataSet,
239 getDicomClientAETitle().c_str(), m_nickname.c_str());
243 void vvQPacsConnection::manageStudiesFilter(bool i_enable)
245 ui.text_PHYS->setEnabled(i_enable);
246 ui.text_SDESC->setEnabled(i_enable);
247 ui.dateTab->setEnabled(i_enable);
251 void vvQPacsConnection::manageSeriesFilter(bool i_enable)
253 ui.modalityTab->setEnabled(i_enable);
257 std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getStudyKeys(const std::string i_val)
259 std::vector< std::pair<gdcm::Tag, std::string> > keys;
261 gdcm::Tag tagsdc(0x0008,0x1030);
262 keys.push_back(std::make_pair(tagsdc, ""));
264 gdcm::Tag tagdb(0x0008,0x0020);
265 keys.push_back(std::make_pair(tagdb, ""));
267 gdcm::Tag tagsdh(0x0008,0x0030);
268 keys.push_back(std::make_pair(tagsdh, ""));
269 // Study Instance UID
270 gdcm::Tag tagsid(0x0020,0x000d);
271 keys.push_back(std::make_pair(tagsid, i_val));
276 std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getKeys()
278 std::vector< std::pair<gdcm::Tag, std::string> > keys;
280 gdcm::Tag tag(0x0010,0x0010);
281 keys.push_back(std::make_pair(tag, ""));
284 gdcm::Tag tagpid(0x0010,0x0020);
285 keys.push_back(std::make_pair(tagpid, ""));
288 gdcm::Tag tagmod(0x0008,0x0061);
289 keys.push_back(std::make_pair(tagmod, ""));
292 gdcm::Tag tagdb(0x0010,0x0030);
293 keys.push_back(std::make_pair(tagdb, ""));
296 gdcm::Tag tagsd(0x0020,0x000D);
297 keys.push_back(std::make_pair(tagsd, ""));
300 //gdcm::Tag tagst(8,30);
301 //keys.push_back(std::make_pair(tagst, ""));
303 //// Study Description
304 //gdcm::Tag tagsdc(8,1030);
305 //keys.push_back(std::make_pair(tagsdc, ""));
308 //gdcm::Tag tagacc(8,50);
309 //keys.push_back(std::make_pair(tagacc, ""));
314 void vvQPacsConnection::on_check_ModAll_clicked(bool state)
316 ui.check_MR->setEnabled(!state);
317 ui.check_CR->setEnabled(!state);
318 ui.check_OT->setEnabled(!state);
319 ui.check_RF->setEnabled(!state);
320 ui.check_SC->setEnabled(!state);
321 ui.check_CT->setEnabled(!state);
322 ui.check_US->setEnabled(!state);
323 ui.check_NM->setEnabled(!state);
324 ui.check_DR->setEnabled(!state);
325 ui.check_US->setEnabled(!state);
326 ui.check_NM->setEnabled(!state);
327 ui.check_DR->setEnabled(!state);
328 ui.check_SR->setEnabled(!state);
329 ui.check_XA->setEnabled(!state);
330 ui.check_MG->setEnabled(!state);
333 ui.check_MR->setChecked(state);
334 ui.check_CR->setChecked(state);
335 ui.check_OT->setChecked(state);
336 ui.check_RF->setChecked(state);
337 ui.check_SC->setChecked(state);
338 ui.check_CT->setChecked(state);
339 ui.check_US->setChecked(state);
340 ui.check_NM->setChecked(state);
341 ui.check_DR->setChecked(state);
342 ui.check_US->setChecked(state);
343 ui.check_NM->setChecked(state);
344 ui.check_DR->setChecked(state);
345 ui.check_SR->setChecked(state);
346 ui.check_XA->setChecked(state);
347 ui.check_MG->setChecked(state);
352 void vvQPacsConnection::chooseServer(int index)
354 std::map < std::string, std:: string> values = getDicomServer(ui.networkCombo->currentText());
355 m_port = values["PORT"];
356 m_aetitle = values["AETITLE"];
357 m_adress= values["ADRESS"];
358 m_nickname = values["nickname"];
359 ui.AdressEdit->setText(QString(m_adress.c_str()));
360 ui.AETitleEdit->setText(QString(m_aetitle.c_str()));
361 ui.NameEdit->setText(QString(m_nickname.c_str()));
362 ui.PortEdit->setText(QString(m_port.c_str()));
365 void vvQPacsConnection::on_importButton_clicked()
368 bool didItWork = gdcm::CompositeNetworkFunctions::CMove(m_adress.c_str(),atoi(m_port.c_str()),
369 gdcm::CompositeNetworkFunctions::ConstructQuery(mQFactory.getMoveQuery().theRoot, mQFactory.getMoveQuery().theLevel ,mQFactory.getMoveQuery().keys,true),
370 getDicomClientPort(), getDicomClientAETitle().c_str(), m_aetitle.c_str(),"D:\\move" );
371 gdcm::Directory theDir;
372 theDir.Load("D:\\move");
373 m_files = theDir.GetFilenames();
377 std::vector <std::string> vvQPacsConnection::getFileNames()
379 std::vector <std::string> filenames;
380 gdcm::Directory::FilenamesType::iterator it = m_files.begin();
381 for (;it != m_files.end(); it++)
382 filenames.push_back(it->c_str());
385 std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::fillMoveKeys()
387 std::vector< std::pair<gdcm::Tag, std::string> > keys;
391 //keys.push_back(getPatientKeys("",""));