7 #include "ioPacs/SQueryEditor.hpp" 9 #include <fwGui/dialog/MessageDialog.hpp> 11 #include <fwGuiQt/container/QtContainer.hpp> 13 #include <fwMedData/DicomSeries.hpp> 15 #include <fwMedDataTools/helper/SeriesDB.hpp> 17 #include <fwPacsIO/exceptions/Base.hpp> 18 #include <fwPacsIO/helper/Series.hpp> 20 #include <fwServices/macros.hpp> 22 #include <boost/filesystem/operations.hpp> 23 #include <boost/foreach.hpp> 25 #include <dcmtk/dcmnet/scu.h> 27 #include <QGridLayout> 28 #include <QHBoxLayout> 51 _sstream <<
"SQueryEditor::info";
67 ::fwGuiQt::container::QtContainer::sptr qtContainer = fwGuiQt::container::QtContainer::dynamicCast(getContainer());
70 QGridLayout* layout =
new QGridLayout();
74 layout->addWidget(
new QLabel(
"Patient name:"), 0, 0);
85 QHBoxLayout* dateLayout =
new QHBoxLayout();
86 layout->addWidget(
new QLabel(
"Study date:"), 1, 0);
87 layout->addLayout(dateLayout, 1, 1);
93 qtContainer->setLayout(layout);
99 QObject::connect(
m_beginStudyDateEdit, SIGNAL(dateChanged(QDate)),
this, SLOT(queryStudyDate()));
100 QObject::connect(
m_endStudyDateEdit, SIGNAL(dateChanged(QDate)),
this, SLOT(queryStudyDate()));
120 QObject::disconnect(
m_beginStudyDateEdit, SIGNAL(dateChanged(QDate)),
this, SLOT(queryStudyDate()));
121 QObject::disconnect(
m_endStudyDateEdit, SIGNAL(dateChanged(QDate)),
this, SLOT(queryStudyDate()));
135 void SQueryEditor::queryPatientName()
146 OFList< QRResponse* > responses;
152 ::fwMedData::SeriesDB::ContainerType series =
157 for(::fwMedData::Series::sptr s: series)
159 ::fwMedData::DicomSeries::sptr dicomSeries = ::fwMedData::DicomSeries::dynamicCast(s);
160 SLM_ASSERT(
"The PACS response should contain only DicomSeries", dicomSeries);
161 const std::string instanceUID =
m_seriesEnquirer->findSOPInstanceUID(dicomSeries->getInstanceUID(), 0);
162 dicomSeries->setFirstInstanceNumber((instanceUID.empty() ? 1 : 0));
167 this->updateSeriesDB(series);
178 void SQueryEditor::queryStudyDate()
188 OFList< QRResponse* > responses;
196 ::fwMedData::SeriesDB::ContainerType series =
201 for(::fwMedData::Series::sptr s: series)
203 ::fwMedData::DicomSeries::sptr dicomSeries = ::fwMedData::DicomSeries::dynamicCast(s);
204 SLM_ASSERT(
"The PACS response should contain only DicomSeries", dicomSeries);
205 const std::string instanceUID =
m_seriesEnquirer->findSOPInstanceUID(dicomSeries->getInstanceUID(), 0);
206 dicomSeries->setFirstInstanceNumber((instanceUID.empty() ? 1 : 0));
211 this->updateSeriesDB(series);
221 void SQueryEditor::updateSeriesDB(::fwMedData::SeriesDB::ContainerType series)
223 ::fwMedData::SeriesDB::sptr seriesDB = this->getInOut< ::fwMedData::SeriesDB >(
"seriesDB");
227 seriesDBHelper.clear();
230 for(const ::fwMedData::Series::sptr& s: series)
232 ::fwMedData::DicomSeries::sptr dicomSeries = ::fwMedData::DicomSeries::dynamicCast(s);
233 seriesDBHelper.add(dicomSeries);
237 seriesDBHelper.notify();
245 std::stringstream ss;
246 ss <<
"Unable to connect to the pacs. Please check your configuration: \n" 255 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::CRITICAL);
256 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
virtual IOPACS_API void starting() override
Override.
QPointer< QPushButton > m_patientNameQueryButton
Patient Name Query Button.
static FWPACSIO_API DicomSeriesContainer toFwMedData(OFList< QRResponse * > responses)
Convert DCMTK series to fwMedData::DicomSeries.
::fwPacsIO::SeriesEnquirer::sptr m_seriesEnquirer
Series enquirer.
ioPacs contains services use to deal with PACS using DCMTK library.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
Defines the service interface managing the editor service for object.
Defines the generic message box for IHM. Use the Delegate design pattern.
FWGUI_API void destroy()
Stops sub-views and toobar services. Destroys view, sub-views and toolbar containers.
::fwPacsIO::data::PacsConfiguration::csptr m_pacsConfiguration
Pacs Configuration object.
QPointer< QDateEdit > m_endStudyDateEdit
End study date widget.
IOPACS_API SQueryEditor() noexcept
Constructor.
#define SLM_WARN(message)
virtual IOPACS_API void stopping() override
Override.
Base class of fwPacsIO Exceptions.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
This editor service is used to perform a IOPACS query on a pacs.
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
virtual IOPACS_API ~SQueryEditor() noexcept
Destructor.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
IOPACS_API void displayErrorMessage(const std::string &message) const
Display an error message.
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
QPointer< QLineEdit > m_patientNameLineEdit
Patient Name Field.
QPointer< QPushButton > m_studyDateQueryButton
Study Date Query Button.
IOPACS_API void updating() override
Override.
virtual IOPACS_API void configuring() override
Configuring method. This method is used to configure the service.
IOPACS_API void info(std::ostream &_sstream) override
Override.
QPointer< QDateEdit > m_beginStudyDateEdit
Begin study date widget.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
FWGUI_API void initialize()
Initialize managers.
static FWPACSIO_API void releaseResponses(OFList< QRResponse * > responses)
Release the responses.