comparison OrthancServer/OrthancRestApi.cpp @ 305:86bb79522f19

name of the private tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Dec 2012 13:01:46 +0100
parents 4eea080e6e7a
children 326d5a4a5af3
comparison
equal deleted inserted replaced
304:4eea080e6e7a 305:86bb79522f19
839 839
840 840
841 841
842 // Modification of DICOM instances ------------------------------------------ 842 // Modification of DICOM instances ------------------------------------------
843 843
844 static void ModifyInstanceInternal(ParsedDicomFile& toModify, 844 static void ReplaceInstanceInternal(ParsedDicomFile& toModify,
845 const Json::Value& replacements) 845 const Json::Value& replacements,
846 DicomReplaceMode mode)
846 { 847 {
847 if (!replacements.isObject()) 848 if (!replacements.isObject())
848 { 849 {
849 throw OrthancException(ErrorCode_BadRequest); 850 throw OrthancException(ErrorCode_BadRequest);
850 } 851 }
855 { 856 {
856 const std::string& name = members[i]; 857 const std::string& name = members[i];
857 std::string value = replacements[name].asString(); 858 std::string value = replacements[name].asString();
858 859
859 DicomTag tag = FromDcmtkBridge::ParseTag(name); 860 DicomTag tag = FromDcmtkBridge::ParseTag(name);
860 toModify.Replace(tag, value); 861 toModify.Replace(tag, value, mode);
861 } 862 }
862 863
863 // A new SOP instance UID is automatically generated 864 // A new SOP instance UID is automatically generated
864 std::string instanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance); 865 std::string instanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance);
865 toModify.Replace(DICOM_TAG_SOP_INSTANCE_UID, instanceUid); 866 toModify.Replace(DICOM_TAG_SOP_INSTANCE_UID, instanceUid, DicomReplaceMode_InsertIfAbsent);
866 } 867 }
868
869
870
867 871
868 872
869 static void ModifyInstance(RestApi::PostCall& call) 873 static void ModifyInstance(RestApi::PostCall& call)
870 { 874 {
871 RETRIEVE_CONTEXT(call); 875 RETRIEVE_CONTEXT(call);
875 879
876 Json::Value request; 880 Json::Value request;
877 if (call.ParseJsonRequest(request)) 881 if (call.ParseJsonRequest(request))
878 { 882 {
879 std::auto_ptr<ParsedDicomFile> modified(dicom.Clone()); 883 std::auto_ptr<ParsedDicomFile> modified(dicom.Clone());
880 ModifyInstanceInternal(*modified, request); 884 ReplaceInstanceInternal(*modified, request, DicomReplaceMode_InsertIfAbsent);
881 modified->Answer(call.GetOutput()); 885 modified->Answer(call.GetOutput());
882 } 886 }
883 887
884 /*std::string studyUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study); 888 /*std::string studyUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study);
885 std::string seriesUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series); 889 std::string seriesUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series);
886 modified->Replace(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid); 890 modified->Replace(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid);
887 modified->Replace(DICOM_TAG_STUDY_INSTANCE_UID, studyUid);*/ 891 modified->Replace(DICOM_TAG_STUDY_INSTANCE_UID, studyUid);*/
888
889
890 } 892 }
891 893
892 894
893 895
894 // Registration of the various REST handlers -------------------------------- 896 // Registration of the various REST handlers --------------------------------