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

ENH: Add removePatient/Series/Study signals to DICOM database #1183

Merged
merged 1 commit into from
Jan 18, 2024
Merged
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
6 changes: 6 additions & 0 deletions Libs/DICOM/Core/Testing/Cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ set(LIBRARY_NAME ${PROJECT_NAME})
ctk_add_executable_utf8(${KIT}CppTests ${Tests})
target_link_libraries(${KIT}CppTests ${LIBRARY_NAME})

find_package(Qt${CTK_QT_VERSION} COMPONENTS Test Widgets REQUIRED)
target_link_libraries(${KIT}CppTests
Qt${CTK_QT_VERSION}::Test
Qt${CTK_QT_VERSION}::Widgets
)

#
# Add Tests
#
Expand Down
29 changes: 29 additions & 0 deletions Libs/DICOM/Core/Testing/Cpp/ctkDICOMDatabaseTest6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// Qt includes
#include <QCoreApplication>
#include <QDir>
#include <QSignalSpy>
#include <QTemporaryDir>

// ctkCore includes
Expand Down Expand Up @@ -157,6 +158,34 @@ int ctkDICOMDatabaseTest6( int argc, char * argv [] )
return EXIT_FAILURE;
}

{
QSignalSpy spySeries(&database, SIGNAL(seriesRemoved(QString)));
database.removeSeries(seriesUID);
CHECK_INT(spySeries.count(), 1);
CHECK_QSTRING(spySeries.at(0).value(0).toString(), seriesUID);

QStringList seriesUIDs = database.seriesForStudy(studyUID);
CHECK_INT(seriesUIDs.count(), 0);
}
{
QSignalSpy spyStudy(&database, SIGNAL(studyRemoved(QString)));
database.removeStudy(studyUID);
CHECK_INT(spyStudy.count(), 1);
CHECK_QSTRING(spyStudy.at(0).value(0).toString(), studyUID);

QStringList studyUIDs = database.studiesForPatient(patientUID);
CHECK_INT(studyUIDs.count(), 0);
}
{
QSignalSpy spyPatient(&database, SIGNAL(patientRemoved(QString)));
database.removePatient(patientUID);
CHECK_INT(spyPatient.count(), 1);
CHECK_QSTRING(spyPatient.at(0).value(0).toString(), patientUID);

QStringList patientIDs = database.patients();
CHECK_INT(patientIDs.count(), 0);
}

database.closeDatabase();

std::cerr << "Database is in " << databaseDirectory.path().toStdString() << std::endl;
Expand Down
14 changes: 14 additions & 0 deletions Libs/DICOM/Core/ctkDICOMDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,8 @@ bool ctkDICOMDatabase::removeSeries(const QString& seriesInstanceUID, bool clear

d->resetLastInsertedValues();

emit seriesRemoved(seriesInstanceUID);

return true;
}

Expand Down Expand Up @@ -2811,6 +2813,12 @@ bool ctkDICOMDatabase::removeStudy(const QString& studyInstanceUID)
}
}
d->resetLastInsertedValues();

if(result)
{
emit studyRemoved(studyInstanceUID);
}

return result;
}

Expand Down Expand Up @@ -2838,6 +2846,12 @@ bool ctkDICOMDatabase::removePatient(const QString& patientID)
}
}
d->resetLastInsertedValues();

if(result)
{
emit patientRemoved(patientID);
}

return result;
}

Expand Down
21 changes: 21 additions & 0 deletions Libs/DICOM/Core/ctkDICOMDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,27 @@ class CTK_DICOM_CORE_EXPORT ctkDICOMDatabase : public QObject
/// - instanceUID (unique)
void instanceAdded(QString);

/// \brief This signal is emitted after a patient is removed by calling removePatient().
///
/// \param patientID (not unique across institutions)
///
/// \sa removePatient()
void patientRemoved(QString);

/// \brief This signal is emitted after a study is removed by calling removeStudy().
///
/// \param studyInstanceUID (unique)
///
/// \sa removeStudy()
void studyRemoved(QString);

/// \brief This signal is emitted after a series is removed by calling removeSeries().
///
/// \param seriesInstanceUID (unique)
///
/// \sa removeSeries()
void seriesRemoved(QString);

/// This signal is emitted when the database has been opened.
void opened();

Expand Down