Skip to content

Commit

Permalink
BUG: proxyserver should work also for CGET
Browse files Browse the repository at this point in the history
  • Loading branch information
Punzo committed Dec 13, 2023
1 parent 6b1d8e9 commit a95ba1f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 35 deletions.
56 changes: 41 additions & 15 deletions Libs/DICOM/Core/ctkDICOMDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ void ctkDICOMDatabasePrivate::insert(const ctkDICOMItem& dataset, QString filePa
return;
}

if (filePath.contains("server://") && storeFile)
if (filePath.contains("dimse+ctk") && storeFile)
{
filePath = "";
}
Expand Down Expand Up @@ -1247,7 +1247,7 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap<QString, QMap<QS
QString ctkDICOMDatabasePrivate::absolutePathFromInternal(const QString& filename)
{
Q_Q(ctkDICOMDatabase);
if (filename.contains("server://"))
if (filename.contains("dimse+ctk"))
{
return filename;
}
Expand Down Expand Up @@ -2108,7 +2108,7 @@ QString ctkDICOMDatabase::instanceValue(QString sopInstanceUID, QString tag)

// Read value from file
QString filePath = this->fileForInstance(sopInstanceUID);
if (filePath.isEmpty() || filePath.contains("server://"))
if (filePath.isEmpty() || filePath.contains("dimse+ctk"))
{
return "";
}
Expand Down Expand Up @@ -2145,7 +2145,7 @@ QString ctkDICOMDatabase::fileValue(const QString fileName, QString tag)
return value;
}

if (fileName.contains("server://"))
if (fileName.contains("dimse+ctk"))
{
return "";
}
Expand Down Expand Up @@ -2178,7 +2178,7 @@ bool ctkDICOMDatabase::instanceValueExists(const QString sopInstanceUID, const Q

// Read value from file
QString filePath = this->fileForInstance(sopInstanceUID);
if (filePath.isEmpty() || filePath.contains("server://"))
if (filePath.isEmpty() || filePath.contains("dimse+ctk"))
{
return false;
}
Expand Down Expand Up @@ -2214,7 +2214,7 @@ bool ctkDICOMDatabase::fileValueExists(const QString fileName, QString tag)
return true;
}

if (fileName.contains("server://"))
if (fileName.contains("dimse+ctk"))
{
return false;
}
Expand Down Expand Up @@ -2486,11 +2486,12 @@ void ctkDICOMDatabase::insert(QList<QSharedPointer<ctkDICOMJobResponseSet>> jobR
{
continue;
}
QString patientID, patientName, studyInstanceUID, seriesInstanceUID;;
QString patientID, patientName, studyInstanceUID, seriesInstanceUID, sopInstanceUID;
patientName = dataset->GetElementAsString(DCM_PatientName);
patientID = dataset->GetElementAsString(DCM_PatientID);
studyInstanceUID = dataset->GetElementAsString(DCM_StudyInstanceUID);
seriesInstanceUID = dataset->GetElementAsString(DCM_SeriesInstanceUID);
sopInstanceUID = dataset->GetElementAsString(DCM_SOPInstanceUID);

if (patientID.isEmpty())
{
Expand Down Expand Up @@ -2552,6 +2553,23 @@ void ctkDICOMDatabase::insert(QList<QSharedPointer<ctkDICOMJobResponseSet>> jobR
dataset->SetElementAsString(DCM_SeriesInstanceUID, seriesInstanceUID);
}

if (sopInstanceUID.isEmpty())
{
if (typeOfTask == ctkDICOMJobResponseSet::JobType::QueryInstances)
{
sopInstanceUID = key;
}
else if (typeOfTask == ctkDICOMJobResponseSet::JobType::RetrieveStudy ||
typeOfTask == ctkDICOMJobResponseSet::JobType::RetrieveSeries ||
typeOfTask == ctkDICOMJobResponseSet::JobType::RetrieveSOPInstance ||
typeOfTask == ctkDICOMJobResponseSet::JobType::StoreSOPInstance)
{
sopInstanceUID = jobResponseSet->sopInstanceUID();
}

dataset->SetElementAsString(DCM_SOPInstanceUID, sopInstanceUID);
}

if (patientID.isEmpty())
{
logger.error("ctkDICOMDatabase::insert: dataset has no patientID");
Expand All @@ -2572,15 +2590,23 @@ void ctkDICOMDatabase::insert(QList<QSharedPointer<ctkDICOMJobResponseSet>> jobR

if (typeOfTask == ctkDICOMJobResponseSet::JobType::QueryInstances)
{
// To Do: change to dimse+ctk (Steve will use dicomweb+gcp)
filePath = "server://" + jobResponseSet->connectionName() +
"_" + studyInstanceUID +
"_" + seriesInstanceUID +
"_" + key;
// To Do: once Steve PR is merged use URL database variable instead of the filepath
filePath = "dimse+ctk://" + jobResponseSet->connectionName();
if (!studyInstanceUID.isEmpty())
{
filePath += "/" + studyInstanceUID;
}
if (!seriesInstanceUID.isEmpty())
{
filePath += "/" + seriesInstanceUID;
}
if (!sopInstanceUID.isEmpty())
{
filePath += "/" + sopInstanceUID;
}
}

// Check to see if the file has already been loaded
QString sopInstanceUID(dataset->GetElementAsString(DCM_SOPInstanceUID));
bool datasetInDatabase = false;
bool datasetUpToDate = false;
if (jobResponseSet->overwriteExistingDataset())
Expand Down Expand Up @@ -2615,7 +2641,7 @@ void ctkDICOMDatabase::insert(QList<QSharedPointer<ctkDICOMJobResponseSet>> jobR
}
}

if (filePath.contains("server://") && storeFile)
if (filePath.contains("dimse+ctk") && storeFile)
{
filePath = "";
}
Expand Down Expand Up @@ -2860,7 +2886,7 @@ bool ctkDICOMDatabase::removeSeries(const QString& seriesInstanceUID, bool clear
QString thumbnailPath = fileToRemove.second;

// check that the file is below our internal storage
if (QFileInfo(dbFilePath).isRelative() && !dbFilePath.contains("server://"))
if (QFileInfo(dbFilePath).isRelative() && !dbFilePath.contains("dimse+ctk"))
{
QString absPath = d->absolutePathFromInternal(dbFilePath);
if (QFile(absPath).remove())
Expand Down
39 changes: 21 additions & 18 deletions Libs/DICOM/Core/ctkDICOMRetrieveWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ void ctkDICOMRetrieveWorker::run()
}
break;
}

if (d->Retrieve->jobResponseSetsShared().count() > 0 &&
retrieveJob->status() != ctkAbstractJob::JobStatus::Stopped)
{
scheduler->insertJobResponseSets(d->Retrieve->jobResponseSetsShared());
}
break;
case ctkDICOMServer::CMOVE:
switch(retrieveJob->dicomLevel())
Expand Down Expand Up @@ -255,22 +249,31 @@ void ctkDICOMRetrieveWorker::run()
}
break;
}

if (retrieveJob->status() != ctkAbstractJob::JobStatus::Stopped)
{
ctkDICOMServer* proxyServer = server->proxyServer();
if (proxyServer && proxyServer->queryRetrieveEnabled())
{
ctkDICOMRetrieveJob* newJob = qobject_cast<ctkDICOMRetrieveJob*>(retrieveJob->generateCopy());
newJob->setRetryCounter(0);
newJob->setServer(*proxyServer);
scheduler->addJob(newJob);
}
}
break;
//case ctkDICOMServer::WADO: // To Do
}

if (retrieveJob->status() == ctkAbstractJob::JobStatus::Stopped)
{
emit retrieveJob->canceled();
this->onJobCanceled();
retrieveJob->setStatus(ctkAbstractJob::JobStatus::Finished);
return;
}

ctkDICOMServer* proxyServer = server->proxyServer();
if (proxyServer && proxyServer->queryRetrieveEnabled())
{
ctkDICOMRetrieveJob* newJob = qobject_cast<ctkDICOMRetrieveJob*>(retrieveJob->generateCopy());
newJob->setRetryCounter(0);
newJob->setServer(*proxyServer);
scheduler->addJob(newJob);
}
else if (d->Retrieve->jobResponseSetsShared().count() > 0)
{
scheduler->insertJobResponseSets(d->Retrieve->jobResponseSetsShared());
}

retrieveJob->setStatus(ctkAbstractJob::JobStatus::Finished);
emit retrieveJob->finished();
}
Expand Down
4 changes: 2 additions & 2 deletions Libs/DICOM/Core/ctkDICOMServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void ctkDICOMServer::setRetrieveProtocolAsString(QString protocolString)
{
d->RetrieveProtocol = RetrieveProtocol::CMOVE;
}
/*else if (protocolString == "WADO")
/*else if (protocolString == "WADO") To Do
{
d->RetrieveProtocol = RetrieveProtocol::WADO;
}*/
Expand All @@ -236,7 +236,7 @@ QString ctkDICOMServer::retrieveProtocolAsString() const
case RetrieveProtocol::CMOVE:
protocolString = "CMOVE";
break;
/*case RetrieveProtocol::WADO:
/*case RetrieveProtocol::WADO: To Do
protocolString = "WADO";
break; */
default:
Expand Down

0 comments on commit a95ba1f

Please sign in to comment.