changeset 5916:305d318f488d get-scu

cleanup get-scu (re-integrate commits from the get-scu-test branch)
author Alain Mazy <am@orthanc.team>
date Mon, 09 Dec 2024 19:41:02 +0100 (5 months ago)
parents 866defb5f95a
children fa8c10f10312
files OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp OrthancServer/Resources/Configuration.json OrthancServer/Sources/ServerJobs/DicomGetScuJob.cpp OrthancServer/Sources/ServerJobs/DicomGetScuJob.h OrthancServer/Sources/ServerJobs/DicomRetrieveScuBaseJob.h TODO
diffstat 6 files changed, 22 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Mon Dec 09 10:04:34 2024 +0100
+++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Mon Dec 09 19:41:02 2024 +0100
@@ -538,10 +538,12 @@
         sopClass = UID_GETPatientRootQueryRetrieveInformationModel;
         break;
       case ResourceType_Study:
+      case ResourceType_Series:
+      case ResourceType_Instance:
         sopClass = UID_GETStudyRootQueryRetrieveInformationModel;
         break;
       default:
-        throw OrthancException(ErrorCode_InternalError); // TODO-GET: implement series + instances
+        throw OrthancException(ErrorCode_InternalError);
     }
 
     // Figure out which of the accepted presentation contexts should be used
@@ -660,8 +662,8 @@
 
           if (result.bad())
           {
+            LOG(WARNING) << "C-GET SCU handler: Failed to receive dataset: " << result.text();
             desiredCStoreReturnStatus = STATUS_STORE_Error_CannotUnderstand;
-            // TODO-GET: return ?
           }
           else
           {
--- a/OrthancServer/Resources/Configuration.json	Mon Dec 09 10:04:34 2024 +0100
+++ b/OrthancServer/Resources/Configuration.json	Mon Dec 09 19:41:02 2024 +0100
@@ -220,7 +220,7 @@
   // The list of rejected Storage SOP classes.
   // This configuration is only meaningful if
   // "AcceptedSopClasses" is using regular expressions
-  // or if it not defined.
+  // or if it is not defined.
   // Each entry can contain wildcards ("?" or "*").
   // (new in Orthanc 1.12.6)
   // "RejectedSopClasses" : [
--- a/OrthancServer/Sources/ServerJobs/DicomGetScuJob.cpp	Mon Dec 09 10:04:34 2024 +0100
+++ b/OrthancServer/Sources/ServerJobs/DicomGetScuJob.cpp	Mon Dec 09 19:41:02 2024 +0100
@@ -68,17 +68,15 @@
     if (connection_.get() == NULL)
     {
       std::set<std::string> sopClassesToPropose;
-      std::set<std::string> sopClassesInStudy;
       std::set<std::string> acceptedSopClasses;
       std::list<DicomTransferSyntax> proposedTransferSyntaxes;
 
-      if (findAnswer.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY) &&
-          findAnswer.LookupStringValues(sopClassesInStudy, DICOM_TAG_SOP_CLASSES_IN_STUDY, false))
+      if (sopClassesFromResourcesToRetrieve_.size() > 0)
       {
         context_.GetAcceptedSopClasses(acceptedSopClasses, 0); 
 
         // keep the sop classes from the resources to retrieve only if they are accepted by Orthanc
-        Toolbox::GetIntersection(sopClassesToPropose, sopClassesInStudy, acceptedSopClasses);
+        Toolbox::GetIntersection(sopClassesToPropose, sopClassesFromResourcesToRetrieve_, acceptedSopClasses);
       }
       else
       {
@@ -104,39 +102,20 @@
     connection_->Get(findAnswer, InstanceReceivedHandler, &context_);
   }
 
-  void DicomGetScuJob::AddResourceToRetrieve(ResourceType level, const std::string& dicomId)
+  void DicomGetScuJob::AddFindAnswer(const DicomMap& answer)
   {
-    // TODO-GET: when retrieving a single series, one must provide the StudyInstanceUID too
-    DicomMap item;
-
-    switch (level)
-    {
-    case ResourceType_Patient:
-      item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false);
-      item.SetValue(DICOM_TAG_PATIENT_ID, dicomId, false);
-      break;
-
-    case ResourceType_Study:
-      item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false);
-      item.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, dicomId, false);
-      break;
+    DicomRetrieveScuBaseJob::AddFindAnswer(answer);
 
-    case ResourceType_Series:
-      item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false);
-      item.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, dicomId, false);
-      break;
-
-    case ResourceType_Instance:
-      item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false);
-      item.SetValue(DICOM_TAG_SOP_INSTANCE_UID, dicomId, false);
-      break;
-
-    default:
-      throw OrthancException(ErrorCode_InternalError);
+    std::set<std::string> sopClassesInStudy;
+    if (answer.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY) 
+        && answer.LookupStringValues(sopClassesInStudy, DICOM_TAG_SOP_CLASSES_IN_STUDY, false))
+    {
+      for (std::set<std::string>::const_iterator it = sopClassesInStudy.begin(); it != sopClassesInStudy.end(); ++it)
+      {
+        sopClassesFromResourcesToRetrieve_.insert(*it);
+      }
     }
-    query_.Add(item);
-    
-    AddCommand(new Command(*this, item));
   }
 
+
 }
--- a/OrthancServer/Sources/ServerJobs/DicomGetScuJob.h	Mon Dec 09 10:04:34 2024 +0100
+++ b/OrthancServer/Sources/ServerJobs/DicomGetScuJob.h	Mon Dec 09 19:41:02 2024 +0100
@@ -35,7 +35,8 @@
   class DicomGetScuJob : public DicomRetrieveScuBaseJob
   {
   private:
-    
+    std::set<std::string> sopClassesFromResourcesToRetrieve_;
+
     virtual void Retrieve(const DicomMap& findAnswer) ORTHANC_OVERRIDE;
     
   public:
@@ -48,7 +49,7 @@
                    const Json::Value& serialized);
 
 
-    void AddResourceToRetrieve(ResourceType level, const std::string& dicomId);
+    virtual void AddFindAnswer(const DicomMap &answer) ORTHANC_OVERRIDE;
 
 
     virtual void GetJobType(std::string& target) const ORTHANC_OVERRIDE
--- a/OrthancServer/Sources/ServerJobs/DicomRetrieveScuBaseJob.h	Mon Dec 09 10:04:34 2024 +0100
+++ b/OrthancServer/Sources/ServerJobs/DicomRetrieveScuBaseJob.h	Mon Dec 09 19:41:02 2024 +0100
@@ -107,7 +107,7 @@
                             const Json::Value &serialized);
 
   public:
-    void AddFindAnswer(const DicomMap &answer);
+    virtual void AddFindAnswer(const DicomMap &answer);
 
     void AddQuery(const DicomMap& query);
 
--- a/TODO	Mon Dec 09 10:04:34 2024 +0100
+++ b/TODO	Mon Dec 09 19:41:02 2024 +0100
@@ -186,9 +186,6 @@
 Mid-term
 --------
 
-* Support C-GET SCU (note that C-GET SCP was introduced in Orthanc 1.7.0)
-* Configure the list of accepted SOP Classes
-  https://discourse.orthanc-server.org/t/can-you-limit-the-sop-classes-accepted-as-store-scp/4606
 * Check how Orthanc shall behave wrt to AcceptedSopClasses in these situations (consider Orthanc
   accepts CT but not PT)
   - What shall we log/warn if an external modality tries to send a PT/CT
@@ -204,9 +201,6 @@
 * Strict hierarchical C-FIND:
   https://groups.google.com/d/msg/orthanc-users/VBHpeGVSNKM/tkaVvjWFBwAJ
 * report DIMSE error codes in Rest API and job status for /store /query /move /retrieve
-* report progress report of C-Move operation in jop progress.  There are 
-  progress callbacks available in DIMSE_moveUser
-  https://groups.google.com/g/orthanc-users/c/c8cGnA7FzsE/m/BSs66D8wBwAJ
 * Log outgoing C-Find queries
 * Support other Transfer Syntaxes in the Worklist plugin:
   https://discourse.orthanc-server.org/t/could-you-please-create-an-option-to-set-the-transfer-syntax-in-the-worklist-plugin-currently-little-endian-explicit-is-fixed/4871