comparison OrthancServer/Sources/ServerContext.cpp @ 4936:8422e4f99a18 more-tags

Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
author Alain Mazy <am@osimis.io>
date Fri, 11 Mar 2022 17:38:16 +0100
parents acd3f72e2a21
children 3f9b9865c8cc
comparison
equal deleted inserted replaced
4935:acd3f72e2a21 4936:8422e4f99a18
2094 } 2094 }
2095 2095
2096 2096
2097 static void SerializeExpandedResource(Json::Value& target, 2097 static void SerializeExpandedResource(Json::Value& target,
2098 const ExpandedResource& resource, 2098 const ExpandedResource& resource,
2099 DicomToJsonFormat format) 2099 DicomToJsonFormat format,
2100 const std::set<DicomTag>& requestedTags)
2100 { 2101 {
2101 target = Json::objectValue; 2102 target = Json::objectValue;
2102 2103
2103 target["Type"] = GetResourceTypeText(resource.type_, false, true); 2104 target["Type"] = GetResourceTypeText(resource.type_, false, true);
2104 target["ID"] = resource.id_; 2105 target["ID"] = resource.id_;
2239 2240
2240 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue; 2241 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
2241 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format); 2242 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format);
2242 } 2243 }
2243 2244
2245 if (requestedTags.size() > 0)
2246 {
2247 static const char* const REQUESTED_TAGS = "RequestedTags";
2248
2249 DicomMap tags;
2250 resource.tags_.ExtractTags(tags, requestedTags);
2251
2252 target[REQUESTED_TAGS] = Json::objectValue;
2253 FromDcmtkBridge::ToJson(target[REQUESTED_TAGS], tags, format);
2254 }
2255
2244 } 2256 }
2245 2257
2246 2258
2247 bool ServerContext::ExpandResource(Json::Value& target, 2259 bool ServerContext::ExpandResource(Json::Value& target,
2248 const std::string& publicId, 2260 const std::string& publicId,
2249 ResourceType level, 2261 ResourceType level,
2250 DicomToJsonFormat format) 2262 DicomToJsonFormat format,
2263 const std::set<DicomTag>& requestedTags)
2251 { 2264 {
2252 ExpandedResource resource; 2265 ExpandedResource resource;
2253 2266
2254 if (GetIndex().ExpandResource(resource, publicId, level, format)) 2267 if (GetIndex().ExpandResource(resource, publicId, level, format, requestedTags))
2255 { 2268 {
2256 // check the main dicom tags list has not changed since the resource was stored 2269 // check the main dicom tags list has not changed since the resource was stored
2257 2270
2258 if (resource.mainDicomTagsSignature_ != DicomMap::GetMainDicomTagsSignature(resource.type_)) 2271 if (resource.mainDicomTagsSignature_ != DicomMap::GetMainDicomTagsSignature(resource.type_))
2259 { 2272 {
2260 OrthancConfiguration::ReaderLock lock; 2273 OrthancConfiguration::ReaderLock lock;
2261 if (lock.GetConfiguration().IsInconsistentDicomTagsLogsEnabled()) 2274 if (lock.GetConfiguration().IsInconsistentDicomTagsLogsEnabled())
2262 { 2275 {
2263 LOG(WARNING) << Orthanc::GetResourceTypeText(resource.type_, false , false) << " has been stored with another version of Main Dicom Tags list, you should POST to /" << Orthanc::GetResourceTypeText(resource.type_, true, false) << "/" << resource.id_ << "/reconstruct to update the list of tags saved in DB. Some tags might be missing from this answer."; 2276 LOG(WARNING) << Orthanc::GetResourceTypeText(resource.type_, false , false) << " has been stored with another version of Main Dicom Tags list, you should POST to /" << Orthanc::GetResourceTypeText(resource.type_, true, false) << "/" << resource.id_ << "/reconstruct to update the list of tags saved in DB. Some MainDicomTags might be missing from this answer.";
2264 } 2277 }
2265 } 2278 }
2266 2279
2267 // MORE_TAGS: TODO: possibly merge missing requested tags from /tags 2280 // MORE_TAGS: TODO: possibly merge missing requested tags from /tags
2268 2281 // log warning
2269 SerializeExpandedResource(target, resource, format); 2282 // use resource.missingRequestedTags_
2283
2284 SerializeExpandedResource(target, resource, format, requestedTags);
2270 2285
2271 return true; 2286 return true;
2272 } 2287 }
2273 2288
2274 return false; 2289 return false;