changeset 350:8031f9cfe7fe

removal of old code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Jan 2013 15:36:44 +0100
parents c5edf0cc6e95
children 64625960af22
files OrthancServer/OrthancRestApi.cpp
diffstat 1 files changed, 1 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi.cpp	Mon Jan 28 15:33:44 2013 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Mon Jan 28 15:36:44 2013 +0100
@@ -869,6 +869,7 @@
   {
     typedef std::set<DicomTag> Removals;
     typedef std::map<DicomTag, std::string> Replacements;
+    typedef std::map< std::pair<DicomRootLevel, std::string>, std::string>  UidMap;
   }
 
   static void ReplaceInstanceInternal(ParsedDicomFile& toModify,
@@ -1159,193 +1160,6 @@
   }
 
 
-  static void AnonymizeOrModifySeries(Removals& removals,
-                                      Replacements& replacements,
-                                      bool removePrivateTags,
-                                      MetadataType metadataType,
-                                      ChangeType changeType,
-                                      RestApi::PostCall& call)
-  {
-    Json::Value result = Json::objectValue;
-    
-    {
-      boost::mutex::scoped_lock lock(cacheMutex_);
-      RETRIEVE_CONTEXT(call);
-
-      typedef std::list<std::string> Instances;
-      Instances instances;
-      std::string id = call.GetUriComponent("id", "");
-      context.GetIndex().GetChildInstances(instances, id);
-
-      if (instances.size() == 0)
-      {
-        return;
-      }
-
-      replacements[DICOM_TAG_SERIES_INSTANCE_UID] = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series);
-
-      std::string newSeriesId, newPatientId;
-      for (Instances::const_iterator it = instances.begin(); 
-           it != instances.end(); it++)
-      {
-        LOG(INFO) << "Modifying instance " << *it;
-        ParsedDicomFile& original = context.GetDicomFile(*it);
-        std::auto_ptr<ParsedDicomFile> modified(original.Clone());
-        ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags);
-
-        std::string modifiedInstance;
-        if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success)
-        {
-          LOG(ERROR) << "Error while storing a modified instance " << *it;
-          return;
-        }
-
-        DicomInstanceHasher modifiedHasher = modified->GetHasher();
-        DicomInstanceHasher originalHasher = original.GetHasher();
-
-        if (newSeriesId.size() == 0)
-        {
-          assert(id == originalHasher.HashSeries());
-          newSeriesId = modifiedHasher.HashSeries();
-          context.GetIndex().SetMetadata(newSeriesId, metadataType, id);
-        }
-
-        if (newPatientId.size() == 0)
-        {
-          newPatientId = modifiedHasher.HashPatient();
-        }
-
-        assert(*it == originalHasher.HashInstance());
-        assert(modifiedInstance == modifiedHasher.HashInstance());
-        context.GetIndex().SetMetadata(modifiedInstance, metadataType, *it);
-      }
-
-      context.GetIndex().LogChange(changeType, newSeriesId);
-
-      assert(newSeriesId.size() != 0);
-      result["Type"] = ToString(ResourceType_Series);
-      result["ID"] = newSeriesId;
-      result["Path"] = GetBasePath(ResourceType_Series, newSeriesId);
-      result["PatientID"] = newPatientId;
-    }
-
-    // Do not answer before the lock has been released
-    call.GetOutput().AnswerJson(result);
-  }
-
-
-  static void AnonymizeOrModifyStudy(Removals& removals,
-                                     Replacements& replacements,
-                                     bool removePrivateTags,
-                                     MetadataType metadataType,
-                                     ChangeType changeType,
-                                     RestApi::PostCall& call)
-  {
-    Json::Value result = Json::objectValue;
-
-    {
-      boost::mutex::scoped_lock lock(cacheMutex_);
-      RETRIEVE_CONTEXT(call);
-
-      typedef std::list<std::string> Instances;
-      typedef std::map<std::string, std::string> SeriesUidMap;
-
-      Instances instances;
-      std::string id = call.GetUriComponent("id", "");
-      context.GetIndex().GetChildInstances(instances, id);
-
-      if (instances.size() == 0)
-      {
-        return;
-      }
-
-      std::string newPatientId;
-      std::string newStudyId;
-      replacements[DICOM_TAG_STUDY_INSTANCE_UID] = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study);
-
-      SeriesUidMap seriesUidMap;
-      for (Instances::const_iterator it = instances.begin(); 
-           it != instances.end(); it++)
-      {
-        LOG(INFO) << "Modifying instance " << *it;
-        ParsedDicomFile& original = context.GetDicomFile(*it);
-
-        std::string seriesUid;
-        if (!original.GetTagValue(seriesUid, DICOM_TAG_SERIES_INSTANCE_UID))
-        {
-          throw OrthancException(ErrorCode_InternalError);
-        }
-
-        bool isNewSeries;
-        SeriesUidMap::const_iterator it2 = seriesUidMap.find(seriesUid);
-        if (it2 == seriesUidMap.end())
-        {
-          std::string newSeriesUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series);
-          seriesUidMap[seriesUid] = newSeriesUid;
-          replacements[DICOM_TAG_SERIES_INSTANCE_UID] = newSeriesUid;
-          isNewSeries = true;
-        }
-        else
-        {
-          replacements[DICOM_TAG_SERIES_INSTANCE_UID] = it2->second;
-          isNewSeries = false;
-        }
-
-        std::auto_ptr<ParsedDicomFile> modified(original.Clone());
-        ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags);
-
-        std::string modifiedInstance;
-        if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success)
-        {
-          LOG(ERROR) << "Error while storing a modified instance " << *it;
-          return;
-        }
-
-        DicomInstanceHasher modifiedHasher = modified->GetHasher();
-        DicomInstanceHasher originalHasher = original.GetHasher();
-
-        if (isNewSeries)
-        {
-          context.GetIndex().SetMetadata
-            (modifiedHasher.HashSeries(), metadataType, originalHasher.HashSeries());
-        }
-
-        if (newStudyId.size() == 0)
-        {
-          newStudyId = modifiedHasher.HashStudy();
-          context.GetIndex().SetMetadata(newStudyId, metadataType, originalHasher.HashStudy());
-        }
-
-        if (newPatientId.size() == 0)
-        {
-          newPatientId = modifiedHasher.HashPatient();
-        }
-
-        assert(*it == originalHasher.HashInstance());
-        assert(modifiedInstance == modifiedHasher.HashInstance());
-        context.GetIndex().SetMetadata(modifiedInstance, metadataType, *it);
-      }
-
-      context.GetIndex().LogChange(changeType, newStudyId);
-
-      assert(newStudyId.size() != 0);
-      result["Type"] = ToString(ResourceType_Study);
-      result["ID"] = newStudyId;
-      result["Path"] = GetBasePath(ResourceType_Study, newStudyId);
-      result["PatientID"] = newPatientId;
-    }
-
-    // Do not answer before the lock has been released
-    call.GetOutput().AnswerJson(result);
-  }
-
-
-
-  namespace
-  {
-    typedef std::map< std::pair<DicomRootLevel, std::string>, std::string>  UidMap;
-  }
-
   static bool RetrieveMappedUid(ParsedDicomFile& dicom,
                                 DicomRootLevel level,
                                 Replacements& replacements,