Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date field issue in query Study #3

Open
wants to merge 5 commits into
base: ITK5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0.2)

project(QTDCM VERSION "2.1.1")
project(QTDCM VERSION "2.1.2")

option(BUILD_EXAMPLE "Build qtdcm example application" OFF)
option(BUILD_DOCUMENTATION "Build QtDcm Documentation (add a Documentation target)" OFF)
Expand Down
8 changes: 7 additions & 1 deletion externals/dcmtk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ endif()
set(DCMTK_SOURCE_DIR "${DCMTK_SOURCE_DIR}" CACHE PATH "" FORCE)
set(DCMTK_DIR "${DCMTK_DIR}" CACHE PATH "" FORCE)

if (WIN32)
set(DCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS ON)
else()
set(DCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS OFF)
endif()

ExternalProject_Add(
dcmtk

Expand All @@ -19,7 +25,7 @@ ExternalProject_Add(

SOURCE_DIR "${DCMTK_SOURCE_DIR}"
BINARY_DIR "${DCMTK_DIR}"
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_APPS:BOOL=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDCMTK_WITH_ZLIB:BOOL=OFF
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_APPS:BOOL=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDCMTK_WITH_ZLIB:BOOL=OFF -DDCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS:BOOL=${DCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS}

INSTALL_COMMAND ""
TEST_COMMAND ""
Expand Down
23 changes: 21 additions & 2 deletions externals/itk.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
message("${Esc}[32mConfiguring ITK external library${Esc}[m")

## #############################################################################
## Look for Git
## #############################################################################
find_program(GIT_BIN NAMES git)
if (NOT GIT_BIN)
find_package(Git)
if(Git_FOUND)
set(GIT_BIN ${GIT_EXECUTABLE})
else()
message(SEND_ERROR "You need to install Git and add it to the PATH environment variable.")
endif()
else()
mark_as_advanced(GIT_BIN)
endif()

if("${ITK_DIR}" STREQUAL "")
set(ITK_DIR ${PROJECT_BINARY_DIR}/externals/itk-build)
endif()

set(ITK_DIR "${ITK_DIR}" CACHE PATH "" FORCE)

set(git_url https://github.com/InsightSoftwareConsortium/ITK.git)
set(git_tag v5.0.0)

ExternalProject_Add(
itk

URL https://sourceforge.net/projects/itk/files/itk/4.13/InsightToolkit-4.13.0.tar.gz
GIT_REPOSITORY ${git_url}
GIT_TAG ${git_tag}

CMAKE_GENERATOR Ninja

Expand Down
14 changes: 7 additions & 7 deletions src/QtDcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void QtDcm::onPatientItemSelected ( QTreeWidgetItem* current, QTreeWidgetItem* p
treeWidgetStudies->clear();

if ( d->mode == QtDcm::PACS_MODE ) {
QtDcmManager::instance()->findStudiesScu ( current->text ( 0 ) );
QtDcmManager::instance()->findStudiesScu (current->text(1), current->text ( 0 ) );
}
else {
QtDcmManager::instance()->findStudiesDicomdir ( current->text ( 0 ) );
Expand All @@ -200,7 +200,7 @@ void QtDcm::onStudyItemSelected ( QTreeWidgetItem* current, QTreeWidgetItem* pre
QtDcmManager::instance()->clearPreview();

if ( d->mode == QtDcm::PACS_MODE ) {
QtDcmManager::instance()->findSeriesScu ( treeWidgetPatients->currentItem()->text ( 0 ), current->data ( 2, 0 ).toString() );
QtDcmManager::instance()->findSeriesScu (treeWidgetPatients->currentItem()->text(1), treeWidgetPatients->currentItem()->text(0), current->data ( 2, 0 ).toString() );
}
else {
QtDcmManager::instance()->findSeriesDicomdir ( treeWidgetPatients->currentItem()->text ( 0 ), current->data ( 2, 0 ).toString() );
Expand Down Expand Up @@ -285,7 +285,7 @@ void QtDcm::onCurrentModalityChanged ( int index )

if ( treeWidgetPatients->currentItem() && treeWidgetStudies->currentItem() ) {
if ( d->mode == QtDcm::PACS_MODE ) {
QtDcmManager::instance()->findSeriesScu ( treeWidgetPatients->currentItem()->text ( 0 ), treeWidgetStudies->currentItem()->data ( 2, 0 ).toString() );
QtDcmManager::instance()->findSeriesScu (treeWidgetPatients->currentItem()->text(1), treeWidgetPatients->currentItem()->text ( 0 ), treeWidgetStudies->currentItem()->data ( 2, 0 ).toString() );
}
else {
QtDcmManager::instance()->findSeriesDicomdir ( treeWidgetPatients->currentItem()->text ( 0 ), treeWidgetStudies->currentItem()->data ( 2, 0 ).toString() );
Expand Down Expand Up @@ -338,7 +338,7 @@ void QtDcm::onStartDateChanged(const QDate &startdate)

if ( treeWidgetPatients->currentItem() ) {
if ( d->mode == QtDcm::PACS_MODE ) {
QtDcmManager::instance()->findStudiesScu ( treeWidgetPatients->currentItem()->text ( 0 ) );
QtDcmManager::instance()->findStudiesScu ( treeWidgetPatients->currentItem()->text(1), treeWidgetPatients->currentItem()->text ( 0 ) );
}
else {
qDebug() << "Date filtering not available in CD-Rom mode";
Expand All @@ -361,7 +361,7 @@ void QtDcm::onEndDateChanged (const QDate &enddate)

if ( treeWidgetPatients->currentItem() ) {
if ( d->mode == QtDcm::PACS_MODE ) {
QtDcmManager::instance()->findStudiesScu ( treeWidgetPatients->currentItem()->text ( 0 ) );
QtDcmManager::instance()->findStudiesScu (treeWidgetPatients->currentItem()->text(1), treeWidgetPatients->currentItem()->text ( 0 ) );
}
else {
qDebug() << "Date filtering not available in CD-Rom mode";
Expand Down Expand Up @@ -435,7 +435,7 @@ void QtDcm::onStudyDescriptionTextChanged (const QString &description)
}

if ( treeWidgetPatients->currentItem() && d->mode == QtDcm::PACS_MODE ) {
QtDcmManager::instance()->findStudiesScu ( treeWidgetPatients->currentItem()->text ( 0 ) );
QtDcmManager::instance()->findStudiesScu (treeWidgetPatients->currentItem()->text(1), treeWidgetPatients->currentItem()->text ( 0 ) );
}
}

Expand All @@ -453,6 +453,6 @@ void QtDcm::onSerieDescriptionTextChanged (const QString &description)
}

if ( treeWidgetPatients->currentItem() && treeWidgetStudies->currentItem() && d->mode == QtDcm::PACS_MODE) {
QtDcmManager::instance()->findSeriesScu ( treeWidgetPatients->currentItem()->text ( 0 ), treeWidgetStudies->currentItem()->data ( 2, 0 ).toString() );
QtDcmManager::instance()->findSeriesScu (treeWidgetPatients->currentItem()->text(1), treeWidgetPatients->currentItem()->text(0), treeWidgetStudies->currentItem()->data ( 2, 0 ).toString() );
}
}
40 changes: 20 additions & 20 deletions src/QtDcmFindScu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ QtDcmFindScu::~QtDcmFindScu()
}


void QtDcmFindScu::findPatientsScu (const QString &patientName)
void QtDcmFindScu::findPatientsScu (const QString &patientId)
{
this->findPatientsScu ( patientName, "*" );
this->findPatientsScu ( patientId, "*" );
}

void QtDcmFindScu::findPatientsScu (const QString &patientName, const QString &patientSex)
void QtDcmFindScu::findPatientsScu (const QString &patientId, const QString &patientSex)
{
OFList<OFString> overrideKeys;
overrideKeys.push_back ( ( QString ( "QueryRetrieveLevel=" ) + QString ( "" "PATIENT" "" ) ).toUtf8().data() );
overrideKeys.push_back ( ( QString ( "PatientName=" ) + patientName ).toUtf8().data() );

//Patient leqvel
overrideKeys.push_back ( QString ( "PatientID" ).toUtf8().data() );
//Patient level
overrideKeys.push_back ( ( QString ( "PatientID=" ) + patientId).toUtf8().data());
overrideKeys.push_back ( QString ( "PatientName").toUtf8().data());
overrideKeys.push_back ( QString ( "PatientSex=" + patientSex ).toUtf8().data() );
overrideKeys.push_back ( QString ( "PatientBirthDate" ).toUtf8().data() );

Expand All @@ -78,26 +78,26 @@ void QtDcmFindScu::findPatientsScu (const QString &patientName, const QString &p

void QtDcmFindScu::findStudiesScu (const QString &patientName)
{
this->findStudiesScu ( patientName, "*", QDate ( 1900,01,01 ).toString ( "yyyyMMdd" ),QDate::currentDate().toString ( "yyyyMMdd" ) );
this->findStudiesScu ( QString("*"), patientName, "*", QDate ( 1900,01,01 ).toString ( "yyyyMMdd" ),QDate::currentDate().toString ( "yyyyMMdd" ) );
}

void QtDcmFindScu::findStudiesScu(const QString &patientName, const QString &studyDescription)
{
this->findStudiesScu ( patientName, studyDescription, QDate ( 1900,01,01 ).toString ( "yyyyMMdd" ),QDate::currentDate().toString ( "yyyyMMdd" ) );
this->findStudiesScu ( QString("*"), patientName, studyDescription, QDate ( 1900,01,01 ).toString ( "yyyyMMdd" ),QDate::currentDate().toString ( "yyyyMMdd" ) );
}

void QtDcmFindScu::findStudiesScu (const QString &patientName, const QString &studyDescription, const QString &startDate, const QString &endDate)
void QtDcmFindScu::findStudiesScu (const QString & patientId, const QString &patientName, const QString &studyDescription, const QString &startDate, const QString &endDate)
{
OFList<OFString> overrideKeys;
overrideKeys.push_back ( ( QString ( "QueryRetrieveLevel=" ) + QString ( "" "STUDY" "" ) ).toUtf8().data() );
overrideKeys.push_back ( ( QString ( "PatientID=" ) + patientId).toUtf8().data() );
overrideKeys.push_back ( ( QString ( "PatientName=" ) + patientName ).toUtf8().data() );
overrideKeys.push_back ( ( QString ( "StudyDescription=" ) + studyDescription ).toUtf8().data() );
overrideKeys.push_back ( QString ( "StudyDate=" + startDate + "-" + endDate ).toUtf8().data() );
overrideKeys.push_back(QString("StudyID").toUtf8().data());
overrideKeys.push_back(QString("AccessionNumber").toUtf8().data());
overrideKeys.push_back(QString("NumberOfStudyRelatedSeries").toUtf8().data());
overrideKeys.push_back(QString("NumberOfStudyRelatedInstances").toUtf8().data());
overrideKeys.push_back(QString("PatientID=*").toUtf8().data());
overrideKeys.push_back ( QString ( "StudyID").toUtf8().data());
overrideKeys.push_back ( QString ( "AccessionNumber").toUtf8().data());
overrideKeys.push_back ( QString ( "NumberOfStudyRelatedSeries").toUtf8().data());
overrideKeys.push_back ( QString ( "NumberOfStudyRelatedInstances").toUtf8().data());

//Study level
overrideKeys.push_back ( QString ( "StudyInstanceUID" ).toUtf8().data() );
Expand All @@ -106,17 +106,17 @@ void QtDcmFindScu::findStudiesScu (const QString &patientName, const QString &st

}

void QtDcmFindScu::findSeriesScu (const QString &patientName, const QString &studyUID)
void QtDcmFindScu::findSeriesScu (const QString & patientId, const QString &patientName, const QString &studyUID)
{
this->findSeriesScu ( patientName, studyUID, "*", "*", "*" );
this->findSeriesScu (patientId, patientName, studyUID, "*", "*", "*" );
}

void QtDcmFindScu::findSeriesScu (const QString &patientName, const QString &studyUID, const QString &studyDescription, const QString &modality)
void QtDcmFindScu::findSeriesScu (const QString &patientId, const QString &patientName, const QString &studyUID, const QString &studyDescription, const QString &modality)
{
this->findSeriesScu ( patientName, studyUID, studyDescription, "*", modality );
this->findSeriesScu (patientId, patientName, studyUID, studyDescription, "*", modality );
}

void QtDcmFindScu::findSeriesScu (const QString &patientName, const QString &studyUID, const QString &studyDescription, const QString &serieDescription, const QString &modality)
void QtDcmFindScu::findSeriesScu (const QString &patientId, const QString &patientName, const QString &studyUID, const QString &studyDescription, const QString &serieDescription, const QString &modality)
{
OFList<OFString> overrideKeys;
overrideKeys.push_back ( ( QString ( "QueryRetrieveLevel=" ) + QString ( "" "SERIES" "" ) ).toUtf8().data() );
Expand All @@ -125,7 +125,7 @@ void QtDcmFindScu::findSeriesScu (const QString &patientName, const QString &stu
overrideKeys.push_back ( QString ( "StudyDescription=" + studyDescription ).toUtf8().data() );
overrideKeys.push_back ( ( QString ( "SeriesDescription=" ) + serieDescription ).toUtf8().data() );
overrideKeys.push_back ( QString ( "Modality=" + modality ).toUtf8().data() );
overrideKeys.push_back ( QString("PatientID=*").toUtf8().data());
overrideKeys.push_back ( (QString("PatientID=") + patientId).toUtf8().data());

//Study level
overrideKeys.push_back ( QString ( "StudyDate" ).toUtf8().data() );
Expand Down
38 changes: 8 additions & 30 deletions src/QtDcmFindScu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,19 @@ class QtDcmFindScu : public QObject
explicit QtDcmFindScu ( QObject * parent = 0);
virtual ~QtDcmFindScu();

void findPatientsScu ( const QString & patientName );

void findPatientsScu ( const QString & patientName,
const QString & patientSex );
void findPatientsScu ( const QString & patientID );
void findPatientsScu ( const QString & patientID, const QString & patientSex );

void findStudiesScu ( const QString & patientName );
void findStudiesScu ( const QString & patientName, const QString & studyDescription );
void findStudiesScu ( const QString & patientId, const QString & patientName, const QString & studyDescription, const QString & startDate, const QString & endDate );

void findStudiesScu ( const QString & patientName,
const QString & studyDescription );

void findStudiesScu ( const QString & patientName,
const QString & studyDescription,
const QString & startDate,
const QString & endDate );

void findSeriesScu ( const QString & patientName,
const QString & studyUID );

void findSeriesScu ( const QString & patientName,
const QString & studyUID,
const QString & modality );

void findSeriesScu ( const QString & patientName,
const QString & studyUID,
const QString & studyDescription,
const QString & modality );

void findSeriesScu ( const QString & patientName,
const QString & studyUID,
const QString & studyDescription,
const QString & serieDescription,
const QString & modality );
void findSeriesScu ( const QString & patientId, const QString & patientName, const QString & studyUID );
void findSeriesScu ( const QString & patientId, const QString & patientName, const QString & studyUID, const QString & modality );
void findSeriesScu ( const QString & patientId, const QString & patientName, const QString & studyUID, const QString & studyDescription, const QString & modality );
void findSeriesScu ( const QString & patientId, const QString & patientName, const QString & studyUID, const QString & studyDescription, const QString & serieDescription, const QString & modality );

void findImagesScu ( const QString & seriesUID );

void findImageScu ( const QString & imageUID);

protected:
Expand Down
36 changes: 26 additions & 10 deletions src/QtDcmManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class QtDcmManagerPrivate
QString serieDescription; /** Attibute representing the serie description used for query PACS */
QString studyDescription; /** Attibute representing the study description used for query PACS */
QtDcmManager::eMoveMode mode; /** Mode that determine the type of media (MEDIA or PACS) */
QString dcm2nii; /** Absolute filename of the dcm2nii program */
//QString dcm2nii; /** Absolute filename of the dcm2nii program */

QtDcmManager::eOutputdirMode outputdirMode; /** Output directory mode DIALOG or CUSTOM */
QtDcmServer currentPacs; /** Current pacs index in the pacs list */
Expand Down Expand Up @@ -276,26 +276,26 @@ void QtDcmManager::findPatientsScu()
d->mode = PACS;

QtDcmFindScu * finder = new QtDcmFindScu ( this );
finder->findPatientsScu ( d->patientName, d->patientSex );
finder->findPatientsScu ( d->patientId, d->patientSex );
delete finder;
}
}

void QtDcmManager::findStudiesScu ( const QString &patientName )
void QtDcmManager::findStudiesScu (const QString &patientId, const QString &patientName)
{
d->seriesToImport.clear();

QtDcmFindScu * finder = new QtDcmFindScu ( this );
finder->findStudiesScu ( patientName, d->studyDescription, dateToString(d->date1), dateToString(d->date2) );
finder->findStudiesScu ( patientId, patientName, d->studyDescription, startDate().toString(Qt::ISODate).replace("-",""),endDate().toString(Qt::ISODate).replace("-",""));
delete finder;
}

void QtDcmManager::findSeriesScu ( const QString &patientName, const QString &studyUid )
void QtDcmManager::findSeriesScu (const QString &patientId, const QString &patientName, const QString &studyUid )
{
d->seriesToImport.clear();

QtDcmFindScu * finder = new QtDcmFindScu ( this );
finder->findSeriesScu ( patientName, studyUid, d->studyDescription, d->serieDescription, d->modality );
finder->findSeriesScu (patientId, patientName, studyUid, d->studyDescription, d->serieDescription, d->modality );
delete finder;
}

Expand Down Expand Up @@ -362,7 +362,8 @@ void QtDcmManager::loadDicomdir()

//Load dicomdir in a DCMTK DicomFileFormat object
OFCondition status;
if ( ! ( status = d->dfile.loadFile ( d->dicomdir.toUtf8().data() ) ).good() ) {
OFFilename dcmFileName(d->dicomdir.toStdString(), OFTrue);
if ( ! ( status = d->dfile.loadFile (dcmFileName) ).good() ) {
return;
}

Expand Down Expand Up @@ -435,6 +436,13 @@ void QtDcmManager::moveSelectedSeries()
break;
case PACS:
{
qWarning() << "****** Prepare move with parameters :";
qWarning() << "* by default IMPORT";
qWarning() << "* OutputDir = " << d->tempDir.absolutePath();
qWarning() << "* SeriesUID = " << d->seriesToImport;
qWarning() << "* ImportDir = " << d->outputDir;
qWarning() << "******";

QtDcmMoveScu * mover = new QtDcmMoveScu ( this );
mover->setOutputDir ( d->tempDir.absolutePath() );
mover->setSeries ( d->seriesToImport );
Expand Down Expand Up @@ -508,6 +516,13 @@ void QtDcmManager::getPreviewFromSelectedSerie ( const QString &uid, int element
makePreview ( filename );
}
else {
qWarning() << "****** Prepare move with parameters :";
qWarning() << "* PREVIEW";
qWarning() << "* PATH = " << d->tempDir.absolutePath();
qWarning() << "* SeriesUID = " << uid;
qWarning() << "* ImageID = " << imageId;
qWarning() << "******";

QtDcmMoveScu * mover = new QtDcmMoveScu ( this );
mover->setMode ( QtDcmMoveScu::PREVIEW );
mover->setOutputDir ( d->tempDir.absolutePath() );
Expand Down Expand Up @@ -670,8 +685,9 @@ void QtDcmManager::makePreview ( const QString &filename )
{
DcmRLEDecoderRegistration::registerCodecs ( OFFalse, OFFalse );
DJDecoderRegistration::registerCodecs ( EDC_photometricInterpretation, EUC_default, EPC_default, OFFalse );
OFFilename dcmFileName(filename.toStdString(), OFTrue);
DcmFileFormat file;
file.loadFile ( filename.toLatin1().data() );
file.loadFile (dcmFileName);
DcmDataset * dset = file.getDataset();
DicomImage* dcimage = new DicomImage ( dset, file.getDataset()->getOriginalXfer(), CIF_MayDetachPixelData );

Expand Down Expand Up @@ -756,8 +772,8 @@ void QtDcmManager::setDicomdir ( const QString &dicomdir )
d->dicomdir = dicomdir;
//Load dicomdir in a DCMTK DicomFileFormat object
OFCondition status;

if ( ! ( status = d->dfile.loadFile ( d->dicomdir.toUtf8().data() ) ).good() ) {
OFFilename dcmFileName(d->dicomdir.toStdString(), OFTrue);
if ( ! ( status = d->dfile.loadFile (dcmFileName) ).good() ) {
return;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/QtDcmManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ class QTDCM_EXPORT QtDcmManager : public QObject
* Find SCU with Dcmtk code
*/
void findPatientsScu();
void findStudiesScu ( const QString &patientName );
void findSeriesScu ( const QString &patientName,
const QString &studyUID );
void findStudiesScu ( const QString &patientId, const QString &patientName );
void findSeriesScu (const QString &patientId, const QString &patientName, const QString &studyUID );
void findImagesScu ( const QString &uid );
void foundPatient ( const QMap<QString, QString> &infosMap );
void foundStudy ( const QMap<QString, QString> &infosMap );
Expand Down
Loading