comparison OrthancServer/OrthancFindRequestHandler.cpp @ 2208:90ea60bee5ff

New metadata automatically computed at the instance level: "SopClassUid"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Dec 2016 14:48:31 +0100
parents 2b1520efa282
children 3eefb84ac0bd
comparison
equal deleted inserted replaced
2207:6dc3bdb4088b 2208:90ea60bee5ff
105 } 105 }
106 } 106 }
107 } 107 }
108 108
109 109
110 static void ExtractTagFromInstances(std::set<std::string>& target, 110 static bool ExtractMetadata(std::set<std::string>& target,
111 ServerContext& context, 111 ServerIndex& index,
112 const DicomTag& tag, 112 MetadataType metadata,
113 const std::list<std::string>& instances) 113 const std::list<std::string>& resources)
114 {
115 for (std::list<std::string>::const_iterator
116 it = resources.begin(); it != resources.end(); ++it)
117 {
118 std::string value;
119 if (index.LookupMetadata(value, *it, metadata))
120 {
121 target.insert(value);
122 }
123 else
124 {
125 // This metadata is unavailable for some resource, give up
126 return false;
127 }
128 }
129
130 return true;
131 }
132
133
134 static void ExtractTagFromInstancesOnDisk(std::set<std::string>& target,
135 ServerContext& context,
136 const DicomTag& tag,
137 const std::list<std::string>& instances)
114 { 138 {
115 // WARNING: This function is slow, as it reads the JSON file 139 // WARNING: This function is slow, as it reads the JSON file
116 // summarizing each instance of interest from the hard drive. 140 // summarizing each instance of interest from the hard drive.
117 141
118 std::string formatted = tag.Format(); 142 std::string formatted = tag.Format();
224 boost::lexical_cast<std::string>(instances.size()), false); 248 boost::lexical_cast<std::string>(instances.size()), false);
225 } 249 }
226 250
227 if (query.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY)) 251 if (query.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY))
228 { 252 {
229 if (Configuration::GetGlobalBoolParameter("AllowFindSopClassesInStudy", false)) 253 std::set<std::string> values;
230 { 254
231 std::set<std::string> values; 255 if (ExtractMetadata(values, index, MetadataType_Instance_SopClassUid, instances))
232 ExtractTagFromInstances(values, context, DICOM_TAG_SOP_CLASS_UID, instances); 256 {
257 // The metadata "SopClassUid" is available for each of these instances
258 StoreSetOfStrings(result, DICOM_TAG_SOP_CLASSES_IN_STUDY, values);
259 }
260 else if (Configuration::GetGlobalBoolParameter("AllowFindSopClassesInStudy", false))
261 {
262 ExtractTagFromInstancesOnDisk(values, context, DICOM_TAG_SOP_CLASS_UID, instances);
233 StoreSetOfStrings(result, DICOM_TAG_SOP_CLASSES_IN_STUDY, values); 263 StoreSetOfStrings(result, DICOM_TAG_SOP_CLASSES_IN_STUDY, values);
234 } 264 }
235 else 265 else
236 { 266 {
237 result.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, "", false); 267 result.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, "", false);