comparison OrthancServer/Search/DatabaseLookup.cpp @ 3072:1b05fd072c57 db-changes

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Jan 2019 11:47:58 +0100
parents 2df061cf2fec
children 683d572424b6
comparison
equal deleted inserted replaced
3071:2df061cf2fec 3072:1b05fd072c57
97 { 97 {
98 for (size_t i = 0; i < constraints_.size(); i++) 98 for (size_t i = 0; i < constraints_.size(); i++)
99 { 99 {
100 assert(constraints_[i] != NULL); 100 assert(constraints_[i] != NULL);
101 101
102 DcmTagKey tag = ToDcmtkBridge::Convert(constraints_[i]->GetTag()); 102 const bool isOptionalConstraint = !constraints_[i]->IsMandatory();
103 const DcmTagKey tag = ToDcmtkBridge::Convert(constraints_[i]->GetTag());
103 104
104 DcmElement* element = NULL; 105 DcmElement* element = NULL;
105 if (!item.findAndGetElement(tag, element).good()) 106 if (!item.findAndGetElement(tag, element).good())
106 { 107 {
107 if (constraints_[i]->IsMandatory()) 108 return isOptionalConstraint;
108 {
109 return false;
110 }
111 else
112 {
113 return true;
114 }
115 } 109 }
116 110
117 if (element == NULL) 111 if (element == NULL)
118 { 112 {
119 return false; 113 return false;
120 } 114 }
121 115
122 std::set<DicomTag> ignoreTagLength; 116 std::set<DicomTag> ignoreTagLength;
123 std::auto_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement 117 std::auto_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement
124 (*element, DicomToJsonFlags_None, 118 (*element, DicomToJsonFlags_None,
125 ORTHANC_MAXIMUM_TAG_LENGTH, encoding, ignoreTagLength)); 119 0, encoding, ignoreTagLength));
126 120
127 if (value->IsNull() || 121 // WARNING: Also modify "HierarchicalMatcher::Setup()" if modifying this code
128 value->IsBinary() || 122 if (value.get() == NULL ||
129 !constraints_[i]->IsMatch(value->GetContent())) 123 value->IsNull())
124 {
125 return isOptionalConstraint;
126 }
127 else if (value->IsBinary() ||
128 !constraints_[i]->IsMatch(value->GetContent()))
130 { 129 {
131 return false; 130 return false;
132 } 131 }
133 } 132 }
134 133