comparison OrthancServer/Sources/Database/ResourcesContent.cpp @ 5044:6fed78e13233

Refactored DicomMap to handle sequences when needed
author Alain Mazy <am@osimis.io>
date Tue, 28 Jun 2022 17:45:09 +0200
parents 6eff25f70121
children 0ea402b4d901
comparison
equal deleted inserted replaced
5043:ec5c203a97ea 5044:6fed78e13233
26 #include "Compatibility/ISetResourcesContent.h" 26 #include "Compatibility/ISetResourcesContent.h"
27 #include "../ServerToolbox.h" 27 #include "../ServerToolbox.h"
28 28
29 #include "../../../OrthancFramework/Sources/DicomFormat/DicomArray.h" 29 #include "../../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
30 #include "../../../OrthancFramework/Sources/OrthancException.h" 30 #include "../../../OrthancFramework/Sources/OrthancException.h"
31 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
31 32
32 #include <cassert> 33 #include <cassert>
33 34
34 35
35 namespace Orthanc 36 namespace Orthanc
43 for (size_t i = 0; i < flattened.GetSize(); i++) 44 for (size_t i = 0; i < flattened.GetSize(); i++)
44 { 45 {
45 const DicomElement& element = flattened.GetElement(i); 46 const DicomElement& element = flattened.GetElement(i);
46 const DicomTag& tag = element.GetTag(); 47 const DicomTag& tag = element.GetTag();
47 const DicomValue& value = element.GetValue(); 48 const DicomValue& value = element.GetValue();
48 if (!value.IsNull() && 49 if (value.IsString())
49 !value.IsBinary())
50 { 50 {
51 target.AddMainDicomTag(resource, tag, element.GetValue().GetContent()); 51 target.AddMainDicomTag(resource, tag, element.GetValue().GetContent());
52 } 52 }
53 } 53 }
54 } 54 }
68 { 68 {
69 // The identifiers tags are a subset of the main DICOM tags 69 // The identifiers tags are a subset of the main DICOM tags
70 assert(DicomMap::IsMainDicomTag(tags[i])); 70 assert(DicomMap::IsMainDicomTag(tags[i]));
71 71
72 const DicomValue* value = map.TestAndGetValue(tags[i]); 72 const DicomValue* value = map.TestAndGetValue(tags[i]);
73 if (value != NULL && 73 if (value != NULL && value->IsString())
74 !value->IsNull() &&
75 !value->IsBinary())
76 { 74 {
77 std::string s = ServerToolbox::NormalizeIdentifier(value->GetContent()); 75 std::string s = ServerToolbox::NormalizeIdentifier(value->GetContent());
78 target.AddIdentifierTag(resource, tags[i], s); 76 target.AddIdentifierTag(resource, tags[i], s);
79 } 77 }
80 } 78 }
131 129
132 default: 130 default:
133 throw OrthancException(ErrorCode_InternalError); 131 throw OrthancException(ErrorCode_InternalError);
134 } 132 }
135 133
136 StoreMainDicomTagsInternal(*this, resource, tags); 134 StoreMainDicomTagsInternal(*this, resource, tags); // saves only leaf tags, not sequences
137 } 135 }
138 136
139 137
140 void ResourcesContent::Store(Compatibility::ISetResourcesContent& compatibility) const 138 void ResourcesContent::Store(Compatibility::ISetResourcesContent& compatibility) const
141 { 139 {