comparison OrthancServer/Sources/ServerContext.cpp @ 4944:f377d5643538 more-tags

new Warnings configuration + InstanceAvailability tag
author Alain Mazy <am@osimis.io>
date Thu, 17 Mar 2022 17:03:59 +0100
parents 96a3e81eba90
children dad71e6da406
comparison
equal deleted inserted replaced
4941:96a3e81eba90 4944:f377d5643538
1403 lookup.HasOnlyMainDicomTags()) 1403 lookup.HasOnlyMainDicomTags())
1404 { 1404 {
1405 // Case (1): The main DICOM tags, as stored in the database, 1405 // Case (1): The main DICOM tags, as stored in the database,
1406 // are sufficient to look for match 1406 // are sufficient to look for match
1407 1407
1408 if (!GetIndex().GetAllMainDicomTags(allMainDicomTagsFromDB, instances[i])) // MORE_TAGS: TODO: we could read only the current and upper level to reduce the number of SQL queries 1408 if (!GetIndex().GetAllMainDicomTags(allMainDicomTagsFromDB, instances[i]))
1409 { 1409 {
1410 // The instance has been removed during the execution of the 1410 // The instance has been removed during the execution of the
1411 // lookup, ignore it 1411 // lookup, ignore it
1412 continue; 1412 continue;
1413 } 1413 }
2254 } 2254 }
2255 2255
2256 } 2256 }
2257 2257
2258 2258
2259 static void ComputeInstanceTags(ExpandedResource& resource,
2260 ServerContext& context,
2261 const std::string& instancePublicId,
2262 const std::set<DicomTag>& requestedTags)
2263 {
2264 if (requestedTags.count(DICOM_TAG_INSTANCE_AVAILABILITY) > 0)
2265 {
2266 resource.tags_.SetValue(DICOM_TAG_INSTANCE_AVAILABILITY, "ONLINE", false);
2267 resource.missingRequestedTags_.erase(DICOM_TAG_INSTANCE_AVAILABILITY);
2268 }
2269 }
2270
2271
2259 static void ComputeSeriesTags(ExpandedResource& resource, 2272 static void ComputeSeriesTags(ExpandedResource& resource,
2260 ServerContext& context, 2273 ServerContext& context,
2261 const std::string& seriesPublicId, 2274 const std::string& seriesPublicId,
2262 const std::set<DicomTag>& requestedTags) 2275 const std::set<DicomTag>& requestedTags)
2263 { 2276 {
2448 2461
2449 if (level == ResourceType_Series 2462 if (level == ResourceType_Series
2450 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Series)) 2463 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Series))
2451 { 2464 {
2452 ComputeSeriesTags(resource, context, resourceId, requestedTags); 2465 ComputeSeriesTags(resource, context, resourceId, requestedTags);
2466 }
2467
2468 if (level == ResourceType_Instance
2469 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Instance))
2470 {
2471 ComputeInstanceTags(resource, context, resourceId, requestedTags);
2453 } 2472 }
2454 } 2473 }
2455 2474
2456 bool ServerContext::ExpandResource(Json::Value& target, 2475 bool ServerContext::ExpandResource(Json::Value& target,
2457 const std::string& publicId, 2476 const std::string& publicId,
2535 { 2554 {
2536 // check the main dicom tags list has not changed since the resource was stored 2555 // check the main dicom tags list has not changed since the resource was stored
2537 if (resource.mainDicomTagsSignature_ != DicomMap::GetMainDicomTagsSignature(resource.type_)) 2556 if (resource.mainDicomTagsSignature_ != DicomMap::GetMainDicomTagsSignature(resource.type_))
2538 { 2557 {
2539 OrthancConfiguration::ReaderLock lock; 2558 OrthancConfiguration::ReaderLock lock;
2540 if (lock.GetConfiguration().IsInconsistentDicomTagsLogsEnabled()) 2559 if (lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb))
2541 { 2560 {
2542 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."; 2561 LOG(WARNING) << "W002: " << 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.";
2543 } 2562 }
2544 } 2563 }
2545 2564
2546 // possibly merge missing requested tags from dicom-as-json 2565 // possibly merge missing requested tags from dicom-as-json
2547 if (!resource.missingRequestedTags_.empty() && !DicomMap::HasOnlyComputedTags(resource.missingRequestedTags_)) 2566 if (!resource.missingRequestedTags_.empty() && !DicomMap::HasOnlyComputedTags(resource.missingRequestedTags_))
2548 { 2567 {
2549 OrthancConfiguration::ReaderLock lock; 2568 OrthancConfiguration::ReaderLock lock;
2550 if (lock.GetConfiguration().IsStorageAccessOnFindLogsEnabled()) 2569 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage))
2551 { 2570 {
2552 std::set<DicomTag> missingTags; 2571 std::set<DicomTag> missingTags;
2553 Toolbox::AppendSets(missingTags, resource.missingRequestedTags_); 2572 Toolbox::AppendSets(missingTags, resource.missingRequestedTags_);
2554 for (std::set<DicomTag>::const_iterator it = resource.missingRequestedTags_.begin(); it != resource.missingRequestedTags_.end(); it++) 2573 for (std::set<DicomTag>::const_iterator it = resource.missingRequestedTags_.begin(); it != resource.missingRequestedTags_.end(); it++)
2555 { 2574 {
2560 } 2579 }
2561 2580
2562 std::string missings; 2581 std::string missings;
2563 FromDcmtkBridge::FormatListOfTags(missings, missingTags); 2582 FromDcmtkBridge::FormatListOfTags(missings, missingTags);
2564 2583
2565 LOG(WARNING) << "PERFORMANCE WARNING: Accessing Dicom tags from storage when accessing " << Orthanc::GetResourceTypeText(resource.type_, false , false) << " : " << missings; 2584 LOG(WARNING) << "W001: Accessing Dicom tags from storage when accessing " << Orthanc::GetResourceTypeText(resource.type_, false , false) << " : " << missings;
2566 } 2585 }
2567 2586
2568 2587
2569 std::string instanceId_ = instanceId; 2588 std::string instanceId_ = instanceId;
2570 DicomMap tagsFromJson; 2589 DicomMap tagsFromJson;