comparison OrthancServer/ServerContext.cpp @ 3679:6358923d3ced

C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Feb 2020 20:06:19 +0100
parents 4182cde57afb
children 9dac85e807c2 2a170a8f1faf
comparison
equal deleted inserted replaced
3678:26c6d47467a9 3679:6358923d3ced
799 const DatabaseLookup& lookup, 799 const DatabaseLookup& lookup,
800 ResourceType queryLevel, 800 ResourceType queryLevel,
801 size_t since, 801 size_t since,
802 size_t limit) 802 size_t limit)
803 { 803 {
804 unsigned int databaseLimit = (queryLevel == ResourceType_Instance ? limitFindInstances_ : limitFindResults_); 804 unsigned int databaseLimit = (queryLevel == ResourceType_Instance ?
805 limitFindInstances_ : limitFindResults_);
805 806
806 std::vector<std::string> resources, instances; 807 std::vector<std::string> resources, instances;
807 808
808 { 809 {
809 const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1); 810 const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1);
813 bool complete = (databaseLimit == 0 || 814 bool complete = (databaseLimit == 0 ||
814 resources.size() <= databaseLimit); 815 resources.size() <= databaseLimit);
815 816
816 LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << resources.size(); 817 LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << resources.size();
817 818
819 /**
820 * "resources" contains the Orthanc ID of the resource at level
821 * "queryLevel", "instances" contains one the Orthanc ID of one
822 * sample instance from this resource.
823 **/
818 assert(resources.size() == instances.size()); 824 assert(resources.size() == instances.size());
819 825
820 size_t countResults = 0; 826 size_t countResults = 0;
821 size_t skipped = 0; 827 size_t skipped = 0;
822 828
837 lookup.HasOnlyMainDicomTags()) 843 lookup.HasOnlyMainDicomTags())
838 { 844 {
839 // Case (1): The main DICOM tags, as stored in the database, 845 // Case (1): The main DICOM tags, as stored in the database,
840 // are sufficient to look for match 846 // are sufficient to look for match
841 847
842 if (!GetIndex().GetAllMainDicomTags(dicom, instances[i])) 848 DicomMap tmp;
849 if (!GetIndex().GetAllMainDicomTags(tmp, instances[i]))
843 { 850 {
844 // The instance has been removed during the execution of the 851 // The instance has been removed during the execution of the
845 // lookup, ignore it 852 // lookup, ignore it
846 continue; 853 continue;
847 } 854 }
855
856 #if 1
857 // New in Orthanc 1.6.0: Only keep the main DICOM tags at the
858 // level of interest for the query
859 switch (queryLevel)
860 {
861 // WARNING: Don't reorder cases below, and don't add "break"
862 case ResourceType_Instance:
863 dicom.MergeMainDicomTags(tmp, ResourceType_Instance);
864
865 case ResourceType_Series:
866 dicom.MergeMainDicomTags(tmp, ResourceType_Series);
867
868 case ResourceType_Study:
869 dicom.MergeMainDicomTags(tmp, ResourceType_Study);
870
871 case ResourceType_Patient:
872 dicom.MergeMainDicomTags(tmp, ResourceType_Patient);
873 break;
874
875 default:
876 throw OrthancException(ErrorCode_InternalError);
877 }
878
879 // Special case of the "Modality" at the study level, in order
880 // to deal with C-FIND on "ModalitiesInStudy" (0008,0061).
881 // Check out integration test "test_rest_modalities_in_study".
882 if (queryLevel == ResourceType_Study)
883 {
884 dicom.CopyTagIfExists(tmp, DICOM_TAG_MODALITY);
885 }
886 #else
887 dicom.Assign(tmp); // This emulates Orthanc <= 1.5.8
888 #endif
848 889
849 hasOnlyMainDicomTags = true; 890 hasOnlyMainDicomTags = true;
850 } 891 }
851 else 892 else
852 { 893 {